diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2018-12-11 14:18:30 -0500 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2019-01-03 21:56:52 -0500 |
| commit | 6d54672acf431ceae0b057f45e0351e84793d9f2 (patch) | |
| tree | b8e88777d89f62761df51f0a032cc44c9d7b68d0 /src/test/rustdoc | |
| parent | c0bbc3927e28c22edefe6a1353b5ecc95ea9a104 (diff) | |
| download | rust-6d54672acf431ceae0b057f45e0351e84793d9f2.tar.gz rust-6d54672acf431ceae0b057f45e0351e84793d9f2.zip | |
Fix stack overflow when finding blanket impls
Currently, SelectionContext tries to prevent stack overflow by keeping track of the current recursion depth. However, this depth tracking is only used when performing normal section (which includes confirmation). No such tracking is performed for evaluate_obligation_recursively, which can allow a stack overflow to occur. To fix this, this commit tracks the current predicate evaluation depth. This is done separately from the existing obligation depth tracking: an obligation overflow can occur across multiple calls to 'select' (e.g. when fulfilling a trait), while a predicate evaluation overflow can only happen as a result of a deep recursive call stack. Fixes #56701
Diffstat (limited to 'src/test/rustdoc')
| -rw-r--r-- | src/test/rustdoc/issue-56701.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/rustdoc/issue-56701.rs b/src/test/rustdoc/issue-56701.rs new file mode 100644 index 00000000000..6fb30a4ff4c --- /dev/null +++ b/src/test/rustdoc/issue-56701.rs @@ -0,0 +1,34 @@ +// This shouldn't cause a stack overflow when rustdoc is run + +use std::ops::Deref; +use std::ops::DerefMut; + +pub trait SimpleTrait { + type SimpleT; +} + +impl<Inner: SimpleTrait, Outer: Deref<Target = Inner>> SimpleTrait for Outer { + type SimpleT = Inner::SimpleT; +} + +pub trait AnotherTrait { + type AnotherT; +} + +impl<T, Simple: SimpleTrait<SimpleT = Vec<T>>> AnotherTrait for Simple { + type AnotherT = T; +} + +pub struct Unrelated<Inner, UnrelatedT: DerefMut<Target = Vec<Inner>>>(UnrelatedT); + +impl<Inner, UnrelatedT: DerefMut<Target = Vec<Inner>>> Deref for Unrelated<Inner, UnrelatedT> { + type Target = Vec<Inner>; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + + +pub fn main() { } + |
