-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Continue to borrowck even if there were previous errors #120550
Conversation
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
self.cont_ln | ||
.get(&sc) | ||
.cloned() | ||
.unwrap_or_else(|| span_bug!(expr.span, "continue to unknown label")) | ||
self.cont_ln.get(&sc).cloned().unwrap_or_else(|| { | ||
self.ir.tcx.dcx().span_delayed_bug(expr.span, "continue to unknown label"); | ||
self.ir.add_live_node(ErrNode) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't (yet) know that we should not be doing liveness checks, because the error happens in check_mod_loops for which we have no path to forward a taint to here ("here" being check_liveness
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw this (at least used to?) fire here I believe: #113379
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh neat. More evidence that those ICEs I've caused are preexisting, but hard to trigger
let Some(drops) = self.scopes.breakable_scopes[break_index].continue_drops.as_mut() | ||
else { | ||
self.tcx.dcx().span_delayed_bug( | ||
source_info.span, | ||
"unlabelled `continue` within labelled block", | ||
); | ||
self.cfg.terminate(block, source_info, TerminatorKind::Unreachable); | ||
|
||
return self.cfg.start_new_block().unit(); | ||
}; | ||
drops |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also part of the continue
without target issue
error: lifetime may not live long enough | ||
--> $DIR/underscore-lifetime-binders.rs:16:43 | ||
| | ||
LL | fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y } | ||
| - ^ returning this value requires that `'1` must outlive `'static` | ||
| | | ||
| let's call the lifetime of this reference `'1` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is a shame, and it is because we use ReStatic
as a fallback. That was a reasonable solution before this change, but after we should likely introduce a ReError
and silence lifetime errors that involve them.
@@ -15,18 +15,18 @@ fn no_arms_or_guards(x: Void) { | |||
//~^ ERROR a never pattern is always unreachable | |||
None => {} | |||
} | |||
match None::<Void> { | |||
match None::<Void> { //~ ERROR: `Some(_)` not covered | |||
Some(!) if true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this not a parse error!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, but we fall back to generating all arms up to and including the parse error arm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried replacing the entire match with an error expression, but then we lose the information that we don't need a semicolon after it. I guess I could encode that fact in the error variant. I'll try that out tomorrow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just surprised that we didn't have an //~ERROR
annotation in the test.
What is the motivation for this PR? |
if let Some(reported) = tcx.dcx().has_errors() { Err(reported) } else { Ok(()) } | ||
Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the motivation of this PR. removing another has_errors
that affects compilation progress
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This comment has been minimized.
This comment has been minimized.
tests/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-4.rs
Outdated
Show resolved
Hide resolved
for i in 0..4 { //~ ERROR `for` is not allowed in a `const` | ||
//~^ ERROR: cannot call | ||
//~| ERROR: mutable references | ||
//~| ERROR: cannot convert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should deduplicate these errors in constants, but it's fine for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me
a32abc9
to
6ff8054
Compare
@bors r=estebank |
🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened. |
This comment has been minimized.
This comment has been minimized.
@bors r- |
6ff8054
to
0f3976b
Compare
@bors r=estebank |
…=compiler-errors fix ICE for deref coercions with type errors Follow-up to rust-lang#120895, where I made types with errors go through the full coercion code, which is necessary if we want to build MIR for bodies with errors (rust-lang#120550). The code for coercing `&T` to `&U` currently assumes that autoderef for `&T` will succeed for at least two steps (`&T` and `T`): https://github.com/rust-lang/rust/blob/b17491c8f6d555386104dfd82004c01bfef09c95/compiler/rustc_hir_typeck/src/coercion.rs#L339-L464 But for types with errors, we previously only returned the no-op autoderef step (`&{type error}` -> `&{type error}`) and then stopped early. This PR changes autoderef for types with errors to still go through the built-in derefs (e.g. `&&{type error}` -> `&{type error}` -> `{type error}`) and only stop early when it would have to go looking for `Deref` trait impls. fixes rust-lang#120945 r? `@compiler-errors` or compiler
…=compiler-errors fix ICE for deref coercions with type errors Follow-up to rust-lang#120895, where I made types with errors go through the full coercion code, which is necessary if we want to build MIR for bodies with errors (rust-lang#120550). The code for coercing `&T` to `&U` currently assumes that autoderef for `&T` will succeed for at least two steps (`&T` and `T`): https://github.com/rust-lang/rust/blob/b17491c8f6d555386104dfd82004c01bfef09c95/compiler/rustc_hir_typeck/src/coercion.rs#L339-L464 But for types with errors, we previously only returned the no-op autoderef step (`&{type error}` -> `&{type error}`) and then stopped early. This PR changes autoderef for types with errors to still go through the built-in derefs (e.g. `&&{type error}` -> `&{type error}` -> `{type error}`) and only stop early when it would have to go looking for `Deref` trait impls. fixes rust-lang#120945 r? ``@compiler-errors`` or compiler
Rollup merge of rust-lang#120972 - lukas-code:autoderef-type-error, r=compiler-errors fix ICE for deref coercions with type errors Follow-up to rust-lang#120895, where I made types with errors go through the full coercion code, which is necessary if we want to build MIR for bodies with errors (rust-lang#120550). The code for coercing `&T` to `&U` currently assumes that autoderef for `&T` will succeed for at least two steps (`&T` and `T`): https://github.com/rust-lang/rust/blob/b17491c8f6d555386104dfd82004c01bfef09c95/compiler/rustc_hir_typeck/src/coercion.rs#L339-L464 But for types with errors, we previously only returned the no-op autoderef step (`&{type error}` -> `&{type error}`) and then stopped early. This PR changes autoderef for types with errors to still go through the built-in derefs (e.g. `&&{type error}` -> `&{type error}` -> `{type error}`) and only stop early when it would have to go looking for `Deref` trait impls. fixes rust-lang#120945 r? ``@compiler-errors`` or compiler
…-errors fix ICE for deref coercions with type errors Follow-up to rust-lang/rust#120895, where I made types with errors go through the full coercion code, which is necessary if we want to build MIR for bodies with errors (rust-lang/rust#120550). The code for coercing `&T` to `&U` currently assumes that autoderef for `&T` will succeed for at least two steps (`&T` and `T`): https://github.com/rust-lang/rust/blob/b17491c8f6d555386104dfd82004c01bfef09c95/compiler/rustc_hir_typeck/src/coercion.rs#L339-L464 But for types with errors, we previously only returned the no-op autoderef step (`&{type error}` -> `&{type error}`) and then stopped early. This PR changes autoderef for types with errors to still go through the built-in derefs (e.g. `&&{type error}` -> `&{type error}` -> `{type error}`) and only stop early when it would have to go looking for `Deref` trait impls. fixes rust-lang/rust#120945 r? ``@compiler-errors`` or compiler
…-errors fix ICE for deref coercions with type errors Follow-up to rust-lang/rust#120895, where I made types with errors go through the full coercion code, which is necessary if we want to build MIR for bodies with errors (rust-lang/rust#120550). The code for coercing `&T` to `&U` currently assumes that autoderef for `&T` will succeed for at least two steps (`&T` and `T`): https://github.com/rust-lang/rust/blob/b17491c8f6d555386104dfd82004c01bfef09c95/compiler/rustc_hir_typeck/src/coercion.rs#L339-L464 But for types with errors, we previously only returned the no-op autoderef step (`&{type error}` -> `&{type error}`) and then stopped early. This PR changes autoderef for types with errors to still go through the built-in derefs (e.g. `&&{type error}` -> `&{type error}` -> `{type error}`) and only stop early when it would have to go looking for `Deref` trait impls. fixes rust-lang/rust#120945 r? ``@compiler-errors`` or compiler
but only from the perspective of the whole compiler. Individual items should not get borrowcked if their MIR is tainted by errors.
r? @estebank @nnethercote