-Znext-solver Prevent committing unfulfilled unsized coercion#152444
-Znext-solver Prevent committing unfulfilled unsized coercion#152444rust-bors[bot] merged 1 commit intorust-lang:mainfrom
-Znext-solver Prevent committing unfulfilled unsized coercion#152444Conversation
|
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
| .add(0.0) | ||
| .add(0.0) | ||
| .add(0.0) | ||
| .add(0.0) |
There was a problem hiding this comment.
Added some more .add calls from adwin's original code to make it sure this exceeds the default recursion limit (10)
This comment has been minimized.
This comment has been minimized.
1751d10 to
e93b68c
Compare
| if self.depth < visitor.config().max_depth { | ||
| try_visit!(visitor.visit_goal(self)); | ||
| } else { | ||
| return visitor.on_recursion_limit(); | ||
| } | ||
|
|
||
| V::Result::output() |
| fn on_recursion_limit(&mut self) -> Self::Result { | ||
| // This prevents accidentally committing unfulfilled unsized coercions while trying to find | ||
| // the error source for diagnostics. | ||
| // See https://github.com/rust-lang/trait-system-refactor-initiative/issues/266. |
There was a problem hiding this comment.
i think this breaks the following snippet if we encounter it in the Certainty::Maybe recursion
struct W<T: ?Sized>(T);
type Four<T: ?Sized> = W<W<W<W<T>>>>;
type Sixteen<T: ?Sized> = Four<Four<Four<Four<T>>>>;
fn ret<T>(x: T) -> Sixteen<T> {
todo!();
}
fn please_coerce() {
let mut y = Default::default();
let x = ret(y);
let _: &Sixteen<dyn Send> = &x;
y = 1u32;
}There was a problem hiding this comment.
Oops, I missed the case that we could visit nested goal here 😅
rust/compiler/rustc_hir_typeck/src/coercion.rs
Lines 2012 to 2015 in 7b25457
e93b68c to
96d2318
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| struct CoerceVisitor<'a, 'tcx> { | ||
| fcx: &'a FnCtxt<'a, 'tcx>, | ||
| span: Span, | ||
| // Whether the coercion is impossible and just continuing to visit to locate the error source. |
There was a problem hiding this comment.
| // Whether the coercion is impossible and just continuing to visit to locate the error source. | |
| /// Whether the coercion is impossible. If so we someties still try to | |
| /// coerce in these cases to emit better errors. This impacts changes the | |
| /// behavior when hitting the recursion limit. |
|
@bors delegate+ |
|
✌️ @ShoyuVanilla, you can now approve this pull request! If @lcnr told you to " |
96d2318 to
069c78f
Compare
This comment has been minimized.
This comment has been minimized.
069c78f to
891acbd
Compare
|
@bors r=lcnr rollup |
…it, r=lcnr `-Znext-solver` Prevent committing unfulfilled unsized coercion Fixes rust-lang/trait-system-refactor-initiative#266 r? lcnr
…uwer Rollup of 11 pull requests Successful merges: - #146901 (Support AVRTiny devices in AVR inline assembly) - #150988 (Improve code suggestion for incorrect macro_rules! usage) - #152422 (Change query proc macro to be more rust-analyzer friendly) - #152496 (Fix multi-cgu+debug builds using autodiff by delaying autodiff till lto) - #152520 (Don't use `DepContext` in `rustc_middle::traits::cache`) - #152528 (Support serializing CodegenContext) - #152082 (Move tests) - #152444 (`-Znext-solver` Prevent committing unfulfilled unsized coercion) - #152486 (remove redundant backchain attribute in codegen) - #152529 (sparc64: enable abi compatibility test) - #152548 (reject inline const patterns pre-expansion)
…it, r=lcnr `-Znext-solver` Prevent committing unfulfilled unsized coercion Fixes rust-lang/trait-system-refactor-initiative#266 r? lcnr
Rollup of 18 pull requests Successful merges: - #150551 (Compute localized outlives constraints lazily) - #150752 (Update libc to v0.2.181) - #150988 (Improve code suggestion for incorrect macro_rules! usage) - #152422 (Change query proc macro to be more rust-analyzer friendly) - #152496 (Fix multi-cgu+debug builds using autodiff by delaying autodiff till lto) - #152514 (Collect active query jobs into struct `QueryJobMap`) - #152520 (Don't use `DepContext` in `rustc_middle::traits::cache`) - #152528 (Support serializing CodegenContext) - #152082 (Move tests) - #152232 (Add must_use for FileTimes) - #152329 (Simplify parallel! macro) - #152444 (`-Znext-solver` Prevent committing unfulfilled unsized coercion) - #152486 (remove redundant backchain attribute in codegen) - #152519 (Fix feature gating for new `try bikeshed` expressions) - #152529 (sparc64: enable abi compatibility test) - #152548 (reject inline const patterns pre-expansion) - #152550 (Port #[prelude_import] to the attribute parser) - #152552 (Add 2048-bit HvxVectorPair support to Hexagon SIMD ABI checks)
Rollup of 17 pull requests Successful merges: - #150551 (Compute localized outlives constraints lazily) - #150988 (Improve code suggestion for incorrect macro_rules! usage) - #152422 (Change query proc macro to be more rust-analyzer friendly) - #152496 (Fix multi-cgu+debug builds using autodiff by delaying autodiff till lto) - #152514 (Collect active query jobs into struct `QueryJobMap`) - #152520 (Don't use `DepContext` in `rustc_middle::traits::cache`) - #152528 (Support serializing CodegenContext) - #152082 (Move tests) - #152232 (Add must_use for FileTimes) - #152329 (Simplify parallel! macro) - #152444 (`-Znext-solver` Prevent committing unfulfilled unsized coercion) - #152486 (remove redundant backchain attribute in codegen) - #152519 (Fix feature gating for new `try bikeshed` expressions) - #152529 (sparc64: enable abi compatibility test) - #152548 (reject inline const patterns pre-expansion) - #152550 (Port #[prelude_import] to the attribute parser) - #152552 (Add 2048-bit HvxVectorPair support to Hexagon SIMD ABI checks) Failed merges: - #152515 (Extract `DepKindVTable` constructors to their own module)
Rollup merge of #152444 - ShoyuVanilla:unsized-recursion-limit, r=lcnr `-Znext-solver` Prevent committing unfulfilled unsized coercion Fixes rust-lang/trait-system-refactor-initiative#266 r? lcnr
Fixes rust-lang/trait-system-refactor-initiative#266
r? lcnr