Check associated const binding types - #161131
YUZHEthefool wants to merge 1 commit into
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 |
|
FYI havent forgotten about this and am doing some thinky think about this approach |
take your time :) |
| if self.tcx().features().const_param_ty_unchecked() || ty.has_escaping_bound_vars() { | ||
| return; | ||
| } | ||
|
|
There was a problem hiding this comment.
We can add check for const type here, because we already check for type const in check_type_const
| if ct.kind.is_type_const(self.tcx()) { | |
| return; | |
| } |
There was a problem hiding this comment.
emm... seems this method no name is_type_const
I took a look, and it seems it should now be called is_direct_const.
|
All right, I'll go fix it right away. |
7255a5a to
895051d
Compare
This comment has been minimized.
This comment has been minimized.
895051d to
7a24a14
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
7a24a14 to
213b874
Compare
This comment has been minimized.
This comment has been minimized.
213b874 to
70ce178
Compare
This comment has been minimized.
This comment has been minimized.
|
Hi okay I've thought about this a bit now. The stuff about struggling to get a test case for free and inherent consts is interesting but also makes sense. I think that there probably actually is no need to check Every const argument is an argument to some const parameter which at its definition site has its type checked to implement So I think the fix here is really less of a "const items in the type system should have their types checked to implement
Both of those are handled in the Though I think you already handle the second case with your existing set of changes (nice! :3) I think you also handle the first case by having updated @rustbot author thanks for being patient and waiting for me to get around to this |
70ce178 to
da45850
Compare
This comment has been minimized.
This comment has been minimized.
|
oh it‘s update to gca! |
da45850 to
8df357f
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. |
|
all right! |
8df357f to
fbe9d36
Compare
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