forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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 rust-lang#73335 - Aaron1011:fix/rustdoc-overflow, r=e…
…stebank Ignore overflow when finding auto-trait impls in Rustdoc In rust-lang#72936 (comment), it was determined that some unusual code could cause rustc to overflow when evaluating a predicate of the form `T: AutoTrait`. Even if this is a bug, it will still be possible to cause overflow through writing explicit impls of auto traits, just like any other type of impl. In rustdoc, this overflow can happen simply as a result of defining certain types, since we will automatically generate and evaluate auto-trait predicates when generating documentation. For now, we just ignore overflow during selection if it occurs in rustdoc. We should probably come up with a better way to handle this - e.g. rendering some kind of error in the generated documentation. However, this is a very unusual corner case, and this PR is sufficient to unblock landing a Chalk update in PR rust-lang#72936 This adds additional hacks to `librustc_trait_selection`. The auto-trait-finding code should probably be completely rewritten, but I think this is good enough for the time being.
- Loading branch information
Showing
4 changed files
with
119 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Tests that we don't fail with an overflow error for certain | ||
// strange types | ||
// See https://github.com/rust-lang/rust/pull/72936#issuecomment-643676915 | ||
|
||
pub trait Interner { | ||
type InternedType; | ||
} | ||
|
||
struct RustInterner<'tcx> { | ||
foo: &'tcx () | ||
} | ||
|
||
impl<'tcx> Interner for RustInterner<'tcx> { | ||
type InternedType = Box<TyData<Self>>; | ||
} | ||
|
||
enum TyData<I: Interner> { | ||
FnDef(I::InternedType) | ||
} | ||
|
||
struct VariableKind<I: Interner>(I::InternedType); | ||
|
||
// @has overflow/struct.BoundVarsCollector.html | ||
// @has - '//code' "impl<'tcx> Send for BoundVarsCollector<'tcx>" | ||
pub struct BoundVarsCollector<'tcx> { | ||
val: VariableKind<RustInterner<'tcx>> | ||
} | ||
|
||
fn is_send<T: Send>() {} | ||
|
||
struct MyInterner<'tcx> { | ||
val: &'tcx () | ||
} | ||
|
||
fn main() {} |