Rollup merge of #46801 - estebank:impl-extra-req-def-span, r=arielb1

Point at def span in "impl has stricter requirements" diagnostic
This commit is contained in:
Guillaume Gomez 2017-12-18 23:08:34 +01:00 committed by GitHub
commit 12cd45286e
8 changed files with 23 additions and 32 deletions

View File

@ -484,19 +484,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
-> DiagnosticBuilder<'tcx>
{
let msg = "impl has stricter requirements than trait";
let mut err = struct_span_err!(self.tcx.sess,
error_span,
E0276,
"{}", msg);
let sp = self.tcx.sess.codemap().def_span(error_span);
let mut err = struct_span_err!(self.tcx.sess, sp, E0276, "{}", msg);
if let Some(trait_item_span) = self.tcx.hir.span_if_local(trait_item_def_id) {
let span = self.tcx.sess.codemap().def_span(trait_item_span);
err.span_label(span, format!("definition of `{}` from trait", item_name));
}
err.span_label(
error_span,
format!("impl has extra requirement {}", requirement));
err.span_label(sp, format!("impl has extra requirement {}", requirement));
err
}

View File

@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait
| --------------------- definition of `foo` from trait
...
19 | fn foo() where U: 'a { } //~ ERROR E0276
| ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: 'a`
| ^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: 'a`
error: aborting due to previous error

View File

@ -1,14 +1,11 @@
error[E0276]: impl has stricter requirements than trait
--> $DIR/region-extra-2.rs:19:5
|
15 | fn renew<'b: 'a>(self) -> &'b mut [T];
| -------------------------------------- definition of `renew` from trait
15 | fn renew<'b: 'a>(self) -> &'b mut [T];
| -------------------------------------- definition of `renew` from trait
...
19 | / fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b {
20 | | //~^ ERROR E0276
21 | | &mut self[..]
22 | | }
| |_____^ impl has extra requirement `'a: 'b`
19 | fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'a: 'b`
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait
| --------- definition of `foo` from trait
...
19 | fn foo() where 'a: 'b { } //~ ERROR impl has stricter
| ^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'a: 'b`
| ^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'a: 'b`
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait
| --------------------- definition of `foo` from trait
...
19 | fn foo() where V: 'a { }
| ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `V: 'a`
| ^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `V: 'a`
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait
| ---------------------------- definition of `b` from trait
...
25 | fn b<F: Sync, G>(&self, _x: F) -> F { panic!() } //~ ERROR E0276
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `F: std::marker::Sync`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `F: std::marker::Sync`
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait
| -------------------------------- definition of `test_error1_fn` from trait
...
36 | fn test_error1_fn<T: Ord>(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::cmp::Ord`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::cmp::Ord`
error[E0276]: impl has stricter requirements than trait
--> $DIR/traits-misc-mismatch-1.rs:40:5
@ -14,7 +14,7 @@ error[E0276]: impl has stricter requirements than trait
| -------------------------------------- definition of `test_error2_fn` from trait
...
40 | fn test_error2_fn<T: Eq + B>(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
error[E0276]: impl has stricter requirements than trait
--> $DIR/traits-misc-mismatch-1.rs:44:5
@ -23,7 +23,7 @@ error[E0276]: impl has stricter requirements than trait
| -------------------------------------- definition of `test_error3_fn` from trait
...
44 | fn test_error3_fn<T: B + Eq>(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
error[E0276]: impl has stricter requirements than trait
--> $DIR/traits-misc-mismatch-1.rs:54:5
@ -32,7 +32,7 @@ error[E0276]: impl has stricter requirements than trait
| ------------------------------- definition of `test_error5_fn` from trait
...
54 | fn test_error5_fn<T: B>(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
error[E0276]: impl has stricter requirements than trait
--> $DIR/traits-misc-mismatch-1.rs:60:5
@ -41,7 +41,7 @@ error[E0276]: impl has stricter requirements than trait
| ------------------------------- definition of `test_error7_fn` from trait
...
60 | fn test_error7_fn<T: A + Eq>(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::cmp::Eq`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::cmp::Eq`
error[E0276]: impl has stricter requirements than trait
--> $DIR/traits-misc-mismatch-1.rs:63:5
@ -50,7 +50,7 @@ error[E0276]: impl has stricter requirements than trait
| ------------------------------- definition of `test_error8_fn` from trait
...
63 | fn test_error8_fn<T: C>(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: C`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: C`
error[E0276]: impl has stricter requirements than trait
--> $DIR/traits-misc-mismatch-1.rs:76:5
@ -59,7 +59,7 @@ error[E0276]: impl has stricter requirements than trait
| ---------------------------------- definition of `method` from trait
...
76 | fn method<G: Getter<usize>>(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `G: Getter<usize>`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `G: Getter<usize>`
error: aborting due to 7 previous errors

View File

@ -1,14 +1,11 @@
error[E0276]: impl has stricter requirements than trait
--> $DIR/traits-misc-mismatch-2.rs:23:5
|
19 | fn zip<B, U: Iterator<U>>(self, other: U) -> ZipIterator<Self, U>;
| ------------------------------------------------------------------ definition of `zip` from trait
19 | fn zip<B, U: Iterator<U>>(self, other: U) -> ZipIterator<Self, U>;
| ------------------------------------------------------------------ definition of `zip` from trait
...
23 | / fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<T, U> {
24 | | //~^ ERROR E0276
25 | | ZipIterator{a: self, b: other}
26 | | }
| |_____^ impl has extra requirement `U: Iterator<B>`
23 | fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<T, U> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: Iterator<B>`
error: aborting due to previous error