-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #73005 - Aaron1011:fix/error-overflow, r=estebank
Don't create impl candidates when obligation contains errors Fixes #72839 In PR #72621, trait selection was modified to no longer bail out early when an error type was encountered. This allowed us treat `ty::Error` as `Sized`, causing us to avoid emitting a spurious "not sized" error after a type error had already occured. However, this means that we may now try to match an impl candidate against the error type. Since the error type will unify with almost anything, this can cause us to infinitely recurse (eventually triggering an overflow) when trying to verify certain `where` clauses. This commit causes us to skip generating any impl candidates when an error type is involved.
- Loading branch information
Showing
6 changed files
with
55 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Regression test for issue #72839 | ||
// Tests that we do not overflow during trait selection after | ||
// a type error occurs | ||
use std::ops::Rem; | ||
trait Foo {} | ||
struct MyStruct<T>(T); | ||
|
||
impl<T, U> Rem<MyStruct<T>> for MyStruct<U> where MyStruct<U>: Rem<MyStruct<T>> { | ||
type Output = u8; | ||
fn rem(self, _: MyStruct<T>) -> Self::Output { | ||
panic!() | ||
} | ||
} | ||
|
||
fn main() {} | ||
|
||
fn foo() { | ||
if missing_var % 8 == 0 {} //~ ERROR cannot find | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0425]: cannot find value `missing_var` in this scope | ||
--> $DIR/issue-72839-error-overflow.rs:18:8 | ||
| | ||
LL | if missing_var % 8 == 0 {} | ||
| ^^^^^^^^^^^ not found in this scope | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0425`. |