diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index f249a6131ae..54da23821f5 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -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 } diff --git a/src/test/ui/compare-method/proj-outlives-region.stderr b/src/test/ui/compare-method/proj-outlives-region.stderr index f871f034a92..e6e93d14b3c 100644 --- a/src/test/ui/compare-method/proj-outlives-region.stderr +++ b/src/test/ui/compare-method/proj-outlives-region.stderr @@ -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 diff --git a/src/test/ui/compare-method/region-extra-2.stderr b/src/test/ui/compare-method/region-extra-2.stderr index af974d50183..2b8a268fdcc 100644 --- a/src/test/ui/compare-method/region-extra-2.stderr +++ b/src/test/ui/compare-method/region-extra-2.stderr @@ -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 diff --git a/src/test/ui/compare-method/region-extra.stderr b/src/test/ui/compare-method/region-extra.stderr index d46376b4a42..d89b3a921b9 100644 --- a/src/test/ui/compare-method/region-extra.stderr +++ b/src/test/ui/compare-method/region-extra.stderr @@ -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 diff --git a/src/test/ui/compare-method/region-unrelated.stderr b/src/test/ui/compare-method/region-unrelated.stderr index 1df83c7fb0c..156143cd54c 100644 --- a/src/test/ui/compare-method/region-unrelated.stderr +++ b/src/test/ui/compare-method/region-unrelated.stderr @@ -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 diff --git a/src/test/ui/compare-method/trait-bound-on-type-parameter.stderr b/src/test/ui/compare-method/trait-bound-on-type-parameter.stderr index 7112a00c7b7..e3a1eb9ee66 100644 --- a/src/test/ui/compare-method/trait-bound-on-type-parameter.stderr +++ b/src/test/ui/compare-method/trait-bound-on-type-parameter.stderr @@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait | ---------------------------- definition of `b` from trait ... 25 | fn b(&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 diff --git a/src/test/ui/compare-method/traits-misc-mismatch-1.stderr b/src/test/ui/compare-method/traits-misc-mismatch-1.stderr index f221ebe3302..ba5284eb653 100644 --- a/src/test/ui/compare-method/traits-misc-mismatch-1.stderr +++ b/src/test/ui/compare-method/traits-misc-mismatch-1.stderr @@ -5,7 +5,7 @@ error[E0276]: impl has stricter requirements than trait | -------------------------------- definition of `test_error1_fn` from trait ... 36 | fn test_error1_fn(&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(&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(&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(&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(&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(&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>(&self) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `G: Getter` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `G: Getter` error: aborting due to 7 previous errors diff --git a/src/test/ui/compare-method/traits-misc-mismatch-2.stderr b/src/test/ui/compare-method/traits-misc-mismatch-2.stderr index 622e144c53a..983d87d5b88 100644 --- a/src/test/ui/compare-method/traits-misc-mismatch-2.stderr +++ b/src/test/ui/compare-method/traits-misc-mismatch-2.stderr @@ -1,14 +1,11 @@ error[E0276]: impl has stricter requirements than trait --> $DIR/traits-misc-mismatch-2.rs:23:5 | -19 | fn zip>(self, other: U) -> ZipIterator; - | ------------------------------------------------------------------ definition of `zip` from trait +19 | fn zip>(self, other: U) -> ZipIterator; + | ------------------------------------------------------------------ definition of `zip` from trait ... -23 | / fn zip>(self, other: U) -> ZipIterator { -24 | | //~^ ERROR E0276 -25 | | ZipIterator{a: self, b: other} -26 | | } - | |_____^ impl has extra requirement `U: Iterator` +23 | fn zip>(self, other: U) -> ZipIterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: Iterator` error: aborting due to previous error