-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Handle asm const similar to inline const #137686
Conversation
There is a `visit_inline_const` visitor method and it is used instead.
expr_ty: impl Fn(&hir::Expr<'tcx>) -> Ty<'tcx> + 'a, | ||
node_ty: impl Fn(hir::HirId) -> Ty<'tcx> + 'a, |
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.
These are morally the same function--hir::Expr
has a HirId
. No need to have two.
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.
The expr_ty
callback in fn_ctxt/checks.rs
currently uses the expr_ty_adjusted
; switching to node_type
will cause adjustment to be lost.
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.
LGTM, but a few questions first
@bors r+ rollup |
Handle asm const similar to inline const Previously, asm consts are handled similar to anon consts rather than inline consts. Anon consts are not good at dealing with lifetimes, because `type_of` has lifetimes erased already. Inline consts can deal with lifetimes because they live in an outer typeck context. And since `global_asm!` lacks an outer typeck context, we have implemented asm consts with anon consts while they're in fact more similar to inline consts. This was changed in rust-lang#137180, and this means that handling asm consts as inline consts are possible. While as `@compiler-errors` pointed out, `const` currently can't be used with any types with lifetime, this is about to change if rust-lang#128464 is implemented. This PR is a preparatory PR for that feature. As an unintentional side effect, fix rust-lang#117877. cc `@Amanieu` r? `@compiler-errors`
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#137045 (Defer repeat expr `Copy` checks to end of type checking) - rust-lang#137171 (Suggest swapping equality on E0277) - rust-lang#137634 (Update `compiler-builtins` to 0.1.149) - rust-lang#137686 (Handle asm const similar to inline const) - rust-lang#137689 (Use `Binder<Vec<Ty>>` instead of `Vec<Binder<Ty>>` in both solvers for sized/auto traits/etc.) - rust-lang#137718 (Use original command for showing sccache stats) - rust-lang#137723 (Make `rust.description` more general-purpose and pass `CFG_VER_DESCRIPTION`) - rust-lang#137730 (checked_ilog tests: deal with a bit of float imprecision) - rust-lang#137735 (Update E0133 docs for 2024 edition) - rust-lang#137742 (unconditionally lower match arm even if it's unneeded for never pattern in match) - rust-lang#137771 (Tweak incorrect ABI suggestion) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#137045 (Defer repeat expr `Copy` checks to end of type checking) - rust-lang#137171 (Suggest swapping equality on E0277) - rust-lang#137634 (Update `compiler-builtins` to 0.1.149) - rust-lang#137686 (Handle asm const similar to inline const) - rust-lang#137689 (Use `Binder<Vec<Ty>>` instead of `Vec<Binder<Ty>>` in both solvers for sized/auto traits/etc.) - rust-lang#137718 (Use original command for showing sccache stats) - rust-lang#137723 (Make `rust.description` more general-purpose and pass `CFG_VER_DESCRIPTION`) - rust-lang#137730 (checked_ilog tests: deal with a bit of float imprecision) - rust-lang#137735 (Update E0133 docs for 2024 edition) - rust-lang#137742 (unconditionally lower match arm even if it's unneeded for never pattern in match) - rust-lang#137771 (Tweak incorrect ABI suggestion) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#137045 (Defer repeat expr `Copy` checks to end of type checking) - rust-lang#137171 (Suggest swapping equality on E0277) - rust-lang#137634 (Update `compiler-builtins` to 0.1.149) - rust-lang#137686 (Handle asm const similar to inline const) - rust-lang#137689 (Use `Binder<Vec<Ty>>` instead of `Vec<Binder<Ty>>` in both solvers for sized/auto traits/etc.) - rust-lang#137718 (Use original command for showing sccache stats) - rust-lang#137723 (Make `rust.description` more general-purpose and pass `CFG_VER_DESCRIPTION`) - rust-lang#137730 (checked_ilog tests: deal with a bit of float imprecision) - rust-lang#137735 (Update E0133 docs for 2024 edition) - rust-lang#137742 (unconditionally lower match arm even if it's unneeded for never pattern in match) - rust-lang#137771 (Tweak incorrect ABI suggestion) r? `@ghost` `@rustbot` modify labels: rollup
Handle asm const similar to inline const Previously, asm consts are handled similar to anon consts rather than inline consts. Anon consts are not good at dealing with lifetimes, because `type_of` has lifetimes erased already. Inline consts can deal with lifetimes because they live in an outer typeck context. And since `global_asm!` lacks an outer typeck context, we have implemented asm consts with anon consts while they're in fact more similar to inline consts. This was changed in rust-lang#137180, and this means that handling asm consts as inline consts are possible. While as ``@compiler-errors`` pointed out, `const` currently can't be used with any types with lifetime, this is about to change if rust-lang#128464 is implemented. This PR is a preparatory PR for that feature. As an unintentional side effect, fix rust-lang#117877. cc ``@Amanieu`` r? ``@compiler-errors``
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#137045 (Defer repeat expr `Copy` checks to end of type checking) - rust-lang#137171 (Suggest swapping equality on E0277) - rust-lang#137686 (Handle asm const similar to inline const) - rust-lang#137689 (Use `Binder<Vec<Ty>>` instead of `Vec<Binder<Ty>>` in both solvers for sized/auto traits/etc.) - rust-lang#137718 (Use original command for showing sccache stats) - rust-lang#137730 (checked_ilog tests: deal with a bit of float imprecision) - rust-lang#137735 (Update E0133 docs for 2024 edition) - rust-lang#137742 (unconditionally lower match arm even if it's unneeded for never pattern in match) - rust-lang#137771 (Tweak incorrect ABI suggestion and make suggestion verbose) Failed merges: - rust-lang#137723 (Make `rust.description` more general-purpose and pass `CFG_VER_DESCRIPTION`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#137686 - nbdd0121:asm_const, r=compiler-errors Handle asm const similar to inline const Previously, asm consts are handled similar to anon consts rather than inline consts. Anon consts are not good at dealing with lifetimes, because `type_of` has lifetimes erased already. Inline consts can deal with lifetimes because they live in an outer typeck context. And since `global_asm!` lacks an outer typeck context, we have implemented asm consts with anon consts while they're in fact more similar to inline consts. This was changed in rust-lang#137180, and this means that handling asm consts as inline consts are possible. While as `@compiler-errors` pointed out, `const` currently can't be used with any types with lifetime, this is about to change if rust-lang#128464 is implemented. This PR is a preparatory PR for that feature. As an unintentional side effect, fix rust-lang#117877. cc `@Amanieu` r? `@compiler-errors`
Previously, asm consts are handled similar to anon consts rather than inline consts. Anon consts are not good at dealing with lifetimes, because
type_of
has lifetimes erased already. Inline consts can deal with lifetimes because they live in an outer typeck context. And sinceglobal_asm!
lacks an outer typeck context, we have implemented asm consts with anon consts while they're in fact more similar to inline consts.This was changed in #137180, and this means that handling asm consts as inline consts are possible. While as @compiler-errors pointed out,
const
currently can't be used with any types with lifetime, this is about to change if #128464 is implemented. This PR is a preparatory PR for that feature.As an unintentional side effect, fix #117877.
cc @Amanieu
r? @compiler-errors