mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Rollup merge of #154710 - khyperia:rename-ogca, r=BoxyUwU
opaque_generic_const_args -> generic_const_args This is part of a larger rework/plan of how to move forward with GCA. Please comment here, or message/ping me or @BoxyUwU if you have questions about the future of oGCA/GCA! For ease of review, the first commit is renaming, and the second commit is removing the opaque parts. fyi @camelid r? @BoxyUwU
This commit is contained in:
@@ -520,6 +520,8 @@ pub fn internal(&self, feature: Symbol) -> bool {
|
||||
(unstable, frontmatter, "1.88.0", Some(136889)),
|
||||
/// Allows defining gen blocks and `gen fn`.
|
||||
(unstable, gen_blocks, "1.75.0", Some(117078)),
|
||||
/// Allows using generics in more complex const expressions, based on definitional equality.
|
||||
(unstable, generic_const_args, "1.95.0", Some(151972)),
|
||||
/// Allows non-trivial generic constants which have to have wfness manually propagated to callers
|
||||
(incomplete, generic_const_exprs, "1.56.0", Some(76560)),
|
||||
/// Allows generic parameters and where-clauses on free & associated const items.
|
||||
@@ -623,8 +625,6 @@ pub fn internal(&self, feature: Symbol) -> bool {
|
||||
(unstable, offset_of_enum, "1.75.0", Some(120141)),
|
||||
/// Allows using fields with slice type in offset_of!
|
||||
(unstable, offset_of_slice, "1.81.0", Some(126151)),
|
||||
/// Allows using generics in more complex const expressions, based on definitional equality.
|
||||
(unstable, opaque_generic_const_args, "1.95.0", Some(151972)),
|
||||
/// Allows using `#[optimize(X)]`.
|
||||
(unstable, optimize_attribute, "1.34.0", Some(54882)),
|
||||
/// Allows specifying nop padding on functions for dynamic patching.
|
||||
@@ -806,6 +806,6 @@ struct FeatureUsage {
|
||||
|
||||
/// Some features require one or more other features to be enabled.
|
||||
pub const DEPENDENT_FEATURES: &[(Symbol, &[Symbol])] = &[
|
||||
(sym::opaque_generic_const_args, &[sym::min_generic_const_args]),
|
||||
(sym::generic_const_args, &[sym::min_generic_const_args]),
|
||||
(sym::unsized_const_params, &[sym::adt_const_params]),
|
||||
];
|
||||
|
||||
@@ -1598,8 +1598,8 @@ fn anon_const_kind<'tcx>(tcx: TyCtxt<'tcx>, def: LocalDefId) -> ty::AnonConstKin
|
||||
let parent_hir_node = tcx.hir_node(tcx.parent_hir_id(const_arg_id));
|
||||
if tcx.features().generic_const_exprs() {
|
||||
ty::AnonConstKind::GCE
|
||||
} else if tcx.features().opaque_generic_const_args() {
|
||||
// Only anon consts that are the RHS of a const item can be OGCA.
|
||||
} else if tcx.features().generic_const_args() {
|
||||
// Only anon consts that are the RHS of a const item can be GCA.
|
||||
// Note: We can't just check tcx.parent because it needs to be EXACTLY
|
||||
// the RHS, not just part of the RHS.
|
||||
if !is_anon_const_rhs_of_const_item(tcx, def) {
|
||||
@@ -1607,9 +1607,9 @@ fn anon_const_kind<'tcx>(tcx: TyCtxt<'tcx>, def: LocalDefId) -> ty::AnonConstKin
|
||||
}
|
||||
|
||||
let body = tcx.hir_body_owned_by(def);
|
||||
let mut visitor = OGCAParamVisitor(tcx);
|
||||
let mut visitor = GCAParamVisitor(tcx);
|
||||
match visitor.visit_body(body) {
|
||||
ControlFlow::Break(UsesParam) => ty::AnonConstKind::OGCA,
|
||||
ControlFlow::Break(UsesParam) => ty::AnonConstKind::GCA,
|
||||
ControlFlow::Continue(()) => ty::AnonConstKind::MCG,
|
||||
}
|
||||
} else if tcx.features().min_generic_const_args() {
|
||||
@@ -1650,11 +1650,11 @@ fn is_anon_const_rhs_of_const_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId)
|
||||
def_id == rhs_anon.def_id
|
||||
}
|
||||
|
||||
struct OGCAParamVisitor<'tcx>(TyCtxt<'tcx>);
|
||||
struct GCAParamVisitor<'tcx>(TyCtxt<'tcx>);
|
||||
|
||||
struct UsesParam;
|
||||
|
||||
impl<'tcx> Visitor<'tcx> for OGCAParamVisitor<'tcx> {
|
||||
impl<'tcx> Visitor<'tcx> for GCAParamVisitor<'tcx> {
|
||||
type NestedFilter = nested_filter::OnlyBodies;
|
||||
type Result = ControlFlow<UsesParam>;
|
||||
|
||||
|
||||
@@ -97,8 +97,8 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
match tcx.anon_const_kind(def_id) {
|
||||
// Stable: anon consts are not able to use any generic parameters...
|
||||
ty::AnonConstKind::MCG => None,
|
||||
// OGCA anon consts inherit their parent's generics.
|
||||
ty::AnonConstKind::OGCA => Some(parent_did),
|
||||
// GCA anon consts inherit their parent's generics.
|
||||
ty::AnonConstKind::GCA => Some(parent_did),
|
||||
// we provide generics to repeat expr counts as a backwards compatibility hack. #76200
|
||||
ty::AnonConstKind::RepeatExprCount => Some(parent_did),
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ impl<'tcx> ForbidMCGParamUsesFolder<'tcx> {
|
||||
fn error(&self) -> ErrorGuaranteed {
|
||||
let msg = if self.is_self_alias {
|
||||
"generic `Self` types are currently not permitted in anonymous constants"
|
||||
} else if self.tcx.features().opaque_generic_const_args() {
|
||||
} else if self.tcx.features().generic_const_args() {
|
||||
"generic parameters in const blocks are only allowed as the direct value of a `type const`"
|
||||
} else {
|
||||
"generic parameters may not be used in const operations"
|
||||
@@ -408,8 +408,8 @@ fn error(&self) -> ErrorGuaranteed {
|
||||
}
|
||||
}
|
||||
if self.tcx.features().min_generic_const_args() {
|
||||
if !self.tcx.features().opaque_generic_const_args() {
|
||||
diag.help("add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items");
|
||||
if !self.tcx.features().generic_const_args() {
|
||||
diag.help("add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items");
|
||||
} else {
|
||||
diag.help("consider factoring the expression into a `type const` item and use it as the const argument instead");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rustc_type_ir::{self as ty, Interner, TypingMode};
|
||||
use rustc_type_ir::{self as ty, Interner};
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::delegate::SolverDelegate;
|
||||
@@ -14,18 +14,7 @@ pub(super) fn normalize_anon_const(
|
||||
&mut self,
|
||||
goal: Goal<I, ty::NormalizesTo<I>>,
|
||||
) -> QueryResult<I> {
|
||||
if self.typing_mode() == TypingMode::Coherence
|
||||
&& self.cx().anon_const_kind(goal.predicate.alias.def_id) == ty::AnonConstKind::OGCA
|
||||
{
|
||||
// During coherence, OGCA consts should be normalized ambiguously
|
||||
// because they are opaque but eventually resolved to a real value.
|
||||
// We don't want two OGCAs that have the same value to be treated
|
||||
// as distinct for coherence purposes. (Just like opaque types.)
|
||||
//
|
||||
// We can't rely on evaluate_const below because that particular wrapper
|
||||
// treats too-generic consts as a successful evaluation.
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
|
||||
} else if let Some(normalized_const) = self.evaluate_const(
|
||||
if let Some(normalized_const) = self.evaluate_const(
|
||||
goal.param_env,
|
||||
ty::UnevaluatedConst::new(
|
||||
goal.predicate.alias.def_id.try_into().unwrap(),
|
||||
|
||||
@@ -1011,14 +1011,14 @@ pub(crate) fn into_struct_error(
|
||||
ResolutionError::ParamInTyOfConstParam { name } => {
|
||||
self.dcx().create_err(errs::ParamInTyOfConstParam { span, name })
|
||||
}
|
||||
ResolutionError::ParamInNonTrivialAnonConst { is_ogca, name, param_kind: is_type } => {
|
||||
ResolutionError::ParamInNonTrivialAnonConst { is_gca, name, param_kind: is_type } => {
|
||||
self.dcx().create_err(errs::ParamInNonTrivialAnonConst {
|
||||
span,
|
||||
name,
|
||||
param_kind: is_type,
|
||||
help: self.tcx.sess.is_nightly_build(),
|
||||
is_ogca,
|
||||
help_ogca: is_ogca,
|
||||
is_gca,
|
||||
help_gca: is_gca,
|
||||
})
|
||||
}
|
||||
ResolutionError::ParamInEnumDiscriminant { name, param_kind: is_type } => self
|
||||
|
||||
@@ -407,7 +407,7 @@ pub(crate) struct SelfInConstGenericTy {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"{$is_ogca ->
|
||||
"{$is_gca ->
|
||||
[true] generic parameters in const blocks are only allowed as the direct value of a `type const`
|
||||
*[false] generic parameters may not be used in const operations
|
||||
}"
|
||||
@@ -421,11 +421,11 @@ pub(crate) struct ParamInNonTrivialAnonConst {
|
||||
pub(crate) param_kind: ParamKindInNonTrivialAnonConst,
|
||||
#[help("add `#![feature(generic_const_exprs)]` to allow generic const expressions")]
|
||||
pub(crate) help: bool,
|
||||
pub(crate) is_ogca: bool,
|
||||
pub(crate) is_gca: bool,
|
||||
#[help(
|
||||
"consider factoring the expression into a `type const` item and use it as the const argument instead"
|
||||
)]
|
||||
pub(crate) help_ogca: bool,
|
||||
pub(crate) help_gca: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -1568,10 +1568,7 @@ fn validate_res_from_ribs(
|
||||
}
|
||||
NoConstantGenericsReason::NonTrivialConstArg => {
|
||||
ResolutionError::ParamInNonTrivialAnonConst {
|
||||
is_ogca: self
|
||||
.tcx
|
||||
.features()
|
||||
.opaque_generic_const_args(),
|
||||
is_gca: self.tcx.features().generic_const_args(),
|
||||
name: rib_ident.name,
|
||||
param_kind: ParamKindInNonTrivialAnonConst::Type,
|
||||
}
|
||||
@@ -1663,10 +1660,7 @@ fn validate_res_from_ribs(
|
||||
}
|
||||
NoConstantGenericsReason::NonTrivialConstArg => {
|
||||
ResolutionError::ParamInNonTrivialAnonConst {
|
||||
is_ogca: self
|
||||
.tcx
|
||||
.features()
|
||||
.opaque_generic_const_args(),
|
||||
is_gca: self.tcx.features().generic_const_args(),
|
||||
name: rib_ident.name,
|
||||
param_kind: ParamKindInNonTrivialAnonConst::Const {
|
||||
name: rib_ident.name,
|
||||
|
||||
@@ -3921,8 +3921,8 @@ pub(crate) fn emit_forbidden_non_static_lifetime_error(
|
||||
name: lifetime_ref.ident.name,
|
||||
param_kind: errors::ParamKindInNonTrivialAnonConst::Lifetime,
|
||||
help: self.r.tcx.sess.is_nightly_build(),
|
||||
is_ogca: self.r.tcx.features().opaque_generic_const_args(),
|
||||
help_ogca: self.r.tcx.features().opaque_generic_const_args(),
|
||||
is_gca: self.r.tcx.features().generic_const_args(),
|
||||
help_gca: self.r.tcx.features().generic_const_args(),
|
||||
})
|
||||
.emit()
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ enum ResolutionError<'ra> {
|
||||
///
|
||||
/// This error is only emitted when using `min_const_generics`.
|
||||
ParamInNonTrivialAnonConst {
|
||||
is_ogca: bool,
|
||||
is_gca: bool,
|
||||
name: Symbol,
|
||||
param_kind: ParamKindInNonTrivialAnonConst,
|
||||
},
|
||||
|
||||
@@ -1014,6 +1014,7 @@
|
||||
generic_assert,
|
||||
generic_associated_types,
|
||||
generic_associated_types_extended,
|
||||
generic_const_args,
|
||||
generic_const_exprs,
|
||||
generic_const_items,
|
||||
generic_const_parameter_types,
|
||||
@@ -1414,7 +1415,6 @@
|
||||
on_move,
|
||||
on_unimplemented,
|
||||
opaque,
|
||||
opaque_generic_const_args,
|
||||
opaque_module_name_placeholder: "<opaque>",
|
||||
ops,
|
||||
opt_out_copy,
|
||||
|
||||
@@ -676,21 +676,10 @@ pub fn try_evaluate_const<'tcx>(
|
||||
|
||||
(args, typing_env)
|
||||
}
|
||||
Some(ty::AnonConstKind::OGCA) => {
|
||||
if infcx.typing_mode() != TypingMode::PostAnalysis {
|
||||
// OGCA anon consts should be treated as always having generics
|
||||
// during anything before codegen (or maybe MIR opts too).
|
||||
return Err(EvaluateConstErr::HasGenericsOrInfers);
|
||||
}
|
||||
|
||||
if uv.args.has_non_region_param() || uv.args.has_non_region_infer() {
|
||||
return Err(EvaluateConstErr::HasGenericsOrInfers);
|
||||
}
|
||||
|
||||
let typing_env = ty::TypingEnv::fully_monomorphized();
|
||||
(uv.args, typing_env)
|
||||
}
|
||||
Some(ty::AnonConstKind::MCG) | Some(ty::AnonConstKind::NonTypeSystem) | None => {
|
||||
Some(ty::AnonConstKind::GCA)
|
||||
| Some(ty::AnonConstKind::MCG)
|
||||
| Some(ty::AnonConstKind::NonTypeSystem)
|
||||
| None => {
|
||||
// We are only dealing with "truly" generic/uninferred constants here:
|
||||
// - GCEConsts have been handled separately
|
||||
// - Repeat expr count back compat consts have also been handled separately
|
||||
|
||||
@@ -210,9 +210,9 @@ pub enum AnonConstKind {
|
||||
GCE,
|
||||
/// stable `min_const_generics` anon consts are not allowed to use any generic parameters
|
||||
MCG,
|
||||
/// `feature(opaque_generic_const_args)` anon consts are allowed to use arbitrary
|
||||
/// `feature(generic_const_args)` anon consts are allowed to use arbitrary
|
||||
/// generic parameters in scope, but only if they syntactically reference them.
|
||||
OGCA,
|
||||
GCA,
|
||||
/// anon consts used as the length of a repeat expr are syntactically allowed to use generic parameters
|
||||
/// but must not depend on the actual instantiation. See #76200 for more information
|
||||
RepeatExprCount,
|
||||
|
||||
+3
-3
@@ -1,6 +1,8 @@
|
||||
//@ check-pass
|
||||
|
||||
#![feature(generic_const_items)]
|
||||
#![feature(min_generic_const_args)]
|
||||
#![feature(opaque_generic_const_args)]
|
||||
#![feature(generic_const_args)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
type const ADD1<const N: usize>: usize = const { N + 1 };
|
||||
@@ -11,8 +13,6 @@
|
||||
|
||||
type const OTHER_ONE: usize = INC::<0>;
|
||||
|
||||
// Not definitionally equal.
|
||||
const ARR: [(); ADD1::<0>] = [(); INC::<0>];
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
fn main() {}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#![feature(generic_const_items)]
|
||||
#![feature(min_generic_const_args)]
|
||||
#![feature(opaque_generic_const_args)]
|
||||
#![feature(generic_const_args)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
type const ADD1<const N: usize>: usize = const { N + 1 };
|
||||
@@ -0,0 +1,28 @@
|
||||
#![feature(generic_const_items, min_generic_const_args, generic_const_args)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
// computing the same value with different constant items but same generic arguments should fail
|
||||
trait Trait1 {}
|
||||
type const FOO<const N: usize>: usize = const { N + 1 };
|
||||
type const BAR<const N: usize>: usize = const { N + 1 };
|
||||
impl Trait1 for [(); FOO::<1>] {}
|
||||
impl Trait1 for [(); BAR::<1>] {}
|
||||
//~^ ERROR conflicting implementations of trait `Trait1` for type `[(); 2]`
|
||||
|
||||
// computing the same value with the same constant item but different generic arguments should fail
|
||||
type const DIV2<const N: usize>: usize = const { N / 2 };
|
||||
trait Trait2 {}
|
||||
impl Trait2 for [(); DIV2::<2>] {}
|
||||
impl Trait2 for [(); DIV2::<3>] {}
|
||||
//~^ ERROR conflicting implementations of trait `Trait2` for type `[(); 1]`
|
||||
|
||||
// computing the same value with different constant items and different generic arguments should
|
||||
// fail
|
||||
trait Trait3 {}
|
||||
type const ADD1<const N: usize>: usize = const { N + 1 };
|
||||
type const SUB1<const N: usize>: usize = const { N - 1 };
|
||||
impl Trait3 for [(); ADD1::<1>] {}
|
||||
impl Trait3 for [(); SUB1::<3>] {}
|
||||
//~^ ERROR conflicting implementations of trait `Trait3` for type `[(); 2]`
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,27 @@
|
||||
error[E0119]: conflicting implementations of trait `Trait1` for type `[(); 2]`
|
||||
--> $DIR/coherence-fail.rs:9:1
|
||||
|
|
||||
LL | impl Trait1 for [(); FOO::<1>] {}
|
||||
| ------------------------------ first implementation here
|
||||
LL | impl Trait1 for [(); BAR::<1>] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[(); 2]`
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Trait2` for type `[(); 1]`
|
||||
--> $DIR/coherence-fail.rs:16:1
|
||||
|
|
||||
LL | impl Trait2 for [(); DIV2::<2>] {}
|
||||
| ------------------------------- first implementation here
|
||||
LL | impl Trait2 for [(); DIV2::<3>] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[(); 1]`
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Trait3` for type `[(); 2]`
|
||||
--> $DIR/coherence-fail.rs:25:1
|
||||
|
|
||||
LL | impl Trait3 for [(); ADD1::<1>] {}
|
||||
| ------------------------------- first implementation here
|
||||
LL | impl Trait3 for [(); SUB1::<3>] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[(); 2]`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
@@ -0,0 +1,14 @@
|
||||
//@ check-pass
|
||||
#![feature(generic_const_items, min_generic_const_args, generic_const_args)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
// computing different values with the same type const item should be fine
|
||||
|
||||
type const ADD1<const N: usize>: usize = const { N + 1 };
|
||||
|
||||
trait Trait {}
|
||||
|
||||
impl Trait for [(); ADD1::<1>] {}
|
||||
impl Trait for [(); ADD1::<2>] {}
|
||||
|
||||
fn main() {}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#![feature(min_generic_const_args, opaque_generic_const_args)]
|
||||
#![feature(min_generic_const_args, generic_const_args)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
fn foo<const N: usize>() {}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
#![feature(generic_const_items)]
|
||||
#![feature(min_generic_const_args)]
|
||||
#![feature(opaque_generic_const_args)]
|
||||
#![feature(generic_const_args)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
// Anon consts must be the root of the RHS to be OGCA.
|
||||
// Anon consts must be the root of the RHS to be GCA.
|
||||
type const FOO<const N: usize>: usize = ID::<const { N + 1 }>;
|
||||
//~^ ERROR generic parameters in const blocks are only allowed as the direct value of a `type const`
|
||||
type const ID<const N: usize>: usize = N;
|
||||
@@ -10,7 +10,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | foo::<{ Some::<u32> { 0: const { N + 1 } } }>();
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | T: Trait<const { let a: &'a (); 1 }>
|
||||
| ^^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | type const ITEM3<const N: usize>: usize = const { N };
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/explicit_anon_consts.rs:60:31
|
||||
@@ -48,7 +48,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | T3: Trait<ASSOC = const { N }>,
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/explicit_anon_consts.rs:69:58
|
||||
@@ -56,7 +56,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | struct Default3<const N: usize, const M: usize = const { N }>;
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/explicit_anon_consts.rs:28:27
|
||||
@@ -64,7 +64,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | let _3 = [(); const { N }];
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/explicit_anon_consts.rs:33:26
|
||||
@@ -72,7 +72,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | let _6: [(); const { N }] = todo!();
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/explicit_anon_consts.rs:11:41
|
||||
@@ -80,7 +80,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | type Adt3<const N: usize> = Foo<const { N }>;
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/explicit_anon_consts.rs:19:42
|
||||
@@ -88,7 +88,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | type Arr3<const N: usize> = [(); const { N }];
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ note: not a concrete type
|
||||
|
|
||||
LL | impl<const N: usize> S<N> {
|
||||
| ^^^^
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | fn foo() -> [(); const { let _: Self; 1 }];
|
||||
| ^^^^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | [0; const { size_of::<*mut T>() }];
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | with_point::<{ Point(const { N + 1 }, N) }>();
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | takes_nested_tuple::<{ (N, (N, const { N + 1 })) }>();
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | type const FREE1<T>: usize = const { std::mem::size_of::<T>() };
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/type_const-on-generic-expr.rs:8:51
|
||||
@@ -12,7 +12,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | type const FREE2<const I: usize>: usize = const { I + 1 };
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | type const N1<T>: usize = const { std::mem::size_of::<T>() };
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/type_const-on-generic_expr-2.rs:15:52
|
||||
@@ -12,7 +12,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | type const N2<const I: usize>: usize = const { I + 1 };
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/type_const-on-generic_expr-2.rs:17:40
|
||||
@@ -20,7 +20,7 @@ error: generic parameters may not be used in const operations
|
||||
LL | type const N3: usize = const { 2 & X };
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/basic-fail.rs:15:30
|
||||
|
|
||||
LL | const ARR: [(); ADD1::<0>] = [(); INC::<0>];
|
||||
| --------------- ^^^^^^^^^^^^^^ expected an array with a size of const { N + 1 }, found one with a size of const { N + 1 }
|
||||
| |
|
||||
| expected because of the type of the constant
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
@@ -1,18 +0,0 @@
|
||||
//@ check-fail
|
||||
|
||||
#![feature(generic_const_items, min_generic_const_args, opaque_generic_const_args)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
type const FOO<const N: usize>: usize = const { N + 1 };
|
||||
|
||||
type const BAR<const N: usize>: usize = const { N + 1 };
|
||||
|
||||
trait Trait {}
|
||||
|
||||
impl Trait for [(); FOO::<1>] {}
|
||||
impl Trait for [(); BAR::<1>] {}
|
||||
//~^ ERROR conflicting implementations of trait `Trait` for type `[(); FOO::<1>]`
|
||||
impl Trait for [(); BAR::<2>] {}
|
||||
//~^ ERROR conflicting implementations of trait `Trait` for type `[(); FOO::<1>]`
|
||||
|
||||
fn main() {}
|
||||
@@ -1,20 +0,0 @@
|
||||
error[E0119]: conflicting implementations of trait `Trait` for type `[(); FOO::<1>]`
|
||||
--> $DIR/coherence-ambiguous.rs:13:1
|
||||
|
|
||||
LL | impl Trait for [(); FOO::<1>] {}
|
||||
| ----------------------------- first implementation here
|
||||
LL | impl Trait for [(); BAR::<1>] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[(); FOO::<1>]`
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Trait` for type `[(); FOO::<1>]`
|
||||
--> $DIR/coherence-ambiguous.rs:15:1
|
||||
|
|
||||
LL | impl Trait for [(); FOO::<1>] {}
|
||||
| ----------------------------- first implementation here
|
||||
...
|
||||
LL | impl Trait for [(); BAR::<2>] {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[(); FOO::<1>]`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
+1
-1
@@ -3,6 +3,6 @@
|
||||
|
||||
type const INC<const N: usize>: usize = const { N + 1 };
|
||||
//~^ ERROR generic parameters may not be used in const operations
|
||||
//~| HELP add `#![feature(opaque_generic_const_args)]`
|
||||
//~| HELP add `#![feature(generic_const_args)]`
|
||||
|
||||
fn main() {}
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/feature-gate-opaque-generic-const-args.rs:4:49
|
||||
--> $DIR/feature-gate-generic-const-args.rs:4:49
|
||||
|
|
||||
LL | type const INC<const N: usize>: usize = const { N + 1 };
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
= help: add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
Reference in New Issue
Block a user