forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Rustdoc ICE when checking blanket impls
Fixes rust-lang#55001, rust-lang#54744 Previously, SelectionContext would unconditionally cache the selection result for an obligation. This worked fine for most users of SelectionContext, but it caused an issue when used by Rustdoc's blanket impl finder. The issue occured when SelectionContext chose a ParamCandidate which contained inference variables. Since inference variables can change between calls to select(), it's not safe to cache the selection result - the chosen candidate might not be applicable for future results, leading to an ICE when we try to run confirmation. This commit prevents SelectionContext from caching any ParamCandidate that contains inference variables. This should always be completely safe, as trait selection should never depend on a particular result being cached. I've also added some extra debug!() statements, which I found helpful in tracking down this bug.
- Loading branch information
Showing
5 changed files
with
87 additions
and
3 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,31 @@ | ||
// Regression test for issue #55001. Previously, we would incorrectly | ||
// cache certain trait selection results when checking for blanket impls, | ||
// resulting in an ICE when we tried to confirm the cached ParamCandidate | ||
// against an obligation. | ||
|
||
pub struct DefaultAllocator; | ||
pub struct Standard; | ||
pub struct Inner; | ||
|
||
pub trait Rand {} | ||
|
||
pub trait Distribution<T> {} | ||
pub trait Allocator<N> {} | ||
|
||
impl<T> Rand for T where Standard: Distribution<T> {} | ||
|
||
impl<A> Distribution<Point<A>> for Standard | ||
where | ||
DefaultAllocator: Allocator<A>, | ||
Standard: Distribution<A> {} | ||
|
||
impl Distribution<Inner> for Standard {} | ||
|
||
|
||
pub struct Point<N> | ||
where DefaultAllocator: Allocator<N> | ||
{ | ||
field: N | ||
} | ||
|
||
fn main() {} |