-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TooGeneric
variant to LayoutError
and emit Unknown
#135158
base: master
Are you sure you want to change the base?
Conversation
HIR ty lowering was modified cc @fmease |
Feel free to ask me anything. |
This comment has been minimized.
This comment has been minimized.
(The fluent slug needs to be sorted lexicographically) |
5a546aa
to
6d48c1a
Compare
seems somewhat unfortunate diagnostics-wise because:
Introducing this Anyway, cc @lukas-code. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In particular, let me know if you would like the addition of a test within the
tests/ui/layout/
folder.
Yes, this definitely needs tests, for both of the issues. See here for a guide on adding tests.
6d48c1a
to
fc6c929
Compare
This comment has been minimized.
This comment has been minimized.
3463d0f
to
3d8a88a
Compare
This comment has been minimized.
This comment has been minimized.
3d8a88a
to
0ef08fb
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5a0ba5d
to
514360b
Compare
Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
17b87fd
to
32cdc4d
Compare
This comment has been minimized.
This comment has been minimized.
32cdc4d
to
d09c4e4
Compare
87473c4
to
0940c4e
Compare
This comment has been minimized.
This comment has been minimized.
0940c4e
to
fdda34d
Compare
We should be there, let me know @lukas-code :D |
@@ -317,13 +317,25 @@ fn layout_of_uncached<'tcx>( | |||
if count.has_aliases() { | |||
count = tcx.normalize_erasing_regions(cx.typing_env, count); | |||
if count.has_aliases() { | |||
return Err(error(cx, LayoutError::Unknown(ty))); | |||
return Err(error(cx, LayoutError::TooGeneric(ty))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had missed this case before, but there can actually be unevaluated constants that are rigid but not generic. In this case the LayoutError::TooGeneric
here is still wrong:
#![feature(trivial_bounds)]
trait Project {
const ASSOC: usize;
}
fn foo()
where
(): Project,
{
[(); <() as Project>::ASSOC];
}
We already normalize above in fn layout_of
so checking for aliases and normalizing here looks redundant anyway -- can we just remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can just remove it.
This is currently an ICE:
error: internal compiler error: Missing value for constant, but no error reported?
--> tests/ui/layout/uneval-const-rigid.rs:11:5
|
11 | [(); <() as Project>::ASSOC];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:132:44 - disabled backtrace
--> tests/ui/layout/uneval-const-rigid.rs:11:5
|
11 | [(); <() as Project>::ASSOC];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Can we fix it in another PR? I will open an issue if yes. @lukas-code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, I see now that this is actually a different issue. So yes, feel free to open a new issue and you don't have to fix it here.
But then I'm also wondering whether the case where count
is unevaluated but doesn't have params is actually reachable, because now I can't come up with an example for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will investigate as soon as possible. That case may be unreachable, but I am not sure. @lukas-code
☔ The latest upstream changes (presumably #135519) made this pull request unmergeable. Please resolve the merge conflicts. |
e860813
to
3605306
Compare
This comment has been minimized.
This comment has been minimized.
3605306
to
66fce46
Compare
This comment has been minimized.
This comment has been minimized.
66fce46
to
927d74d
Compare
This comment has been minimized.
This comment has been minimized.
927d74d
to
81d477a
Compare
81d477a
to
997c3f4
Compare
@bors delegate=lukas-code |
✌️ @lukas-code, you can now approve this pull request! If @oli-obk told you to " |
This comment has been minimized.
This comment has been minimized.
997c3f4
to
888d7c0
Compare
This comment has been minimized.
This comment has been minimized.
- `check-pass` test for a MRE of rust-lang#135020 - fail test for rust-lang#135138 - switch to `TooGeneric` for checking CMSE fn signatures - switch to `TooGeneric` for compute `SizeSkeleton` (for transmute) - fix broken tests
888d7c0
to
768fef5
Compare
What's in this PR?
TooGeneric
variant toLayoutError
and emitUnknown
oneErrorGuaranteed
fromitems_of_instance
queryWith this PR these issues and their respective ICEs are resolved:
encountered unexpected unsized field in layout of
#135020-Zpolymorphize=on"
#118913For instance, given this code:
the following error is generated
Then, according to @lukas-code: "Keeping this assertion in some sensible manner seems like it would be more effort than it's worth". So, I decided to remove it and the ICE related to #135138 has been fixed.
rust/compiler/rustc_ty_utils/src/layout.rs
Lines 107 to 111 in 6ca6659