-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking Issue for more complex const parameter types: feature(adt_const_params)
#95174
Comments
adt_const_params
)feature(adt_const_params)
…e, r=Dylan-DPC move `adt_const_params` to its own tracking issue the new tracking issue is rust-lang#95174 r? `@rust-lang/project-const-generics`
…e, r=Dylan-DPC move `adt_const_params` to its own tracking issue the new tracking issue is rust-lang#95174 r? ``@rust-lang/project-const-generics``
=== stdout === === stderr === warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes --> /home/runner/work/glacier/glacier/ices/97047-1.rs:1:12 | 1 | #![feature(adt_const_params, generic_const_exprs)] | ^^^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #95174 <rust-lang/rust#95174> for more information warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes --> /home/runner/work/glacier/glacier/ices/97047-1.rs:1:30 | 1 | #![feature(adt_const_params, generic_const_exprs)] | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #76560 <rust-lang/rust#76560> for more information warning: field `changes` is never read --> /home/runner/work/glacier/glacier/ices/97047-1.rs:7:5 | 3 | pub struct Changes<const CHANGES: &'static [&'static str]> | ------- field in this struct ... 7 | changes: [usize; CHANGES.len()], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: 3 warnings emitted ==============
=== stdout === === stderr === warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes --> /home/runner/work/glacier/glacier/ices/97047-2.rs:1:12 | 1 | #![feature(adt_const_params, generic_const_exprs)] | ^^^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #95174 <rust-lang/rust#95174> for more information warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes --> /home/runner/work/glacier/glacier/ices/97047-2.rs:1:30 | 1 | #![feature(adt_const_params, generic_const_exprs)] | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #76560 <rust-lang/rust#76560> for more information warning: unused variable: `other` --> /home/runner/work/glacier/glacier/ices/97047-2.rs:14:31 | 14 | pub fn combine(&mut self, other: &Self) { | ^^^^^ help: if this is intentional, prefix it with an underscore: `_other` | = note: `#[warn(unused_variables)]` on by default warning: 3 warnings emitted ==============
=== stdout === === stderr === warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes --> /home/runner/work/glacier/glacier/ices/98813.rs:1:12 | 1 | #![feature(adt_const_params)] | ^^^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #95174 <rust-lang/rust#95174> for more information error[E0741]: `f64` is forbidden as the type of a const generic parameter --> /home/runner/work/glacier/glacier/ices/98813.rs:5:25 | 5 | pub struct Foo<const X: f64> {} | ^^^ | = note: floats do not derive `Eq` or `Ord`, which are required for const parameters error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0741`. ==============
=== stdout === === stderr === warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes --> <anon>:2:12 | 2 | #![feature(adt_const_params)] | ^^^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #95174 <rust-lang/rust#95174> for more information error[E0741]: using function pointers as const generic parameters is forbidden --> <anon>:5:35 | 5 | pub struct Color<const WHITE: (fn(),)>; | ^^^^^^^ error[E0741]: using function pointers as const generic parameters is forbidden --> <anon>:7:23 | 7 | impl<const WHITE: (fn(),)> Color<WHITE> { | ^^^^^^^ error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0741`. ==============
I think at least simple enums without assigned values should be allowed for now |
@griffi-gh I agree. However, in the meantime if you have an e.g. |
For what it's worth, I am currently hacking around this in |
This comment was marked as off-topic.
This comment was marked as off-topic.
Once place where #[repr(u8)]
pub enum Facing {
Up,
Down,
}
pub struct Card<const FACING: u8> {
// would normally have a "suit" and "number" field
}
pub fn foo(card: Card<{Facing::Up as u8}>) {
let _: Card<{Facing::Down as u8}> = card;
}
But with a real enum and
|
This comment was marked as off-topic.
This comment was marked as off-topic.
Remove `try_from_lit` from `from_anon_const` This PR tries to fix rust-lang#116308. TODO: - [ ] write up the reason why `try_from_lit` should be removed from `from_anon_const` - [ ] write up the reason why it is safe to do this - [ ] do a perf run and see if doing this affect performance ui tests changes: - [ ] failed run-pass/check-pass (`const-arg-in-const-arg.rs#full`, `abstract-const-as-cast-4.rs`, `no_dependence.rs`, `issue-94293.rs`) - [ ] symbol mangling affected (`symbol-names/*`) - [ ] different error report (`const-projection-err.rs#gce`, `abstract-const-as-cast-3.rs`, `type_mismatch.rs`) - [x] misc - error report reordering - same error, but different const type reprs This PR is related to two unstable features (`adt_const_params`: rust-lang#95174, `generic_const_exprs`: rust-lang#76560). r? `@BoxyUwU`
It seems that the main blocker to stabilising this is:
Although I'm not exactly sure what exactly these differences are, and whether it's needed based after rust-lang/rfcs#3535 has clarified the details on constant patterns. Would someone be willing to update the description to clarify the details on this, and which RFC it's referring to for the original details? (I know that there are other open issues for this feature, although it feels like the semantic clarification is the most difficult to resolve.) |
Special-case alias ty during the delayed bug emission in `try_from_lit` This PR tries to fix rust-lang#116308. A delayed bug in `try_from_lit` will not be emitted so that the compiler will not ICE when it sees the pair `(ast::LitKind::Int, ty::TyKind::Alias)` in `lit_to_const` (called from `try_from_lit`). This PR is related to an unstable feature `adt_const_params` (rust-lang#95174). r? `@BoxyUwU`
Special-case alias ty during the delayed bug emission in `try_from_lit` This PR tries to fix rust-lang#116308. A delayed bug in `try_from_lit` will not be emitted so that the compiler will not ICE when it sees the pair `(ast::LitKind::Int, ty::TyKind::Alias)` in `lit_to_const` (called from `try_from_lit`). This PR is related to an unstable feature `adt_const_params` (rust-lang#95174). r? ``@BoxyUwU``
Rollup merge of rust-lang#129042 - Jaic1:fix-116308, r=BoxyUwU Special-case alias ty during the delayed bug emission in `try_from_lit` This PR tries to fix rust-lang#116308. A delayed bug in `try_from_lit` will not be emitted so that the compiler will not ICE when it sees the pair `(ast::LitKind::Int, ty::TyKind::Alias)` in `lit_to_const` (called from `try_from_lit`). This PR is related to an unstable feature `adt_const_params` (rust-lang#95174). r? ``@BoxyUwU``
Fix order of normalization and recursion in const folding. Fixes rust-lang#126831. Without this patch, type normalization is not always idempotent, which leads to all sorts of bugs in places that assume that normalizing a normalized type does nothing. Tracking issue: rust-lang#95174 r? BoxyUwU
Fix order of normalization and recursion in const folding. Fixes rust-lang#126831. Without this patch, type normalization is not always idempotent, which leads to all sorts of bugs in places that assume that normalizing a normalized type does nothing. Tracking issue: rust-lang#95174 r? BoxyUwU
Rollup merge of rust-lang#129208 - veluca93:adt_const_fix, r=BoxyUwU Fix order of normalization and recursion in const folding. Fixes rust-lang#126831. Without this patch, type normalization is not always idempotent, which leads to all sorts of bugs in places that assume that normalizing a normalized type does nothing. Tracking issue: rust-lang#95174 r? BoxyUwU
Fix order of normalization and recursion in const folding. Fixes #126831. Without this patch, type normalization is not always idempotent, which leads to all sorts of bugs in places that assume that normalizing a normalized type does nothing. Tracking issue: rust-lang/rust#95174 r? BoxyUwU
Handle unsized consts with type `str` in v0 symbol mangling This PR fixes rust-lang#116303 by handling consts with type `str` in v0 symbol mangling as partial support for unsized consts. This PR is related to `#![feature(adt_const_params)]` (rust-lang#95174) and `#![feature(unsized_const_params)]` (rust-lang#128028). r? `@BoxyUwU`
Handle unsized consts with type `str` in v0 symbol mangling This PR fixes rust-lang#116303 by handling consts with type `str` in v0 symbol mangling as partial support for unsized consts. This PR is related to `#![feature(adt_const_params)]` (rust-lang#95174) and `#![feature(unsized_const_params)]` (rust-lang#128028). r? ``@BoxyUwU``
Rollup merge of rust-lang#130344 - Jaic1:fix-116306, r=BoxyUwU Handle unsized consts with type `str` in v0 symbol mangling This PR fixes rust-lang#116303 by handling consts with type `str` in v0 symbol mangling as partial support for unsized consts. This PR is related to `#![feature(adt_const_params)]` (rust-lang#95174) and `#![feature(unsized_const_params)]` (rust-lang#128028). r? ``@BoxyUwU``
…8179, r=compiler-errors Fix `adt_const_params` leaking `{type error}` in error msg Fixes the confusing diagnostic described in rust-lang#118179. (users would see `{type error}` in some situations, which is pretty weird) `adt_const_params` tracking issue: rust-lang#95174
Rollup merge of rust-lang#131038 - onkoe:fix/adt_const_params_leak_118179, r=compiler-errors Fix `adt_const_params` leaking `{type error}` in error msg Fixes the confusing diagnostic described in rust-lang#118179. (users would see `{type error}` in some situations, which is pretty weird) `adt_const_params` tracking issue: rust-lang#95174
This is a tracking issue for allowing more const parameter types.
The feature gate for this issue is
#![feature(adt_const_params)]
.About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
Most of the work here will be coordinated in the
#project-const-generics
stream on zulip.valtrees
expected int of size 8, but got size 1
inrustc_middle/src/ty/consts/int.rs
with featureadt_const_params
#131052 ICE:InterpErrorInfo(InterpErrorInfoInner { kind: UndefinedBehavior(BoundsCheckFailed
#129095 ICE:unable to construct a valtree for the unevaluated constant
#128232)min_generic_const_args
<const>
to includestr
and structural constants. rfcs#3161)Unresolved Questions
adt_const_params
forwards compatible withunsized_const_params
(Tracking Issue for unsized const parameter types:feature(unsized_const_params)
#128028)cc @rust-lang/project-const-generics
The text was updated successfully, but these errors were encountered: