mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-10 14:02:57 +00:00
review comments
This commit is contained in:
parent
c3521fe940
commit
ef2a8539aa
@ -1,5 +1,7 @@
|
||||
//! Error Reporting for `impl` items that do not match the obligations from their `trait`.
|
||||
|
||||
use syntax_pos::Span;
|
||||
use crate::ty::Ty;
|
||||
use crate::infer::{ValuePairs, Subtype};
|
||||
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
@ -25,21 +27,11 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
) = (&sub_trace.values, &sup_trace.values) {
|
||||
if sup_expected_found == sub_expected_found {
|
||||
let sp = var_origin.span();
|
||||
let mut err = self.tcx().sess.struct_span_err(
|
||||
self.emit_err(
|
||||
sp,
|
||||
"`impl` item doesn't match `trait` item"
|
||||
);
|
||||
err.note(&format!(
|
||||
"expected: {:?}\n found: {:?}",
|
||||
sub_expected_found.expected,
|
||||
sub_expected_found.found,
|
||||
));
|
||||
err.span_label(sp, &format!(
|
||||
"found {:?}",
|
||||
sub_expected_found.found,
|
||||
));
|
||||
// FIXME: recover the `FnPtr`'s `HirId`/`Node` to point to it.
|
||||
err.emit();
|
||||
);
|
||||
return Some(ErrorReported);
|
||||
}
|
||||
}
|
||||
@ -50,4 +42,15 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn emit_err(&self, sp: Span, expected: Ty<'tcx>, found: Ty<'tcx>) {
|
||||
let mut err = self.tcx().sess.struct_span_err(
|
||||
sp,
|
||||
"`impl` item signature doesn't match `trait` item signature",
|
||||
);
|
||||
err.note(&format!("expected: {:?}\n found: {:?}", expected, found));
|
||||
err.span_label(sp, &format!("found {:?}", found));
|
||||
// FIXME: recover the `FnPtr`'s `HirId`/`Node` to point to it.
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ impl Deref for Struct {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
//~^^^^ ERROR `impl` item doesn't match `trait` item
|
||||
//~^^^^ ERROR `impl` item signature doesn't match `trait` item signature
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: `impl` item doesn't match `trait` item
|
||||
error: `impl` item signature doesn't match `trait` item signature
|
||||
--> $DIR/mismatched_trait_impl-2.rs:8:5
|
||||
|
|
||||
LL | fn deref(&self) -> &dyn Trait {
|
||||
|
@ -6,7 +6,7 @@ trait Get {
|
||||
}
|
||||
|
||||
impl Get for i32 {
|
||||
fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR `impl` item doesn't match `trait`
|
||||
fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR `impl` item signature doesn't match
|
||||
x //~ ERROR lifetime mismatch
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: `impl` item doesn't match `trait` item
|
||||
error: `impl` item signature doesn't match `trait` item signature
|
||||
--> $DIR/mismatched_trait_impl.rs:9:5
|
||||
|
|
||||
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
|
||||
|
@ -4,7 +4,7 @@ trait Foo {
|
||||
|
||||
impl Foo for () {
|
||||
fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
|
||||
//~^ ERROR `impl` item doesn't match `trait` item
|
||||
//~^ ERROR `impl` item signature doesn't match `trait` item signature
|
||||
if x > y { x } else { y }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: `impl` item doesn't match `trait` item
|
||||
error: `impl` item signature doesn't match `trait` item signature
|
||||
--> $DIR/lifetime-mismatch-between-trait-and-impl.rs:6:5
|
||||
|
|
||||
LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
|
||||
|
@ -52,6 +52,6 @@ impl<One> Drop for V<One,One> { fn drop(&mut self) { } } // REJECT
|
||||
//~^ ERROR Implementations of Drop cannot be specialized
|
||||
|
||||
impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
|
||||
//~^ ERROR `impl` item doesn't match `trait` item
|
||||
//~^ ERROR `impl` item signature doesn't match `trait` item signature
|
||||
|
||||
pub fn main() { }
|
||||
|
@ -89,7 +89,7 @@ note: Use same sequence of generic type and region parameters that is on the str
|
||||
LL | struct V<Tva, Tvb> { x: *const Tva, y: *const Tvb }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `impl` item doesn't match `trait` item
|
||||
error: `impl` item signature doesn't match `trait` item signature
|
||||
--> $DIR/reject-specialized-drops-8142.rs:54:1
|
||||
|
|
||||
LL | impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
|
||||
|
Loading…
Reference in New Issue
Block a user