Skip to content

Commit

Permalink
Add label to item source of bound obligation
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Apr 19, 2020
1 parent ce936e9 commit d9a5419
Show file tree
Hide file tree
Showing 32 changed files with 61 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1532,14 +1532,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
let item_name = tcx.def_path_str(item_def_id);
let msg = format!("required by this bound in `{}`", item_name);
if let Some(ident) = tcx.opt_item_name(item_def_id) {
let sm = self.tcx.sess.source_map();
let sm = tcx.sess.source_map();
let same_line =
match (sm.lookup_line(ident.span.hi()), sm.lookup_line(span.lo())) {
(Ok(l), Ok(r)) => l.line == r.line,
_ => true,
};
if !ident.span.overlaps(span) && !same_line {
err.span_label(ident.span, "");
err.span_label(ident.span, "required by a bound in this");
}
}
if span != DUMMY_SP {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: `<L1 as Lam<&'a u8>>::App` doesn't implement `std::fmt::Debug`
--> $DIR/bad-bounds-on-assoc-in-trait.rs:31:6
|
LL | trait Case1 {
| -----
| ----- required by a bound in this
...
LL | Debug
| ----- required by this bound in `Case1`
Expand All @@ -26,7 +26,7 @@ error[E0277]: `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be sent be
--> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20
|
LL | trait Case1 {
| -----
| ----- required by a bound in this
LL | type C: Clone + Iterator<Item:
LL | Send + Iterator<Item:
| ---- required by this bound in `Case1`
Expand All @@ -42,7 +42,7 @@ error[E0277]: `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be shared
--> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20
|
LL | trait Case1 {
| -----
| ----- required by a bound in this
...
LL | > + Sync>;
| ---- required by this bound in `Case1`
Expand All @@ -58,7 +58,7 @@ error[E0277]: `<_ as Lam<&'a u8>>::App` doesn't implement `std::fmt::Debug`
--> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20
|
LL | trait Case1 {
| -----
| ----- required by a bound in this
...
LL | Debug
| ----- required by this bound in `Case1`
Expand Down
14 changes: 7 additions & 7 deletions src/test/ui/associated-types/associated-types-eq-hr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize
--> $DIR/associated-types-eq-hr.rs:82:5
|
LL | fn foo<T>()
| ---
| --- required by a bound in this
LL | where T : for<'x> TheTrait<&'x isize, A = &'x isize>
| ------------- required by this bound in `foo`
...
Expand All @@ -16,7 +16,7 @@ error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>
--> $DIR/associated-types-eq-hr.rs:86:5
|
LL | fn bar<T>()
| ---
| --- required by a bound in this
LL | where T : for<'x> TheTrait<&'x isize, A = &'x usize>
| ------------- required by this bound in `bar`
...
Expand All @@ -30,7 +30,7 @@ error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize
--> $DIR/associated-types-eq-hr.rs:91:17
|
LL | fn tuple_one<T>()
| ---------
| --------- required by a bound in this
LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize>
| ---------------------------------------------------------- required by this bound in `tuple_one`
...
Expand All @@ -44,7 +44,7 @@ error[E0271]: type mismatch resolving `for<'x, 'y> <Tuple as TheTrait<(&'x isize
--> $DIR/associated-types-eq-hr.rs:91:5
|
LL | fn tuple_one<T>()
| ---------
| --------- required by a bound in this
LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize>
| ------------- required by this bound in `tuple_one`
...
Expand All @@ -55,7 +55,7 @@ error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize
--> $DIR/associated-types-eq-hr.rs:97:17
|
LL | fn tuple_two<T>()
| ---------
| --------- required by a bound in this
LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>
| ---------------------------------------------------------- required by this bound in `tuple_two`
...
Expand All @@ -69,7 +69,7 @@ error[E0271]: type mismatch resolving `for<'x, 'y> <Tuple as TheTrait<(&'x isize
--> $DIR/associated-types-eq-hr.rs:97:5
|
LL | fn tuple_two<T>()
| ---------
| --------- required by a bound in this
LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>
| ------------- required by this bound in `tuple_two`
...
Expand All @@ -80,7 +80,7 @@ error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize
--> $DIR/associated-types-eq-hr.rs:107:18
|
LL | fn tuple_four<T>()
| ----------
| ---------- required by a bound in this
LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)>
| ------------------------------------------- required by this bound in `tuple_four`
...
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/associated-types/defaults-unsound-62211-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ error[E0277]: `T` doesn't implement `std::fmt::Display`
--> $DIR/defaults-unsound-62211-1.rs:41:9
|
LL | trait UncheckedCopy: Sized {
| -------------
| ------------- required by a bound in this
...
LL | + Display = Self;
| ------- required by this bound in `UncheckedCopy`
Expand All @@ -62,7 +62,7 @@ error[E0277]: the trait bound `T: std::ops::Deref` is not satisfied
--> $DIR/defaults-unsound-62211-1.rs:41:9
|
LL | trait UncheckedCopy: Sized {
| -------------
| ------------- required by a bound in this
...
LL | + Deref<Target = str>
| ------------------- required by this bound in `UncheckedCopy`
Expand All @@ -79,7 +79,7 @@ error[E0277]: cannot add-assign `&'static str` to `T`
--> $DIR/defaults-unsound-62211-1.rs:41:9
|
LL | trait UncheckedCopy: Sized {
| -------------
| ------------- required by a bound in this
...
LL | + AddAssign<&'static str>
| ----------------------- required by this bound in `UncheckedCopy`
Expand All @@ -97,7 +97,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
--> $DIR/defaults-unsound-62211-1.rs:41:9
|
LL | trait UncheckedCopy: Sized {
| -------------
| ------------- required by a bound in this
...
LL | type Output: Copy
| ---- required by this bound in `UncheckedCopy`
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/associated-types/defaults-unsound-62211-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ error[E0277]: `T` doesn't implement `std::fmt::Display`
--> $DIR/defaults-unsound-62211-2.rs:41:9
|
LL | trait UncheckedCopy: Sized {
| -------------
| ------------- required by a bound in this
...
LL | + Display = Self;
| ------- required by this bound in `UncheckedCopy`
Expand All @@ -62,7 +62,7 @@ error[E0277]: the trait bound `T: std::ops::Deref` is not satisfied
--> $DIR/defaults-unsound-62211-2.rs:41:9
|
LL | trait UncheckedCopy: Sized {
| -------------
| ------------- required by a bound in this
...
LL | + Deref<Target = str>
| ------------------- required by this bound in `UncheckedCopy`
Expand All @@ -79,7 +79,7 @@ error[E0277]: cannot add-assign `&'static str` to `T`
--> $DIR/defaults-unsound-62211-2.rs:41:9
|
LL | trait UncheckedCopy: Sized {
| -------------
| ------------- required by a bound in this
...
LL | + AddAssign<&'static str>
| ----------------------- required by this bound in `UncheckedCopy`
Expand All @@ -97,7 +97,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
--> $DIR/defaults-unsound-62211-2.rs:41:9
|
LL | trait UncheckedCopy: Sized {
| -------------
| ------------- required by a bound in this
...
LL | type Output: Copy
| ---- required by this bound in `UncheckedCopy`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _`
--> $DIR/higher-ranked-projection.rs:25:5
|
LL | fn foo<U, T>(_t: T)
| ---
| --- required by a bound in this
LL | where for<'a> &'a T: Mirror<Image=U>
| ------- required by this bound in `foo`
...
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/associated-types/issue-43924.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error[E0277]: the trait bound `(dyn std::string::ToString + 'static): std::defau
--> $DIR/issue-43924.rs:10:6
|
LL | trait Foo<T: Default + ToString> {
| ---
| --- required by a bound in this
LL | type Out: Default + ToString + ?Sized = dyn ToString;
| ------- required by this bound in `Foo`
...
Expand All @@ -21,7 +21,7 @@ error[E0277]: the trait bound `(dyn std::string::ToString + 'static): std::defau
--> $DIR/issue-43924.rs:11:6
|
LL | trait Foo<T: Default + ToString> {
| ---
| --- required by a bound in this
LL | type Out: Default + ToString + ?Sized = dyn ToString;
| ------- required by this bound in `Foo`
...
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/associated-types/issue-65774-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied
--> $DIR/issue-65774-1.rs:16:6
|
LL | trait MPU {
| ---
| --- required by a bound in this
LL | type MpuConfig: MyDisplay = T;
| --------- required by this bound in `MPU`
...
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/associated-types/issue-65774-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied
--> $DIR/issue-65774-2.rs:16:6
|
LL | trait MPU {
| ---
| --- required by a bound in this
LL | type MpuConfig: MyDisplay = T;
| --------- required by this bound in `MPU`
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the trait bound `bool: Bar` is not satisfied
--> $DIR/point-at-type-on-obligation-failure-2.rs:8:18
|
LL | trait Foo {
| ---
| --- required by a bound in this
LL | type Assoc: Bar;
| --- required by this bound in `Foo`
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:30:5
|
LL | fn with_closure_expecting_fn_with_free_region<F>(_: F)
| ------------------------------------------
| ------------------------------------------ required by a bound in this
LL | where F: for<'a> FnOnce(fn(&'a u32), &i32)
| ------------------------- required by this bound in `with_closure_expecting_fn_with_free_region`
...
Expand All @@ -15,7 +15,7 @@ error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:37:5
|
LL | fn with_closure_expecting_fn_with_bound_region<F>(_: F)
| -------------------------------------------
| ------------------------------------------- required by a bound in this
LL | where F: FnOnce(fn(&u32), &i32)
| ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region`
...
Expand All @@ -28,7 +28,7 @@ error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:46:5
|
LL | fn with_closure_expecting_fn_with_bound_region<F>(_: F)
| -------------------------------------------
| ------------------------------------------- required by a bound in this
LL | where F: FnOnce(fn(&u32), &i32)
| ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region`
...
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:30:5
|
LL | fn with_closure_expecting_fn_with_free_region<F>(_: F)
| ------------------------------------------
| ------------------------------------------ required by a bound in this
LL | where F: for<'a> FnOnce(fn(&'a u32), &i32)
| ------------------------- required by this bound in `with_closure_expecting_fn_with_free_region`
...
Expand All @@ -53,7 +53,7 @@ error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:37:5
|
LL | fn with_closure_expecting_fn_with_bound_region<F>(_: F)
| -------------------------------------------
| ------------------------------------------- required by a bound in this
LL | where F: FnOnce(fn(&u32), &i32)
| ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region`
...
Expand All @@ -66,7 +66,7 @@ error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:46:5
|
LL | fn with_closure_expecting_fn_with_bound_region<F>(_: F)
| -------------------------------------------
| ------------------------------------------- required by a bound in this
LL | where F: FnOnce(fn(&u32), &i32)
| ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region`
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments
--> $DIR/expect-infer-var-appearing-twice.rs:14:5
|
LL | fn with_closure<F, A>(_: F)
| ------------
| ------------ required by a bound in this
LL | where F: FnOnce(A, A)
| ------------ required by this bound in `with_closure`
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-re
--> $DIR/generator-yielding-or-returning-itself.rs:15:5
|
LL | pub fn want_cyclic_generator_return<T>(_: T)
| ----------------------------
| ---------------------------- required by a bound in this
LL | where T: Generator<Yield = (), Return = T>
| ---------- required by this bound in `want_cyclic_generator_return`
...
Expand All @@ -18,7 +18,7 @@ error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-re
--> $DIR/generator-yielding-or-returning-itself.rs:28:5
|
LL | pub fn want_cyclic_generator_yield<T>(_: T)
| ---------------------------
| --------------------------- required by a bound in this
LL | where T: Generator<Yield = T, Return = ()>
| --------- required by this bound in `want_cyclic_generator_yield`
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0280]: the requirement `for<'a> <Self as Iterator>::Item<'a>: 'a` is not
--> $DIR/issue-62326-parameter-out-of-range.rs:7:20
|
LL | trait Iterator {
| --------
| -------- required by a bound in this
LL | type Item<'a>: 'a;
| ^^ required by this bound in `Iterator`

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/iterable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ error[E0271]: type mismatch resolving `for<'a> <<std::vec::Vec<T> as Iterable>::
--> $DIR/iterable.rs:19:30
|
LL | trait Iterable {
| --------
| -------- required by a bound in this
LL | type Item<'a> where Self: 'a;
LL | type Iter<'a>: Iterator<Item = Self::Item<'a>> where Self: 'a;
| --------------------- required by this bound in `Iterable`
Expand All @@ -41,7 +41,7 @@ error[E0271]: type mismatch resolving `for<'a> <<[T] as Iterable>::Iter<'a> as s
--> $DIR/iterable.rs:31:30
|
LL | trait Iterable {
| --------
| -------- required by a bound in this
LL | type Item<'a> where Self: 'a;
LL | type Iter<'a>: Iterator<Item = Self::Item<'a>> where Self: 'a;
| --------------------- required by this bound in `Iterable`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hrtb/hrtb-conflate-regions.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the trait bound `for<'a, 'b> SomeStruct: Foo<(&'a isize, &'b isize
--> $DIR/hrtb-conflate-regions.rs:27:22
|
LL | fn want_foo2<T>()
| ---------
| --------- required by a bound in this
LL | where T : for<'a,'b> Foo<(&'a isize, &'b isize)>
| -------------------------------------- required by this bound in `want_foo2`
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the trait bound `(): Trait<for<'b> fn(&'b u32)>` is not satisfied
--> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:11
|
LL | fn foo<T>()
| ---
| --- required by a bound in this
LL | where
LL | T: Trait<for<'b> fn(&'b u32)>,
| -------------------------- required by this bound in `foo`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the trait bound `(): Trait<for<'b> fn(fn(&'b u32))>` is not satisf
--> $DIR/hrtb-exists-forall-trait-covariant.rs:36:11
|
LL | fn foo<T>()
| ---
| --- required by a bound in this
LL | where
LL | T: Trait<for<'b> fn(fn(&'b u32))>,
| ------------------------------ required by this bound in `foo`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the trait bound `(): Trait<for<'b> fn(std::cell::Cell<&'b u32>)>`
--> $DIR/hrtb-exists-forall-trait-invariant.rs:28:11
|
LL | fn foo<T>()
| ---
| --- required by a bound in this
LL | where
LL | T: Trait<for<'b> fn(Cell<&'b u32>)>,
| -------------------------------- required by this bound in `foo`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied
--> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:47:26
|
LL | fn want_bar_for_any_ccx<B>(b: &B)
| --------------------
| -------------------- required by a bound in this
LL | where B : for<'ccx> Bar<'ccx>
| ------------------- required by this bound in `want_bar_for_any_ccx`
...
Expand Down
Loading

0 comments on commit d9a5419

Please sign in to comment.