diff --git a/INSTALL.md b/INSTALL.md index 0e998101fcd1d..0e3566af4b051 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -96,7 +96,7 @@ See [the rustc-dev-guide for more info][sysllvm]. --set llvm.libzstd=true \ --set llvm.ninja=false \ --set rust.debug-assertions=false \ - --set rust.jemalloc \ + --set rust.override-allocator=jemalloc \ --set rust.bootstrap-override-lld=true \ --set rust.lto=thin \ --set rust.codegen-units=1 diff --git a/bootstrap.example.toml b/bootstrap.example.toml index adc667554d1be..418562609a9b9 100644 --- a/bootstrap.example.toml +++ b/bootstrap.example.toml @@ -853,9 +853,15 @@ # Useful for reproducible builds. Generally only set for releases #rust.remap-debuginfo = false -# Link the compiler and LLVM against `jemalloc` instead of the default libc allocator. +# Link the compiler and LLVM against the specified allocator instead of the default libc allocator. # This option is only tested on Linux and OSX. It can also be configured per-target in the # [target.] section. +# Possible options: "jemalloc" +#rust.override-allocator = "jemalloc" + +# Deprecated alias for `rust.override-allocator`. Setting this to `true` is +# equivalent to `rust.override-allocator = "jemalloc"`. If both are set, they +# must agree. #rust.jemalloc = false # Run tests in various test suites with the "nll compare mode" in addition to @@ -1164,8 +1170,11 @@ # order to run `x check`. #optimized-compiler-builtins = build.optimized-compiler-builtins (bool or path) -# Link the compiler and LLVM against `jemalloc` instead of the default libc allocator. -# This overrides the global `rust.jemalloc` option. See that option for more info. +# Link the compiler and LLVM against the specified allocator instead of the default libc allocator. +# This overrides the global `rust.override-allocator` option. See that option for more info. +#override-allocator = rust.override-allocator (string) + +# Deprecated alias for `override-allocator`. See `rust.jemalloc` for more info. #jemalloc = rust.jemalloc (bool) # The linker configuration that will *override* the default linker used for Linux diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 882464c5dcfea..ed0cfb1a10d74 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -3413,6 +3413,29 @@ pub struct Attribute { /// Denotes if the attribute decorates the following construct (outer) /// or the construct this attribute is contained within (inner). pub style: AttrStyle, + + /// The carets in the examples below show the spans for various cases. + /// ```text + /// #[foo] - A vanilla parsed attribute. + /// ^^^^^^ - Its span covers it all. + /// + /// /** abc */ /// xyz - A parsed doc comment. + /// ^^^^^^^^^^ ^^^^^^^ - Its span covers the text and comment marker(s). + /// - The same span is also used if the doc comment is desugared (into + /// a new normal `#[doc = r"..."]` attribute) by + /// `desugar_doc_comments` before being passed to a macro (which + /// is done so that `#[$m:meta]` will match). + /// + /// #[cfg_attr(pred, foo)] - A parsed `cfg_attr` attribute. + /// ^^^^^^^^^^^^^^^^^^^^^^ - Its span covers it all. + /// ^^^ - Span of the new replacement attribute (equivalent to `#[foo]`) + /// created by `cfg_attr` expansion (if `pred` is true). + /// ^^^^^^^^^^^^^^^^^^^^^^ - Span of the synthetic `CfgAttrTrace` attribute created by + /// `cfg_attr` expansion. (`CfgTrace` is derived from `#[cfg(..)]` and + /// handled similarly.) + /// ``` + /// Finally, for compiler-generated attributes the span is whatever the construction site + /// chooses. Usually `DUMMY_SP` or some relevant span from the source code. pub span: Span, } diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 2a3251c80d15e..39c4f403bf855 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -7,7 +7,7 @@ use std::fmt::Debug; use std::sync::atomic::{AtomicU32, Ordering}; use rustc_index::bit_set::GrowableBitSet; -use rustc_span::{Ident, Span, Symbol, kw, sym}; +use rustc_span::{Ident, Span, Symbol, sym}; use smallvec::{SmallVec, smallvec}; use thin_vec::{ThinVec, thin_vec}; @@ -748,29 +748,9 @@ pub fn mk_attr_from_item( fn mk_attr_tokens( style: AttrStyle, - unsafety: Safety, item_tokens: AttrTokenStream, span: Span, ) -> LazyAttrTokenStream { - let safety_kw = match unsafety { - Safety::Default => None, - Safety::Unsafe(span) => Some((kw::Unsafe, span)), - Safety::Safe(span) => Some((kw::Safe, span)), - }; - let item_tokens = if let Some((kw, kw_span)) = safety_kw { - AttrTokenStream::new(vec![ - AttrTokenTree::Token(Token::from_ast_ident(Ident::new(kw, kw_span)), Spacing::Alone), - AttrTokenTree::Delimited( - DelimSpan::from_single(span), - DelimSpacing::new(Spacing::JointHidden, Spacing::Alone), - Delimiter::Parenthesis, - item_tokens, - ), - ]) - } else { - item_tokens - }; - let mut tokens = match style { AttrStyle::Outer => { vec![AttrTokenTree::Token(Token::new(token::Pound, span), Spacing::JointHidden)] @@ -792,19 +772,12 @@ fn mk_attr_tokens( // `span` is used for the `Attribute` and everything within it (except for any span within // `unsafety`). -pub fn mk_attr_word( - g: &AttrIdGenerator, - style: AttrStyle, - unsafety: Safety, - name: Symbol, - span: Span, -) -> Attribute { +pub fn mk_attr_word(g: &AttrIdGenerator, style: AttrStyle, name: Symbol, span: Span) -> Attribute { let path = Path::from_ident(Ident::new(name, span)); let args = AttrArgs::Empty; let tokens = Some(mk_attr_tokens( style, - unsafety, AttrTokenStream::new(vec![AttrTokenTree::Token( Token::from_ast_ident(Ident::new(name, span)), Spacing::Alone, @@ -812,7 +785,13 @@ pub fn mk_attr_word( span, )); - mk_attr_from_item(g, AttrItem { unsafety, path, args, span }, tokens, style, span) + mk_attr_from_item( + g, + AttrItem { unsafety: Safety::Default, path, args, span }, + tokens, + style, + span, + ) } // `span` is used for the `Attribute` and everything within it (except for any span within @@ -820,7 +799,6 @@ pub fn mk_attr_word( pub fn mk_attr_nested_word( g: &AttrIdGenerator, style: AttrStyle, - unsafety: Safety, outer: Symbol, inner: Symbol, span: Span, @@ -839,7 +817,6 @@ pub fn mk_attr_nested_word( let tokens = Some(mk_attr_tokens( style, - unsafety, AttrTokenStream::new(vec![ AttrTokenTree::Token(Token::from_ast_ident(Ident::new(outer, span)), Spacing::Alone), AttrTokenTree::Delimited( @@ -855,7 +832,13 @@ pub fn mk_attr_nested_word( span, )); - mk_attr_from_item(g, AttrItem { unsafety, path, args: attr_args, span }, tokens, style, span) + mk_attr_from_item( + g, + AttrItem { unsafety: Safety::Default, path, args: attr_args, span }, + tokens, + style, + span, + ) } // `span` is used for the `Attribute` and everything within it (except for any span within @@ -863,7 +846,6 @@ pub fn mk_attr_nested_word( pub fn mk_attr_name_value_str( g: &AttrIdGenerator, style: AttrStyle, - unsafety: Safety, name: Symbol, val: Symbol, span: Span, @@ -881,7 +863,6 @@ pub fn mk_attr_name_value_str( let tokens = Some(mk_attr_tokens( style, - unsafety, AttrTokenStream::new(vec![ AttrTokenTree::Token(Token::from_ast_ident(Ident::new(name, span)), Spacing::Alone), AttrTokenTree::Token(Token::new(token::Eq, span), Spacing::Alone), @@ -893,7 +874,13 @@ pub fn mk_attr_name_value_str( span, )); - mk_attr_from_item(g, AttrItem { unsafety, path, args, span }, tokens, style, span) + mk_attr_from_item( + g, + AttrItem { unsafety: Safety::Default, path, args, span }, + tokens, + style, + span, + ) } pub fn filter_by_name(attrs: &[Attribute], name: Symbol) -> impl Iterator { diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 613b312bf73a4..06673379a5e9f 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -2323,7 +2323,6 @@ impl<'hir> LoweringContext<'_, 'hir> { let attr = attr::mk_attr_nested_word( &self.tcx.sess.psess.attr_id_generator, AttrStyle::Outer, - Safety::Default, sym::allow, sym::unreachable_code, span, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index b30774318dee7..f04b5cfc92724 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1465,12 +1465,23 @@ impl<'hir> LoweringContext<'_, 'hir> { TyKind::DirectConstArg(expr) if self.tcx.features().min_generic_const_args() => { - let ct = match self.can_lower_expr_to_const_arg_direct(expr) { + let ct = match self.can_lower_expr_to_const_arg_direct( + expr, + DirectConstArgContext::MacrolessMinGenericConstArgs, + ) { Ok(()) => self.lower_expr_to_const_arg_direct(expr, None), Err(e) => e.emit(self), }; let ct = self.arena.alloc(ct); - return GenericArg::Const(ct.try_as_ambig_ct().unwrap()); + // note: this allows direct_const_arg!(_) to be inferred to a type. a little + // wonky. + return match ct.try_as_ambig_ct() { + Some(ct) => GenericArg::Const(ct), + None => GenericArg::Infer(hir::InferArg { + hir_id: ct.hir_id, + span: ct.span, + }), + }; } _ => {} } @@ -2608,7 +2619,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let is_trivial_path = path.is_potential_trivial_const_arg() && matches!(res, Res::Def(DefKind::ConstParam, _)); - let ct_kind = if is_trivial_path || tcx.features().min_generic_const_args() { + let ct_kind = if is_trivial_path || tcx.features().macroless_generic_const_args() { let qpath = self.lower_qpath( ty_id, &None, @@ -2671,7 +2682,15 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::ConstItemRhs::Body(self.lower_const_body(span, None)) } ConstItemRhsKind::TypeConst { rhs: Some(anon) } => { - hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg_and_alloc(anon)) + hir::ConstItemRhs::TypeConst(self.arena.alloc( + match self.can_lower_expr_to_const_arg_direct( + &anon.value, + DirectConstArgContext::MacrolessMinGenericConstArgs, + ) { + Ok(()) => self.lower_expr_to_const_arg_direct(&anon.value, Some(anon.id)), + Err(err) => err.emit(self), + }, + )) } ConstItemRhsKind::TypeConst { rhs: None } => { let const_arg = ConstArg { @@ -2690,63 +2709,67 @@ impl<'hir> LoweringContext<'_, 'hir> { fn can_lower_expr_to_const_arg_direct( &mut self, expr: &Expr, + context: DirectConstArgContext, ) -> Result<(), UnrepresentableConstArgError> { - let is_mgca = self.tcx.features().min_generic_const_args(); - // Note the only stable case is currently ExprKind::Path. All others have an is_mgca guard. - match &expr.kind { - ExprKind::Call(func, args) - if is_mgca && let ExprKind::Path(_qself, _path) = &func.kind => - { + use DirectConstArgContext::*; + // Note the only stable case is currently ExprKind::Path + match (&expr.kind, context) { + ( + ExprKind::Call(Expr { kind: ExprKind::Path(_, _), .. }, args), + MacrolessMinGenericConstArgs, + ) => { for arg in args { - self.can_lower_expr_to_const_arg_direct(arg)?; + self.can_lower_expr_to_const_arg_direct(arg, context)?; } Ok(()) } - ExprKind::Tup(exprs) if is_mgca => { + (ExprKind::Tup(exprs), MacrolessMinGenericConstArgs) => { for expr in exprs { - self.can_lower_expr_to_const_arg_direct(expr)?; + self.can_lower_expr_to_const_arg_direct(expr, context)?; } Ok(()) } - ExprKind::Path(qself, path) - if is_mgca - || path.is_potential_trivial_const_arg() - && matches!( - self.get_partial_res(expr.id) - .and_then(|partial_res| partial_res.full_res()), - Some(Res::Def(DefKind::ConstParam, _)) - ) => - { - Ok(()) + (ExprKind::Path(_, _), MacrolessMinGenericConstArgs) => Ok(()), + (ExprKind::Path(_, path), _) => { + if path.is_potential_trivial_const_arg() + && matches!( + self.get_partial_res(expr.id) + .and_then(|partial_res| partial_res.full_res()), + Some(Res::Def(DefKind::ConstParam, _)) + ) + { + Ok(()) + } else { + Err(UnrepresentableConstArgError::new(expr)) + } } - ExprKind::Struct(se) if is_mgca => { + (ExprKind::Struct(se), MacrolessMinGenericConstArgs) => { for f in &se.fields { - self.can_lower_expr_to_const_arg_direct(&f.expr)?; + self.can_lower_expr_to_const_arg_direct(&f.expr, context)?; } Ok(()) } - ExprKind::Array(elements) if is_mgca => { + (ExprKind::Array(elements), MacrolessMinGenericConstArgs) => { for element in elements { - self.can_lower_expr_to_const_arg_direct(element)?; + self.can_lower_expr_to_const_arg_direct(element, context)?; } Ok(()) } - ExprKind::Underscore if is_mgca => Ok(()), - ExprKind::Block(block, _) - if is_mgca - && let [stmt] = block.stmts.as_slice() + (ExprKind::Underscore, MacrolessMinGenericConstArgs) => Ok(()), + (ExprKind::Block(block, _), MacrolessMinGenericConstArgs) + if let [stmt] = block.stmts.as_slice() && let StmtKind::Expr(expr) = &stmt.kind => { - self.can_lower_expr_to_const_arg_direct(expr) + self.can_lower_expr_to_const_arg_direct(expr, context) } - ExprKind::Lit(literal) if is_mgca => Ok(()), - ExprKind::Unary(UnOp::Neg, inner_expr) - if is_mgca && let ExprKind::Lit(_) = &inner_expr.kind => + (ExprKind::Lit(_), MacrolessMinGenericConstArgs) => Ok(()), + (ExprKind::Unary(UnOp::Neg, inner_expr), MacrolessMinGenericConstArgs) + if let ExprKind::Lit(_) = &inner_expr.kind => { Ok(()) } - ExprKind::ConstBlock(anon) if is_mgca => Ok(()), - ExprKind::DirectConstArg(expr) if is_mgca => { + (ExprKind::ConstBlock(_), MacrolessMinGenericConstArgs) => Ok(()), + (ExprKind::DirectConstArg(_), MacrolessMinGenericConstArgs | MinGenericConstArgs) => { // Always report this as able to be represented directly. If it turns out not to be, // `lower_expr_to_const_arg_direct` will report an error. Ok(()) @@ -2763,8 +2786,6 @@ impl<'hir> LoweringContext<'_, 'hir> { expr: &Expr, id_override: Option, ) -> hir::ConstArg<'hir> { - debug_assert!(self.can_lower_expr_to_const_arg_direct(expr).is_ok()); - let span = self.lower_span(expr.span); let node_id = id_override.unwrap_or(expr.id); match &expr.kind { @@ -2925,7 +2946,12 @@ impl<'hir> LoweringContext<'_, 'hir> { // ExprKind::DirectConstArg, which effectively forces the expression to be lowered // as a direct arg. If it actually turns out to not be possible, emit an error // instead. - match self.can_lower_expr_to_const_arg_direct(expr) { + // Always use MacrolessMinGenericConstArgs, even if we're under regular GCA, because + // that's what the macro means: to enter a context that is like macroless GCA. + match self.can_lower_expr_to_const_arg_direct( + expr, + DirectConstArgContext::MacrolessMinGenericConstArgs, + ) { Ok(()) => self.lower_expr_to_const_arg_direct(expr, id_override), Err(err) => err.emit(self), } @@ -2947,24 +2973,28 @@ impl<'hir> LoweringContext<'_, 'hir> { &mut self, anon: &AnonConst, ) -> &'hir hir::ConstArg<'hir> { - self.arena.alloc(self.lower_anon_const_to_const_arg(anon, anon.value.span)) + self.arena.alloc(self.lower_anon_const_to_const_arg(anon)) } #[instrument(level = "debug", skip(self))] - fn lower_anon_const_to_const_arg( - &mut self, - anon: &AnonConst, - span: Span, - ) -> hir::ConstArg<'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().min_generic_const_args() { + let expr = if self.tcx.features().macroless_generic_const_args() { &anon.value } else { anon.value.maybe_unwrap_block() }; - if self.can_lower_expr_to_const_arg_direct(expr).is_ok() { + let context = if self.tcx.features().macroless_generic_const_args() { + DirectConstArgContext::MacrolessMinGenericConstArgs + } else if self.tcx.features().min_generic_const_args() { + DirectConstArgContext::MinGenericConstArgs + } else { + DirectConstArgContext::Stable + }; + + if self.can_lower_expr_to_const_arg_direct(expr, context).is_ok() { return self.lower_expr_to_const_arg_direct(expr, Some(anon.id)); } @@ -3269,6 +3299,21 @@ impl<'hir> GenericArgsCtor<'hir> { } } +#[derive(Copy, Clone, Debug)] +enum DirectConstArgContext { + /// The only allowed direct const arg representation is simple paths that nameres to generic + /// const parameters. + Stable, + /// The allowed representations are what is allowed on stable, plus the `direct_const_arg!` macro. + MinGenericConstArgs, + /// Expressions attempt to be lowered directly, and if that fails, the expression falls back to + /// being represented as an anon const. + /// + /// This context is also used under MinGenericConstArgs inside a `direct_const_arg!` macro, for + /// simplicity, as they allow the same code. + MacrolessMinGenericConstArgs, +} + #[derive(Debug)] struct UnrepresentableConstArgError { span: Span, diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 268ca2a7e26f8..42d01a92eebbf 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -17,7 +17,7 @@ use rustc_ast::util::comments::{Comment, CommentStyle}; use rustc_ast::{ self as ast, AttrArgs, AttrKind, BindingMode, BlockCheckMode, ByRef, DelimArgs, GenericArg, GenericBound, InlineAsmOperand, InlineAsmOptions, InlineAsmRegOrRegClass, - InlineAsmTemplatePiece, PatKind, RangeEnd, RangeSyntax, Safety, SelfKind, Term, attr, + InlineAsmTemplatePiece, PatKind, RangeEnd, RangeSyntax, SelfKind, Term, attr, }; use rustc_span::edition::Edition; use rustc_span::source_map::SourceMap; @@ -292,7 +292,6 @@ fn print_crate_inner<'a>( let fake_attr = attr::mk_attr_nested_word( g, ast::AttrStyle::Inner, - Safety::Default, sym::feature, sym::prelude_import, DUMMY_SP, @@ -303,13 +302,7 @@ fn print_crate_inner<'a>( // root, so this is not needed, and actually breaks things. if edition.is_rust_2015() { // `#![no_std]` - let fake_attr = attr::mk_attr_word( - g, - ast::AttrStyle::Inner, - Safety::Default, - sym::no_std, - DUMMY_SP, - ); + let fake_attr = attr::mk_attr_word(g, ast::AttrStyle::Inner, sym::no_std, DUMMY_SP); s.print_attribute(&fake_attr); } } diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs index 99ac3f5e2ecd7..af0c9ed7ee656 100644 --- a/compiler/rustc_builtin_macros/src/test_harness.rs +++ b/compiler/rustc_builtin_macros/src/test_harness.rs @@ -207,7 +207,6 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> { let allow_dead_code = attr::mk_attr_nested_word( &self.sess.psess.attr_id_generator, ast::AttrStyle::Outer, - ast::Safety::Default, sym::allow, sym::dead_code, self.def_site, diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 3d8b4616f37fd..93b02989eb8b0 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -38,9 +38,11 @@ use crate::mbe::macro_rules::ParserAnyMacro; use crate::module::DirOwnership; use crate::stats::MacroStat; -// When adding new variants, make sure to -// adjust the `visit_*` / `flat_map_*` calls in `InvocationCollector` -// to use `assign_id!` +/// This type encapsulates every AST node that can have attributes, i.e. those +/// nodes with a non-trivial implementation of `HasAttrs`. +/// +/// When adding new variants, make sure to adjust the `visit_*` / `flat_map_*` +/// calls in `InvocationCollector` to use `assign_id!` #[derive(Debug, Clone)] pub enum Annotatable { Item(Box), @@ -117,6 +119,7 @@ impl Annotatable { } } + /// Converts the `Annotatable` to a token stream, e.g. to hand to a proc macro. pub fn to_tokens(&self) -> TokenStream { match self { Annotatable::Item(node) => TokenStream::from_ast(node), diff --git a/compiler/rustc_expand/src/build.rs b/compiler/rustc_expand/src/build.rs index 325cf413bd236..750c1407001f6 100644 --- a/compiler/rustc_expand/src/build.rs +++ b/compiler/rustc_expand/src/build.rs @@ -743,7 +743,7 @@ impl<'a> ExtCtxt<'a> { // Builds `#[name]`. pub fn attr_word(&self, name: Symbol, span: Span) -> ast::Attribute { let g = &self.sess.psess.attr_id_generator; - attr::mk_attr_word(g, ast::AttrStyle::Outer, ast::Safety::Default, name, span) + attr::mk_attr_word(g, ast::AttrStyle::Outer, name, span) } // Builds `#[name = val]`. @@ -751,27 +751,13 @@ impl<'a> ExtCtxt<'a> { // Note: `span` is used for both the identifier and the value. pub fn attr_name_value_str(&self, name: Symbol, val: Symbol, span: Span) -> ast::Attribute { let g = &self.sess.psess.attr_id_generator; - attr::mk_attr_name_value_str( - g, - ast::AttrStyle::Outer, - ast::Safety::Default, - name, - val, - span, - ) + attr::mk_attr_name_value_str(g, ast::AttrStyle::Outer, name, val, span) } // Builds `#[outer(inner)]`. pub fn attr_nested_word(&self, outer: Symbol, inner: Symbol, span: Span) -> ast::Attribute { let g = &self.sess.psess.attr_id_generator; - attr::mk_attr_nested_word( - g, - ast::AttrStyle::Outer, - ast::Safety::Default, - outer, - inner, - span, - ) + attr::mk_attr_nested_word(g, ast::AttrStyle::Outer, outer, inner, span) } // Builds an attribute fully manually. diff --git a/compiler/rustc_expand/src/diagnostics.rs b/compiler/rustc_expand/src/diagnostics.rs index a9493b8654805..202a5440b2d47 100644 --- a/compiler/rustc_expand/src/diagnostics.rs +++ b/compiler/rustc_expand/src/diagnostics.rs @@ -450,14 +450,14 @@ pub(crate) struct GlobDelegationOutsideImpls { } #[derive(Diagnostic)] -#[diag("`crate_name` within an `#![cfg_attr]` attribute is forbidden")] +#[diag("`crate_name` within a `#![cfg_attr]` attribute is forbidden")] pub(crate) struct CrateNameInCfgAttr { #[primary_span] pub span: Span, } #[derive(Diagnostic)] -#[diag("`crate_type` within an `#![cfg_attr]` attribute is forbidden")] +#[diag("`crate_type` within a `#![cfg_attr]` attribute is forbidden")] pub(crate) struct CrateTypeInCfgAttr { #[primary_span] pub span: Span, diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 6c74612fe50e3..86cc8bb56c6b5 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -632,6 +632,8 @@ 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 without the `direct_const_arg!` macro. + (incomplete, macroless_generic_const_args, "CURRENT_RUSTC_VERSION", Some(159006)), /// Allows `#[marker]` on certain traits allowing overlapping implementations. (unstable, marker_trait_attr, "1.30.0", Some(29864)), /// Enable mgca `type const` syntax before expansion. @@ -877,5 +879,6 @@ 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::unsized_const_params, &[sym::adt_const_params]), ]; diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 1a7dc06d97c90..b0539b973c201 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -14,7 +14,6 @@ use rustc_middle::util::Providers; use rustc_parse::lexer::StripTokens; use rustc_parse::new_parser_from_source_str; use rustc_parse::parser::Recovery; -use rustc_parse::parser::attr::AllowLeadingUnsafe; use rustc_query_impl::print_query_stack; use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName}; use rustc_session::parse::ParseSess; @@ -62,7 +61,7 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec) -> Cfg { { Ok(mut parser) => { parser = parser.recovery(Recovery::Forbidden); - match parser.parse_meta_item(AllowLeadingUnsafe::No) { + match parser.parse_meta_item() { Ok(meta_item) if parser.token == token::Eof && parser.dcx().has_errors().is_none() => @@ -167,7 +166,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec) -> Ch } }; - let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::No) { + let meta_item = match parser.parse_meta_item() { Ok(meta_item) if parser.token == token::Eof && parser.dcx().has_errors().is_none() => { meta_item } diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs index 5e3f15fbdf56b..fae58c29954d0 100644 --- a/compiler/rustc_parse/src/parser/attr.rs +++ b/compiler/rustc_parse/src/parser/attr.rs @@ -35,12 +35,6 @@ enum OuterAttributeType { Attribute, } -#[derive(Clone, Copy, PartialEq, Eq)] -pub enum AllowLeadingUnsafe { - Yes, - No, -} - impl<'a> Parser<'a> { /// Parses attributes that appear before an item. pub(super) fn parse_outer_attributes(&mut self) -> PResult<'a, AttrWrapper> { @@ -435,10 +429,7 @@ impl<'a> Parser<'a> { /// MetaItem = SimplePath ( '=' UNSUFFIXED_LIT | '(' MetaSeq? ')' )? ; /// MetaSeq = MetaItemInner (',' MetaItemInner)* ','? ; /// ``` - pub fn parse_meta_item( - &mut self, - unsafe_allowed: AllowLeadingUnsafe, - ) -> PResult<'a, ast::MetaItem> { + pub fn parse_meta_item(&mut self) -> PResult<'a, ast::MetaItem> { if let Some(MetaVarKind::Meta { has_meta_form }) = self.token.is_metavar_seq() { return if has_meta_form { let attr_item = self @@ -452,30 +443,13 @@ impl<'a> Parser<'a> { self.unexpected_any() }; } - let lo = self.token.span; - let is_unsafe = if unsafe_allowed == AllowLeadingUnsafe::Yes { - self.eat_keyword(exp!(Unsafe)) - } else { - false - }; - let unsafety = if is_unsafe { - let unsafe_span = self.prev_token.span; - self.expect(exp!(OpenParen))?; - - ast::Safety::Unsafe(unsafe_span) - } else { - ast::Safety::Default - }; let path = self.parse_path(PathStyle::Mod)?; let kind = self.parse_meta_item_kind()?; - if is_unsafe { - self.expect(exp!(CloseParen))?; - } let span = lo.to(self.prev_token.span); - Ok(ast::MetaItem { unsafety, path, kind, span }) + Ok(ast::MetaItem { unsafety: ast::Safety::Default, path, kind, span }) } pub(crate) fn parse_meta_item_kind(&mut self) -> PResult<'a, ast::MetaItemKind> { @@ -500,7 +474,7 @@ impl<'a> Parser<'a> { Err(err) => err.cancel(), // we provide a better error below } - match self.parse_meta_item(AllowLeadingUnsafe::No) { + match self.parse_meta_item() { Ok(mi) => return Ok(ast::MetaItemInner::MetaItem(mi)), Err(err) => err.cancel(), // we provide a better error below } diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs index 49627a6c92c7c..fe34d9951dc5f 100644 --- a/compiler/rustc_parse/src/parser/attr_wrapper.rs +++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs @@ -102,11 +102,27 @@ impl<'a> Parser<'a> { /// Parses code with `f`. If appropriate, it records the tokens (in /// `LazyAttrTokenStream` form) that were parsed in the result, accessible - /// via the `HasTokens` trait. The `Trailing` part of the callback's - /// result indicates if an extra token should be captured, e.g. a comma or - /// semicolon. The `UsePreAttrPos` part of the callback's result indicates - /// if we should use `pre_attr_pos` as the collection start position (only - /// required in a few cases). + /// via the `HasTokens` trait. + /// + /// Why is this done? Various macro cases require an AST node's tokens. + /// - Proc macros: all proc macros take a token stream. + /// - Function-style proc macros (`foo!(..)`): these can receive a token + /// stream without any parsing occurring within the parentheses. + /// - Attribute macros (`#[foo]`): at parse time (pre-resolution) we + /// don't know if a non-builtin `#[foo]` is an attribute proc macro, so + /// the parser does a full parse and collects tokens (lazily) in case. + /// - Derive macros (`derive(Foo)`): any input with + /// `#[cfg]`/`#[cfg_attr]` must be stripped before being passed to the + /// derive macro, which requires parsing. Identifying the end of the + /// item also requires parsing. + /// - Decl macros: a matched nonterminal (e.g. `$e:expr`) needs tokens in + /// case it is passed into a proc macro. + /// + /// The `Trailing` part of the callback's result indicates if an extra + /// token should be captured, e.g. a comma or semicolon. The + /// `UsePreAttrPos` part of the callback's result indicates if we should + /// use `pre_attr_pos` as the collection start position (only required in a + /// few cases). /// /// The `attrs` passed in are in `AttrWrapper` form, which is opaque. The /// `AttrVec` within is passed to `f`. See the comment on `AttrWrapper` for diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index b1f18aefb659d..7917478cc2c60 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1252,6 +1252,7 @@ symbols! { macro_reexport, macro_use, macro_vis_matcher, + macroless_generic_const_args, macros_in_extern, main, managed_boxes, diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index 8729e98278a82..8560a644f207b 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -52,7 +52,8 @@ unsafe extern "Rust" { /// Note: while this type is unstable, the functionality it provides can be /// accessed through the [free functions in `alloc`](self#functions). #[unstable(feature = "allocator_api", issue = "32838")] -#[derive(Copy, Clone, Default, Debug)] +#[derive(Copy, Debug)] +#[derive_const(Clone, Default)] // the compiler needs to know when a Box uses the global allocator vs a custom one #[lang = "global_alloc_ty"] pub struct Global; diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 7ed551262951c..75cd7397e8c5d 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -124,6 +124,7 @@ #![feature(cursor_split)] #![feature(deprecated_suggestion)] #![feature(deref_pure_trait)] +#![feature(derive_const)] #![feature(diagnostic_on_move)] #![feature(dispatch_from_dyn)] #![feature(drop_guard)] diff --git a/library/core/src/num/error.rs b/library/core/src/num/error.rs index d8d66cfc9b08c..ccf50a2c81a1b 100644 --- a/library/core/src/num/error.rs +++ b/library/core/src/num/error.rs @@ -21,7 +21,14 @@ impl TryFromIntError { #[stable(feature = "try_from", since = "1.34.0")] impl fmt::Display for TryFromIntError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - "out of range integral type conversion attempted".fmt(f) + match self.0 { + IntErrorKind::Empty | IntErrorKind::InvalidDigit => unreachable!(), + IntErrorKind::PosOverflow => "number too large to fit in target type", + IntErrorKind::NegOverflow => "number too small to fit in target type", + IntErrorKind::Zero => "number would be zero for non-zero type", + IntErrorKind::NotAPowerOfTwo => "number is not a power of two", + } + .fmt(f) } } diff --git a/library/core/src/random.rs b/library/core/src/random.rs index 7275b3c203b5c..1123e1949a02d 100644 --- a/library/core/src/random.rs +++ b/library/core/src/random.rs @@ -14,6 +14,15 @@ pub trait Rng { fn fill_bytes(&mut self, bytes: &mut [u8]); } +/// Implements `Rng` for mutable references to random number generators by +/// forwarding all methods to the referenced generator. +#[unstable(feature = "random", issue = "130703")] +impl<'a, R: Rng + ?Sized> Rng for &'a mut R { + fn fill_bytes(&mut self, bytes: &mut [u8]) { + R::fill_bytes(self, bytes); + } +} + /// A trait representing a distribution of random values for a type. #[unstable(feature = "random", issue = "130703")] pub trait Distribution { diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index 753ca5aba561c..84447c06aaecf 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -136,7 +136,8 @@ use crate::{hint, mem, ptr}; /// program opts in to using jemalloc as the global allocator, `System` will /// still allocate memory using `malloc` and `HeapAlloc`. #[stable(feature = "alloc_system_type", since = "1.28.0")] -#[derive(Debug, Default, Copy, Clone)] +#[derive(Copy, Debug)] +#[derive_const(Clone, Default)] pub struct System; impl System { diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index a2582355d6794..6829f0fafd6c8 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -327,6 +327,7 @@ #![feature(cast_maybe_uninit)] #![feature(char_internals)] #![feature(clone_to_uninit)] +#![feature(const_clone)] #![feature(const_convert)] #![feature(const_default)] #![feature(core_float_math)] @@ -336,6 +337,7 @@ #![feature(core_io_internals)] #![feature(cstr_display)] #![feature(cursor_split)] +#![feature(derive_const)] #![feature(drop_guard)] #![feature(duration_constants)] #![feature(error_generic_member_access)] diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 2335efc870a9c..d186e15c75cf2 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -28,7 +28,7 @@ use crate::core::builder::{ }; use crate::core::config::toml::target::DefaultLinuxLinkerOverride; use crate::core::config::{ - CompilerBuiltins, DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection, + CompilerBuiltins, DebuginfoLevel, LlvmLibunwind, OverrideAllocator, RustcLto, TargetSelection, }; use crate::utils::build_stamp; use crate::utils::build_stamp::BuildStamp; @@ -1388,7 +1388,9 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS } // See also the "JEMALLOC_SYS_WITH_LG_PAGE" setting in the tool build step. - if builder.config.jemalloc(target) && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() { + if let Some(OverrideAllocator::Jemalloc) = builder.config.override_allocator(target) + && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() + { // Build jemalloc on AArch64 with support for page sizes up to 64K // See: https://github.com/rust-lang/rust/pull/135081 if target.starts_with("aarch64") { diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index b283325949a9f..a6ecdea06623f 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -21,7 +21,7 @@ use crate::core::builder::{ Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step, StepMetadata, apply_pgo, cargo_profile_var, }; -use crate::core::config::{DebuginfoLevel, RustcLto, TargetSelection}; +use crate::core::config::{DebuginfoLevel, OverrideAllocator, RustcLto, TargetSelection}; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{add_dylib_path, exe, t}; use crate::{Compiler, FileType, Kind, Mode}; @@ -245,7 +245,9 @@ pub fn prepare_tool_cargo( cargo.env("LZMA_API_STATIC", "1"); // See also the "JEMALLOC_SYS_WITH_LG_PAGE" setting in the compile build step. - if builder.config.jemalloc(target) && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() { + if let Some(OverrideAllocator::Jemalloc) = builder.config.override_allocator(target) + && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() + { // Build jemalloc on AArch64 with support for page sizes up to 64K // See: https://github.com/rust-lang/rust/pull/135081 if target.starts_with("aarch64") { @@ -769,8 +771,8 @@ impl Step for Rustdoc { // to build rustdoc. // let mut extra_features = Vec::new(); - if builder.config.jemalloc(target) { - extra_features.push("jemalloc".to_string()); + if let Some(allocator) = builder.config.override_allocator(target) { + extra_features.push(allocator.feature_name().to_string()); } let compilers = RustcPrivateCompilers::from_target_compiler(builder, target_compiler); @@ -1593,8 +1595,8 @@ tool_rustc_extended!(Clippy { stable: true, add_bins_to_sysroot: ["clippy-driver"], add_features: |builder, target, features| { - if builder.config.jemalloc(target) { - features.push("jemalloc".to_string()); + if let Some(allocator) = builder.config.override_allocator(target) { + features.push(allocator.feature_name().to_string()); } } }); @@ -1604,8 +1606,8 @@ tool_rustc_extended!(Miri { stable: false, add_bins_to_sysroot: ["miri"], add_features: |builder, target, features| { - if builder.config.jemalloc(target) { - features.push("jemalloc".to_string()); + if let Some(allocator) = builder.config.override_allocator(target) { + features.push(allocator.feature_name().to_string()); } }, // Always compile also tests when building miri. Otherwise feature unification can cause rebuilds between building and testing miri. diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index e58618c4027c1..9ff106c5ac229 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -50,7 +50,7 @@ use crate::core::config::toml::target::{ }; use crate::core::config::{ CompilerBuiltins, CompressDebuginfo, DebuginfoLevel, DryRun, GccCiMode, LlvmLibunwind, Merge, - ReplaceOpt, RustcLto, SplitDebuginfo, StringOrBool, threads_from_config, + OverrideAllocator, ReplaceOpt, RustcLto, SplitDebuginfo, StringOrBool, threads_from_config, }; use crate::core::download::{ DownloadContext, download_beta_toolchain, is_download_ci_available, maybe_download_rustfmt, @@ -247,7 +247,7 @@ pub struct Config { pub hosts: Vec, pub targets: Vec, pub local_rebuild: bool, - pub jemalloc: bool, + pub override_allocator: Option, pub control_flow_guard: bool, pub ehcont_guard: bool, @@ -589,6 +589,7 @@ impl Config { thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit, parallel_frontend_threads: rust_parallel_frontend_threads, remap_debuginfo: rust_remap_debuginfo, + override_allocator: rust_override_allocator, jemalloc: rust_jemalloc, test_compare_mode: rust_test_compare_mode, llvm_libunwind: rust_llvm_libunwind, @@ -976,6 +977,7 @@ impl Config { codegen_backends: target_codegen_backends, runner: target_runner, optimized_compiler_builtins: target_optimized_compiler_builtins, + override_allocator: target_override_allocator, jemalloc: target_jemalloc, } = cfg; @@ -1052,7 +1054,11 @@ impl Config { target.rpath = target_rpath; target.rustflags = target_rustflags.unwrap_or_default(); target.optimized_compiler_builtins = target_optimized_compiler_builtins; - target.jemalloc = target_jemalloc; + target.override_allocator = reconcile_jemalloc( + target_jemalloc, + target_override_allocator, + &format!("target.{triple}"), + ); if let Some(backends) = target_codegen_backends { target.codegen_backends = Some(parse_codegen_backends(backends, &format!("target.{triple}"))) @@ -1463,7 +1469,6 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to initial_rustdoc, initial_rustfmt, initial_sysroot, - jemalloc: rust_jemalloc.unwrap_or(false), jobs: Some(threads_from_config(flags_jobs.or(build_jobs).unwrap_or(0))), json_output: flags_json_output, keep_stage: flags_keep_stage, @@ -1524,6 +1529,7 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to on_fail: flags_on_fail, optimized_compiler_builtins, out, + override_allocator: reconcile_jemalloc(rust_jemalloc, rust_override_allocator, "rust"), patch_binaries_for_nix: build_patch_binaries_for_nix, path_modification_cache, paths, @@ -1957,8 +1963,11 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to self.enabled_codegen_backends(target).first().unwrap() } - pub fn jemalloc(&self, target: TargetSelection) -> bool { - self.target_config.get(&target).and_then(|cfg| cfg.jemalloc).unwrap_or(self.jemalloc) + pub fn override_allocator(&self, target: TargetSelection) -> Option { + self.target_config + .get(&target) + .and_then(|cfg| cfg.override_allocator) + .or(self.override_allocator) } pub fn rpath_enabled(&self, target: TargetSelection) -> bool { @@ -2051,6 +2060,38 @@ impl AsRef for Config { } } +/// Reconciles the deprecated `jemalloc` boolean option with the new +/// `override-allocator` option. +/// +/// Emits a warning if `jemalloc` is present and errors out if it is set but +/// `override-allocator` is not `jemalloc`. The allocator is overridden if +/// either option is set. +fn reconcile_jemalloc( + jemalloc: Option, + override_allocator: Option, + section: &str, +) -> Option { + if let Some(jemalloc) = jemalloc { + println!( + "WARNING: The `{section}.jemalloc` option is deprecated. \ + Use `{section}.override-allocator` instead.", + ); + if jemalloc && override_allocator.is_some_and(|a| a != OverrideAllocator::Jemalloc) { + panic!( + "ERROR: `{section}.jemalloc` is set but `{section}.override-allocator` is \ + not `jemalloc` ({:?}). Remove the deprecated `jemalloc` option or set \ + `override-allocator = \"jemalloc\"`.", + override_allocator, + ); + } + } + override_allocator.or(if jemalloc == Some(true) { + Some(OverrideAllocator::Jemalloc) + } else { + None + }) +} + fn compute_src_directory(src_dir: Option, exec_ctx: &ExecutionContext) -> Option { if let Some(src) = src_dir { return Some(src); diff --git a/src/bootstrap/src/core/config/mod.rs b/src/bootstrap/src/core/config/mod.rs index c07e7d28fbb26..6d7cca4897379 100644 --- a/src/bootstrap/src/core/config/mod.rs +++ b/src/bootstrap/src/core/config/mod.rs @@ -251,6 +251,32 @@ impl<'de> Deserialize<'de> for CompilerBuiltins { } } +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum OverrideAllocator { + Jemalloc, +} + +impl OverrideAllocator { + pub fn feature_name(self) -> &'static str { + match self { + OverrideAllocator::Jemalloc => "jemalloc", + } + } +} + +impl<'de> Deserialize<'de> for OverrideAllocator { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let name = String::deserialize(deserializer)?; + match name.as_str() { + "jemalloc" => Ok(Self::Jemalloc), + other => Err(serde::de::Error::unknown_variant(other, &["jemalloc"])), + } + } +} + #[derive(Copy, Clone, Default, Debug, Eq, PartialEq)] pub enum DebuginfoLevel { #[default] diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index 5c0fd37e46c2e..fa4573ef1734f 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -5,7 +5,9 @@ use build_helper::ci::CiEnv; use serde::{Deserialize, Deserializer}; use crate::core::config::toml::TomlConfig; -use crate::core::config::{CompressDebuginfo, DebuginfoLevel, Merge, ReplaceOpt, StringOrBool}; +use crate::core::config::{ + CompressDebuginfo, DebuginfoLevel, Merge, OverrideAllocator, ReplaceOpt, StringOrBool, +}; use crate::{BTreeSet, CodegenBackendKind, HashSet, PathBuf, TargetSelection, define_config, exit}; define_config! { @@ -57,6 +59,8 @@ define_config! { verify_llvm_ir: Option = "verify-llvm-ir", thin_lto_import_instr_limit: Option = "thin-lto-import-instr-limit", remap_debuginfo: Option = "remap-debuginfo", + override_allocator: Option = "override-allocator", + // FIXME: Remove this option in Q1 2027 jemalloc: Option = "jemalloc", test_compare_mode: Option = "test-compare-mode", llvm_libunwind: Option = "llvm-libunwind", @@ -331,6 +335,7 @@ pub fn check_incompatible_options_for_ci_rustc( stack_protector, strip, jemalloc, + override_allocator, rpath, channel, default_linker, @@ -401,6 +406,7 @@ pub fn check_incompatible_options_for_ci_rustc( err!(current_rust_config.llvm_tools, llvm_tools, "rust"); err!(current_rust_config.llvm_bitcode_linker, llvm_bitcode_linker, "rust"); err!(current_rust_config.jemalloc, jemalloc, "rust"); + err!(current_rust_config.override_allocator, override_allocator, "rust"); err!(current_rust_config.default_linker, default_linker, "rust"); err!(current_rust_config.stack_protector, stack_protector, "rust"); err!(current_rust_config.std_features, std_features, "rust"); diff --git a/src/bootstrap/src/core/config/toml/target.rs b/src/bootstrap/src/core/config/toml/target.rs index 311d9add9a144..5f12b1295bc2e 100644 --- a/src/bootstrap/src/core/config/toml/target.rs +++ b/src/bootstrap/src/core/config/toml/target.rs @@ -15,8 +15,8 @@ use serde::de::Error; use serde::{Deserialize, Deserializer}; use crate::core::config::{ - CompilerBuiltins, CompressDebuginfo, LlvmLibunwind, Merge, ReplaceOpt, SplitDebuginfo, - StringOrBool, + CompilerBuiltins, CompressDebuginfo, LlvmLibunwind, Merge, OverrideAllocator, ReplaceOpt, + SplitDebuginfo, StringOrBool, }; use crate::{CodegenBackendKind, HashSet, PathBuf, define_config, exit}; @@ -48,6 +48,7 @@ define_config! { codegen_backends: Option> = "codegen-backends", runner: Option = "runner", optimized_compiler_builtins: Option = "optimized-compiler-builtins", + override_allocator: Option = "override-allocator", jemalloc: Option = "jemalloc", } } @@ -83,7 +84,7 @@ pub struct Target { pub no_std: bool, pub codegen_backends: Option>, pub optimized_compiler_builtins: Option, - pub jemalloc: Option, + pub override_allocator: Option, } impl Target { diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index f08346789e7e8..4ff9b02dff396 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -866,8 +866,10 @@ impl Build { crates.is_empty() || possible_features_by_crates.contains(feature) }; let mut features = vec![]; - if self.config.jemalloc(target) && check("jemalloc") { - features.push("jemalloc"); + if let Some(allocator) = self.config.override_allocator(target) + && check(allocator.feature_name()) + { + features.push(allocator.feature_name()); } if (self.config.llvm_enabled(target) || kind == Kind::Check) && check("llvm") { features.push("llvm"); diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 0a87925018538..912b5cdc8b2ff 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -641,4 +641,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Info, summary: "New config section `pgo` was introduced, to configure PGO profiling options. The `--rust-profile-use`/`--rust-profile-generate`/`--llvm-profile-use`/`--llvm-profile-generate` flags and the `rust.profile-use`/`rust.profile-generate` config options have been deprecated.", }, + ChangeInfo { + change_id: 155617, + severity: ChangeSeverity::Warning, + summary: "`jemalloc` options are replaced with `override-allocator` which take allocator names such as `jemalloc`", + }, ]; diff --git a/src/ci/citool/tests/jobs.rs b/src/ci/citool/tests/jobs.rs index 247871de60255..3ab24b353fd76 100644 --- a/src/ci/citool/tests/jobs.rs +++ b/src/ci/citool/tests/jobs.rs @@ -6,7 +6,7 @@ const TEST_JOBS_YML_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/tes fn auto_jobs() { let stdout = get_matrix("push", "commit", "refs/heads/automation/bors/auto"); insta::assert_snapshot!(stdout, @r#" - jobs=[{"name":"aarch64-gnu","full_name":"auto - aarch64-gnu","os":"ubuntu-22.04-arm","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"x86_64-gnu-llvm-18-1","full_name":"auto - x86_64-gnu-llvm-18-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DOCKER_SCRIPT":"stage_2_test_set1.sh","IMAGE":"x86_64-gnu-llvm-18","READ_ONLY_SRC":"0","RUST_BACKTRACE":1,"TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"aarch64-apple","full_name":"auto - aarch64-apple","os":"macos-15","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DEVELOPER_DIR":"/Applications/Xcode_26.2.app/Contents/Developer","MACOSX_DEPLOYMENT_TARGET":11.0,"MACOSX_STD_DEPLOYMENT_TARGET":11.0,"NO_DEBUG_ASSERTIONS":1,"NO_LLVM_ASSERTIONS":1,"NO_OVERFLOW_CHECKS":1,"RUSTC_RETRY_LINKER_ON_SEGFAULT":1,"RUST_CONFIGURE_ARGS":"--enable-sanitizers --enable-profiler --set rust.jemalloc","SCRIPT":"./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin","TOOLSTATE_PUBLISH":1}},{"name":"dist-i686-msvc","full_name":"auto - dist-i686-msvc","os":"windows-2022","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","CODEGEN_BACKENDS":"llvm,cranelift","DEPLOY_BUCKET":"rust-lang-ci2","DIST_REQUIRE_ALL_TOOLS":1,"RUST_CONFIGURE_ARGS":"--build=i686-pc-windows-msvc --host=i686-pc-windows-msvc --target=i686-pc-windows-msvc,i586-pc-windows-msvc --enable-full-tools --enable-profiler","SCRIPT":"python x.py dist bootstrap --include-default-paths","TOOLSTATE_PUBLISH":1}},{"name":"pr-check-1","full_name":"auto - pr-check-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"pr-check-2","full_name":"auto - pr-check-2","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"tidy","full_name":"auto - tidy","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true,"doc_url":"https://foo.bar"}] + jobs=[{"name":"aarch64-gnu","full_name":"auto - aarch64-gnu","os":"ubuntu-22.04-arm","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"x86_64-gnu-llvm-18-1","full_name":"auto - x86_64-gnu-llvm-18-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DOCKER_SCRIPT":"stage_2_test_set1.sh","IMAGE":"x86_64-gnu-llvm-18","READ_ONLY_SRC":"0","RUST_BACKTRACE":1,"TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"aarch64-apple","full_name":"auto - aarch64-apple","os":"macos-15","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DEVELOPER_DIR":"/Applications/Xcode_26.2.app/Contents/Developer","MACOSX_DEPLOYMENT_TARGET":11.0,"MACOSX_STD_DEPLOYMENT_TARGET":11.0,"NO_DEBUG_ASSERTIONS":1,"NO_LLVM_ASSERTIONS":1,"NO_OVERFLOW_CHECKS":1,"RUSTC_RETRY_LINKER_ON_SEGFAULT":1,"RUST_CONFIGURE_ARGS":"--enable-sanitizers --enable-profiler --set rust.override-allocator=jemalloc","SCRIPT":"./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin","TOOLSTATE_PUBLISH":1}},{"name":"dist-i686-msvc","full_name":"auto - dist-i686-msvc","os":"windows-2022","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","CODEGEN_BACKENDS":"llvm,cranelift","DEPLOY_BUCKET":"rust-lang-ci2","DIST_REQUIRE_ALL_TOOLS":1,"RUST_CONFIGURE_ARGS":"--build=i686-pc-windows-msvc --host=i686-pc-windows-msvc --target=i686-pc-windows-msvc,i586-pc-windows-msvc --enable-full-tools --enable-profiler","SCRIPT":"python x.py dist bootstrap --include-default-paths","TOOLSTATE_PUBLISH":1}},{"name":"pr-check-1","full_name":"auto - pr-check-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"pr-check-2","full_name":"auto - pr-check-2","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"tidy","full_name":"auto - tidy","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true,"doc_url":"https://foo.bar"}] run_type=auto "#); } diff --git a/src/ci/citool/tests/test-jobs.yml b/src/ci/citool/tests/test-jobs.yml index 3bad1fe1b4271..eb0ef8a9b4c02 100644 --- a/src/ci/citool/tests/test-jobs.yml +++ b/src/ci/citool/tests/test-jobs.yml @@ -28,7 +28,7 @@ runners: envs: env-x86_64-apple-tests: &env-x86_64-apple-tests SCRIPT: ./x.py check compiletest && ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc-html -- --exact - RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc + RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.override-allocator=jemalloc RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 # Ensure that host tooling is tested on our minimum supported macOS version. MACOSX_DEPLOYMENT_TARGET: 10.12 @@ -110,7 +110,7 @@ auto: RUST_CONFIGURE_ARGS: >- --enable-sanitizers --enable-profiler - --set rust.jemalloc + --set rust.override-allocator=jemalloc RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer # Aarch64 tooling only needs to support macOS 11.0 and up as nothing else diff --git a/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile b/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile index 750cafaca0b2c..684e8cf9051fc 100644 --- a/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile +++ b/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile @@ -89,7 +89,7 @@ ENV RUST_CONFIGURE_ARGS="--build=aarch64-unknown-linux-gnu \ --set llvm.libzstd=true \ --set llvm.ninja=false \ --set rust.debug-assertions=false \ - --set rust.jemalloc \ + --set rust.override-allocator=jemalloc \ --set rust.bootstrap-override-lld=true \ --set rust.lto=thin \ --set rust.codegen-units=1" diff --git a/src/ci/docker/host-x86_64/disabled/dist-x86_64-haiku/Dockerfile b/src/ci/docker/host-x86_64/disabled/dist-x86_64-haiku/Dockerfile index 6692e82847c32..69b47005bd666 100644 --- a/src/ci/docker/host-x86_64/disabled/dist-x86_64-haiku/Dockerfile +++ b/src/ci/docker/host-x86_64/disabled/dist-x86_64-haiku/Dockerfile @@ -43,7 +43,7 @@ RUN sh /scripts/sccache.sh ENV HOST=x86_64-unknown-haiku ENV TARGET=target.$HOST -ENV RUST_CONFIGURE_ARGS="--disable-jemalloc \ +ENV RUST_CONFIGURE_ARGS=" \ --set=$TARGET.cc=x86_64-unknown-haiku-gcc \ --set=$TARGET.cxx=x86_64-unknown-haiku-g++ \ --set=$TARGET.llvm-config=/bin/llvm-config-haiku" diff --git a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile index 8165258cc49f2..88f484d0e8643 100644 --- a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile @@ -76,7 +76,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-full-tools \ --set target.i686-unknown-linux-gnu.linker=clang \ --build=i686-unknown-linux-gnu \ --set llvm.ninja=false \ - --set rust.jemalloc" + --set rust.override-allocator=jemalloc" ENV SCRIPT="python3 ../x.py dist --build $HOSTS --host $HOSTS --target $HOSTS" ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=clang diff --git a/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile index c4f8351bd9466..f037b6faa563c 100644 --- a/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile @@ -51,7 +51,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-extended \ --enable-profiler \ --enable-sanitizers \ --disable-docs \ - --set rust.jemalloc \ + --set rust.override-allocator=jemalloc \ --set rust.lto=thin \ --set rust.codegen-units=1" diff --git a/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile b/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile index 61b28e4189a4a..2b77249c494c8 100644 --- a/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile @@ -33,7 +33,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-extended \ --enable-profiler \ --enable-sanitizers \ --disable-docs \ - --set rust.jemalloc \ + --set rust.override-allocator=jemalloc \ --set rust.lto=thin \ --set rust.codegen-units=1 \ --set target.loongarch64-unknown-linux-musl.crt-static=false \ diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile index b168c739c9793..2fa936056233f 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile @@ -90,7 +90,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-full-tools \ --set llvm.thin-lto=true \ --set llvm.ninja=false \ --set llvm.libzstd=true \ - --set rust.jemalloc \ + --set rust.override-allocator=jemalloc \ --set rust.bootstrap-override-lld=true \ --set rust.lto=thin \ --set rust.codegen-units=1" diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index a8eebe7599fda..a236effaa9b40 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -485,7 +485,7 @@ auto: --enable-sanitizers --enable-profiler --disable-docs - --set rust.jemalloc + --set rust.override-allocator=jemalloc --set llvm.link-shared=true --set rust.lto=thin --set rust.codegen-units=1 @@ -520,7 +520,7 @@ auto: RUST_CONFIGURE_ARGS: >- --enable-sanitizers --enable-profiler - --set rust.jemalloc + --set rust.override-allocator=jemalloc --set target.aarch64-apple-ios-macabi.sanitizers=false --set target.x86_64-apple-ios-macabi.sanitizers=false --set target.aarch64-apple-tvos.profiler=false @@ -545,7 +545,7 @@ auto: --enable-full-tools --enable-sanitizers --enable-profiler - --set rust.jemalloc + --set rust.override-allocator=jemalloc --set llvm.link-shared=true --set rust.lto=thin --set rust.codegen-units=1 @@ -566,7 +566,7 @@ auto: RUST_CONFIGURE_ARGS: >- --enable-sanitizers --enable-profiler - --set rust.jemalloc + --set rust.override-allocator=jemalloc DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer # Aarch64 tooling only needs to support macOS 11.0 and up as nothing else # supports the hardware, so only need to test it there. diff --git a/src/doc/rustc-dev-guide/src/building/optimized-build.md b/src/doc/rustc-dev-guide/src/building/optimized-build.md index 0a6b82eba46ac..a9c19fa58589f 100644 --- a/src/doc/rustc-dev-guide/src/building/optimized-build.md +++ b/src/doc/rustc-dev-guide/src/building/optimized-build.md @@ -31,11 +31,11 @@ Enabling LTO on Linux has [produced] speed-ups by up to 10%. ## Memory allocator Using a different memory allocator for `rustc` can provide significant performance benefits. -If you want to enable the `jemalloc` allocator, you can set the `rust.jemalloc` option to `true` +If you want to enable the `jemalloc` allocator, you can set the `rust.override-allocator` option to `jemalloc` in `bootstrap.toml`: ```toml -rust.jemalloc = true +rust.override-allocator = "jemalloc" ``` > Note that this option is currently only supported for Linux and macOS targets. diff --git a/src/doc/rustc-dev-guide/src/profiling/with-perf.md b/src/doc/rustc-dev-guide/src/profiling/with-perf.md index 50281b6b60088..3285a486eb452 100644 --- a/src/doc/rustc-dev-guide/src/profiling/with-perf.md +++ b/src/doc/rustc-dev-guide/src/profiling/with-perf.md @@ -7,7 +7,7 @@ This is a guide for how to profile rustc with [perf](https://perf.wiki.kernel.or - Get a clean checkout of rust-lang/rust - Set the following settings in your `bootstrap.toml`: - `rust.debuginfo-level = 1` - enables line debuginfo - - `rust.jemalloc = false` - lets you do memory use profiling with valgrind + - leave `rust.override-allocator` unset - lets you do memory use profiling with valgrind - leave everything else the defaults - Run `./x build` to get a full build - Make a rustup toolchain pointing to that result diff --git a/src/doc/unstable-book/src/language-features/macroless-generic-const-args.md b/src/doc/unstable-book/src/language-features/macroless-generic-const-args.md new file mode 100644 index 0000000000000..18f4e5cd97a98 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/macroless-generic-const-args.md @@ -0,0 +1,68 @@ +# macroless_generic_const_args + +Enables using `#![feature(min_generic_const_args)]` without the `direct_const_arg!` macro. + +The tracking issue for this feature is: [#159006] + +[#159006]: https://github.com/rust-lang/rust/issues/159006 + +------------------------ + +Warning: This feature is incomplete; its design and syntax may change. + +Related features: [min_generic_const_args]. See that doc for what the `direct_const_arg!` is. This feature enables +support for directly represented const arguments without the macro. + +[min_generic_const_args]: min-generic-const-args.md + +## Examples + +Here is an example from [min_generic_const_args]: + +[min_generic_const_args]: min-generic-const-args.md + +```rust +#![allow(incomplete_features)] +#![feature(min_generic_const_args)] + +trait Bar { + type const VAL: usize; + type const VAL2: usize; +} + +struct Baz; + +impl Bar for Baz { + type const VAL: usize = 2; + type const VAL2: usize = const { Self::VAL * 2 }; +} + +struct Foo { + arr1: [usize; core::direct_const_arg!(B::VAL)], + arr2: [usize; core::direct_const_arg!(B::VAL2)], +} +``` + +Using `#![feature(macroless_generic_const_args)]` enables you to write the above without the macro: + +```rust +#![allow(incomplete_features)] +#![feature(min_generic_const_args, macroless_generic_const_args)] + +trait Bar { + type const VAL: usize; + type const VAL2: usize; +} + +struct Baz; + +impl Bar for Baz { + type const VAL: usize = 2; + type const VAL2: usize = const { Self::VAL * 2 }; +} + +struct Foo { + arr1: [usize; B::VAL], + arr2: [usize; B::VAL2], +} +``` diff --git a/src/doc/unstable-book/src/language-features/min-generic-const-args.md b/src/doc/unstable-book/src/language-features/min-generic-const-args.md index 336b6a420c2d6..c7815b176b6c3 100644 --- a/src/doc/unstable-book/src/language-features/min-generic-const-args.md +++ b/src/doc/unstable-book/src/language-features/min-generic-const-args.md @@ -15,13 +15,29 @@ and uses a different approach for implementation. It is intentionally more restr cases that make the `generic_const_exprs` hard to implement properly. See [Feature background][feature_background] for more details. -Related features: [generic_const_args], [generic_const_items]. +Related features: [macroless_generic_const_args], [generic_const_args], [generic_const_items]. [feature_background]: https://github.com/rust-lang/project-const-generics/blob/main/documents/min_const_generics_plan.md [generic_const_exprs]: generic-const-exprs.md +[macroless_generic_const_args]: macroless-generic-const-args.md [generic_const_args]: generic-const-args.md [generic_const_items]: generic-const-items.md +## `direct_const_arg!` macro + +This feature introduces a new macro: `direct_const_arg!`. + +When an expression is used as a generic argument, it is typically lowered as an "anon const", which is an expression +that is opaque to the type system and cannot contain generics. Using `direct_const_arg!` instead represents the +expression "directly", i.e. without an anon const, in a way that is visible to the type system. + +(Note that plain paths to generic parameters are always represented directly, without `direct_const_arg!`, as this +already works on stable) + +See [macroless_generic_const_args] as a feature to disable the requirement of writing `direct_const_arg!`. + +[macroless_generic_const_args]: macroless-generic-const-args.md + ## `type const` syntax This feature introduces new syntax: `type const`. @@ -35,8 +51,8 @@ type const X: usize = 1; const Y: usize = 1; struct Foo { - good_arr: [(); X], // Allowed - bad_arr: [(); Y], // Will not compile, `Y` must be `type const`. + good_arr: [(); core::direct_const_arg!(X)], // Allowed + bad_arr: [(); core::direct_const_arg!(Y)], // Will not compile, `Y` must be `type const`. } ``` @@ -59,8 +75,8 @@ impl Bar for Baz { } struct Foo { - arr1: [usize; B::VAL], - arr2: [usize; B::VAL2], + arr1: [usize; core::direct_const_arg!(B::VAL)], + arr2: [usize; core::direct_const_arg!(B::VAL2)], } ``` diff --git a/tests/crashes/138009.rs b/tests/crashes/138009.rs index a1b890823e7d2..15c34a848e05f 100644 --- a/tests/crashes/138009.rs +++ b/tests/crashes/138009.rs @@ -1,6 +1,6 @@ //@ known-bug: #138009 #![feature(min_generic_const_args)] #[repr(simd)] -struct T([isize; N]); +struct T([isize; core::direct_const_arg!(N)]); static X: T = T(); diff --git a/tests/crashes/138088.rs b/tests/crashes/138088.rs index 25496d804fef7..bd0d0949d43d2 100644 --- a/tests/crashes/138088.rs +++ b/tests/crashes/138088.rs @@ -1,5 +1,5 @@ //@ known-bug: #138088 #![feature(min_generic_const_args)] trait Bar { - fn x(&self) -> [i32; Bar::x]; + fn x(&self) -> [i32; core::direct_const_arg!(Bar::x)]; } diff --git a/tests/crashes/149809.rs b/tests/crashes/149809.rs index f70498f11c878..fafd1d5224e89 100644 --- a/tests/crashes/149809.rs +++ b/tests/crashes/149809.rs @@ -6,7 +6,7 @@ struct Qux<'a> { } impl<'a> Qux<'a> { type const LEN: usize = 4; - fn foo(_: [u8; Qux::LEN]) {} + fn foo(_: [u8; core::direct_const_arg!(Qux::LEN)]) {} } fn main() {} diff --git a/tests/crashes/150049.rs b/tests/crashes/150049.rs index fa39785779c0f..45289679e04ba 100644 --- a/tests/crashes/150049.rs +++ b/tests/crashes/150049.rs @@ -6,7 +6,9 @@ struct Foo<'a> { } impl<'a> Foo<'a> { - fn foo(_: [u8; Foo::X]) { std::mem::transmute([4]) } + fn foo(_: [u8; core::direct_const_arg!(Foo::X)]) { + std::mem::transmute([4]) + } } fn main() {} diff --git a/tests/crashes/150749.rs b/tests/crashes/150749.rs index 572dc67c27511..59d07f9860b9a 100644 --- a/tests/crashes/150749.rs +++ b/tests/crashes/150749.rs @@ -6,7 +6,7 @@ trait CollectArray { } impl CollectArray for () { fn inner_array() { - let temp_ptr: [(); Self]; + let temp_ptr: [(); core::direct_const_arg!(Self)]; } } fn main() {} diff --git a/tests/crashes/150969.rs b/tests/crashes/150969.rs index daab977bce193..5f0e09becf36f 100644 --- a/tests/crashes/150969.rs +++ b/tests/crashes/150969.rs @@ -3,5 +3,5 @@ #![feature(min_generic_const_args)] fn pass_enum { - pass_enum::<{None}> + pass_enum::<{core::direct_const_arg!(None)}> } diff --git a/tests/rustdoc-html/type-const-associated-const-no-body.rs b/tests/rustdoc-html/type-const-associated-const-no-body.rs index 1ee22b45c4226..1a5bb72f05fdd 100644 --- a/tests/rustdoc-html/type-const-associated-const-no-body.rs +++ b/tests/rustdoc-html/type-const-associated-const-no-body.rs @@ -2,7 +2,7 @@ //! and #![crate_name = "foo"] -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] pub trait Tr { diff --git a/tests/rustdoc-html/type-const-free-in-array.rs b/tests/rustdoc-html/type-const-free-in-array.rs index bea46596caa58..fed209f16d1e0 100644 --- a/tests/rustdoc-html/type-const-free-in-array.rs +++ b/tests/rustdoc-html/type-const-free-in-array.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] type const N: usize = 2; diff --git a/tests/rustdoc-html/type-const-inherent-with-body.rs b/tests/rustdoc-html/type-const-inherent-with-body.rs index e9771b1f606c1..fae06a12f55f5 100644 --- a/tests/rustdoc-html/type-const-inherent-with-body.rs +++ b/tests/rustdoc-html/type-const-inherent-with-body.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -#![feature(min_generic_const_args, inherent_associated_types)] +#![feature(min_generic_const_args, macroless_generic_const_args, inherent_associated_types)] #![expect(incomplete_features)] pub struct Foo; diff --git a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.rs b/tests/ui/associated-consts/type-const-in-array-len-wrong-type.rs index c260ab1ee584d..a61ca256baf91 100644 --- a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.rs +++ b/tests/ui/associated-consts/type-const-in-array-len-wrong-type.rs @@ -1,6 +1,9 @@ -#![feature(generic_const_exprs)] -#![feature(min_generic_const_args)] -#![feature(inherent_associated_types)] +#![feature( + generic_const_exprs, + min_generic_const_args, + macroless_generic_const_args, + inherent_associated_types +)] struct OnDiskDirEntry<'a>(&'a ()); diff --git a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.stderr b/tests/ui/associated-consts/type-const-in-array-len-wrong-type.stderr index a90b1f666067d..dcb88f77f82cd 100644 --- a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.stderr +++ b/tests/ui/associated-consts/type-const-in-array-len-wrong-type.stderr @@ -1,5 +1,5 @@ error: the constant `2` is not of type `usize` - --> $DIR/type-const-in-array-len-wrong-type.rs:10:26 + --> $DIR/type-const-in-array-len-wrong-type.rs:13:26 | LL | fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `i64` diff --git a/tests/ui/associated-consts/type-const-in-array-len.rs b/tests/ui/associated-consts/type-const-in-array-len.rs index 7a809cefe9f75..976d8c9ffd533 100644 --- a/tests/ui/associated-consts/type-const-in-array-len.rs +++ b/tests/ui/associated-consts/type-const-in-array-len.rs @@ -1,7 +1,6 @@ //@ check-pass -#![feature(min_generic_const_args)] -#![feature(inherent_associated_types)] +#![feature(min_generic_const_args, macroless_generic_const_args, inherent_associated_types)] // Test case from #138226: generic impl with multiple type parameters struct Foo(A, B); diff --git a/tests/ui/cfg/crate-attributes-using-cfg_attr.stderr b/tests/ui/cfg/crate-attributes-using-cfg_attr.stderr index 3d6f007605026..cd0a662cce384 100644 --- a/tests/ui/cfg/crate-attributes-using-cfg_attr.stderr +++ b/tests/ui/cfg/crate-attributes-using-cfg_attr.stderr @@ -1,16 +1,16 @@ -error: `crate_type` within an `#![cfg_attr]` attribute is forbidden +error: `crate_type` within a `#![cfg_attr]` attribute is forbidden --> $DIR/crate-attributes-using-cfg_attr.rs:5:18 | LL | #![cfg_attr(foo, crate_type="bin")] | ^^^^^^^^^^^^^^^^ -error: `crate_name` within an `#![cfg_attr]` attribute is forbidden +error: `crate_name` within a `#![cfg_attr]` attribute is forbidden --> $DIR/crate-attributes-using-cfg_attr.rs:8:18 | LL | #![cfg_attr(foo, crate_name="bar")] | ^^^^^^^^^^^^^^^^ -error: `crate_type` within an `#![cfg_attr]` attribute is forbidden +error: `crate_type` within a `#![cfg_attr]` attribute is forbidden --> $DIR/crate-attributes-using-cfg_attr.rs:5:18 | LL | #![cfg_attr(foo, crate_type="bin")] @@ -18,7 +18,7 @@ LL | #![cfg_attr(foo, crate_type="bin")] | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `crate_name` within an `#![cfg_attr]` attribute is forbidden +error: `crate_name` within a `#![cfg_attr]` attribute is forbidden --> $DIR/crate-attributes-using-cfg_attr.rs:8:18 | LL | #![cfg_attr(foo, crate_name="bar")] diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.rs index 8130960195d9d..6bfedab837714 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.rs @@ -1,7 +1,7 @@ // Test that we force users to explicitly specify const arguments for const parameters that // have defaults if the default mentions the `Self` type parameter. -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] trait X::N }> {} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs index 9564903dce5b7..ffc568a7b2c3f 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs @@ -5,7 +5,7 @@ // The author of the trait object type can't fix this unlike the supertrait bound // equivalent where they just need to explicitly specify the assoc const. -#![feature(min_generic_const_args, trait_alias)] +#![feature(min_generic_const_args, macroless_generic_const_args, trait_alias)] #![expect(incomplete_features)] trait Trait { diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-from-supertrait-mentions-self.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-from-supertrait-mentions-self.rs index 560a1b7f3f7a1..3a36c0ccbc418 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-from-supertrait-mentions-self.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-from-supertrait-mentions-self.rs @@ -1,7 +1,7 @@ // Test that we force users to explicitly specify associated constants (via bindings) // which reference the `Self` type parameter. -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] trait X: Y { diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs index fb2bc308ae188..1ca24178ef2c2 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs @@ -7,6 +7,7 @@ #![feature( adt_const_params, min_generic_const_args, + macroless_generic_const_args, const_param_ty_trait, generic_const_parameter_types )] diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.stderr index 7443c2977d54d..30b2b4776f93d 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.stderr +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.stderr @@ -1,11 +1,11 @@ error: type annotations needed for the literal - --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:32:33 + --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:33:33 | LL | let _: dyn A; | ^ error: type annotations needed for the literal - --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:34:34 + --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:35:34 | LL | let _: &dyn A = &(); | ^ diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-methods.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-methods.rs index 9886213743c8a..193eedc02c0ca 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-methods.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-methods.rs @@ -11,7 +11,7 @@ // correct values from the type assoc consts). //@ run-pass -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] trait Trait { diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-supertrait-bounds.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-supertrait-bounds.rs index f2ae98accda57..375adb78513b6 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-supertrait-bounds.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-supertrait-bounds.rs @@ -4,7 +4,7 @@ //@ dont-require-annotations: NOTE -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] trait Trait: SuperTrait<{ Self::N }> { diff --git a/tests/ui/const-generics/associated-const-bindings/normalization-via-param-env.rs b/tests/ui/const-generics/associated-const-bindings/normalization-via-param-env.rs index a1efa74090bb4..4c57d8d14d039 100644 --- a/tests/ui/const-generics/associated-const-bindings/normalization-via-param-env.rs +++ b/tests/ui/const-generics/associated-const-bindings/normalization-via-param-env.rs @@ -1,5 +1,5 @@ //@ check-pass -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features)] // Regression test for normalizing const projections diff --git a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.rs b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.rs index 3eeb7703aa2b0..92ae129c7310a 100644 --- a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.rs +++ b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.rs @@ -1,7 +1,7 @@ //! Check that we correctly handle associated const bindings //! where the RHS is a normalizable const projection (#151642). -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] trait Trait { type const CT: bool; } diff --git a/tests/ui/const-generics/fn-item-as-const-arg-137084.rs b/tests/ui/const-generics/fn-item-as-const-arg-137084.rs index 8b75a3c8c96d1..c8679494955b9 100644 --- a/tests/ui/const-generics/fn-item-as-const-arg-137084.rs +++ b/tests/ui/const-generics/fn-item-as-const-arg-137084.rs @@ -1,7 +1,7 @@ // Regression test for https://github.com/rust-lang/rust/issues/137084 // Previously caused ICE when using function item as const generic argument -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features)] fn a() {} diff --git a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.next.stderr b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.next.stderr index efe7265a924c4..e0bf63f4b066d 100644 --- a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.next.stderr +++ b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.next.stderr @@ -1,11 +1,11 @@ error[E0284]: type annotations needed for `([(); _], [(); 10])` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:29:9 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:32:9 | LL | let (mut arr, mut arr_with_weird_len) = free(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------ type must be known at this point | note: required by a const generic parameter in `free` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:24:9 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:27:9 | LL | fn free() -> ([(); N], [(); FREE::]) { | ^^^^^^^^^^^^^^ required by this const generic parameter in `free` @@ -15,7 +15,7 @@ LL | let (mut arr, mut arr_with_weird_len): ([_; N], _) = free(); | +++++++++++++ error[E0271]: type mismatch resolving `FREE<10> == 2` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:35:45 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:38:45 | LL | let (mut arr, mut arr_with_weird_len) = free(); | ^^^^^^ expected `2`, found `10` @@ -24,13 +24,13 @@ LL | let (mut arr, mut arr_with_weird_len) = free(); found constant `10` error[E0284]: type annotations needed for `([(); _], [(); 10])` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:46:9 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:49:9 | LL | let (mut arr, mut arr_with_weird_len) = proj(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------ type must be known at this point | note: required by a const generic parameter in `proj` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:41:9 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:44:9 | LL | fn proj() -> ([(); N], [(); ::PROJ::]) { | ^^^^^^^^^^^^^^ required by this const generic parameter in `proj` @@ -40,7 +40,7 @@ LL | let (mut arr, mut arr_with_weird_len): ([_; N], _) = proj(); | +++++++++++++ error[E0271]: type mismatch resolving `::PROJ<10> == 2` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:52:45 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:55:45 | LL | let (mut arr, mut arr_with_weird_len) = proj(); | ^^^^^^ expected `2`, found `10` diff --git a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.old.stderr b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.old.stderr index f27badafa2ca7..11274b947b8f6 100644 --- a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.old.stderr +++ b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.old.stderr @@ -1,8 +1,8 @@ error: `generic_const_args` requires -Znext-solver=globally to be enabled - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:9:12 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:10:5 | -LL | #![feature(generic_const_args)] - | ^^^^^^^^^^^^^^^^^^ +LL | generic_const_args, + | ^^^^^^^^^^^^^^^^^^ | = help: enable all of these features diff --git a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.rs b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.rs index 902be2d8b1a8f..ef6d047309b13 100644 --- a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.rs +++ b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.rs @@ -4,10 +4,13 @@ // runs on the old solver, just in case someone attempts to implement GCA for the old solver and // removes the restriction that -Znext-solver must be enabled) -#![feature(generic_const_items)] -#![feature(min_generic_const_args)] -#![feature(generic_const_args)] +#![feature( + min_generic_const_args, + macroless_generic_const_args, + generic_const_args, //[old]~^ ERROR next-solver + generic_const_items +)] #![expect(incomplete_features)] const FREE: usize = 10; diff --git a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars.rs b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars.rs index 4be1b036d6946..3d78566e15c92 100644 --- a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars.rs +++ b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars.rs @@ -1,9 +1,12 @@ //@ check-pass //@ compile-flags: -Znext-solver -#![feature(generic_const_items)] -#![feature(min_generic_const_args)] -#![feature(generic_const_args)] +#![feature( + min_generic_const_args, + macroless_generic_const_args, + generic_const_args, + generic_const_items +)] #![expect(incomplete_features)] const FREE: usize = 10; diff --git a/tests/ui/const-generics/gca/generic-free-const.rs b/tests/ui/const-generics/gca/generic-free-const.rs index e7816728d461e..8fef5931db1ca 100644 --- a/tests/ui/const-generics/gca/generic-free-const.rs +++ b/tests/ui/const-generics/gca/generic-free-const.rs @@ -1,9 +1,12 @@ //@ check-pass //@ compile-flags: -Znext-solver -#![feature(min_generic_const_args)] -#![feature(generic_const_args)] -#![feature(generic_const_items)] +#![feature( + min_generic_const_args, + macroless_generic_const_args, + generic_const_args, + generic_const_items +)] #![expect(incomplete_features)] const ADD1: usize = N + 1; diff --git a/tests/ui/const-generics/gca/non-type-equality-fail.rs b/tests/ui/const-generics/gca/non-type-equality-fail.rs index 235ab37f8b570..6e71125a4cffb 100644 --- a/tests/ui/const-generics/gca/non-type-equality-fail.rs +++ b/tests/ui/const-generics/gca/non-type-equality-fail.rs @@ -1,7 +1,6 @@ //@ compile-flags: -Znext-solver -#![feature(min_generic_const_args)] -#![feature(generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args, generic_const_args)] #![expect(incomplete_features)] trait Trait { diff --git a/tests/ui/const-generics/gca/non-type-equality-fail.stderr b/tests/ui/const-generics/gca/non-type-equality-fail.stderr index 05d90f5632728..5a9c1bb6d4faa 100644 --- a/tests/ui/const-generics/gca/non-type-equality-fail.stderr +++ b/tests/ui/const-generics/gca/non-type-equality-fail.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/non-type-equality-fail.rs:32:9 + --> $DIR/non-type-equality-fail.rs:31:9 | LL | let _: Struct<{ as Trait>::PROJECTED_A }> = | -------------------------------------------------------- expected due to this @@ -10,7 +10,7 @@ LL | Struct::<{ as Trait>::PROJECTED_B }>; found struct `Struct< as Trait>::PROJECTED_B>` error[E0308]: mismatched types - --> $DIR/non-type-equality-fail.rs:37:41 + --> $DIR/non-type-equality-fail.rs:36:41 | LL | let _: Struct<{ T::PROJECTED_A }> = Struct::<{ T::PROJECTED_B }>; | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `::PROJECTED_A`, found `::PROJECTED_B` diff --git a/tests/ui/const-generics/gca/non-type-equality-ok.rs b/tests/ui/const-generics/gca/non-type-equality-ok.rs index 443fbc46bd8a0..e476b5d8124ca 100644 --- a/tests/ui/const-generics/gca/non-type-equality-ok.rs +++ b/tests/ui/const-generics/gca/non-type-equality-ok.rs @@ -1,9 +1,12 @@ //@ check-pass //@ compile-flags: -Znext-solver -#![feature(min_generic_const_args)] -#![feature(generic_const_args)] -#![feature(generic_const_items)] +#![feature( + min_generic_const_args, + macroless_generic_const_args, + generic_const_args, + generic_const_items +)] #![expect(incomplete_features)] trait Trait { diff --git a/tests/ui/const-generics/gca/path-to-non-type-const.rs b/tests/ui/const-generics/gca/path-to-non-type-const.rs index c36dbbcc578fa..9deb517095cbd 100644 --- a/tests/ui/const-generics/gca/path-to-non-type-const.rs +++ b/tests/ui/const-generics/gca/path-to-non-type-const.rs @@ -1,8 +1,7 @@ //@ check-pass //@ compile-flags: -Znext-solver -#![feature(min_generic_const_args)] -#![feature(generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args, generic_const_args)] #![expect(incomplete_features)] trait Trait { diff --git a/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.rs b/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.rs index 1b9164d4a2300..d15341836e493 100644 --- a/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.rs +++ b/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.rs @@ -2,9 +2,12 @@ //! off on implementing paths to IACs until a refactoring of how IAC generics are represented. //@ compile-flags: -Znext-solver -#![feature(min_generic_const_args)] -#![feature(generic_const_args)] -#![feature(inherent_associated_types)] +#![feature( + inherent_associated_types, + min_generic_const_args, + generic_const_args, + macroless_generic_const_args +)] #![expect(incomplete_features)] struct StructImpl; diff --git a/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.stderr b/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.stderr index b5da53f0f1c8e..af671fb614e31 100644 --- a/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.stderr +++ b/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.stderr @@ -1,5 +1,5 @@ error: use of `const` in the type system not defined as `type const` - --> $DIR/path-to-non-type-inherent-associated-const.rs:24:24 + --> $DIR/path-to-non-type-inherent-associated-const.rs:27:24 | LL | let _ = Struct::<{ StructImpl::INHERENT }>; | ^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | type const INHERENT: usize = 1; | ++++ error: use of `const` in the type system not defined as `type const` - --> $DIR/path-to-non-type-inherent-associated-const.rs:26:24 + --> $DIR/path-to-non-type-inherent-associated-const.rs:29:24 | LL | let _ = Struct::<{ GenericStructImpl::<2>::INHERENT }>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/generic_const_exprs/non-local-const.rs b/tests/ui/const-generics/generic_const_exprs/non-local-const.rs index d0efdb2c20171..16fdab0f9e7f4 100644 --- a/tests/ui/const-generics/generic_const_exprs/non-local-const.rs +++ b/tests/ui/const-generics/generic_const_exprs/non-local-const.rs @@ -1,8 +1,7 @@ // regression test for #133808. //@ aux-build:non_local_type_const.rs -#![feature(generic_const_exprs)] -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args, generic_const_exprs)] #![allow(incomplete_features)] #![crate_type = "lib"] extern crate non_local_type_const; diff --git a/tests/ui/const-generics/generic_const_exprs/non-local-const.stderr b/tests/ui/const-generics/generic_const_exprs/non-local-const.stderr index 3d1ec60eb908d..0519c0965c669 100644 --- a/tests/ui/const-generics/generic_const_exprs/non-local-const.stderr +++ b/tests/ui/const-generics/generic_const_exprs/non-local-const.stderr @@ -1,5 +1,5 @@ error: the constant `'a'` is not of type `usize` - --> $DIR/non-local-const.rs:11:14 + --> $DIR/non-local-const.rs:10:14 | LL | impl Foo for [u8; non_local_type_const::NON_LOCAL_CONST] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `char` diff --git a/tests/ui/const-generics/ice-151186-fn-ptr-in-where-clause.rs b/tests/ui/const-generics/ice-151186-fn-ptr-in-where-clause.rs index 7710fc68d7957..d1c5db5ae0345 100644 --- a/tests/ui/const-generics/ice-151186-fn-ptr-in-where-clause.rs +++ b/tests/ui/const-generics/ice-151186-fn-ptr-in-where-clause.rs @@ -1,6 +1,6 @@ // Regression test for https://github.com/rust-lang/rust/issues/151186 -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features)] trait Maybe {} diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs b/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs index b09d17fb11262..35ce7b7d9ead0 100644 --- a/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs +++ b/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] #[derive(Eq, PartialEq, std::marker::ConstParamTy)] diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.rs b/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.rs index 68f999fb76fa6..8268a6b5689ae 100644 --- a/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.rs +++ b/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.rs @@ -1,7 +1,11 @@ -#![feature(min_generic_const_args, adt_const_params, unsized_const_params)] +#![feature( + min_generic_const_args, + macroless_generic_const_args, + adt_const_params, + unsized_const_params +)] #![expect(incomplete_features)] - trait Trait { type const ASSOC: usize; } diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.stderr b/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.stderr index 9d80ebeaa680a..961aedbae66d6 100644 --- a/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.stderr +++ b/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_fail.stderr @@ -1,35 +1,35 @@ error: the constant `N` is not of type `u32` - --> $DIR/adt_expr_arg_tuple_expr_fail.rs:13:21 + --> $DIR/adt_expr_arg_tuple_expr_fail.rs:17:21 | LL | takes_tuple::<{ (N, N2) }>(); | ^^^^^^^ expected `u32`, found `usize` error: the constant `N` is not of type `u32` - --> $DIR/adt_expr_arg_tuple_expr_fail.rs:15:21 + --> $DIR/adt_expr_arg_tuple_expr_fail.rs:19:21 | LL | takes_tuple::<{ (N, T::ASSOC) }>(); | ^^^^^^^^^^^^^ expected `u32`, found `usize` error: the constant `::ASSOC` is not of type `u32` - --> $DIR/adt_expr_arg_tuple_expr_fail.rs:15:21 + --> $DIR/adt_expr_arg_tuple_expr_fail.rs:19:21 | LL | takes_tuple::<{ (N, T::ASSOC) }>(); | ^^^^^^^^^^^^^ expected `u32`, found `usize` error: the constant `N` is not of type `u32` - --> $DIR/adt_expr_arg_tuple_expr_fail.rs:19:28 + --> $DIR/adt_expr_arg_tuple_expr_fail.rs:23:28 | LL | takes_nested_tuple::<{ (N, (N, N2)) }>(); | ^^^^^^^^^^^^ expected `u32`, found `usize` error: the constant `N` is not of type `u32` - --> $DIR/adt_expr_arg_tuple_expr_fail.rs:21:28 + --> $DIR/adt_expr_arg_tuple_expr_fail.rs:25:28 | LL | takes_nested_tuple::<{ (N, (N, T::ASSOC)) }>(); | ^^^^^^^^^^^^^^^^^^ expected `u32`, found `usize` error: the constant `::ASSOC` is not of type `u32` - --> $DIR/adt_expr_arg_tuple_expr_fail.rs:21:28 + --> $DIR/adt_expr_arg_tuple_expr_fail.rs:25:28 | LL | takes_nested_tuple::<{ (N, (N, T::ASSOC)) }>(); | ^^^^^^^^^^^^^^^^^^ expected `u32`, found `usize` diff --git a/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs b/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs index 13016d02e4aee..f11bd2e51660b 100644 --- a/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs +++ b/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] #![crate_type = "lib"] diff --git a/tests/ui/const-generics/mgca/adt_expr_fields_type_check.rs b/tests/ui/const-generics/mgca/adt_expr_fields_type_check.rs index 496a424bac650..ecb68b53fcb65 100644 --- a/tests/ui/const-generics/mgca/adt_expr_fields_type_check.rs +++ b/tests/ui/const-generics/mgca/adt_expr_fields_type_check.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] #[derive(Eq, PartialEq, std::marker::ConstParamTy)] diff --git a/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs b/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs index f27cbddaae285..4b66c563e5fda 100644 --- a/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs +++ b/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs @@ -3,13 +3,14 @@ #![feature( generic_const_items, min_generic_const_args, + macroless_generic_const_args, adt_const_params, generic_const_parameter_types, - const_param_ty_trait, + const_param_ty_trait )] #![expect(incomplete_features)] -use std::marker::{PhantomData, ConstParamTy, ConstParamTy_}; +use std::marker::{ConstParamTy, ConstParamTy_, PhantomData}; #[derive(PartialEq, Eq, ConstParamTy)] struct Foo { @@ -34,11 +35,12 @@ fn main() { // This tests that we are able to infer `?x=3` even though the first `ty::Const` // may be a fully evaluated constant, and the latter is not fully evaluatable due // to inference variables. - let _: PC<_, { WRAP:: }> - = PC::<_, { Foo:: { field: _ }}>; + let _: PC<_, { WRAP:: }> = PC::<_, { Foo:: { field: _ } }>; } // "PhantomConst" helper equivalent to "PhantomData" used for testing equalities // of arbitrarily typed const arguments. -struct PC { _0: PhantomData } +struct PC { + _0: PhantomData, +} const PC: PC = PC { _0: PhantomData:: }; diff --git a/tests/ui/const-generics/mgca/adt_expr_unit_enum_extra_field.rs b/tests/ui/const-generics/mgca/adt_expr_unit_enum_extra_field.rs index 6d25e7ef798fa..6ae942c8dc06d 100644 --- a/tests/ui/const-generics/mgca/adt_expr_unit_enum_extra_field.rs +++ b/tests/ui/const-generics/mgca/adt_expr_unit_enum_extra_field.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #[derive(Eq, PartialEq, std::marker::ConstParamTy)] enum E { diff --git a/tests/ui/const-generics/mgca/adt_expr_unit_struct_extra_field.rs b/tests/ui/const-generics/mgca/adt_expr_unit_struct_extra_field.rs index fbb8db0952f04..ef0b885388f7e 100644 --- a/tests/ui/const-generics/mgca/adt_expr_unit_struct_extra_field.rs +++ b/tests/ui/const-generics/mgca/adt_expr_unit_struct_extra_field.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #[derive(Eq, PartialEq, std::marker::ConstParamTy)] struct Foo; diff --git a/tests/ui/const-generics/mgca/ambiguous-assoc-const.rs b/tests/ui/const-generics/mgca/ambiguous-assoc-const.rs index d7df9c22afd69..ff828f6323fba 100644 --- a/tests/ui/const-generics/mgca/ambiguous-assoc-const.rs +++ b/tests/ui/const-generics/mgca/ambiguous-assoc-const.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] trait Tr { diff --git a/tests/ui/const-generics/mgca/array-const-arg-type-mismatch.rs b/tests/ui/const-generics/mgca/array-const-arg-type-mismatch.rs index 614532d3ec68e..3b36017445b59 100644 --- a/tests/ui/const-generics/mgca/array-const-arg-type-mismatch.rs +++ b/tests/ui/const-generics/mgca/array-const-arg-type-mismatch.rs @@ -1,5 +1,5 @@ #![expect(incomplete_features)] -#![feature(adt_const_params, min_generic_const_args)] +#![feature(adt_const_params, min_generic_const_args, macroless_generic_const_args)] use std::marker::ConstParamTy; #[derive(Eq, PartialEq, ConstParamTy)] diff --git a/tests/ui/const-generics/mgca/array-expr-simple.rs b/tests/ui/const-generics/mgca/array-expr-simple.rs index 44feeccb4f9f2..3a096d98e7fa0 100644 --- a/tests/ui/const-generics/mgca/array-expr-simple.rs +++ b/tests/ui/const-generics/mgca/array-expr-simple.rs @@ -1,6 +1,6 @@ //@ run-pass #![expect(incomplete_features)] -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![allow(dead_code)] fn takes_array_u32() {} diff --git a/tests/ui/const-generics/mgca/array-expr-type-mismatch-in-where-bound.rs b/tests/ui/const-generics/mgca/array-expr-type-mismatch-in-where-bound.rs index 98feccfc99c74..be12837c4481f 100644 --- a/tests/ui/const-generics/mgca/array-expr-type-mismatch-in-where-bound.rs +++ b/tests/ui/const-generics/mgca/array-expr-type-mismatch-in-where-bound.rs @@ -1,5 +1,5 @@ //! regression test for -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![feature(adt_const_params)] #![expect(incomplete_features)] diff --git a/tests/ui/const-generics/mgca/array-expr-with-assoc-const.rs b/tests/ui/const-generics/mgca/array-expr-with-assoc-const.rs index 7401181962bb8..f4fb878fead35 100644 --- a/tests/ui/const-generics/mgca/array-expr-with-assoc-const.rs +++ b/tests/ui/const-generics/mgca/array-expr-with-assoc-const.rs @@ -1,6 +1,6 @@ //@ run-pass #![expect(incomplete_features)] -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![allow(dead_code)] fn takes_array() {} diff --git a/tests/ui/const-generics/mgca/array-expr-with-macro.rs b/tests/ui/const-generics/mgca/array-expr-with-macro.rs index aef5acc1c8030..24e9280e543e7 100644 --- a/tests/ui/const-generics/mgca/array-expr-with-macro.rs +++ b/tests/ui/const-generics/mgca/array-expr-with-macro.rs @@ -1,6 +1,6 @@ //@ run-pass #![expect(incomplete_features)] -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![allow(dead_code)] macro_rules! make_array { diff --git a/tests/ui/const-generics/mgca/array-expr-with-struct.rs b/tests/ui/const-generics/mgca/array-expr-with-struct.rs index 883af57e918e3..4cc958a9f0273 100644 --- a/tests/ui/const-generics/mgca/array-expr-with-struct.rs +++ b/tests/ui/const-generics/mgca/array-expr-with-struct.rs @@ -1,5 +1,5 @@ //@ run-pass -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] #![allow(dead_code)] diff --git a/tests/ui/const-generics/mgca/array-expr-with-tuple.rs b/tests/ui/const-generics/mgca/array-expr-with-tuple.rs index 004663dcefaba..4e5124a6d7ae1 100644 --- a/tests/ui/const-generics/mgca/array-expr-with-tuple.rs +++ b/tests/ui/const-generics/mgca/array-expr-with-tuple.rs @@ -1,5 +1,10 @@ //@ run-pass -#![feature(min_generic_const_args, adt_const_params, unsized_const_params)] +#![feature( + min_generic_const_args, + macroless_generic_const_args, + adt_const_params, + unsized_const_params +)] #![expect(incomplete_features)] #![allow(dead_code)] diff --git a/tests/ui/const-generics/mgca/array-with-wrong-tuple-type.rs b/tests/ui/const-generics/mgca/array-with-wrong-tuple-type.rs index d96a626b74226..138f3c41d6799 100644 --- a/tests/ui/const-generics/mgca/array-with-wrong-tuple-type.rs +++ b/tests/ui/const-generics/mgca/array-with-wrong-tuple-type.rs @@ -1,4 +1,9 @@ -#![feature(adt_const_params, min_generic_const_args, unsized_const_params)] +#![feature( + adt_const_params, + min_generic_const_args, + macroless_generic_const_args, + unsized_const_params +)] #![allow(incomplete_features)] use std::marker::ConstParamTy; @@ -9,7 +14,6 @@ struct A; fn takes_tuple() {} fn takes_nested_tuple() {} - fn main() { takes_tuple::<{ [A] }>(); //~^ ERROR the constant `A` is not of type `(u32, u32)` diff --git a/tests/ui/const-generics/mgca/array-with-wrong-tuple-type.stderr b/tests/ui/const-generics/mgca/array-with-wrong-tuple-type.stderr index d7b1fe096cb42..6d7de13d81073 100644 --- a/tests/ui/const-generics/mgca/array-with-wrong-tuple-type.stderr +++ b/tests/ui/const-generics/mgca/array-with-wrong-tuple-type.stderr @@ -1,11 +1,11 @@ error: the constant `A` is not of type `(u32, u32)` - --> $DIR/array-with-wrong-tuple-type.rs:14:21 + --> $DIR/array-with-wrong-tuple-type.rs:18:21 | LL | takes_tuple::<{ [A] }>(); | ^^^ expected `(u32, u32)`, found `A` error: the constant `A` is not of type `(u32, (u32, u32))` - --> $DIR/array-with-wrong-tuple-type.rs:16:28 + --> $DIR/array-with-wrong-tuple-type.rs:20:28 | LL | takes_nested_tuple::<{ [A] }>(); | ^^^ expected `(u32, (u32, u32))`, found `A` diff --git a/tests/ui/const-generics/mgca/array_elem_type_mismatch.rs b/tests/ui/const-generics/mgca/array_elem_type_mismatch.rs index b15f90acb477e..b8cbbed030fe5 100644 --- a/tests/ui/const-generics/mgca/array_elem_type_mismatch.rs +++ b/tests/ui/const-generics/mgca/array_elem_type_mismatch.rs @@ -1,6 +1,11 @@ //! Regression test for #![expect(incomplete_features)] -#![feature(adt_const_params, generic_const_parameter_types, min_generic_const_args)] +#![feature( + adt_const_params, + generic_const_parameter_types, + min_generic_const_args, + macroless_generic_const_args +)] fn foo() {} fn main() { diff --git a/tests/ui/const-generics/mgca/array_elem_type_mismatch.stderr b/tests/ui/const-generics/mgca/array_elem_type_mismatch.stderr index f98dbf1e311ba..dc65022b674b5 100644 --- a/tests/ui/const-generics/mgca/array_elem_type_mismatch.stderr +++ b/tests/ui/const-generics/mgca/array_elem_type_mismatch.stderr @@ -1,11 +1,11 @@ error: the constant `2` is not of type `u8` - --> $DIR/array_elem_type_mismatch.rs:7:16 + --> $DIR/array_elem_type_mismatch.rs:12:16 | LL | foo::<_, { [0, 1u8, 2u32, 8u64] }>(); | ^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `u32` error: the constant `8` is not of type `u8` - --> $DIR/array_elem_type_mismatch.rs:7:16 + --> $DIR/array_elem_type_mismatch.rs:12:16 | LL | foo::<_, { [0, 1u8, 2u32, 8u64] }>(); | ^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `u64` diff --git a/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs b/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs index 13b2e031b118b..a278d5f69eb22 100644 --- a/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs +++ b/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs @@ -1,7 +1,7 @@ //! regression test for //@ run-pass #![expect(incomplete_features)] -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(dead_code)] trait Abc {} diff --git a/tests/ui/const-generics/mgca/assoc-const-without-type_const.rs b/tests/ui/const-generics/mgca/assoc-const-without-type_const.rs index ca7299e7690b9..f3f4779330b74 100644 --- a/tests/ui/const-generics/mgca/assoc-const-without-type_const.rs +++ b/tests/ui/const-generics/mgca/assoc-const-without-type_const.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features)] pub trait Tr { diff --git a/tests/ui/const-generics/mgca/assoc-const.rs b/tests/ui/const-generics/mgca/assoc-const.rs index c49b84edba108..a618cfa7049b4 100644 --- a/tests/ui/const-generics/mgca/assoc-const.rs +++ b/tests/ui/const-generics/mgca/assoc-const.rs @@ -1,6 +1,6 @@ //@ check-pass -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features)] pub trait Tr { diff --git a/tests/ui/const-generics/mgca/bad-impl-trait-with-apit.rs b/tests/ui/const-generics/mgca/bad-impl-trait-with-apit.rs index c509c52951197..a049b05e64363 100644 --- a/tests/ui/const-generics/mgca/bad-impl-trait-with-apit.rs +++ b/tests/ui/const-generics/mgca/bad-impl-trait-with-apit.rs @@ -1,7 +1,7 @@ // Regression test for issue #155834 #![expect(incomplete_features)] -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] trait Trait {} diff --git a/tests/ui/const-generics/mgca/braced-const-infer.rs b/tests/ui/const-generics/mgca/braced-const-infer.rs index 9b007d338d1da..e5b2df8af5568 100644 --- a/tests/ui/const-generics/mgca/braced-const-infer.rs +++ b/tests/ui/const-generics/mgca/braced-const-infer.rs @@ -1,5 +1,5 @@ //! Regression test for https://github.com/rust-lang/rust/issues/153198 -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features, rust_2021_compatibility)] trait Trait {} diff --git a/tests/ui/const-generics/mgca/const-ctor-overflow-eval.rs b/tests/ui/const-generics/mgca/const-ctor-overflow-eval.rs index ec74a6e530127..a4538ffff3854 100644 --- a/tests/ui/const-generics/mgca/const-ctor-overflow-eval.rs +++ b/tests/ui/const-generics/mgca/const-ctor-overflow-eval.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] use std::marker::ConstParamTy; diff --git a/tests/ui/const-generics/mgca/const-ctor-with-error.rs b/tests/ui/const-generics/mgca/const-ctor-with-error.rs index 95a910e3dd2c6..c72feb65b959f 100644 --- a/tests/ui/const-generics/mgca/const-ctor-with-error.rs +++ b/tests/ui/const-generics/mgca/const-ctor-with-error.rs @@ -1,6 +1,6 @@ // to ensure it does not ices like before -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] use std::marker::ConstParamTy; diff --git a/tests/ui/const-generics/mgca/const-ctor.rs b/tests/ui/const-generics/mgca/const-ctor.rs index d84b05f909099..4d95fc5013dde 100644 --- a/tests/ui/const-generics/mgca/const-ctor.rs +++ b/tests/ui/const-generics/mgca/const-ctor.rs @@ -6,6 +6,7 @@ #![feature( min_generic_const_args, + macroless_generic_const_args, adt_const_params, generic_const_parameter_types, const_param_ty_trait diff --git a/tests/ui/const-generics/mgca/infer-vars-in-const-args-conflicting.rs b/tests/ui/const-generics/mgca/infer-vars-in-const-args-conflicting.rs index eeb76683eedf1..7baf7c23cc42b 100644 --- a/tests/ui/const-generics/mgca/infer-vars-in-const-args-conflicting.rs +++ b/tests/ui/const-generics/mgca/infer-vars-in-const-args-conflicting.rs @@ -4,7 +4,12 @@ //! See https://github.com/rust-lang/rust/pull/153557 #![allow(incomplete_features)] -#![feature(adt_const_params, min_generic_const_args, generic_const_parameter_types)] +#![feature( + adt_const_params, + min_generic_const_args, + macroless_generic_const_args, + generic_const_parameter_types +)] fn main() { foo::<_, { 2 }>(); @@ -14,7 +19,7 @@ fn main() { } struct PC { -//~^ ERROR: `T` can't be used as a const parameter type [E0741] + //~^ ERROR: `T` can't be used as a const parameter type [E0741] a: T, } diff --git a/tests/ui/const-generics/mgca/infer-vars-in-const-args-conflicting.stderr b/tests/ui/const-generics/mgca/infer-vars-in-const-args-conflicting.stderr index a4b13f41aef07..05942fab68f1f 100644 --- a/tests/ui/const-generics/mgca/infer-vars-in-const-args-conflicting.stderr +++ b/tests/ui/const-generics/mgca/infer-vars-in-const-args-conflicting.stderr @@ -1,17 +1,17 @@ error[E0741]: `T` can't be used as a const parameter type - --> $DIR/infer-vars-in-const-args-conflicting.rs:16:23 + --> $DIR/infer-vars-in-const-args-conflicting.rs:21:23 | LL | struct PC { | ^ error: type annotations needed for the literal - --> $DIR/infer-vars-in-const-args-conflicting.rs:10:16 + --> $DIR/infer-vars-in-const-args-conflicting.rs:15:16 | LL | foo::<_, { 2 }>(); | ^ error: type annotations needed for the literal - --> $DIR/infer-vars-in-const-args-conflicting.rs:12:20 + --> $DIR/infer-vars-in-const-args-conflicting.rs:17:20 | LL | let _: PC<_, { 42 }> = PC { a: 1, b: 1 }; | ^^ diff --git a/tests/ui/const-generics/mgca/infer-vars-in-const-args-correct.rs b/tests/ui/const-generics/mgca/infer-vars-in-const-args-correct.rs index f1c0e0b2b4c30..dfa1ae436aa7a 100644 --- a/tests/ui/const-generics/mgca/infer-vars-in-const-args-correct.rs +++ b/tests/ui/const-generics/mgca/infer-vars-in-const-args-correct.rs @@ -7,8 +7,10 @@ //@check-pass #![allow(incomplete_features)] -#![feature(adt_const_params, +#![feature( + adt_const_params, min_generic_const_args, + macroless_generic_const_args, generic_const_parameter_types, unsized_const_params )] diff --git a/tests/ui/const-generics/mgca/inherent-const-gating.rs b/tests/ui/const-generics/mgca/inherent-const-gating.rs index c39b8e6f7f64a..f4328435dc578 100644 --- a/tests/ui/const-generics/mgca/inherent-const-gating.rs +++ b/tests/ui/const-generics/mgca/inherent-const-gating.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features)] struct S; diff --git a/tests/ui/const-generics/mgca/invalid-array-in-tuple.rs b/tests/ui/const-generics/mgca/invalid-array-in-tuple.rs index 8c84e12e654bc..e22ccf3480650 100644 --- a/tests/ui/const-generics/mgca/invalid-array-in-tuple.rs +++ b/tests/ui/const-generics/mgca/invalid-array-in-tuple.rs @@ -1,4 +1,9 @@ -#![feature(adt_const_params, min_generic_const_args, unsized_const_params)] +#![feature( + adt_const_params, + min_generic_const_args, + macroless_generic_const_args, + unsized_const_params +)] #![allow(incomplete_features)] use std::marker::ConstParamTy; diff --git a/tests/ui/const-generics/mgca/invalid-array-in-tuple.stderr b/tests/ui/const-generics/mgca/invalid-array-in-tuple.stderr index 1cd46883dcf79..306e972d8ffd4 100644 --- a/tests/ui/const-generics/mgca/invalid-array-in-tuple.stderr +++ b/tests/ui/const-generics/mgca/invalid-array-in-tuple.stderr @@ -1,5 +1,5 @@ error: the constant `Bar` is not of type `Foo` - --> $DIR/invalid-array-in-tuple.rs:14:32 + --> $DIR/invalid-array-in-tuple.rs:19:32 | LL | takes_tuple_with_array::<{ ([Bar], 1) }>(); | ^^^^^^^^^^ expected `Foo`, found `Bar` diff --git a/tests/ui/const-generics/mgca/macro-const-arg-infer.rs b/tests/ui/const-generics/mgca/macro-const-arg-infer.rs index 017c63d8b0db5..ef36148467c00 100644 --- a/tests/ui/const-generics/mgca/macro-const-arg-infer.rs +++ b/tests/ui/const-generics/mgca/macro-const-arg-infer.rs @@ -1,5 +1,5 @@ //! Regression test for https://github.com/rust-lang/rust/issues/153198 -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features)] macro_rules! y { ( $($matcher:tt)*) => { diff --git a/tests/ui/const-generics/mgca/missing_generic_params.rs b/tests/ui/const-generics/mgca/missing_generic_params.rs index ab1db3364ec3e..f5ad80011435b 100644 --- a/tests/ui/const-generics/mgca/missing_generic_params.rs +++ b/tests/ui/const-generics/mgca/missing_generic_params.rs @@ -7,7 +7,7 @@ // is only possible within bodies. So a delayed // bug was generated with no error ever reported. -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features)] trait Trait {} impl Trait for [(); N] {} diff --git a/tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs b/tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs index bbe624269672d..f328b5d0ba209 100644 --- a/tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs +++ b/tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs @@ -1,6 +1,6 @@ //@ check-pass -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] struct Foo; diff --git a/tests/ui/const-generics/mgca/non-local-const-without-type_const.rs b/tests/ui/const-generics/mgca/non-local-const-without-type_const.rs index 6f1235269dfc8..11974d034040a 100644 --- a/tests/ui/const-generics/mgca/non-local-const-without-type_const.rs +++ b/tests/ui/const-generics/mgca/non-local-const-without-type_const.rs @@ -1,6 +1,6 @@ // Just a test of the error message (it's different for non-local consts) //@ aux-build:non_local_const.rs -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features)] extern crate non_local_const; fn main() { diff --git a/tests/ui/const-generics/mgca/nonsensical-negated-literal.rs b/tests/ui/const-generics/mgca/nonsensical-negated-literal.rs index 4a3efb801cb01..80833153bd469 100644 --- a/tests/ui/const-generics/mgca/nonsensical-negated-literal.rs +++ b/tests/ui/const-generics/mgca/nonsensical-negated-literal.rs @@ -1,11 +1,16 @@ -#![feature(adt_const_params, min_generic_const_args, unsized_const_params)] +#![feature( + adt_const_params, + min_generic_const_args, + macroless_generic_const_args, + unsized_const_params +)] #![expect(incomplete_features)] use std::marker::ConstParamTy; #[derive(Eq, PartialEq, ConstParamTy)] struct Foo { - field: isize + field: isize, } fn foo() {} diff --git a/tests/ui/const-generics/mgca/nonsensical-negated-literal.stderr b/tests/ui/const-generics/mgca/nonsensical-negated-literal.stderr index 60c559d1d5ba9..f66b0f5f7f2fa 100644 --- a/tests/ui/const-generics/mgca/nonsensical-negated-literal.stderr +++ b/tests/ui/const-generics/mgca/nonsensical-negated-literal.stderr @@ -1,41 +1,41 @@ error: negated literal must be an integer - --> $DIR/nonsensical-negated-literal.rs:20:26 + --> $DIR/nonsensical-negated-literal.rs:25:26 | LL | foo::<{ Foo { field: -true } }>(); | ^^^^^ error: negated literal must be an integer - --> $DIR/nonsensical-negated-literal.rs:22:28 + --> $DIR/nonsensical-negated-literal.rs:27:28 | LL | foo::<{ Foo { field: { -true } } }>(); | ^^^^^ error: negated literal must be an integer - --> $DIR/nonsensical-negated-literal.rs:24:26 + --> $DIR/nonsensical-negated-literal.rs:29:26 | LL | foo::<{ Foo { field: -"<3" } }>(); | ^^^^^ error: negated literal must be an integer - --> $DIR/nonsensical-negated-literal.rs:26:28 + --> $DIR/nonsensical-negated-literal.rs:31:28 | LL | foo::<{ Foo { field: { -"<3" } } }>(); | ^^^^^ error: negated literal must be an integer - --> $DIR/nonsensical-negated-literal.rs:29:13 + --> $DIR/nonsensical-negated-literal.rs:34:13 | LL | bar::<{ -"hi" }>(); | ^^^^^ error: type annotations needed for the literal - --> $DIR/nonsensical-negated-literal.rs:16:26 + --> $DIR/nonsensical-negated-literal.rs:21:26 | LL | foo::<{ Foo { field: -1_usize } }>(); | ^^^^^^^^ error: type annotations needed for the literal - --> $DIR/nonsensical-negated-literal.rs:18:28 + --> $DIR/nonsensical-negated-literal.rs:23:28 | LL | foo::<{ Foo { field: { -1_usize } } }>(); | ^^^^^^^^ diff --git a/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs b/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs index 4829196d1078c..44f977d219d72 100644 --- a/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs +++ b/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs @@ -2,7 +2,7 @@ //@ edition: 2024 #![allow(incomplete_features)] -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #[derive(Eq, PartialEq, core::marker::ConstParamTy)] struct Foo; diff --git a/tests/ui/const-generics/mgca/resolution-with-inherent-associated-types.rs b/tests/ui/const-generics/mgca/resolution-with-inherent-associated-types.rs index 6a8d291e3cc00..60d6858e88b27 100644 --- a/tests/ui/const-generics/mgca/resolution-with-inherent-associated-types.rs +++ b/tests/ui/const-generics/mgca/resolution-with-inherent-associated-types.rs @@ -4,7 +4,7 @@ //@compile-flags: --crate-type=lib #![expect(incomplete_features)] -#![feature(inherent_associated_types, min_generic_const_args)] +#![feature(inherent_associated_types, min_generic_const_args, macroless_generic_const_args)] trait Trait {} struct Struct; diff --git a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs index d06ea7a10c745..919b3bce9f260 100644 --- a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs +++ b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs @@ -1,6 +1,6 @@ //! regression test for #![expect(incomplete_features)] -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] fn foo() { [0; size_of::<*mut T>()]; diff --git a/tests/ui/const-generics/mgca/struct-ctor-in-array-len.rs b/tests/ui/const-generics/mgca/struct-ctor-in-array-len.rs index c8288431c7ed4..e8f4a806e3847 100644 --- a/tests/ui/const-generics/mgca/struct-ctor-in-array-len.rs +++ b/tests/ui/const-generics/mgca/struct-ctor-in-array-len.rs @@ -5,7 +5,7 @@ // for const alias to resolve to: Ctor(Struct, Const)". // It should now produce a proper type error. -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] struct S; diff --git a/tests/ui/const-generics/mgca/suggest-pub-type_const.fixed b/tests/ui/const-generics/mgca/suggest-pub-type_const.fixed index 310cb5d17a490..501452b4846af 100644 --- a/tests/ui/const-generics/mgca/suggest-pub-type_const.fixed +++ b/tests/ui/const-generics/mgca/suggest-pub-type_const.fixed @@ -1,7 +1,7 @@ //! Regression test for //! Tests suggesting `pub type const` instead of `type pub const`. //@ run-rustfix -#![feature(min_generic_const_args, inherent_associated_types)] +#![feature(min_generic_const_args, macroless_generic_const_args, inherent_associated_types)] #![allow(dead_code)] mod impl_item { diff --git a/tests/ui/const-generics/mgca/suggest-pub-type_const.rs b/tests/ui/const-generics/mgca/suggest-pub-type_const.rs index 0d86f47089388..ae6efa8f85960 100644 --- a/tests/ui/const-generics/mgca/suggest-pub-type_const.rs +++ b/tests/ui/const-generics/mgca/suggest-pub-type_const.rs @@ -1,7 +1,7 @@ //! Regression test for //! Tests suggesting `pub type const` instead of `type pub const`. //@ run-rustfix -#![feature(min_generic_const_args, inherent_associated_types)] +#![feature(min_generic_const_args, macroless_generic_const_args, inherent_associated_types)] #![allow(dead_code)] mod impl_item { diff --git a/tests/ui/const-generics/mgca/synth-gen-arg-ice-158152.rs b/tests/ui/const-generics/mgca/synth-gen-arg-ice-158152.rs index 53cf964b8f5a5..1f3519efe3272 100644 --- a/tests/ui/const-generics/mgca/synth-gen-arg-ice-158152.rs +++ b/tests/ui/const-generics/mgca/synth-gen-arg-ice-158152.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] trait A {} trait Trait {} diff --git a/tests/ui/const-generics/mgca/tuple_ctor_arg_simple.rs b/tests/ui/const-generics/mgca/tuple_ctor_arg_simple.rs index e946441453d82..f2edaf184914e 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_arg_simple.rs +++ b/tests/ui/const-generics/mgca/tuple_ctor_arg_simple.rs @@ -1,5 +1,5 @@ //@ run-pass -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] #![allow(dead_code)] diff --git a/tests/ui/const-generics/mgca/tuple_ctor_complex_args.rs b/tests/ui/const-generics/mgca/tuple_ctor_complex_args.rs index 460c8af840a1c..8bdafd6c270f8 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_complex_args.rs +++ b/tests/ui/const-generics/mgca/tuple_ctor_complex_args.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] use std::marker::ConstParamTy; diff --git a/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs b/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs index 43d0d21fb7361..1eb347774f8e0 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs +++ b/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] use std::marker::ConstParamTy; diff --git a/tests/ui/const-generics/mgca/tuple_ctor_in_array_len.rs b/tests/ui/const-generics/mgca/tuple_ctor_in_array_len.rs index 5c7290b40be27..9d4067c08ba18 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_in_array_len.rs +++ b/tests/ui/const-generics/mgca/tuple_ctor_in_array_len.rs @@ -1,6 +1,6 @@ //! Regression test for -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] pub struct S(); diff --git a/tests/ui/const-generics/mgca/tuple_ctor_nested.rs b/tests/ui/const-generics/mgca/tuple_ctor_nested.rs index 49a31ea3e5270..97c5b294798a4 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_nested.rs +++ b/tests/ui/const-generics/mgca/tuple_ctor_nested.rs @@ -1,5 +1,5 @@ //@ run-pass -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] use std::marker::ConstParamTy; diff --git a/tests/ui/const-generics/mgca/tuple_ctor_type_relative.rs b/tests/ui/const-generics/mgca/tuple_ctor_type_relative.rs index d5a07cbb7d70a..4593780c14219 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_type_relative.rs +++ b/tests/ui/const-generics/mgca/tuple_ctor_type_relative.rs @@ -1,5 +1,5 @@ //@ run-pass -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] use std::marker::ConstParamTy; diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_bad-issue-151048.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_bad-issue-151048.rs index 70b955589d3e7..3f221db5d6ec5 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_bad-issue-151048.rs +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_bad-issue-151048.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] struct Y { diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_macroless.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_macroless.rs new file mode 100644 index 0000000000000..cf0effe884e63 --- /dev/null +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_macroless.rs @@ -0,0 +1,26 @@ +//@ check-pass + +#![feature( + min_generic_const_args, + macroless_generic_const_args, + adt_const_params, + unsized_const_params +)] +#![expect(incomplete_features)] + +trait Trait { + type const ASSOC: u32; +} + +fn takes_tuple() {} +fn takes_nested_tuple() {} + +fn generic_caller() { + takes_tuple::<{ (N, N2) }>(); + takes_tuple::<{ (N, T::ASSOC) }>(); + + takes_nested_tuple::<{ (N, (N, N2)) }>(); + takes_nested_tuple::<{ (N, (N, T::ASSOC)) }>(); +} + +fn main() {} diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_mismatch_type.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_mismatch_type.rs index 608a4af353a5e..87accb01c2912 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_mismatch_type.rs +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_mismatch_type.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] pub fn takes_nested_tuple() { diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs index 4c040bcaa9452..776c1e3208feb 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs @@ -11,11 +11,11 @@ fn takes_tuple() {} fn takes_nested_tuple() {} fn generic_caller() { - takes_tuple::<{ (N, N2) }>(); - takes_tuple::<{ (N, T::ASSOC) }>(); + takes_tuple::<{ core::direct_const_arg!((N, N2)) }>(); + takes_tuple::<{ core::direct_const_arg!((N, T::ASSOC)) }>(); - takes_nested_tuple::<{ (N, (N, N2)) }>(); - takes_nested_tuple::<{ (N, (N, T::ASSOC)) }>(); + takes_nested_tuple::<{ core::direct_const_arg!((N, (N, N2))) }>(); + takes_nested_tuple::<{ core::direct_const_arg!((N, (N, T::ASSOC))) }>(); } fn main() {} diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_unbounded_assoc_const.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_unbounded_assoc_const.rs index f844dae5c8220..753185b35f0b3 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_unbounded_assoc_const.rs +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_unbounded_assoc_const.rs @@ -1,4 +1,4 @@ -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] // Regression test for an ICE in privacy checking while walking the `T` qself // of `T::ASSOC` inside a tuple const argument. diff --git a/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.rs b/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.rs index 4bf62b3a30708..95b0d836e53fc 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.rs +++ b/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.rs @@ -3,6 +3,7 @@ #![feature( adt_const_params, min_generic_const_args, + macroless_generic_const_args, unsized_const_params )] fn foo() {} diff --git a/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.stderr b/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.stderr index 4136c7337cd4e..4e7560e4583ef 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.stderr +++ b/tests/ui/const-generics/mgca/tuple_expr_type_mismatch.stderr @@ -1,23 +1,23 @@ error: type annotations needed for the literal - --> $DIR/tuple_expr_type_mismatch.rs:13:14 + --> $DIR/tuple_expr_type_mismatch.rs:14:14 | LL | foo::<{ (1, true) }>(); | ^ error: expected `i32`, found const array - --> $DIR/tuple_expr_type_mismatch.rs:15:21 + --> $DIR/tuple_expr_type_mismatch.rs:16:21 | LL | bar::<{ (1_u32, [1, 2]) }>(); | ^^^^^^ error: the constant `1` is not of type `char` - --> $DIR/tuple_expr_type_mismatch.rs:17:13 + --> $DIR/tuple_expr_type_mismatch.rs:18:13 | LL | qux::<{ (1i32, 'a') }>(); | ^^^^^^^^^^^ expected `char`, found `i32` error: the constant `'a'` is not of type `i32` - --> $DIR/tuple_expr_type_mismatch.rs:17:13 + --> $DIR/tuple_expr_type_mismatch.rs:18:13 | LL | qux::<{ (1i32, 'a') }>(); | ^^^^^^^^^^^ expected `i32`, found `char` diff --git a/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.next.stderr b/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.next.stderr index 3ef6ede90d933..d96726829ee0b 100644 --- a/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.next.stderr +++ b/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.next.stderr @@ -10,7 +10,7 @@ error[E0284]: type annotations needed LL | fn f() -> [u8; const { N }] {} | ^^^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` | - = note: cannot satisfy `f::{constant#0}::{constant#0} == _` + = note: cannot satisfy `f::{constant#0} == _` error[E0308]: mismatched types --> $DIR/type-const-free-value-type-mismatch.rs:11:11 diff --git a/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.next.stderr b/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.next.stderr index 551a1d496e910..eeabde2d06320 100644 --- a/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.next.stderr +++ b/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.next.stderr @@ -4,7 +4,7 @@ error[E0284]: type annotations needed LL | fn f() -> [u8; const { Struct::N }] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` | - = note: cannot satisfy `f::{constant#0}::{constant#0} == _` + = note: cannot satisfy `f::{constant#0} == _` error: the constant `"this isn't a usize"` is not of type `usize` --> $DIR/type-const-inherent-value-type-mismatch.rs:13:5 diff --git a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.rs b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.rs index 4d94ab2be70d3..73507f6e5d7ec 100644 --- a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.rs +++ b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.rs @@ -5,7 +5,7 @@ //@[next] compile-flags: -Znext-solver //@ compile-flags: -Zvalidate-mir -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] pub struct A; diff --git a/tests/ui/const-generics/mgca/type_as_const_in_array_len.rs b/tests/ui/const-generics/mgca/type_as_const_in_array_len.rs index b6b76fe3fc919..398bcb16aa621 100644 --- a/tests/ui/const-generics/mgca/type_as_const_in_array_len.rs +++ b/tests/ui/const-generics/mgca/type_as_const_in_array_len.rs @@ -1,6 +1,6 @@ //! Regression test for -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] struct B(Box<[u8; C]>); diff --git a/tests/ui/const-generics/mgca/type_const-array-return.rs b/tests/ui/const-generics/mgca/type_const-array-return.rs index 43db35966a45a..be01590c99bdd 100644 --- a/tests/ui/const-generics/mgca/type_const-array-return.rs +++ b/tests/ui/const-generics/mgca/type_const-array-return.rs @@ -1,7 +1,7 @@ //@ check-pass // This test should compile without an ICE. #![expect(incomplete_features)] -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] pub struct A; diff --git a/tests/ui/const-generics/mgca/unexpected-fn-item-in-array.rs b/tests/ui/const-generics/mgca/unexpected-fn-item-in-array.rs index 4d96d236cf7fb..97c1a2fb86e55 100644 --- a/tests/ui/const-generics/mgca/unexpected-fn-item-in-array.rs +++ b/tests/ui/const-generics/mgca/unexpected-fn-item-in-array.rs @@ -1,6 +1,6 @@ // Make sure we don't ICE when encountering an fn item during lowering in mGCA. -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] trait A {} diff --git a/tests/ui/const-generics/mgca/unmarked-free-const.rs b/tests/ui/const-generics/mgca/unmarked-free-const.rs index d6d9b936d95b3..c06b3b399c669 100644 --- a/tests/ui/const-generics/mgca/unmarked-free-const.rs +++ b/tests/ui/const-generics/mgca/unmarked-free-const.rs @@ -1,6 +1,6 @@ // regression test, used to ICE -#![feature(min_generic_const_args)] +#![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features)] const N: usize = 4; diff --git a/tests/ui/const-generics/mgca/wrapped_array_elem_type_mismatch.rs b/tests/ui/const-generics/mgca/wrapped_array_elem_type_mismatch.rs index efc21808787b1..c2414b0fb8648 100644 --- a/tests/ui/const-generics/mgca/wrapped_array_elem_type_mismatch.rs +++ b/tests/ui/const-generics/mgca/wrapped_array_elem_type_mismatch.rs @@ -1,5 +1,5 @@ #![expect(incomplete_features)] -#![feature(adt_const_params, min_generic_const_args)] +#![feature(adt_const_params, min_generic_const_args, macroless_generic_const_args)] struct ArrWrap; diff --git a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag.rs b/tests/ui/const-generics/mgca/wrong_type_const_arr_diag.rs index 8a2117096a4a8..d0b6aa5dfab5a 100644 --- a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag.rs +++ b/tests/ui/const-generics/mgca/wrong_type_const_arr_diag.rs @@ -1,6 +1,6 @@ // This test causes ERROR: mismatched types [E0308] // and makes rustc to print array from const arguments -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![allow(incomplete_features)] struct TakesArr; diff --git a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag_trait.rs b/tests/ui/const-generics/mgca/wrong_type_const_arr_diag_trait.rs index 909189ae48752..81ec01eeffbab 100644 --- a/tests/ui/const-generics/mgca/wrong_type_const_arr_diag_trait.rs +++ b/tests/ui/const-generics/mgca/wrong_type_const_arr_diag_trait.rs @@ -1,6 +1,6 @@ // This test causes ERROR: mismatched types [E0308] // and makes rustc to print array from const arguments -#![feature(min_generic_const_args, adt_const_params, trivial_bounds)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params, trivial_bounds)] #![allow(incomplete_features)] trait Trait { diff --git a/tests/ui/const-generics/min_adt_const_params/tuple_with_infer_arg.rs b/tests/ui/const-generics/min_adt_const_params/tuple_with_infer_arg.rs index 4ce1d08249b56..081e0db80997c 100644 --- a/tests/ui/const-generics/min_adt_const_params/tuple_with_infer_arg.rs +++ b/tests/ui/const-generics/min_adt_const_params/tuple_with_infer_arg.rs @@ -1,7 +1,6 @@ //@ check-pass -#![feature(min_adt_const_params)] -#![feature(min_generic_const_args)] +#![feature(min_adt_const_params, min_generic_const_args, macroless_generic_const_args)] struct S; diff --git a/tests/ui/const-generics/type-relative-path-144547.rs b/tests/ui/const-generics/type-relative-path-144547.rs index e3532fe635c2f..fe79fa2897856 100644 --- a/tests/ui/const-generics/type-relative-path-144547.rs +++ b/tests/ui/const-generics/type-relative-path-144547.rs @@ -4,7 +4,7 @@ //@[mgca] check-pass #![allow(incomplete_features)] #![feature(mgca_type_const_syntax)] -#![cfg_attr(mgca, feature(min_generic_const_args))] +#![cfg_attr(mgca, feature(min_generic_const_args, macroless_generic_const_args))] // FIXME(mgca) syntax is it's own feature flag before // expansion and is also an incomplete feature. //#![cfg_attr(mgca, expect(incomplete_features))] diff --git a/tests/ui/feature-gates/feature-gate-macroless-generic-const-args.rs b/tests/ui/feature-gates/feature-gate-macroless-generic-const-args.rs new file mode 100644 index 0000000000000..49916736d46e9 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-macroless-generic-const-args.rs @@ -0,0 +1,13 @@ +trait Trait { + type const ASSOC: usize; + //~^ ERROR: associated `type const` are unstable [E0658] + //~| ERROR: `type const` syntax is experimental [E0658] +} + +// FIXME(mgca): add suggestion for mgca to this error +fn foo() -> [u8; ::ASSOC] { + //~^ ERROR generic parameters may not be used in const operations + loop {} +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-macroless-generic-const-args.stderr b/tests/ui/feature-gates/feature-gate-macroless-generic-const-args.stderr new file mode 100644 index 0000000000000..e50042fb431d9 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-macroless-generic-const-args.stderr @@ -0,0 +1,33 @@ +error: generic parameters may not be used in const operations + --> $DIR/feature-gate-macroless-generic-const-args.rs:8:29 + | +LL | fn foo() -> [u8; ::ASSOC] { + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in const expressions + = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions + = help: alternatively, you can use `#![feature(generic_const_args)]` and extract the expression into a `type const` item + +error[E0658]: `type const` syntax is experimental + --> $DIR/feature-gate-macroless-generic-const-args.rs:2:5 + | +LL | type const ASSOC: usize; + | ^^^^^^^^^^ + | + = note: see issue #132980 for more information + = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: associated `type const` are unstable + --> $DIR/feature-gate-macroless-generic-const-args.rs:2:5 + | +LL | type const ASSOC: usize; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #132980 for more information + = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-min-generic-const-args.rs b/tests/ui/feature-gates/feature-gate-min-generic-const-args.rs index 49916736d46e9..6ac8ef8fa4181 100644 --- a/tests/ui/feature-gates/feature-gate-min-generic-const-args.rs +++ b/tests/ui/feature-gates/feature-gate-min-generic-const-args.rs @@ -5,8 +5,10 @@ trait Trait { } // FIXME(mgca): add suggestion for mgca to this error -fn foo() -> [u8; ::ASSOC] { +fn foo() -> [u8; core::direct_const_arg!(::ASSOC)] { //~^ ERROR generic parameters may not be used in const operations + //~| ERROR use of unstable library feature `min_generic_const_args` [E0658] + //~| ERROR expected expression, found `direct_const_arg!()` constant loop {} } diff --git a/tests/ui/feature-gates/feature-gate-min-generic-const-args.stderr b/tests/ui/feature-gates/feature-gate-min-generic-const-args.stderr index c0e79c6694b0a..f896d0de99ec6 100644 --- a/tests/ui/feature-gates/feature-gate-min-generic-const-args.stderr +++ b/tests/ui/feature-gates/feature-gate-min-generic-const-args.stderr @@ -1,8 +1,18 @@ +error[E0658]: use of unstable library feature `min_generic_const_args` + --> $DIR/feature-gate-min-generic-const-args.rs:8:28 + | +LL | fn foo() -> [u8; core::direct_const_arg!(::ASSOC)] { + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #132980 for more information + = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + error: generic parameters may not be used in const operations - --> $DIR/feature-gate-min-generic-const-args.rs:8:29 + --> $DIR/feature-gate-min-generic-const-args.rs:8:53 | -LL | fn foo() -> [u8; ::ASSOC] { - | ^ cannot perform const operation using `T` +LL | fn foo() -> [u8; core::direct_const_arg!(::ASSOC)] { + | ^ cannot perform const operation using `T` | = note: type parameters may not be used in const expressions = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions @@ -28,6 +38,12 @@ LL | type const ASSOC: usize; = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 3 previous errors +error: expected expression, found `direct_const_arg!()` constant + --> $DIR/feature-gate-min-generic-const-args.rs:8:28 + | +LL | fn foo() -> [u8; core::direct_const_arg!(::ASSOC)] { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.rs b/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.rs index 2b4e100aa100a..51ad438ec9bfb 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.rs +++ b/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.rs @@ -4,7 +4,12 @@ // FIXME: Ideally, this test would be check-pass. See below for details. -#![feature(min_generic_const_args, inherent_associated_types, generic_const_items)] +#![feature( + min_generic_const_args, + macroless_generic_const_args, + inherent_associated_types, + generic_const_items +)] #![expect(incomplete_features)] mod own { // the lifetime comes from the own generics diff --git a/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.stderr b/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.stderr index 8323c2a94ce3a..2762f69719099 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.stderr +++ b/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.stderr @@ -1,5 +1,5 @@ error[E0228]: cannot deduce the lifetime bound for this trait object type from context - --> $DIR/object-lifetime-default-inherent-gac.rs:19:48 + --> $DIR/object-lifetime-default-inherent-gac.rs:24:48 | LL | fn check<'r>() where [(); Parent::CT::<'r, dyn super::Trait>]: {} | ^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | fn check<'r>() where [(); Parent::CT::<'r, dyn super::Trait + /* 'a */> | ++++++++++ error[E0228]: cannot deduce the lifetime bound for this trait object type from context - --> $DIR/object-lifetime-default-inherent-gac.rs:32:50 + --> $DIR/object-lifetime-default-inherent-gac.rs:37:50 | LL | fn check<'r>() where [(); Parent::<'r>::CT::]: {} | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/sanitizer/cfi/assoc-const-projection-issue-151878.rs b/tests/ui/sanitizer/cfi/assoc-const-projection-issue-151878.rs index ec7a6d1605588..3fd33c7c1bb67 100644 --- a/tests/ui/sanitizer/cfi/assoc-const-projection-issue-151878.rs +++ b/tests/ui/sanitizer/cfi/assoc-const-projection-issue-151878.rs @@ -4,7 +4,7 @@ //@ build-pass //@ no-prefer-dynamic -#![feature(min_generic_const_args, associated_type_defaults)] +#![feature(min_generic_const_args, macroless_generic_const_args, associated_type_defaults)] #![expect(incomplete_features)] trait Trait { diff --git a/tests/ui/transmutability/non_scalar_alignment_value.rs b/tests/ui/transmutability/non_scalar_alignment_value.rs index 3b21cdd1c84c3..ffc0e186978c1 100644 --- a/tests/ui/transmutability/non_scalar_alignment_value.rs +++ b/tests/ui/transmutability/non_scalar_alignment_value.rs @@ -1,6 +1,4 @@ -#![feature(min_generic_const_args)] - -#![feature(transmutability)] +#![feature(min_generic_const_args, macroless_generic_const_args, transmutability)] mod assert { use std::mem::{Assume, TransmuteFrom}; diff --git a/tests/ui/transmutability/non_scalar_alignment_value.stderr b/tests/ui/transmutability/non_scalar_alignment_value.stderr index 99d1852b7790b..80a125d540a8f 100644 --- a/tests/ui/transmutability/non_scalar_alignment_value.stderr +++ b/tests/ui/transmutability/non_scalar_alignment_value.stderr @@ -1,23 +1,23 @@ error: struct expression with missing field initialiser for `alignment` - --> $DIR/non_scalar_alignment_value.rs:14:32 + --> $DIR/non_scalar_alignment_value.rs:12:32 | LL | alignment: Assume {}, | ^^^^^^^^^ error: struct expression with missing field initialiser for `lifetimes` - --> $DIR/non_scalar_alignment_value.rs:14:32 + --> $DIR/non_scalar_alignment_value.rs:12:32 | LL | alignment: Assume {}, | ^^^^^^^^^ error: struct expression with missing field initialiser for `safety` - --> $DIR/non_scalar_alignment_value.rs:14:32 + --> $DIR/non_scalar_alignment_value.rs:12:32 | LL | alignment: Assume {}, | ^^^^^^^^^ error: struct expression with missing field initialiser for `validity` - --> $DIR/non_scalar_alignment_value.rs:14:32 + --> $DIR/non_scalar_alignment_value.rs:12:32 | LL | alignment: Assume {}, | ^^^^^^^^^ diff --git a/tests/ui/type-alias/recursive-lazy-type-alias-ice-152633.rs b/tests/ui/type-alias/recursive-lazy-type-alias-ice-152633.rs index ac20f5862edd5..9180623a6c66c 100644 --- a/tests/ui/type-alias/recursive-lazy-type-alias-ice-152633.rs +++ b/tests/ui/type-alias/recursive-lazy-type-alias-ice-152633.rs @@ -3,8 +3,7 @@ //! //! Regression test for . -#![feature(checked_type_aliases)] -#![feature(min_generic_const_args)] +#![feature(checked_type_aliases, min_generic_const_args, macroless_generic_const_args)] trait Trait { type const ASSOC: (); diff --git a/tests/ui/type-alias/recursive-lazy-type-alias-ice-152633.stderr b/tests/ui/type-alias/recursive-lazy-type-alias-ice-152633.stderr index a8e68a05253b9..f432026449e12 100644 --- a/tests/ui/type-alias/recursive-lazy-type-alias-ice-152633.stderr +++ b/tests/ui/type-alias/recursive-lazy-type-alias-ice-152633.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow normalizing the type alias `Arr2` - --> $DIR/recursive-lazy-type-alias-ice-152633.rs:12:1 + --> $DIR/recursive-lazy-type-alias-ice-152633.rs:11:1 | LL | type Arr2 = [usize; ::ASSOC]; | ^^^^^^^^^ diff --git a/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.rs b/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.rs index 5f2d6680efac6..c8ae449d13856 100644 --- a/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.rs +++ b/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.rs @@ -1,7 +1,7 @@ //@ compile-flags: -Zunpretty=hir //@ check-pass -#![feature(min_generic_const_args, adt_const_params)] +#![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] #![allow(dead_code)] diff --git a/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.stdout b/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.stdout index 8c016f5083d24..974ffd3b9c4e1 100644 --- a/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.stdout +++ b/tests/ui/unpretty/struct-exprs-tuple-call-pretty-printing.stdout @@ -3,7 +3,8 @@ #![expect(incomplete_features)] #![allow(dead_code)] -#![attr = Feature([min_generic_const_args#0, adt_const_params#0])] +#![attr = Feature([min_generic_const_args#0, macroless_generic_const_args#0, +adt_const_params#0])] extern crate std; #[attr = PreludeImport] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/use/import_trait_associated_item_bad.rs b/tests/ui/use/import_trait_associated_item_bad.rs index d3d2a8e83cdde..cb45004e4e335 100644 --- a/tests/ui/use/import_trait_associated_item_bad.rs +++ b/tests/ui/use/import_trait_associated_item_bad.rs @@ -1,5 +1,4 @@ -#![feature(import_trait_associated_functions)] -#![feature(min_generic_const_args)] +#![feature(import_trait_associated_functions, min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features)] trait Trait { diff --git a/tests/ui/use/import_trait_associated_item_bad.stderr b/tests/ui/use/import_trait_associated_item_bad.stderr index d5cd5d37bd714..dcd892076dd1b 100644 --- a/tests/ui/use/import_trait_associated_item_bad.stderr +++ b/tests/ui/use/import_trait_associated_item_bad.stderr @@ -1,5 +1,5 @@ error[E0223]: ambiguous associated type - --> $DIR/import_trait_associated_item_bad.rs:11:15 + --> $DIR/import_trait_associated_item_bad.rs:10:15 | LL | type Alias1 = AssocTy; | ^^^^^^^ @@ -10,7 +10,7 @@ LL | type Alias1 = ::AssocTy; | ++++++++++++++++++++ error[E0223]: ambiguous associated type - --> $DIR/import_trait_associated_item_bad.rs:12:15 + --> $DIR/import_trait_associated_item_bad.rs:11:15 | LL | type Alias2 = self::AssocTy; | ^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL + type Alias2 = ::AssocTy; | error[E0223]: ambiguous associated constant - --> $DIR/import_trait_associated_item_bad.rs:15:20 + --> $DIR/import_trait_associated_item_bad.rs:14:20 | LL | type Alias3 = [u8; CONST]; | ^^^^^ @@ -33,7 +33,7 @@ LL | type Alias3 = [u8; ::CONST]; | ++++++++++++++++++++ error[E0223]: ambiguous associated constant - --> $DIR/import_trait_associated_item_bad.rs:16:20 + --> $DIR/import_trait_associated_item_bad.rs:15:20 | LL | type Alias4 = [u8; self::CONST]; | ^^^^^^^^^^^