-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use ControlFlow
in HIR Visitor
#108598
Use ControlFlow
in HIR Visitor
#108598
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in need_type_info.rs cc @lcnr Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in src/tools/clippy cc @rust-lang/clippy These commits modify the If this was intentional then you can ignore this comment. |
Looks like the clippy test suite is having ICEs now |
ef3b880
to
32ea017
Compare
Do you have a link to clippy discussions that motivated this change? Not that it's not desirable on its own, but seems good to have some links. You should also open a compiler team MCP, as this is definitely a major change 😆 |
cef18e9
to
936cbbe
Compare
No clippy discussion for this. Just observing how clippy breaks early from most visitors. |
936cbbe
to
b56aaa2
Compare
☔ The latest upstream changes (presumably #108620) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @oli-obk |
Discussed in today's T-compiler triage meeting. Now this did have an MCP which was seconded, that's rust-lang/compiler-team#597 but the MCP second did note that there may be room for adjusting what the actual solution here looks like. There may be good material to review in the Zulip stream associated with the MCP |
Kind of blocked on rust-lang/libs-team#187 |
The ACP was closed |
With the ACP closed that rules out using trait VisitorResult {
type BreakTy;
fn continue() -> Self;
fn from_break_ty(_: Self::BreakTy) -> Self;
}
impl VisitorResult for () {
type BreakTy = !;
fn continue() -> Self {
()
}
fn from_break_ty(_: !) -> Self {
()
}
}
impl<T: Try<Output = ()>> VisitorResult for T {
type BreakTy = T::Residual;
fn continue() -> Self {
Self::from_output(())
}
fn from_break_ty(x: Self::BreakTy) -> Self {
Self::from_residual(x)
}
} This does rule out using |
Allow AST and HIR visitors to return `ControlFlow` Alternative to rust-lang#108598. Since rust-lang/libs-team#187 was rejected, this implements our own version of the `Try` trait (`VisitorResult`) and the `try` macro (`try_visit`). Since this change still allows visitors to return `()`, no changes have been made to the existing ones. They can be done in a separate PR.
Allow AST and HIR visitors to return `ControlFlow` Alternative to rust-lang#108598. Since rust-lang/libs-team#187 was rejected, this implements our own version of the `Try` trait (`VisitorResult`) and the `try` macro (`try_visit`). Since this change still allows visitors to return `()`, no changes have been made to the existing ones. They can be done in a separate PR.
Rollup merge of rust-lang#121256 - Jarcho:visitor2, r=oli-obk Allow AST and HIR visitors to return `ControlFlow` Alternative to rust-lang#108598. Since rust-lang/libs-team#187 was rejected, this implements our own version of the `Try` trait (`VisitorResult`) and the `try` macro (`try_visit`). Since this change still allows visitors to return `()`, no changes have been made to the existing ones. They can be done in a separate PR.
This ended up significantly larger than I originally though it would be. Most changes are trivial signature changes plus code changes to make the function actually return the correct type.
Some visitors were changed to return their result as
BreakTy
rather than through a field. Most of these are from clippy, which is the main motivation behind this change, but a few are from rustc as well.There are a few behavior in some diagnostics, but only in the case of unusual spans (e.g. multiple nodes having the same span). This should only cause changes when the diagnostic spans were already questionable in the first place.