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
| @@ -0,0 +1,14 @@ | |||
| //@ compile-flags: -Znext-solver=globally | |||
| //@ dont-check-compiler-stderr | |||
There was a problem hiding this comment.
Could you remove this? I think it's okay to track the stderr for this case.
There was a problem hiding this comment.
Ok, I will remove it, and fix the current ci problem and submit it together.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
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. |
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