Skip to content

Commit a69a219

Browse files
committed
Use the span of the whole bound when the diagnostic talks about a bound
1 parent a4166da commit a69a219

18 files changed

+33
-33
lines changed

Diff for: compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
838838
| PredicateFilter::SelfOnly
839839
| PredicateFilter::SelfAndAssociatedTypeBounds => {
840840
match constness {
841-
hir::BoundConstness::Always(span) => {
841+
hir::BoundConstness::Always(_) => {
842842
if polarity == ty::PredicatePolarity::Positive {
843843
bounds.push((
844844
poly_trait_ref
@@ -864,7 +864,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
864864
// in `lower_assoc_item_constraint`.
865865
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {
866866
match constness {
867-
hir::BoundConstness::Maybe(span) => {
867+
hir::BoundConstness::Maybe(_) => {
868868
if polarity == ty::PredicatePolarity::Positive {
869869
bounds.push((
870870
poly_trait_ref

Diff for: tests/ui/consts/const-block-const-bound.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required by a bound in `f`
1010
--> $DIR/const-block-const-bound.rs:6:15
1111
|
1212
LL | const fn f<T: ~const Destruct>(x: T) {}
13-
| ^^^^^^ required by this bound in `f`
13+
| ^^^^^^^^^^^^^^^ required by this bound in `f`
1414

1515
error: aborting due to 1 previous error
1616

Diff for: tests/ui/traits/const-traits/assoc-type.current.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: required by a bound in `Foo::Bar`
88
--> $DIR/assoc-type.rs:33:15
99
|
1010
LL | type Bar: ~const Add;
11-
| ^^^^^^ required by this bound in `Foo::Bar`
11+
| ^^^^^^^^^^ required by this bound in `Foo::Bar`
1212

1313
error: aborting due to 1 previous error
1414

Diff for: tests/ui/traits/const-traits/assoc-type.next.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: required by a bound in `Foo::Bar`
88
--> $DIR/assoc-type.rs:33:15
99
|
1010
LL | type Bar: ~const Add;
11-
| ^^^^^^ required by this bound in `Foo::Bar`
11+
| ^^^^^^^^^^ required by this bound in `Foo::Bar`
1212

1313
error: aborting due to 1 previous error
1414

Diff for: tests/ui/traits/const-traits/call-generic-method-nonconst.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required by a bound in `equals_self`
1010
--> $DIR/call-generic-method-nonconst.rs:17:25
1111
|
1212
LL | const fn equals_self<T: ~const Foo>(t: &T) -> bool {
13-
| ^^^^^^ required by this bound in `equals_self`
13+
| ^^^^^^^^^^ required by this bound in `equals_self`
1414

1515
error: aborting due to 1 previous error
1616

Diff for: tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `const
88
--> $DIR/const-drop-fail-2.rs:25:25
99
|
1010
LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
11-
| ------ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
11+
| -------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
| |
1313
| unsatisfied trait bound introduced here
1414
note: required by a bound in `check`
1515
--> $DIR/const-drop-fail-2.rs:21:19
1616
|
1717
LL | const fn check<T: ~const Destruct>(_: T) {}
18-
| ^^^^^^ required by this bound in `check`
18+
| ^^^^^^^^^^^^^^^ required by this bound in `check`
1919

2020
error: aborting due to 1 previous error
2121

Diff for: tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `const
88
--> $DIR/const-drop-fail-2.rs:25:25
99
|
1010
LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
11-
| ------ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
11+
| -------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
| |
1313
| unsatisfied trait bound introduced here
1414
note: required by a bound in `check`
1515
--> $DIR/const-drop-fail-2.rs:21:19
1616
|
1717
LL | const fn check<T: ~const Destruct>(_: T) {}
18-
| ^^^^^^ required by this bound in `check`
18+
| ^^^^^^^^^^^^^^^ required by this bound in `check`
1919

2020
error: aborting due to 1 previous error
2121

Diff for: tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: required by a bound in `check`
1111
--> $DIR/const-drop-fail.rs:24:19
1212
|
1313
LL | const fn check<T: ~const Destruct>(_: T) {}
14-
| ^^^^^^ required by this bound in `check`
14+
| ^^^^^^^^^^^^^^^ required by this bound in `check`
1515

1616
error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
1717
--> $DIR/const-drop-fail.rs:35:5
@@ -26,7 +26,7 @@ note: required by a bound in `check`
2626
--> $DIR/const-drop-fail.rs:24:19
2727
|
2828
LL | const fn check<T: ~const Destruct>(_: T) {}
29-
| ^^^^^^ required by this bound in `check`
29+
| ^^^^^^^^^^^^^^^ required by this bound in `check`
3030

3131
error: aborting due to 2 previous errors
3232

Diff for: tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: required by a bound in `check`
1111
--> $DIR/const-drop-fail.rs:24:19
1212
|
1313
LL | const fn check<T: ~const Destruct>(_: T) {}
14-
| ^^^^^^ required by this bound in `check`
14+
| ^^^^^^^^^^^^^^^ required by this bound in `check`
1515

1616
error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
1717
--> $DIR/const-drop-fail.rs:35:5
@@ -26,7 +26,7 @@ note: required by a bound in `check`
2626
--> $DIR/const-drop-fail.rs:24:19
2727
|
2828
LL | const fn check<T: ~const Destruct>(_: T) {}
29-
| ^^^^^^ required by this bound in `check`
29+
| ^^^^^^^^^^^^^^^ required by this bound in `check`
3030

3131
error: aborting due to 2 previous errors
3232

Diff for: tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: required by a bound in `check`
1111
--> $DIR/const-drop-fail.rs:24:19
1212
|
1313
LL | const fn check<T: ~const Destruct>(_: T) {}
14-
| ^^^^^^ required by this bound in `check`
14+
| ^^^^^^^^^^^^^^^ required by this bound in `check`
1515

1616
error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
1717
--> $DIR/const-drop-fail.rs:35:5
@@ -26,7 +26,7 @@ note: required by a bound in `check`
2626
--> $DIR/const-drop-fail.rs:24:19
2727
|
2828
LL | const fn check<T: ~const Destruct>(_: T) {}
29-
| ^^^^^^ required by this bound in `check`
29+
| ^^^^^^^^^^^^^^^ required by this bound in `check`
3030

3131
error: aborting due to 2 previous errors
3232

Diff for: tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: required by a bound in `check`
1111
--> $DIR/const-drop-fail.rs:24:19
1212
|
1313
LL | const fn check<T: ~const Destruct>(_: T) {}
14-
| ^^^^^^ required by this bound in `check`
14+
| ^^^^^^^^^^^^^^^ required by this bound in `check`
1515

1616
error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
1717
--> $DIR/const-drop-fail.rs:35:5
@@ -26,7 +26,7 @@ note: required by a bound in `check`
2626
--> $DIR/const-drop-fail.rs:24:19
2727
|
2828
LL | const fn check<T: ~const Destruct>(_: T) {}
29-
| ^^^^^^ required by this bound in `check`
29+
| ^^^^^^^^^^^^^^^ required by this bound in `check`
3030

3131
error: aborting due to 2 previous errors
3232

Diff for: tests/ui/traits/const-traits/const-opaque.no.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required by a bound in `bar`
1010
--> $DIR/const-opaque.rs:26:17
1111
|
1212
LL | const fn bar<T: ~const Foo>(t: T) -> impl ~const Foo {
13-
| ^^^^^^ required by this bound in `bar`
13+
| ^^^^^^^^^^ required by this bound in `bar`
1414

1515
error[E0277]: the trait bound `(): const Foo` is not satisfied
1616
--> $DIR/const-opaque.rs:33:12

Diff for: tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: required by a bound in `foo`
88
--> $DIR/default-method-body-is-const-body-checking.rs:7:28
99
|
1010
LL | const fn foo<T>() where T: ~const Tr {}
11-
| ^^^^^^ required by this bound in `foo`
11+
| ^^^^^^^^^ required by this bound in `foo`
1212

1313
error: aborting due to 1 previous error
1414

Diff for: tests/ui/traits/const-traits/item-bound-entailment-fails.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: required by a bound in `Foo::Assoc`
88
--> $DIR/item-bound-entailment-fails.rs:5:20
99
|
1010
LL | type Assoc<T>: ~const Bar
11-
| ^^^^^^ required by this bound in `Foo::Assoc`
11+
| ^^^^^^^^^^ required by this bound in `Foo::Assoc`
1212

1313
error[E0277]: the trait bound `T: ~const Bar` is not satisfied
1414
--> $DIR/item-bound-entailment-fails.rs:24:21
@@ -20,12 +20,12 @@ note: required for `C<T>` to implement `~const Bar`
2020
--> $DIR/item-bound-entailment-fails.rs:14:15
2121
|
2222
LL | impl<T> const Bar for C<T> where T: ~const Bar {}
23-
| ^^^ ^^^^ ------ unsatisfied trait bound introduced here
23+
| ^^^ ^^^^ ---------- unsatisfied trait bound introduced here
2424
note: required by a bound in `Foo::Assoc`
2525
--> $DIR/item-bound-entailment-fails.rs:5:20
2626
|
2727
LL | type Assoc<T>: ~const Bar
28-
| ^^^^^^ required by this bound in `Foo::Assoc`
28+
| ^^^^^^^^^^ required by this bound in `Foo::Assoc`
2929

3030
error: aborting due to 2 previous errors
3131

Diff for: tests/ui/traits/const-traits/minicore-fn-fail.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required by a bound in `call_indirect`
1010
--> $DIR/minicore-fn-fail.rs:11:27
1111
|
1212
LL | const fn call_indirect<T: ~const Fn()>(t: &T) { t() }
13-
| ^^^^^^ required by this bound in `call_indirect`
13+
| ^^^^^^^^^^^ required by this bound in `call_indirect`
1414

1515
error: aborting due to 1 previous error
1616

Diff for: tests/ui/traits/const-traits/predicate-entailment-fails.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | type Bar<T> where T: ~const Bar;
55
| ----------- definition of `Bar` from trait
66
...
77
LL | type Bar<T> = () where T: const Bar;
8-
| ^^^^^ impl has extra requirement `T: const Bar`
8+
| ^^^^^^^^^ impl has extra requirement `T: const Bar`
99

1010
error[E0276]: impl has stricter requirements than trait
1111
--> $DIR/predicate-entailment-fails.rs:17:26
@@ -14,7 +14,7 @@ LL | fn foo<T>() where T: ~const Bar;
1414
| -------------------------------- definition of `foo` from trait
1515
...
1616
LL | fn foo<T>() where T: const Bar {}
17-
| ^^^^^ impl has extra requirement `T: const Bar`
17+
| ^^^^^^^^^ impl has extra requirement `T: const Bar`
1818

1919
error[E0276]: impl has stricter requirements than trait
2020
--> $DIR/predicate-entailment-fails.rs:28:31
@@ -23,7 +23,7 @@ LL | type Bar<T> where T: Bar;
2323
| ----------- definition of `Bar` from trait
2424
...
2525
LL | type Bar<T> = () where T: const Bar;
26-
| ^^^^^ impl has extra requirement `T: const Bar`
26+
| ^^^^^^^^^ impl has extra requirement `T: const Bar`
2727

2828
error[E0276]: impl has stricter requirements than trait
2929
--> $DIR/predicate-entailment-fails.rs:31:26
@@ -32,7 +32,7 @@ LL | fn foo<T>() where T: Bar;
3232
| ------------------------- definition of `foo` from trait
3333
...
3434
LL | fn foo<T>() where T: const Bar {}
35-
| ^^^^^ impl has extra requirement `T: const Bar`
35+
| ^^^^^^^^^ impl has extra requirement `T: const Bar`
3636

3737
error[E0276]: impl has stricter requirements than trait
3838
--> $DIR/predicate-entailment-fails.rs:35:31
@@ -41,7 +41,7 @@ LL | type Bar<T> where T: Bar;
4141
| ----------- definition of `Bar` from trait
4242
...
4343
LL | type Bar<T> = () where T: ~const Bar;
44-
| ^^^^^^ impl has extra requirement `T: ~const Bar`
44+
| ^^^^^^^^^^ impl has extra requirement `T: ~const Bar`
4545

4646
error[E0276]: impl has stricter requirements than trait
4747
--> $DIR/predicate-entailment-fails.rs:38:26
@@ -50,7 +50,7 @@ LL | fn foo<T>() where T: Bar;
5050
| ------------------------- definition of `foo` from trait
5151
...
5252
LL | fn foo<T>() where T: ~const Bar {}
53-
| ^^^^^^ impl has extra requirement `T: ~const Bar`
53+
| ^^^^^^^^^^ impl has extra requirement `T: ~const Bar`
5454

5555
error: aborting due to 6 previous errors
5656

Diff for: tests/ui/traits/const-traits/trait-where-clause-const.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: required by a bound in `Foo::b`
88
--> $DIR/trait-where-clause-const.rs:15:24
99
|
1010
LL | fn b() where Self: ~const Bar;
11-
| ^^^^^^ required by this bound in `Foo::b`
11+
| ^^^^^^^^^^ required by this bound in `Foo::b`
1212

1313
error[E0277]: the trait bound `T: ~const Bar` is not satisfied
1414
--> $DIR/trait-where-clause-const.rs:23:12
@@ -20,7 +20,7 @@ note: required by a bound in `Foo::c`
2020
--> $DIR/trait-where-clause-const.rs:16:13
2121
|
2222
LL | fn c<T: ~const Bar>();
23-
| ^^^^^^ required by this bound in `Foo::c`
23+
| ^^^^^^^^^^ required by this bound in `Foo::c`
2424

2525
error: aborting due to 2 previous errors
2626

Diff for: tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ note: required by a bound in `require`
2828
--> $DIR/unsatisfied-const-trait-bound.rs:8:15
2929
|
3030
LL | fn require<T: const Trait>() {}
31-
| ^^^^^ required by this bound in `require`
31+
| ^^^^^^^^^^^ required by this bound in `require`
3232

3333
error: aborting due to 4 previous errors
3434

0 commit comments

Comments
 (0)