Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only check for errors in predicate when skipping impl assembly #91254

Merged
merged 1 commit into from
Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// This helps us avoid overflow: see issue #72839
// Since compilation is already guaranteed to fail, this is just
// to try to show the 'nicest' possible errors to the user.
if obligation.references_error() {
// We don't check for errors in the `ParamEnv` - in practice,
// it seems to cause us to be overly aggressive in deciding
// to give up searching for candidates, leading to spurious errors.
if obligation.predicate.references_error() {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: generic parameters may not be used in const operations
--> $DIR/issue-72787.rs:12:17
--> $DIR/issue-72787.rs:11:17
|
LL | Condition<{ LHS <= RHS }>: True
| ^^^ cannot perform const operation using `LHS`
Expand All @@ -8,7 +8,7 @@ LL | Condition<{ LHS <= RHS }>: True
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

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

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

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

error[E0283]: type annotations needed
--> $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
--> $DIR/issue-72787.rs:21:26
|
LL | IsLessOrEqual<I, 8>: True,
| ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
|
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`

error[E0283]: type annotations needed
--> $DIR/issue-72787.rs:22:26
--> $DIR/issue-72787.rs:21:26
|
LL | IsLessOrEqual<I, 8>: True,
| ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
|
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`

error: aborting due to 7 previous errors
error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0283`.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub struct Condition<const CONDITION: bool>;
pub trait True {}

impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
//[min]~^ ERROR type annotations needed
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
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-77919.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ struct Multiply<N, M> {
}
impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
//~^ ERROR cannot find type `VAL` in this scope
//~| ERROR type annotations needed
//~| ERROR not all trait items implemented, missing: `VAL`
15 changes: 8 additions & 7 deletions src/test/ui/issues/issue-77919.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| |
| help: you might be missing a type parameter: `, VAL`

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

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0283, E0412.
For more information about an error, try `rustc --explain E0283`.
Some errors have detailed explanations: E0046, E0412.
For more information about an error, try `rustc --explain E0046`.
15 changes: 8 additions & 7 deletions src/tools/clippy/tests/ui/crashes/ice-6252.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| |
| help: you might be missing a type parameter: `, VAL`

error[E0283]: type annotations needed
--> $DIR/ice-6252.rs:10:12
error[E0046]: not all trait items implemented, missing: `VAL`
--> $DIR/ice-6252.rs:10:1
|
LL | const VAL: T;
| ------------- `VAL` from trait
...
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| ^^^^^^^^^^^^^^ cannot infer type for struct `Multiply<N, M>`
|
= note: cannot satisfy `Multiply<N, M>: TypeVal<usize>`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation

error: aborting due to 3 previous errors

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