1
Fork 0

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.
This commit is contained in:
Aaron Hill 2021-11-24 17:20:52 -06:00
parent 982c552c90
commit a7cc6bc4d0
No known key found for this signature in database
GPG key ID: B4087E510E98B164
6 changed files with 33 additions and 25 deletions

View file

@ -70,6 +70,7 @@ impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx
} }
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> { fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
self.predicate.visit_with(visitor) self.predicate.visit_with(visitor)?;
self.param_env.visit_with(visitor)
} }
} }

View file

@ -1,5 +1,5 @@
error: generic parameters may not be used in const operations error: generic parameters may not be used in const operations
--> $DIR/issue-72787.rs:11:17 --> $DIR/issue-72787.rs:12:17
| |
LL | Condition<{ LHS <= RHS }>: True LL | Condition<{ LHS <= RHS }>: True
| ^^^ cannot perform const operation using `LHS` | ^^^ cannot perform const operation using `LHS`
@ -8,7 +8,7 @@ LL | Condition<{ LHS <= RHS }>: True
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations error: generic parameters may not be used in const operations
--> $DIR/issue-72787.rs:11:24 --> $DIR/issue-72787.rs:12:24
| |
LL | Condition<{ LHS <= RHS }>: True LL | Condition<{ LHS <= RHS }>: True
| ^^^ cannot perform const operation using `RHS` | ^^^ cannot perform const operation using `RHS`
@ -17,7 +17,7 @@ LL | Condition<{ LHS <= RHS }>: True
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations error: generic parameters may not be used in const operations
--> $DIR/issue-72787.rs:25:25 --> $DIR/issue-72787.rs:26:25
| |
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^ cannot perform const operation using `I` | ^ cannot perform const operation using `I`
@ -26,7 +26,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations error: generic parameters may not be used in const operations
--> $DIR/issue-72787.rs:25:36 --> $DIR/issue-72787.rs:26:36
| |
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^ cannot perform const operation using `J` | ^ cannot perform const operation using `J`
@ -35,7 +35,15 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0283]: type annotations needed error[E0283]: type annotations needed
--> $DIR/issue-72787.rs:21:26 --> $DIR/issue-72787.rs:10:38
|
LL | impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
| ^^^^ cannot infer type for struct `IsLessOrEqual<LHS, RHS>`
|
= note: cannot satisfy `IsLessOrEqual<LHS, RHS>: True`
error[E0283]: type annotations needed
--> $DIR/issue-72787.rs:22:26
| |
LL | IsLessOrEqual<I, 8>: True, LL | IsLessOrEqual<I, 8>: True,
| ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>` | ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
@ -43,13 +51,13 @@ LL | IsLessOrEqual<I, 8>: True,
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True` = note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
error[E0283]: type annotations needed error[E0283]: type annotations needed
--> $DIR/issue-72787.rs:21:26 --> $DIR/issue-72787.rs:22:26
| |
LL | IsLessOrEqual<I, 8>: True, LL | IsLessOrEqual<I, 8>: True,
| ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>` | ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
| |
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True` = note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
error: aborting due to 6 previous errors error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0283`. For more information about this error, try `rustc --explain E0283`.

View file

@ -8,6 +8,7 @@ pub struct Condition<const CONDITION: bool>;
pub trait True {} pub trait True {}
impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
//[min]~^ ERROR type annotations needed
Condition<{ LHS <= RHS }>: True Condition<{ LHS <= RHS }>: True
//[min]~^ Error generic parameters may not be used in const operations //[min]~^ Error generic parameters may not be used in const operations
//[min]~| Error generic parameters may not be used in const operations //[min]~| Error generic parameters may not be used in const operations

View file

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

View file

@ -17,16 +17,15 @@ LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| | | |
| help: you might be missing a type parameter: `, VAL` | help: you might be missing a type parameter: `, VAL`
error[E0046]: not all trait items implemented, missing: `VAL` error[E0283]: type annotations needed
--> $DIR/issue-77919.rs:11:1 --> $DIR/issue-77919.rs:11:12
| |
LL | const VAL: T;
| ------------- `VAL` from trait
...
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {} LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation | ^^^^^^^^^^^^^^ cannot infer type for struct `Multiply<N, M>`
|
= note: cannot satisfy `Multiply<N, M>: TypeVal<usize>`
error: aborting due to 3 previous errors error: aborting due to 3 previous errors
Some errors have detailed explanations: E0046, E0412. Some errors have detailed explanations: E0283, E0412.
For more information about an error, try `rustc --explain E0046`. For more information about an error, try `rustc --explain E0283`.

View file

@ -21,16 +21,15 @@ LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| | | |
| help: you might be missing a type parameter: `, VAL` | help: you might be missing a type parameter: `, VAL`
error[E0046]: not all trait items implemented, missing: `VAL` error[E0283]: type annotations needed
--> $DIR/ice-6252.rs:10:1 --> $DIR/ice-6252.rs:10:12
| |
LL | const VAL: T;
| ------------- `VAL` from trait
...
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {} LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation | ^^^^^^^^^^^^^^ cannot infer type for struct `Multiply<N, M>`
|
= note: cannot satisfy `Multiply<N, M>: TypeVal<usize>`
error: aborting due to 3 previous errors error: aborting due to 3 previous errors
Some errors have detailed explanations: E0046, E0412. Some errors have detailed explanations: E0283, E0412.
For more information about an error, try `rustc --explain E0046`. For more information about an error, try `rustc --explain E0283`.