Skip to content

Commit f074bbf

Browse files
authored
Rollup merge of rust-lang#139374 - oli-obk:const-trait-bound, r=compiler-errors
Use the span of the whole bound when the diagnostic talks about a bound While it makes sense that the host predicate only points to the `~const` part, as whether the actual trait bound is satisfied is checked separately, the user facing diagnostic is talking about the entire trait bound, at which point it makes more sense to just highlight the entire bound r? `@compiler-errors` or `@fee1-dead`
2 parents fa7d66e + a69a219 commit f074bbf

18 files changed

+33
-33
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 2 additions & 2 deletions
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

tests/ui/consts/const-block-const-bound.stderr

Lines changed: 1 addition & 1 deletion
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

tests/ui/traits/const-traits/assoc-type.current.stderr

Lines changed: 1 addition & 1 deletion
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

tests/ui/traits/const-traits/assoc-type.next.stderr

Lines changed: 1 addition & 1 deletion
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

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

Lines changed: 1 addition & 1 deletion
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

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

Lines changed: 2 additions & 2 deletions
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

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

Lines changed: 2 additions & 2 deletions
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

tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr

Lines changed: 2 additions & 2 deletions
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

tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr

Lines changed: 2 additions & 2 deletions
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

tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr

Lines changed: 2 additions & 2 deletions
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

0 commit comments

Comments
 (0)