Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2402,7 +2402,7 @@ pub struct BorrowedFnSig<'a> {
/// * the `G<Ty> = Ty` in `Trait<G<Ty> = Ty>`
/// * the `A: Bound` in `Trait<A: Bound>`
/// * the `RetTy` in `Trait(ArgTy, ArgTy) -> RetTy`
/// * the `C = { Ct }` in `Trait<C = { Ct }>` (feature `min_generic_const_args`)
/// * the `C = { Ct }` in `Trait<C = { Ct }>` (feature `gca_min_const_items`)
/// * the `f(..): Bound` in `Trait<f(..): Bound>` (feature `return_type_notation`)
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
pub struct AssocItemConstraint {
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// type and value namespaces. If we resolved the path in the value namespace, we
// transform it into a generic const argument.
//
// Note that even under `#![feature(min_generic_const_args)]`, only plain paths
// Note that even under `#![feature(gca_min_const_items)]`, only plain paths
// to constants are allowed - e.g. `A::<T::ASSOC_CONST>` and
// `A::<CONST_WITH_PARAM::<2>>` are disallowed (they must be wrapped in `{ }`).
//
Expand All @@ -1420,7 +1420,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let ct = self.arena.alloc(ct);
return GenericArg::Const(ct.try_as_ambig_ct().unwrap());
}
TyKind::GcaMacro(expr) if self.tcx.features().min_generic_const_args() => {
TyKind::GcaMacro(expr) if self.tcx.features().gca_min_const_items() => {
let ct = match self.can_lower_expr_to_const_arg_direct(
expr,
DirectConstArgContext::MacrolessMinGenericConstArgs,
Expand Down Expand Up @@ -2558,7 +2558,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// We cannot just match on `ExprKind::Underscore` as `(_)` is represented as
// `ExprKind::Paren(ExprKind::Underscore)` and should also be lowered to `GenericArg::Infer`
//
// FIXME(macroless_generic_const_args): Handling of underscores should be moved into
// FIXME(gca_macroless_args): Handling of underscores should be moved into
// lower_expr_to_const_arg_direct. It is left here as retaining compatibility of what is
// currently allowed on stable gets hairy and annoying otherwise.
match c.value.peel_parens().kind {
Expand Down Expand Up @@ -2632,7 +2632,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
span: Span,
) -> hir::ConstItemRhs<'hir> {
let is_direct = |body| {
if self.tcx.features().macroless_const_item_generic_const_args() {
if self.tcx.features().gca_macroless_items() {
self.can_lower_expr_to_const_arg_direct(
body,
DirectConstArgContext::MacrolessMinGenericConstArgs,
Expand All @@ -2645,7 +2645,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
matches!(body, Expr { kind: ExprKind::GcaMacro(_), .. })
}
};
if self.tcx.features().min_generic_const_args()
if self.tcx.features().gca_min_const_items()
&& let Some(body) = body
&& is_direct(body)
{
Expand All @@ -2658,9 +2658,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn ambient_direct_const_arg_context(&self) -> DirectConstArgContext {
if self.tcx.features().macroless_generic_const_args() {
if self.tcx.features().gca_macroless_args() {
DirectConstArgContext::MacrolessMinGenericConstArgs
} else if self.tcx.features().min_generic_const_args() {
} else if self.tcx.features().gca_min_const_items() {
DirectConstArgContext::MinGenericConstArgs
} else {
DirectConstArgContext::Stable
Expand Down Expand Up @@ -2965,7 +2965,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
// Stable only allows one nesting of blocks for directly represented paths. mGCA allows
// arbitrarily many, and are handled inside lower_expr_to_const_arg_direct for consistency.
let expr = if self.tcx.features().macroless_generic_const_args() {
let expr = if self.tcx.features().gca_macroless_args() {
&anon.value
} else {
anon.value.maybe_unwrap_block()
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,12 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
gate_all!(final_associated_functions, "`final` on trait functions is experimental");
gate_all!(fn_delegation, "functions delegation is not yet fully implemented");
gate_all!(frontmatter, "frontmatters are experimental");
gate_all!(gca_min_const_items, "unbraced const blocks as const args are experimental");
gate_all!(gen_blocks, "gen blocks are experimental");
gate_all!(generic_const_items, "generic const items are experimental");
gate_all!(global_registration, "global registration is experimental");
gate_all!(guard_patterns, "guard patterns are experimental", "consider using match arm guards");
gate_all!(impl_restriction, "`impl` restrictions are experimental");
gate_all!(min_generic_const_args, "unbraced const blocks as const args are experimental");
gate_all!(more_qualified_paths, "usage of qualified paths in this context is experimental");
gate_all!(move_expr, "`move(expr)` syntax is experimental");
gate_all!(mut_ref, "mutable by-reference bindings are experimental");
Expand Down Expand Up @@ -490,9 +490,9 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
"named parameters in parenthesized generic argument lists are experimental"
);

// `associated_const_equality` will be stabilized as part of `min_generic_const_args`.
// `associated_const_equality` will be stabilized as part of `gca_min_const_items`.
for &span in spans.get(&sym::associated_const_equality).into_flat_iter() {
gate!(visitor, min_generic_const_args, span, "associated const equality is incomplete");
gate!(visitor, gca_min_const_items, span, "associated const equality is incomplete");
}

// Negative bounds are *super* internal. We require `-Zinternal-testing-features` *and*
Expand Down Expand Up @@ -703,13 +703,13 @@ fn check_features_requiring_new_solver(sess: &Session, features: &Features) {
if let Some(gca_span) = features
.enabled_lang_features()
.iter()
.find(|feat| feat.gate_name == sym::generic_const_args)
.find(|feat| feat.gate_name == sym::gca_const_items)
.map(|feat| feat.attr_sp)
{
#[allow(rustc::symbol_intern_string_literal)]
sess.dcx().emit_err(diagnostics::MissingDependentFeatures {
parent_span: gca_span,
parent: sym::generic_const_args,
parent: sym::gca_const_items,
missing: String::from("-Znext-solver=globally"),
});
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/semantics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ impl NoArgsAttributeParser for AlwaysGcaParser {
const PATH: &[Symbol] = &[sym::rustc_always_gca];
const ALLOWED_TARGETS: AllowedTargets<'_> =
AllowedTargets::AllowList(&[Allow(Target::AssocConst(AssocCtxt::Trait))]);
const STABILITY: AttributeStability = unstable!(min_generic_const_args);
const STABILITY: AttributeStability = unstable!(gca_min_const_items);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::AlwaysGca;
}
6 changes: 5 additions & 1 deletion compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ declare_features! (
(removed, allow_fail, "1.60.0", Some(46488), Some("removed due to no clear use cases"), 93416),
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
(removed, associated_const_equality, "1.94.0", Some(92827),
Some("merged into `min_generic_const_args`")),
Some("merged into `gca_min_const_items`")),
(removed, await_macro, "1.38.0", Some(50547),
Some("subsumed by `.await` syntax"), 62293),
/// Allows using `box` in patterns (RFC 469).
Expand Down Expand Up @@ -167,6 +167,7 @@ declare_features! (
),
133768
),
(removed, generic_const_args, "CURRENT_RUSTC_VERSION", Some(151972), Some("renamed to `gca_const_items`")),
(removed, import_shadowing, "1.0.0", None, None),
/// Allows in-band quantification of lifetime bindings (e.g., `fn foo(x: &'a u8) -> &'a u8`).
(removed, in_band_lifetimes, "1.61.0", Some(44524),
Expand All @@ -192,9 +193,12 @@ declare_features! (
which is available from cargo build scripts with `cargo:rustc-link-arg` now"), 83820),
(removed, macro_reexport, "1.0.0", Some(29638),
Some("subsumed by `pub use`"), 49982),
(removed, macroless_const_item_generic_const_args, "CURRENT_RUSTC_VERSION", Some(162540), Some("renamed to `gca_macroless_items`")),
(removed, macroless_generic_const_args, "CURRENT_RUSTC_VERSION", Some(159006), Some("renamed to `gca_macroless_args`")),
/// Allows using `#[main]` to replace the entrypoint `#[lang = "start"]` calls.
(removed, main, "1.53.0", Some(29634), None, 84217),
(removed, managed_boxes, "1.0.0", None, None),
(removed, min_generic_const_args, "CURRENT_RUSTC_VERSION", Some(132980), Some("renamed to `gca_min_const_items`")),
/// Allows the use of type alias impl trait in function return positions
(removed, min_type_alias_impl_trait, "1.56.0", Some(63063),
Some("removed in favor of full type_alias_impl_trait"), 87564),
Expand Down
26 changes: 13 additions & 13 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,18 @@ declare_features! (
(internal, freeze_impls, "1.78.0", Some(121675)),
/// Frontmatter `---` blocks for use by external tools.
(unstable, frontmatter, "1.88.0", Some(136889)),
/// Allows using generics in more complex const expressions, based on definitional equality.
(incomplete, gca_const_items, "1.95.0", Some(151972)),
/// Allows directly represented gca_const_items without the `gca!` macro.
(incomplete, gca_macroless_args, "1.99.0", Some(159006)),
/// Allows directly represented gca_const_items as the rhs of const items without the
/// `gca!` macro.
(incomplete, gca_macroless_items, "CURRENT_RUSTC_VERSION", Some(162540)),
/// Enables the generic const args MVP (paths to type const items and constructors
/// for ADTs and primitives).
(incomplete, gca_min_const_items, "1.84.0", Some(132980)),
/// 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.
(incomplete, generic_const_args, "1.95.0", Some(151972)),
/// Allows non-trivial generic constants which have to be shown to successfully evaluate
/// to a value by being part of an item signature.
(incomplete, generic_const_exprs, "1.56.0", Some(76560)),
Expand Down Expand Up @@ -609,19 +617,11 @@ declare_features! (
(unstable, macro_metavar_expr, "1.61.0", Some(83527)),
/// Provides a way to concatenate identifiers using metavariable expressions.
(unstable, macro_metavar_expr_concat, "1.81.0", Some(124225)),
/// Allows directly represented generic_const_args as the rhs of const items without the
/// `gca!` macro.
(incomplete, macroless_const_item_generic_const_args, "CURRENT_RUSTC_VERSION", Some(162540)),
/// Allows directly represented generic_const_args without the `gca!` macro.
(incomplete, macroless_generic_const_args, "1.99.0", Some(159006)),
/// Allows `#[marker]` on certain traits allowing overlapping implementations.
(unstable, marker_trait_attr, "1.30.0", Some(29864)),
/// Allows additional const parameter types, such as [u8; 10] or user defined types.
/// User defined types must not have fields more private than the type itself.
(unstable, min_adt_const_params, "1.96.0", Some(154042)),
/// Enables the generic const args MVP (paths to type const items and constructors
/// for ADTs and primitives).
(incomplete, min_generic_const_args, "1.84.0", Some(132980)),
/// A minimal, sound subset of specialization intended to be used by the
/// standard library until the soundness issues with specialization
/// are fixed.
Expand Down Expand Up @@ -859,8 +859,8 @@ pub const INCOMPATIBLE_FEATURES: &[(Symbol, Symbol)] = &[

/// Some features require one or more other features to be enabled.
pub const DEPENDENT_FEATURES: &[(Symbol, &[Symbol])] = &[
(sym::generic_const_args, &[sym::min_generic_const_args]),
(sym::macroless_generic_const_args, &[sym::min_generic_const_args]),
(sym::macroless_const_item_generic_const_args, &[sym::min_generic_const_args]),
(sym::gca_const_items, &[sym::gca_min_const_items]),
(sym::gca_macroless_args, &[sym::gca_min_const_items]),
(sym::gca_macroless_items, &[sym::gca_min_const_items]),
(sym::unsized_const_params, &[sym::adt_const_params]),
];
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3093,7 +3093,7 @@ pub enum ImplItemKind<'hir> {
/// * the `G<Ty> = Ty` in `Trait<G<Ty> = Ty>`
/// * the `A: Bound` in `Trait<A: Bound>`
/// * the `RetTy` in `Trait(ArgTy, ArgTy) -> RetTy`
/// * the `C = { Ct }` in `Trait<C = { Ct }>` (feature `min_generic_const_args`)
/// * the `C = { Ct }` in `Trait<C = { Ct }>` (feature `gca_min_const_items`)
/// * the `f(..): Bound` in `Trait<f(..): Bound>` (feature `return_type_notation`)
#[derive(Debug, Clone, Copy, StableHash)]
pub struct AssocItemConstraint<'hir> {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2162,8 +2162,8 @@ pub(super) fn compare_const_directness<'tcx>(
if trait_is_gca == impl_is_gca {
return Ok(());
}
// feature(generic_const_args) is allowed to impl non-GCA traits with a GCA const
if tcx.features().generic_const_args() && !trait_is_gca && impl_is_gca {
// feature(gca_const_items) is allowed to impl non-GCA traits with a GCA const
if tcx.features().gca_const_items() && !trait_is_gca && impl_is_gca {
return Ok(());
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ pub(super) fn check_const_item<'tcx>(
tcx.require_lang_item(LangItem::ConstParamTy, span),
);
}
// FIXME(min_generic_const_args): We *might* want to move this check to `type_of`, so we can
// FIXME(gca_min_const_items): We *might* want to move this check to `type_of`, so we can
// return `ty::Error` if it references invalid params. However, doing so is hard, because
// `type_of` doesn't know if it's a direct const - `const_of_item` determines that, and
// `const_of_item` calls `type_of`.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ fn anon_const_kind<'tcx>(tcx: TyCtxt<'tcx>, def: LocalDefId) -> ty::AnonConstKin
debug_assert_matches!(const_arg.kind, hir::ConstArgKind::Anon(hir::AnonConst { def_id, .. }) if *def_id == def);
if tcx.features().generic_const_exprs() {
ty::AnonConstKind::GCE
} else if tcx.features().min_generic_const_args() {
} else if tcx.features().gca_min_const_items() {
ty::AnonConstKind::MCG
} else if let hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Repeat(_, repeat_count),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect/generics_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
// Node::AnonConst, or whether it will be represented directly, so it must generate a
// DefId. If it ends up being direct, this DefId is then attached to the top-level
// ConstArg, which is what we are seeing here.
debug_assert!(tcx.features().min_generic_const_args());
debug_assert!(tcx.features().gca_min_const_items());
// Forward to the real parent.
Some(tcx.local_parent(def_id))
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {

if let ty::AssocTag::Const = assoc_tag
&& !self.tcx().is_direct_const(assoc_item.def_id)
&& !tcx.features().generic_const_args()
&& !tcx.features().gca_const_items()
{
if tcx.features().min_generic_const_args() {
if tcx.features().gca_min_const_items() {
let err = self.dcx().struct_span_err(
constraint.span,
"use of trait associated const not defined as `#[rustc_always_gca]`",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&& let Some(hir_ty) = constraint.ty()
&& let ty = self.lower_ty(hir_ty)
&& (ty.is_enum() || ty.references_error())
&& tcx.features().min_generic_const_args()
&& tcx.features().gca_min_const_items()
{
Some(diagnostics::AssocKindMismatchWrapInBracesSugg {
lo: hir_ty.span.shrink_to_lo(),
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl<'tcx> ForbidParamUsesFolder<'tcx> {
"generic `Self` types are currently not permitted in anonymous constants"
}
ForbidParamContext::ConstArgument => {
if self.tcx.features().generic_const_args() {
if self.tcx.features().gca_const_items() {
"generic parameters in const blocks are not allowed; use a named `const` item instead"
} else {
"generic parameters may not be used in const operations"
Expand All @@ -442,15 +442,15 @@ impl<'tcx> ForbidParamUsesFolder<'tcx> {
}
}
if matches!(self.context, ForbidParamContext::ConstArgument) {
if self.tcx.features().generic_const_args() {
if self.tcx.features().gca_const_items() {
diag.help("consider factoring the expression into a `type const` item and use it as the const argument instead");
} else if self.tcx.features().min_generic_const_args() {
diag.help("add `#![feature(generic_const_args)]` and extract the expression into a `type const` item");
} else if self.tcx.features().gca_min_const_items() {
diag.help("add `#![feature(gca_const_items)]` and extract the expression into a `type const` item");
} else if self.tcx.sess.is_nightly_build() {
diag.help(
"add `#![feature(generic_const_exprs)]` to allow generic const expressions",
);
diag.help("alternatively, you can use `#![feature(generic_const_args)]` and extract the expression into a `type const` item");
diag.help("alternatively, you can use `#![feature(gca_const_items)]` and extract the expression into a `type const` item");
}
}
diag.emit_err()
Expand Down Expand Up @@ -3127,7 +3127,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
span: Span,
) -> Result<(), ErrorGuaranteed> {
let tcx = self.tcx();
if tcx.features().generic_const_args() || alias_const.is_direct_const(tcx) {
if tcx.features().gca_const_items() || alias_const.is_direct_const(tcx) {
Ok(())
} else {
let mut err = self
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ rustc_queries! {

/// Returns the const of the RHS of a (free or assoc) const item, if it is a `type const`, or if
/// it is a directly represented `const` (i.e. a const with a `gca!` RHS, or a const that
/// `feature(macroless_generic_const_args)` has decided is direct).
/// `feature(gca_macroless_args)` has decided is direct).
///
/// When a const item is used in a type-level expression, like in equality for an assoc const
/// projection, this allows us to retrieve the typesystem-appropriate representation of the
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ pub enum MethodViolation {
/// Reasons an associated const might not be dyn compatible.
#[derive(Clone, Debug, PartialEq, Eq, Hash, StableHash)]
pub enum AssocConstViolation {
/// Unstable feature `min_generic_const_args` wasn't enabled.
/// Unstable feature `gca_min_const_items` wasn't enabled.
FeatureNotEnabled,

/// Not defined as a type-level associated const.
Expand Down
Loading
Loading