Repository navigation
Check associated const binding types - #161131
Conversation
|
HIR ty lowering was modified cc @fmease |
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @mu001999 (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
fe0bccd to
0cda362
Compare
This comment has been minimized.
This comment has been minimized.
|
I don't think |
|
So what diagnosis should be generated here?and whether associated constant equality of non-ConstParamTy types should be rejected here |
|
I think maybe we could emit something like what we did for the following: const f1: fn() = || {};
const f2: fn() = || {};
const r: bool = f1 == f2;And for now we will get: |
|
Ok, I will make changes based on this direction |
IIUC, #![feature(generic_const_args)]
#![feature(min_generic_const_args)]
#![allow(incomplete_features)]
enum Foo {
A,
B,
C,
}
trait Trait {
const X: Foo;
}
fn foo(x: impl Trait<X = { Foo::A }>) {}This could compile successfully, and we don't need to mark For #![feature(adt_const_params)]
#![allow(incomplete_features)]
enum Foo {
A,
B,
C,
}
struct Bar<const X: Foo>();will produce: |
|
Ok,so the correct boundary is not "whether the type implements ConstParamTy", but "whether this specific constant can form a stable value for type system equality",its right? |
|
I'm not sure what's the appropriate solution. At least for myself, I don't think checking in r? BoxyUwU, do you have time to have a look? |
|
|
|
Ok, I will stop my current repair work.I have almost implemented the usage context based on:nonSupportedType passed to associated equality, and then generate the pointer comparison diagnosis required by the maintainer for the function pointer. |
0cda362 to
6914d51
Compare
|
Some changes occurred in cc @BoxyUwU Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
|
Now,NonValTree has been separated from the generic ambiguity. |
|
I hope you don't mind me asking, but did you use an LLM for this? If so, please make sure to disclose its use in accordance with our policy. |
|
Nope.I have contributed to the analyzer before and know the ai guidelines of the rust community. |
This comment has been minimized.
This comment has been minimized.
6914d51 to
2c1853c
Compare
|
just add |
880ac96 to
9517075
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
nice, looks good to me! @BoxyUwU do you wanna take another look? |
|
r? khyperia it looks good to me :) feel free to r+ it whenever you're happy @khyperia |
|
yippee! gosh it's really nice to have this, sorry it took so long to merge ❤️ @bors r=me,BoxyUwU rollup |
|
o nej uuuh can i just @bors r=khyperia,BoxyUwU rollup |
…ria,BoxyUwU Check associated const binding types For situations such as fn() that cannot be used as type system constant types, normal E0741 is generated in advance and the error type is returned to avoid continuing to enter constant evaluation and trigger ICE. Fix: rust-lang#161100
…uwer Rollup of 22 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 22 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 22 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…ria,BoxyUwU Check associated const binding types For situations such as fn() that cannot be used as type system constant types, normal E0741 is generated in advance and the error type is returned to avoid continuing to enter constant evaluation and trigger ICE. Fix: rust-lang#161100
…uwer Rollup of 23 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #165123 (Temporarily drop macos-26 jobs) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 23 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #165123 (Temporarily drop macos-26 jobs) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 22 pull requests Successful merges: - #165032 (stdarch subtree update) - #165123 (Temporarily drop macos-26 jobs) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
Rollup merge of #161131 - YUZHEthefool:issue-161100, r=khyperia,BoxyUwU Check associated const binding types For situations such as fn() that cannot be used as type system constant types, normal E0741 is generated in advance and the error type is returned to avoid continuing to enter constant evaluation and trigger ICE. Fix: #161100
…uwer Rollup of 22 pull requests Successful merges: - rust-lang/rust#165032 (stdarch subtree update) - rust-lang/rust#165123 (Temporarily drop macos-26 jobs) - rust-lang/rust#165072 (Submodule update of rustc-perf) - rust-lang/rust#144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - rust-lang/rust#162342 (More stdarch regression tests) - rust-lang/rust#163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - rust-lang/rust#164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - rust-lang/rust#164916 (CI: rfl: move job forward to Linux v7.3) - rust-lang/rust#164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - rust-lang/rust#164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - rust-lang/rust#165083 (Gate `z` inline asm template modifier) - rust-lang/rust#165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - rust-lang/rust#161131 (Check associated const binding types) - rust-lang/rust#161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - rust-lang/rust#164315 (make powerpc `Complex` ABI GCC-compatible) - rust-lang/rust#164476 (Avoid ICE on None from prepare_vtable_segments) - rust-lang/rust#165003 (follow up for global-alloc-reentry test) - rust-lang/rust#165020 (Bless mir-opt panic-abort tests) - rust-lang/rust#165066 (skip max_repr_align in Layout::eq_abi) - rust-lang/rust#165080 (Syntactically allow C-variadics in parenthesized argument lists) - rust-lang/rust#165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - rust-lang/rust#165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 22 pull requests Successful merges: - rust-lang/rust#165032 (stdarch subtree update) - rust-lang/rust#165123 (Temporarily drop macos-26 jobs) - rust-lang/rust#165072 (Submodule update of rustc-perf) - rust-lang/rust#144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - rust-lang/rust#162342 (More stdarch regression tests) - rust-lang/rust#163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - rust-lang/rust#164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - rust-lang/rust#164916 (CI: rfl: move job forward to Linux v7.3) - rust-lang/rust#164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - rust-lang/rust#164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - rust-lang/rust#165083 (Gate `z` inline asm template modifier) - rust-lang/rust#165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - rust-lang/rust#161131 (Check associated const binding types) - rust-lang/rust#161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - rust-lang/rust#164315 (make powerpc `Complex` ABI GCC-compatible) - rust-lang/rust#164476 (Avoid ICE on None from prepare_vtable_segments) - rust-lang/rust#165003 (follow up for global-alloc-reentry test) - rust-lang/rust#165020 (Bless mir-opt panic-abort tests) - rust-lang/rust#165066 (skip max_repr_align in Layout::eq_abi) - rust-lang/rust#165080 (Syntactically allow C-variadics in parenthesized argument lists) - rust-lang/rust#165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - rust-lang/rust#165082 (Remove stability note from `rust_splat`)
View all comments
For situations such as fn() that cannot be used as type system constant types, normal E0741 is generated in advance and the error type is returned to avoid continuing to enter constant evaluation and trigger ICE.
Fix: #161100