diff options
| author | kennytm <kennytm@gmail.com> | 2018-10-26 18:24:59 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-26 18:24:59 +0800 |
| commit | 46f504543d47e18484a65251918a937147bb8a45 (patch) | |
| tree | 98a73c2cd1ecea9180a658ec02b08993c3889e41 /src/test | |
| parent | d83376c70511b2fc12506bb22c3bb02353e028d1 (diff) | |
| parent | 4f2624cac90ee9145175d6e4b9c59b9ab7875a9c (diff) | |
| download | rust-46f504543d47e18484a65251918a937147bb8a45.tar.gz rust-46f504543d47e18484a65251918a937147bb8a45.zip | |
Rollup merge of #55258 - Aaron1011:fix/rustdoc-blanket, r=GuillaumeGomez
Fix Rustdoc ICE when checking blanket impls Fixes #55001, #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.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/rustdoc/issue-55001.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/rustdoc/issue-55001.rs b/src/test/rustdoc/issue-55001.rs new file mode 100644 index 00000000000..f6c7f9a3d08 --- /dev/null +++ b/src/test/rustdoc/issue-55001.rs @@ -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() {} |
