do generic_const_args Const::Ty hack only on projection consts - #162937
Conversation
|
|
|
wait no I haven't had my coffee yet what am I doing, this isn't the right fix, one moment... (I mean, it worked, but, yeah, actual fix pushed now) |
cabcba9 to
d32dd9e
Compare
| if tcx.features().generic_const_args() | ||
| || matches!(def_kind, DefKind::Const | DefKind::AssocConst) | ||
| && tcx.is_direct_const(def_id) | ||
| if matches!(def_kind, DefKind::Const | DefKind::AssocConst) |
There was a problem hiding this comment.
haha when I was reviewing that PR I thought about how I hate precedence on these things and can never tell where the parens go 😆
|
what does the THIR look like for this test, where does a NamedConst come from with a defid of an anon 🤔 |
comes from here for reference this is what the code looks like: enum T<const N: u8 = { T::<0>::B as u8 }> {
A = 2,
B,
}the anon const for the default in
|
| @@ -80,9 +80,8 @@ pub(crate) fn as_constant_inner<'tcx>( | |||
There was a problem hiding this comment.
Should we mention about anon const exception here?
There was a problem hiding this comment.
when considering other wordings for this, I found myself unable write a wording to justify not doing the exception for just projection consts, rather than all const items. So I rewrote this to only do the exception for just projection consts.
d32dd9e to
acc7501
Compare
|
can you write a different PR title and description :3 @rustbot author |
|
@rustbot ready |
|
@bors r+ rollup |
…xyUwU do generic_const_args Const::Ty hack only on projection consts Under `generic_const_args`, we currently do a bit of a hack to lower all consts to `Const::Ty`, because under `generic_const_args`, projection consts not marked with `#[rustc_always_gca]` could be `impl`'d by a const with a `gca!` rhs, and `Const::Unevaluated` does not support direct consts. Instead, only lower a const to `Const::Ty` if: - it is a direct const (under `min_generic_const_args`), OR - it is a projection const (under `generic_const_args`) This excludes all anon consts, and regular (not direct) free and inherent consts from being lowered as `Const::Ty` under full GCA. It does not fix the underlying issue that lowering a potentially regular projection const to `Const::Ty` is incorrect. Fixes rust-lang#162923 Introduced in rust-lang#162760 r? @BoxyUwU
…uwer Rollup of 7 pull requests Successful merges: - #163218 (stdarch subtree update) - #159287 (Build a new incr comp session dir from scratch every time) - #163222 (Enable EII tests for cg_gcc) - #163251 (cg_gcc subtree sync 2026-09-24) - #162595 (avoid accessing uninferred closure upvars in diagnostics) - #162937 (do generic_const_args Const::Ty hack only on projection consts) - #163238 (Fix incorrect use of await in parser suggestion)
Rollup merge of #162937 - khyperia:gca-fix-unreachable, r=BoxyUwU do generic_const_args Const::Ty hack only on projection consts Under `generic_const_args`, we currently do a bit of a hack to lower all consts to `Const::Ty`, because under `generic_const_args`, projection consts not marked with `#[rustc_always_gca]` could be `impl`'d by a const with a `gca!` rhs, and `Const::Unevaluated` does not support direct consts. Instead, only lower a const to `Const::Ty` if: - it is a direct const (under `min_generic_const_args`), OR - it is a projection const (under `generic_const_args`) This excludes all anon consts, and regular (not direct) free and inherent consts from being lowered as `Const::Ty` under full GCA. It does not fix the underlying issue that lowering a potentially regular projection const to `Const::Ty` is incorrect. Fixes #162923 Introduced in #162760 r? @BoxyUwU
…uwer Rollup of 7 pull requests Successful merges: - rust-lang/rust#163218 (stdarch subtree update) - rust-lang/rust#159287 (Build a new incr comp session dir from scratch every time) - rust-lang/rust#163222 (Enable EII tests for cg_gcc) - rust-lang/rust#163251 (cg_gcc subtree sync 2026-09-24) - rust-lang/rust#162595 (avoid accessing uninferred closure upvars in diagnostics) - rust-lang/rust#162937 (do generic_const_args Const::Ty hack only on projection consts) - rust-lang/rust#163238 (Fix incorrect use of await in parser suggestion)
…uwer Rollup of 7 pull requests Successful merges: - rust-lang/rust#163218 (stdarch subtree update) - rust-lang/rust#159287 (Build a new incr comp session dir from scratch every time) - rust-lang/rust#163222 (Enable EII tests for cg_gcc) - rust-lang/rust#163251 (cg_gcc subtree sync 2026-09-24) - rust-lang/rust#162595 (avoid accessing uninferred closure upvars in diagnostics) - rust-lang/rust#162937 (do generic_const_args Const::Ty hack only on projection consts) - rust-lang/rust#163238 (Fix incorrect use of await in parser suggestion)
Under
generic_const_args, we currently do a bit of a hack to lower all consts toConst::Ty, because undergeneric_const_args, projection consts not marked with#[rustc_always_gca]could beimpl'd by a const with agca!rhs, andConst::Unevaluateddoes not support direct consts.Instead, only lower a const to
Const::Tyif:min_generic_const_args), ORgeneric_const_args)This excludes all anon consts, and regular (not direct) free and inherent consts from being lowered as
Const::Tyunder full GCA. It does not fix the underlying issue that lowering a potentially regular projection const toConst::Tyis incorrect.Fixes #162923
Introduced in #162760
r? @BoxyUwU