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 |
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 comment has been minimized.
This comment has been minimized.
|
all right! |
8df357f to
fbe9d36
Compare
There was a problem hiding this comment.
sorry for taking so long to take a look at this when I said I'd take a look soon a while ago 😅
a few nits on this specific approach, but tbh I'm generally happy with the technical impl as-is too, addressing nits not totally required :P
I haven't done as many thinky thinks as boxy on this yet though, so I'm not as sure of the high-level approach - this generally makes sense though (tbh my main uncertainty is whether we should be checking more things, but, at the very least, that's purely additive and can be done later, I'm fairly certain that what is being checked here is good and correct)
| @@ -1423,11 +1435,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { | |||
| fn report_const_param_not_wf( | |||
There was a problem hiding this comment.
nit: could you rename this method? it's no longer called for just const params
edit: ah, the phrasing is also a bit wonky... there are technically no const generic parameters in some of your test files, but this method is yapping about const generic parameters. maybe that's fine though, eugh, idk, diagnostics are hard. (on the same line of logic, one could argue requiring ConstParamTy for assoc const projection clauses is also conceptually wonky, since again, not a parameter, but, like, whatever, I guess)
There was a problem hiding this comment.
hum... To be honest, I'm not sure what this should be renamed to either...🤔
But this really isn't quite appropriate right now.
There was a problem hiding this comment.
I did not change the original diagnosis;simply renamed the current method to report_const_param_ty_error...
I'm realy not sure how should this new diagnosis written
There was a problem hiding this comment.
I seem to have thought of a good way to do related diagnosis. It may take a while... (or not put it in this pr, and do it together with gca!'s diagnosis :)
fb6fc7d to
880ac96
Compare
This comment has been minimized.
This comment has been minimized.
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? |
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