-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 correct substs in enum discriminant cast #98429
Use correct substs in enum discriminant cast #98429
Conversation
This comment has been minimized.
This comment has been minimized.
9ce21ee
to
2e3221a
Compare
Some(did) => { | ||
// in case we are offsetting from a computed discriminant | ||
// and not the beginning of discriminants (which is always `0`) | ||
|
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.
Some(did) => { | |
// in case we are offsetting from a computed discriminant | |
// and not the beginning of discriminants (which is always `0`) | |
// in case we are offsetting from a computed discriminant | |
// and not the beginning of discriminants (which is always `0`) | |
Some(did) => { |
}; | ||
|
||
let res = self.typeck_results().qpath_res(qpath, source.hir_id); | ||
let (discr_did, discr_offset, discr_ty, substs) = { |
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.
why use that let here instead of keeping the original variables in scope
DefKind::Ctor(CtorOf::Variant, CtorKind::Const), | ||
variant_ctor_id, | ||
) = res else { | ||
return ExprKind::Cast { source: self.mirror_expr(source)}; | ||
}; |
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.
wrong indentation, rustfmt doesn't work for let else 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.
hm did call ./x.py fmt
this time
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.
yes, but rustfmt does not work, you have to manually fix indentation for now
let ty::Adt(adt_def, substs) = ty.kind() else { | ||
return ExprKind::Cast { source: self.mirror_expr(source)}; | ||
}; |
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.
same here
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.
Do you mean the formatting here? As I said this is what x.py
formats this to. We also don't get any tidy check failure.
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.
yes,
As I said this is what x.py formats this to. We also don't get any tidy check failure.
which is happening because rustfmt
ignores let else
for now. It just keeps the formatting from the user. You can change the formatting of let else
to pretty much whatever you want and ./x.py fmt
won't change it or complain
@@ -0,0 +1,10 @@ | |||
//build-pass |
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.
//build-pass | |
// build-pass |
@bors r+ |
📌 Commit bf48b62 has been approved by |
…nant-cast, r=lcnr Use correct substs in enum discriminant cast Fixes rust-lang#97634 r? `@lcnr`
…nant-cast, r=lcnr Use correct substs in enum discriminant cast Fixes rust-lang#97634 r? ``@lcnr``
…askrgr Rollup of 9 pull requests Successful merges: - rust-lang#96412 (Windows: Iterative `remove_dir_all`) - rust-lang#98126 (Mitigate MMIO stale data vulnerability) - rust-lang#98149 (Set relocation_model to Pic on emscripten target) - rust-lang#98194 (Leak pthread_{mutex,rwlock}_t if it's dropped while locked.) - rust-lang#98298 (Point to type parameter definition when not finding variant, method and associated item) - rust-lang#98311 (Reverse folder hierarchy) - rust-lang#98401 (Add tracking issues to `--extern` option docs.) - rust-lang#98429 (Use correct substs in enum discriminant cast) - rust-lang#98431 (Suggest defining variable as mutable on `&mut _` type mismatch in pats) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #97634
r? @lcnr