Skip to content

Commit ab474c7

Browse files
authored
Rollup merge of rust-lang#91205 - Aaron1011:visit_param_env, r=lcnr
Visit `param_env` field in Obligation's `TypeFoldable` impl This oversight appears to have gone unnoticed for a long time without causing issues, but it should still be fixed.
2 parents 952ae50 + d7e8212 commit ab474c7

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

compiler/rustc_infer/src/traits/structural_impls.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx
7070
}
7171

7272
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
73-
self.predicate.visit_with(visitor)
73+
self.predicate.visit_with(visitor)?;
74+
self.param_env.visit_with(visitor)
7475
}
7576
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: generic parameters may not be used in const operations
2-
--> $DIR/issue-72787.rs:11:17
2+
--> $DIR/issue-72787.rs:12:17
33
|
44
LL | Condition<{ LHS <= RHS }>: True
55
| ^^^ cannot perform const operation using `LHS`
@@ -8,7 +8,7 @@ LL | Condition<{ LHS <= RHS }>: True
88
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
99

1010
error: generic parameters may not be used in const operations
11-
--> $DIR/issue-72787.rs:11:24
11+
--> $DIR/issue-72787.rs:12:24
1212
|
1313
LL | Condition<{ LHS <= RHS }>: True
1414
| ^^^ cannot perform const operation using `RHS`
@@ -17,7 +17,7 @@ LL | Condition<{ LHS <= RHS }>: True
1717
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
1818

1919
error: generic parameters may not be used in const operations
20-
--> $DIR/issue-72787.rs:25:25
20+
--> $DIR/issue-72787.rs:26:25
2121
|
2222
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
2323
| ^ cannot perform const operation using `I`
@@ -26,7 +26,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
2626
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
2727

2828
error: generic parameters may not be used in const operations
29-
--> $DIR/issue-72787.rs:25:36
29+
--> $DIR/issue-72787.rs:26:36
3030
|
3131
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
3232
| ^ cannot perform const operation using `J`
@@ -35,21 +35,29 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
3535
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
3636

3737
error[E0283]: type annotations needed
38-
--> $DIR/issue-72787.rs:21:26
38+
--> $DIR/issue-72787.rs:10:38
39+
|
40+
LL | impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
41+
| ^^^^ cannot infer type for struct `IsLessOrEqual<LHS, RHS>`
42+
|
43+
= note: cannot satisfy `IsLessOrEqual<LHS, RHS>: True`
44+
45+
error[E0283]: type annotations needed
46+
--> $DIR/issue-72787.rs:22:26
3947
|
4048
LL | IsLessOrEqual<I, 8>: True,
4149
| ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
4250
|
4351
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
4452

4553
error[E0283]: type annotations needed
46-
--> $DIR/issue-72787.rs:21:26
54+
--> $DIR/issue-72787.rs:22:26
4755
|
4856
LL | IsLessOrEqual<I, 8>: True,
4957
| ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
5058
|
5159
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
5260

53-
error: aborting due to 6 previous errors
61+
error: aborting due to 7 previous errors
5462

5563
For more information about this error, try `rustc --explain E0283`.

src/test/ui/const-generics/generic_const_exprs/issue-72787.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub struct Condition<const CONDITION: bool>;
88
pub trait True {}
99

1010
impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
11+
//[min]~^ ERROR type annotations needed
1112
Condition<{ LHS <= RHS }>: True
1213
//[min]~^ Error generic parameters may not be used in const operations
1314
//[min]~| Error generic parameters may not be used in const operations

src/test/ui/issues/issue-77919.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ struct Multiply<N, M> {
1010
}
1111
impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
1212
//~^ ERROR cannot find type `VAL` in this scope
13-
//~| ERROR not all trait items implemented, missing: `VAL`
13+
//~| ERROR type annotations needed

src/test/ui/issues/issue-77919.stderr

+7-8
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
1717
| |
1818
| help: you might be missing a type parameter: `, VAL`
1919

20-
error[E0046]: not all trait items implemented, missing: `VAL`
21-
--> $DIR/issue-77919.rs:11:1
20+
error[E0283]: type annotations needed
21+
--> $DIR/issue-77919.rs:11:12
2222
|
23-
LL | const VAL: T;
24-
| ------------- `VAL` from trait
25-
...
2623
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
27-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation
24+
| ^^^^^^^^^^^^^^ cannot infer type for struct `Multiply<N, M>`
25+
|
26+
= note: cannot satisfy `Multiply<N, M>: TypeVal<usize>`
2827

2928
error: aborting due to 3 previous errors
3029

31-
Some errors have detailed explanations: E0046, E0412.
32-
For more information about an error, try `rustc --explain E0046`.
30+
Some errors have detailed explanations: E0283, E0412.
31+
For more information about an error, try `rustc --explain E0283`.

0 commit comments

Comments
 (0)