diff options
160 files changed, 2005 insertions, 1537 deletions
diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 851ab46345f..98138cedb24 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -387,7 +387,7 @@ impl MetaItemKind { tokens: &mut impl Iterator<Item = &'a TokenTree>, ) -> Option<MetaItemKind> { match tokens.next() { - Some(TokenTree::Delimited(_, Delimiter::Invisible, inner_tokens)) => { + Some(TokenTree::Delimited(.., Delimiter::Invisible, inner_tokens)) => { MetaItemKind::name_value_from_tokens(&mut inner_tokens.trees()) } Some(TokenTree::Token(token, _)) => { @@ -401,7 +401,7 @@ impl MetaItemKind { tokens: &mut iter::Peekable<impl Iterator<Item = &'a TokenTree>>, ) -> Option<MetaItemKind> { match tokens.peek() { - Some(TokenTree::Delimited(_, Delimiter::Parenthesis, inner_tokens)) => { + Some(TokenTree::Delimited(.., Delimiter::Parenthesis, inner_tokens)) => { let inner_tokens = inner_tokens.clone(); tokens.next(); MetaItemKind::list_from_tokens(inner_tokens).map(MetaItemKind::List) @@ -524,7 +524,7 @@ impl NestedMetaItem { tokens.next(); return Some(NestedMetaItem::Lit(lit)); } - Some(TokenTree::Delimited(_, Delimiter::Invisible, inner_tokens)) => { + Some(TokenTree::Delimited(.., Delimiter::Invisible, inner_tokens)) => { tokens.next(); return NestedMetaItem::from_tokens(&mut inner_tokens.trees().peekable()); } diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 01defcff9ef..10b2025f937 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -682,7 +682,7 @@ pub fn visit_attr_tt<T: MutVisitor>(tt: &mut AttrTokenTree, vis: &mut T) { AttrTokenTree::Token(token, _) => { visit_token(token, vis); } - AttrTokenTree::Delimited(DelimSpan { open, close }, _delim, tts) => { + AttrTokenTree::Delimited(DelimSpan { open, close }, _spacing, _delim, tts) => { vis.visit_span(open); vis.visit_span(close); visit_attr_tts(tts, vis); @@ -709,7 +709,7 @@ pub fn visit_tt<T: MutVisitor>(tt: &mut TokenTree, vis: &mut T) { TokenTree::Token(token, _) => { visit_token(token, vis); } - TokenTree::Delimited(DelimSpan { open, close }, _delim, tts) => { + TokenTree::Delimited(DelimSpan { open, close }, _spacing, _delim, tts) => { vis.visit_span(open); vis.visit_span(close); visit_tts(tts, vis); diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 48854bbae24..4c0c496584e 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -46,7 +46,7 @@ pub enum TokenTree { /// delimiters are implicitly represented by `Delimited`. Token(Token, Spacing), /// A delimited sequence of token trees. - Delimited(DelimSpan, Delimiter, TokenStream), + Delimited(DelimSpan, DelimSpacing, Delimiter, TokenStream), } // Ensure all fields of `TokenTree` are `DynSend` and `DynSync`. @@ -62,11 +62,11 @@ where } impl TokenTree { - /// Checks if this `TokenTree` is equal to the other, regardless of span information. + /// Checks if this `TokenTree` is equal to the other, regardless of span/spacing information. pub fn eq_unspanned(&self, other: &TokenTree) -> bool { match (self, other) { (TokenTree::Token(token, _), TokenTree::Token(token2, _)) => token.kind == token2.kind, - (TokenTree::Delimited(_, delim, tts), TokenTree::Delimited(_, delim2, tts2)) => { + (TokenTree::Delimited(.., delim, tts), TokenTree::Delimited(.., delim2, tts2)) => { delim == delim2 && tts.eq_unspanned(tts2) } _ => false, @@ -99,6 +99,11 @@ impl TokenTree { TokenTree::Token(Token::new(kind, span), Spacing::Joint) } + /// Create a `TokenTree::Token` with joint-hidden spacing. + pub fn token_joint_hidden(kind: TokenKind, span: Span) -> TokenTree { + TokenTree::Token(Token::new(kind, span), Spacing::JointHidden) + } + pub fn uninterpolate(&self) -> Cow<'_, TokenTree> { match self { TokenTree::Token(token, spacing) => match token.uninterpolate() { @@ -183,7 +188,7 @@ pub struct AttrTokenStream(pub Lrc<Vec<AttrTokenTree>>); #[derive(Clone, Debug, Encodable, Decodable)] pub enum AttrTokenTree { Token(Token, Spacing), - Delimited(DelimSpan, Delimiter, AttrTokenStream), + Delimited(DelimSpan, DelimSpacing, Delimiter, AttrTokenStream), /// Stores the attributes for an attribute target, /// along with the tokens for that attribute target. /// See `AttributesData` for more information @@ -208,9 +213,14 @@ impl AttrTokenStream { AttrTokenTree::Token(inner, spacing) => { smallvec![TokenTree::Token(inner.clone(), *spacing)].into_iter() } - AttrTokenTree::Delimited(span, delim, stream) => { - smallvec![TokenTree::Delimited(*span, *delim, stream.to_tokenstream()),] - .into_iter() + AttrTokenTree::Delimited(span, spacing, delim, stream) => { + smallvec![TokenTree::Delimited( + *span, + *spacing, + *delim, + stream.to_tokenstream() + ),] + .into_iter() } AttrTokenTree::Attributes(data) => { let idx = data @@ -230,7 +240,7 @@ impl AttrTokenStream { let mut found = false; // Check the last two trees (to account for a trailing semi) for tree in target_tokens.iter_mut().rev().take(2) { - if let TokenTree::Delimited(span, delim, delim_tokens) = tree { + if let TokenTree::Delimited(span, spacing, delim, delim_tokens) = tree { // Inner attributes are only supported on extern blocks, functions, // impls, and modules. All of these have their inner attributes // placed at the beginning of the rightmost outermost braced group: @@ -250,7 +260,7 @@ impl AttrTokenStream { stream.push_stream(inner_attr.tokens()); } stream.push_stream(delim_tokens.clone()); - *tree = TokenTree::Delimited(*span, *delim, stream); + *tree = TokenTree::Delimited(*span, *spacing, *delim, stream); found = true; break; } @@ -303,21 +313,64 @@ pub struct AttributesData { #[derive(Clone, Debug, Default, Encodable, Decodable)] pub struct TokenStream(pub(crate) Lrc<Vec<TokenTree>>); -/// Similar to `proc_macro::Spacing`, but for tokens. -/// -/// Note that all `ast::TokenTree::Token` instances have a `Spacing`, but when -/// we convert to `proc_macro::TokenTree` for proc macros only `Punct` -/// `TokenTree`s have a `proc_macro::Spacing`. +/// Indicates whether a token can join with the following token to form a +/// compound token. Used for conversions to `proc_macro::Spacing`. Also used to +/// guide pretty-printing, which is where the `JointHidden` value (which isn't +/// part of `proc_macro::Spacing`) comes in useful. #[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)] pub enum Spacing { - /// The token is not immediately followed by an operator token (as - /// determined by `Token::is_op`). E.g. a `+` token is `Alone` in `+ =`, - /// `+/*foo*/=`, `+ident`, and `+()`. + /// The token cannot join with the following token to form a compound + /// token. + /// + /// In token streams parsed from source code, the compiler will use `Alone` + /// for any token immediately followed by whitespace, a non-doc comment, or + /// EOF. + /// + /// When constructing token streams within the compiler, use this for each + /// token that (a) should be pretty-printed with a space after it, or (b) + /// is the last token in the stream. (In the latter case the choice of + /// spacing doesn't matter because it is never used for the last token. We + /// arbitrarily use `Alone`.) + /// + /// Converts to `proc_macro::Spacing::Alone`, and + /// `proc_macro::Spacing::Alone` converts back to this. Alone, - /// The token is immediately followed by an operator token. E.g. a `+` - /// token is `Joint` in `+=` and `++`. + /// The token can join with the following token to form a compound token. + /// + /// In token streams parsed from source code, the compiler will use `Joint` + /// for any token immediately followed by punctuation (as determined by + /// `Token::is_punct`). + /// + /// When constructing token streams within the compiler, use this for each + /// token that (a) should be pretty-printed without a space after it, and + /// (b) is followed by a punctuation token. + /// + /// Converts to `proc_macro::Spacing::Joint`, and + /// `proc_macro::Spacing::Joint` converts back to this. Joint, + + /// The token can join with the following token to form a compound token, + /// but this will not be visible at the proc macro level. (This is what the + /// `Hidden` means; see below.) + /// + /// In token streams parsed from source code, the compiler will use + /// `JointHidden` for any token immediately followed by anything not + /// covered by the `Alone` and `Joint` cases: an identifier, lifetime, + /// literal, delimiter, doc comment. + /// + /// When constructing token streams, use this for each token that (a) + /// should be pretty-printed without a space after it, and (b) is followed + /// by a non-punctuation token. + /// + /// Converts to `proc_macro::Spacing::Alone`, but + /// `proc_macro::Spacing::Alone` converts back to `token::Spacing::Alone`. + /// Because of that, pretty-printing of `TokenStream`s produced by proc + /// macros is unavoidably uglier (with more whitespace between tokens) than + /// pretty-printing of `TokenStream`'s produced by other means (i.e. parsed + /// source code, internally constructed token streams, and token streams + /// produced by declarative macros). + JointHidden, } impl TokenStream { @@ -421,21 +474,14 @@ impl TokenStream { self } - /// Create a token stream containing a single token with alone spacing. + /// Create a token stream containing a single token with alone spacing. The + /// spacing used for the final token in a constructed stream doesn't matter + /// because it's never used. In practice we arbitrarily use + /// `Spacing::Alone`. pub fn token_alone(kind: TokenKind, span: Span) -> TokenStream { TokenStream::new(vec![TokenTree::token_alone(kind, span)]) } - /// Create a token stream containing a single token with joint spacing. - pub fn token_joint(kind: TokenKind, span: Span) -> TokenStream { - TokenStream::new(vec![TokenTree::token_joint(kind, span)]) - } - - /// Create a token stream containing a single `Delimited`. - pub fn delimited(span: DelimSpan, delim: Delimiter, tts: TokenStream) -> TokenStream { - TokenStream::new(vec![TokenTree::Delimited(span, delim, tts)]) - } - pub fn from_ast(node: &(impl HasAttrs + HasSpan + HasTokens + fmt::Debug)) -> TokenStream { let Some(tokens) = node.tokens() else { panic!("missing tokens for node at {:?}: {:?}", node.span(), node); @@ -482,6 +528,7 @@ impl TokenStream { } token::Interpolated(nt) => TokenTree::Delimited( DelimSpan::from_single(token.span), + DelimSpacing::new(Spacing::JointHidden, spacing), Delimiter::Invisible, TokenStream::from_nonterminal_ast(&nt.0).flattened(), ), @@ -492,8 +539,8 @@ impl TokenStream { fn flatten_token_tree(tree: &TokenTree) -> TokenTree { match tree { TokenTree::Token(token, spacing) => TokenStream::flatten_token(token, *spacing), - TokenTree::Delimited(span, delim, tts) => { - TokenTree::Delimited(*span, *delim, tts.flattened()) + TokenTree::Delimited(span, spacing, delim, tts) => { + TokenTree::Delimited(*span, *spacing, *delim, tts.flattened()) } } } @@ -503,7 +550,7 @@ impl TokenStream { fn can_skip(stream: &TokenStream) -> bool { stream.trees().all(|tree| match tree { TokenTree::Token(token, _) => !matches!(token.kind, token::Interpolated(_)), - TokenTree::Delimited(_, _, inner) => can_skip(inner), + TokenTree::Delimited(.., inner) => can_skip(inner), }) } @@ -517,7 +564,7 @@ impl TokenStream { // If `vec` is not empty, try to glue `tt` onto its last token. The return // value indicates if gluing took place. fn try_glue_to_last(vec: &mut Vec<TokenTree>, tt: &TokenTree) -> bool { - if let Some(TokenTree::Token(last_tok, Spacing::Joint)) = vec.last() + if let Some(TokenTree::Token(last_tok, Spacing::Joint | Spacing::JointHidden)) = vec.last() && let TokenTree::Token(tok, spacing) = tt && let Some(glued_tok) = last_tok.glue(tok) { @@ -592,9 +639,10 @@ impl TokenStream { &TokenTree::Token(..) => i += 1, - &TokenTree::Delimited(sp, delim, ref delim_stream) => { + &TokenTree::Delimited(sp, spacing, delim, ref delim_stream) => { if let Some(desugared_delim_stream) = desugar_inner(delim_stream.clone()) { - let new_tt = TokenTree::Delimited(sp, delim, desugared_delim_stream); + let new_tt = + TokenTree::Delimited(sp, spacing, delim, desugared_delim_stream); Lrc::make_mut(&mut stream.0)[i] = new_tt; modified = true; } @@ -622,10 +670,11 @@ impl TokenStream { num_of_hashes = cmp::max(num_of_hashes, count); } - // `/// foo` becomes `doc = r"foo"`. + // `/// foo` becomes `[doc = r"foo"]`. let delim_span = DelimSpan::from_single(span); let body = TokenTree::Delimited( delim_span, + DelimSpacing::new(Spacing::JointHidden, Spacing::Alone), Delimiter::Bracket, [ TokenTree::token_alone(token::Ident(sym::doc, false), span), @@ -641,7 +690,7 @@ impl TokenStream { if attr_style == AttrStyle::Inner { vec![ - TokenTree::token_alone(token::Pound, span), + TokenTree::token_joint(token::Pound, span), TokenTree::token_alone(token::Not, span), body, ] @@ -738,6 +787,18 @@ impl DelimSpan { } } +#[derive(Copy, Clone, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)] +pub struct DelimSpacing { + pub open: Spacing, + pub close: Spacing, +} + +impl DelimSpacing { + pub fn new(open: Spacing, close: Spacing) -> DelimSpacing { + DelimSpacing { open, close } + } +} + // Some types are used a lot. Make sure they don't unintentionally get bigger. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] mod size_asserts { diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index ff36e6c2845..0fae2c78e27 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -10,7 +10,7 @@ use crate::pp::{self, Breaks}; use rustc_ast::attr::AttrIdGenerator; use rustc_ast::ptr::P; use rustc_ast::token::{self, BinOpToken, CommentKind, Delimiter, Nonterminal, Token, TokenKind}; -use rustc_ast::tokenstream::{TokenStream, TokenTree}; +use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree}; use rustc_ast::util::classify; use rustc_ast::util::comments::{gather_comments, Comment, CommentStyle}; use rustc_ast::util::parser; @@ -183,10 +183,10 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool { // // FIXME: Incorrect cases: // - Let: `let(a, b) = (1, 2)` - (Tok(Token { kind: Ident(..), .. }, _), Del(_, Parenthesis, _)) => false, + (Tok(Token { kind: Ident(..), .. }, _), Del(_, _, Parenthesis, _)) => false, // `#` + `[`: `#[attr]` - (Tok(Token { kind: Pound, .. }, _), Del(_, Bracket, _)) => false, + (Tok(Token { kind: Pound, .. }, _), Del(_, _, Bracket, _)) => false, _ => true, } @@ -509,16 +509,17 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere /// appropriate macro, transcribe back into the grammar we just parsed from, /// and then pretty-print the resulting AST nodes (so, e.g., we print /// expression arguments as expressions). It can be done! I think. - fn print_tt(&mut self, tt: &TokenTree, convert_dollar_crate: bool) { + fn print_tt(&mut self, tt: &TokenTree, convert_dollar_crate: bool) -> Spacing { match tt { - TokenTree::Token(token, _) => { + TokenTree::Token(token, spacing) => { let token_str = self.token_to_string_ext(token, convert_dollar_crate); self.word(token_str); if let token::DocComment(..) = token.kind { self.hardbreak() } + *spacing } - TokenTree::Delimited(dspan, delim, tts) => { + TokenTree::Delimited(dspan, spacing, delim, tts) => { self.print_mac_common( None, false, @@ -528,6 +529,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere convert_dollar_crate, dspan.entire(), ); + spacing.close } } } @@ -535,9 +537,20 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere fn print_tts(&mut self, tts: &TokenStream, convert_dollar_crate: bool) { let mut iter = tts.trees().peekable(); while let Some(tt) = iter.next() { - self.print_tt(tt, convert_dollar_crate); + let spacing = self.print_tt(tt, convert_dollar_crate); if let Some(next) = iter.peek() { - if space_between(tt, next) { + // Should we print a space after `tt`? There are two guiding + // factors. + // - `spacing` is the more important and accurate one. Most + // tokens have good spacing information, and + // `Joint`/`JointHidden` get used a lot. + // - `space_between` is the backup. Code produced by proc + // macros has worse spacing information, with no + // `JointHidden` usage and too much `Alone` usage, which + // would result in over-spaced output such as + // `( x () , y . z )`. `space_between` avoids some of the + // excess whitespace. + if spacing == Spacing::Alone && space_between(tt, next) { self.space(); } } @@ -1797,7 +1810,9 @@ impl<'a> State<'a> { } pub(crate) fn tt_to_string(&self, tt: &TokenTree) -> String { - Self::to_string(|s| s.print_tt(tt, false)) + Self::to_string(|s| { + s.print_tt(tt, false); + }) } pub(crate) fn tts_to_string(&self, tokens: &TokenStream) -> String { diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs index 2a4bfe9e200..b54e119189a 100644 --- a/compiler/rustc_builtin_macros/src/assert/context.rs +++ b/compiler/rustc_builtin_macros/src/assert/context.rs @@ -151,7 +151,7 @@ impl<'cx, 'a> Context<'cx, 'a> { fn build_panic(&self, expr_str: &str, panic_path: Path) -> P<Expr> { let escaped_expr_str = escape_to_fmt(expr_str); let initial = [ - TokenTree::token_alone( + TokenTree::token_joint_hidden( token::Literal(token::Lit { kind: token::LitKind::Str, symbol: Symbol::intern(&if self.fmt_string.is_empty() { @@ -170,7 +170,7 @@ impl<'cx, 'a> Context<'cx, 'a> { ]; let captures = self.capture_decls.iter().flat_map(|cap| { [ - TokenTree::token_alone(token::Ident(cap.ident.name, false), cap.ident.span), + TokenTree::token_joint_hidden(token::Ident(cap.ident.name, false), cap.ident.span), TokenTree::token_alone(token::Comma, self.span), ] }); diff --git a/compiler/rustc_builtin_macros/src/env.rs b/compiler/rustc_builtin_macros/src/env.rs index 8c2fa6ee95f..d772642b88b 100644 --- a/compiler/rustc_builtin_macros/src/env.rs +++ b/compiler/rustc_builtin_macros/src/env.rs @@ -13,6 +13,16 @@ use thin_vec::thin_vec; use crate::errors; +fn lookup_env<'cx>(cx: &'cx ExtCtxt<'_>, var: Symbol) -> Option<Symbol> { + let var = var.as_str(); + if let Some(value) = cx.sess.opts.logical_env.get(var) { + return Some(Symbol::intern(value)); + } + // If the environment variable was not defined with the `--env` option, we try to retrieve it + // from rustc's environment. + env::var(var).ok().as_deref().map(Symbol::intern) +} + pub fn expand_option_env<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, @@ -23,7 +33,7 @@ pub fn expand_option_env<'cx>( }; let sp = cx.with_def_site_ctxt(sp); - let value = env::var(var.as_str()).ok().as_deref().map(Symbol::intern); + let value = lookup_env(cx, var); cx.sess.parse_sess.env_depinfo.borrow_mut().insert((var, value)); let e = match value { None => { @@ -77,7 +87,7 @@ pub fn expand_env<'cx>( }; let span = cx.with_def_site_ctxt(sp); - let value = env::var(var.as_str()).ok().as_deref().map(Symbol::intern); + let value = lookup_env(cx, var); cx.sess.parse_sess.env_depinfo.borrow_mut().insert((var, value)); let e = match value { None => { diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index f16014e1361..23b424f25ba 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -10,7 +10,7 @@ use crate::value::Value; use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh, wants_wasm_eh}; use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; use rustc_codegen_ssa::errors::{ExpectedPointerMutability, InvalidMonomorphization}; -use rustc_codegen_ssa::mir::operand::OperandRef; +use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::traits::*; use rustc_hir as hir; @@ -946,6 +946,13 @@ fn generic_simd_intrinsic<'ll, 'tcx>( tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), callee_ty.fn_sig(tcx)); let arg_tys = sig.inputs(); + // Vectors must be immediates (non-power-of-2 #[repr(packed)] are not) + for (ty, arg) in arg_tys.iter().zip(args) { + if ty.is_simd() && !matches!(arg.val, OperandValue::Immediate(_)) { + return_error!(InvalidMonomorphization::SimdArgument { span, name, ty: *ty }); + } + } + if name == sym::simd_select_bitmask { let (len, _) = require_simd!(arg_tys[1], SimdArgument); diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs index d724f9503bb..feee3ac03d0 100644 --- a/compiler/rustc_codegen_ssa/src/mir/operand.rs +++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs @@ -155,7 +155,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { Abi::Scalar(s @ abi::Scalar::Initialized { .. }) => { let size = s.size(bx); assert_eq!(size, layout.size, "abi::Scalar size does not match layout size"); - let val = read_scalar(offset, size, s, bx.backend_type(layout)); + let val = read_scalar(offset, size, s, bx.immediate_backend_type(layout)); OperandRef { val: OperandValue::Immediate(val), layout } } Abi::ScalarPair( diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index e48506bd083..2358caffc9b 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -384,10 +384,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } // Compatible integer types (in particular, usize vs ptr-sized-u32/u64). + // `char` counts as `u32.` let int_ty = |ty: Ty<'tcx>| { Some(match ty.kind() { ty::Int(ity) => (Integer::from_int_ty(&self.tcx, *ity), /* signed */ true), ty::Uint(uty) => (Integer::from_uint_ty(&self.tcx, *uty), /* signed */ false), + ty::Char => (Integer::I32, /* signed */ false), _ => return None, }) }; diff --git a/compiler/rustc_error_codes/src/error_codes/E0705.md b/compiler/rustc_error_codes/src/error_codes/E0705.md index eb76d1836fc..317f3a47eff 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0705.md +++ b/compiler/rustc_error_codes/src/error_codes/E0705.md @@ -1,9 +1,11 @@ +#### Note: this error code is no longer emitted by the compiler. + A `#![feature]` attribute was declared for a feature that is stable in the current edition, but not in all editions. Erroneous code example: -```rust2018,compile_fail,E0705 +```compile_fail #![feature(rust_2018_preview)] #![feature(test_2018_feature)] // error: the feature // `test_2018_feature` is diff --git a/compiler/rustc_expand/messages.ftl b/compiler/rustc_expand/messages.ftl index fc3f7b1d749..475dd348e7b 100644 --- a/compiler/rustc_expand/messages.ftl +++ b/compiler/rustc_expand/messages.ftl @@ -35,9 +35,6 @@ expand_explain_doc_comment_outer = expand_expr_repeat_no_syntax_vars = attempted to repeat an expression containing no syntax variables matched as repeating at this depth -expand_feature_included_in_edition = - the feature `{$feature}` is included in the Rust {$edition} edition - expand_feature_not_allowed = the feature `{$name}` is not in the list of allowed features diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs index 5ccef343b17..0b56dbb2c19 100644 --- a/compiler/rustc_expand/src/config.rs +++ b/compiler/rustc_expand/src/config.rs @@ -1,25 +1,22 @@ //! Conditional compilation stripping. use crate::errors::{ - FeatureIncludedInEdition, FeatureNotAllowed, FeatureRemoved, FeatureRemovedReason, InvalidCfg, - MalformedFeatureAttribute, MalformedFeatureAttributeHelp, RemoveExprNotSupported, + FeatureNotAllowed, FeatureRemoved, FeatureRemovedReason, InvalidCfg, MalformedFeatureAttribute, + MalformedFeatureAttributeHelp, RemoveExprNotSupported, }; use rustc_ast::ptr::P; use rustc_ast::token::{Delimiter, Token, TokenKind}; -use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree}; -use rustc_ast::tokenstream::{DelimSpan, Spacing}; +use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree, DelimSpacing, DelimSpan, Spacing}; use rustc_ast::tokenstream::{LazyAttrTokenStream, TokenTree}; use rustc_ast::NodeId; use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem}; use rustc_attr as attr; use rustc_data_structures::flat_map_in_place::FlatMapInPlace; -use rustc_data_structures::fx::FxHashSet; use rustc_feature::Features; use rustc_feature::{ACCEPTED_FEATURES, REMOVED_FEATURES, UNSTABLE_FEATURES}; use rustc_parse::validate_attr; use rustc_session::parse::feature_err; use rustc_session::Session; -use rustc_span::edition::ALL_EDITIONS; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; use thin_vec::ThinVec; @@ -48,42 +45,6 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) - let mut features = Features::default(); - // The edition from `--edition`. - let crate_edition = sess.edition(); - - // The maximum of (a) the edition from `--edition` and (b) any edition - // umbrella feature-gates declared in the code. - // - E.g. if `crate_edition` is 2015 but `rust_2018_preview` is present, - // `feature_edition` is 2018 - let mut features_edition = crate_edition; - for attr in krate_attrs { - for mi in feature_list(attr) { - if mi.is_word() { - let name = mi.name_or_empty(); - let edition = ALL_EDITIONS.iter().find(|e| name == e.feature_name()).copied(); - if let Some(edition) = edition - && edition > features_edition - { - features_edition = edition; - } - } - } - } - - // Enable edition-dependent features based on `features_edition`. - // - E.g. enable `test_2018_feature` if `features_edition` is 2018 or higher - let mut edition_enabled_features = FxHashSet::default(); - for f in UNSTABLE_FEATURES { - if let Some(edition) = f.feature.edition - && edition <= features_edition - { - // FIXME(Manishearth) there is currently no way to set lib features by - // edition. - edition_enabled_features.insert(f.feature.name); - (f.set_enabled)(&mut features); - } - } - // Process all features declared in the code. for attr in krate_attrs { for mi in feature_list(attr) { @@ -108,38 +69,6 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) - } }; - // If the declared feature is an edition umbrella feature-gate, - // warn if it was redundant w.r.t. `crate_edition`. - // - E.g. warn if `rust_2018_preview` is declared when - // `crate_edition` is 2018 - // - E.g. don't warn if `rust_2018_preview` is declared when - // `crate_edition` is 2015. - if let Some(&edition) = ALL_EDITIONS.iter().find(|e| name == e.feature_name()) { - if edition <= crate_edition { - sess.emit_warning(FeatureIncludedInEdition { - span: mi.span(), - feature: name, - edition, - }); - } - features.set_declared_lang_feature(name, mi.span(), None); - continue; - } - - // If the declared feature is edition-dependent and was already - // enabled due to `feature_edition`, give a warning. - // - E.g. warn if `test_2018_feature` is declared when - // `feature_edition` is 2018 or higher. - if edition_enabled_features.contains(&name) { - sess.emit_warning(FeatureIncludedInEdition { - span: mi.span(), - feature: name, - edition: features_edition, - }); - features.set_declared_lang_feature(name, mi.span(), None); - continue; - } - // If the declared feature has been removed, issue an error. if let Some(f) = REMOVED_FEATURES.iter().find(|f| name == f.feature.name) { sess.emit_err(FeatureRemoved { @@ -242,7 +171,7 @@ impl<'a> StripUnconfigured<'a> { stream.0.iter().all(|tree| match tree { AttrTokenTree::Attributes(_) => false, AttrTokenTree::Token(..) => true, - AttrTokenTree::Delimited(_, _, inner) => can_skip(inner), + AttrTokenTree::Delimited(.., inner) => can_skip(inner), }) } @@ -266,9 +195,9 @@ impl<'a> StripUnconfigured<'a> { None.into_iter() } } - AttrTokenTree::Delimited(sp, delim, mut inner) => { + AttrTokenTree::Delimited(sp, spacing, delim, mut inner) => { inner = self.configure_tokens(&inner); - Some(AttrTokenTree::Delimited(sp, delim, inner)).into_iter() + Some(AttrTokenTree::Delimited(sp, spacing, delim, inner)).into_iter() } AttrTokenTree::Token(ref token, _) if let TokenKind::Interpolated(nt) = &token.kind => @@ -372,27 +301,32 @@ impl<'a> StripUnconfigured<'a> { }; let pound_span = pound_token.span; - let mut trees = vec![AttrTokenTree::Token(pound_token, Spacing::Alone)]; - if attr.style == AttrStyle::Inner { - // For inner attributes, we do the same thing for the `!` in `#![some_attr]` - let TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _) = - orig_trees.next().unwrap().clone() - else { - panic!("Bad tokens for attribute {attr:?}"); - }; - trees.push(AttrTokenTree::Token(bang_token, Spacing::Alone)); - } // We don't really have a good span to use for the synthesized `[]` // in `#[attr]`, so just use the span of the `#` token. let bracket_group = AttrTokenTree::Delimited( DelimSpan::from_single(pound_span), + DelimSpacing::new(Spacing::JointHidden, Spacing::Alone), Delimiter::Bracket, item.tokens .as_ref() .unwrap_or_else(|| panic!("Missing tokens for {item:?}")) .to_attr_token_stream(), ); - trees.push(bracket_group); + let trees = if attr.style == AttrStyle::Inner { + // For inner attributes, we do the same thing for the `!` in `#![some_attr]` + let TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _) = + orig_trees.next().unwrap().clone() + else { + panic!("Bad tokens for attribute {attr:?}"); + }; + vec![ + AttrTokenTree::Token(pound_token, Spacing::Joint), + AttrTokenTree::Token(bang_token, Spacing::JointHidden), + bracket_group, + ] + } else { + vec![AttrTokenTree::Token(pound_token, Spacing::JointHidden), bracket_group] + }; let tokens = Some(LazyAttrTokenStream::new(AttrTokenStream::new(trees))); let attr = attr::mk_attr_from_item( &self.sess.parse_sess.attr_id_generator, diff --git a/compiler/rustc_expand/src/errors.rs b/compiler/rustc_expand/src/errors.rs index 6e919a8fa9f..2b43fae6852 100644 --- a/compiler/rustc_expand/src/errors.rs +++ b/compiler/rustc_expand/src/errors.rs @@ -1,7 +1,6 @@ use rustc_ast::ast; use rustc_macros::Diagnostic; use rustc_session::Limit; -use rustc_span::edition::Edition; use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent}; use rustc_span::{Span, Symbol}; use std::borrow::Cow; @@ -169,15 +168,6 @@ pub(crate) struct TakesNoArguments<'a> { } #[derive(Diagnostic)] -#[diag(expand_feature_included_in_edition, code = "E0705")] -pub(crate) struct FeatureIncludedInEdition { - #[primary_span] - pub span: Span, - pub feature: Symbol, - pub edition: Edition, -} - -#[derive(Diagnostic)] #[diag(expand_feature_removed, code = "E0557")] pub(crate) struct FeatureRemoved<'a> { #[primary_span] diff --git a/compiler/rustc_expand/src/mbe.rs b/compiler/rustc_expand/src/mbe.rs index a43b2a00188..ca4a1f327ad 100644 --- a/compiler/rustc_expand/src/mbe.rs +++ b/compiler/rustc_expand/src/mbe.rs @@ -13,7 +13,7 @@ pub(crate) mod transcribe; use metavar_expr::MetaVarExpr; use rustc_ast::token::{Delimiter, NonterminalKind, Token, TokenKind}; -use rustc_ast::tokenstream::DelimSpan; +use rustc_ast::tokenstream::{DelimSpacing, DelimSpan}; use rustc_span::symbol::Ident; use rustc_span::Span; @@ -68,7 +68,7 @@ pub(crate) enum KleeneOp { enum TokenTree { Token(Token), /// A delimited sequence, e.g. `($e:expr)` (RHS) or `{ $e }` (LHS). - Delimited(DelimSpan, Delimited), + Delimited(DelimSpan, DelimSpacing, Delimited), /// A kleene-style repetition sequence, e.g. `$($e:expr)*` (RHS) or `$($e),*` (LHS). Sequence(DelimSpan, SequenceRepetition), /// e.g., `$var`. @@ -99,7 +99,7 @@ impl TokenTree { TokenTree::Token(Token { span, .. }) | TokenTree::MetaVar(span, _) | TokenTree::MetaVarDecl(span, _, _) => span, - TokenTree::Delimited(span, _) + TokenTree::Delimited(span, ..) | TokenTree::MetaVarExpr(span, _) | TokenTree::Sequence(span, _) => span.entire(), } diff --git a/compiler/rustc_expand/src/mbe/macro_check.rs b/compiler/rustc_expand/src/mbe/macro_check.rs index 42c91824baf..0b1f25b67c8 100644 --- a/compiler/rustc_expand/src/mbe/macro_check.rs +++ b/compiler/rustc_expand/src/mbe/macro_check.rs @@ -290,7 +290,7 @@ fn check_binders( } // `MetaVarExpr` can not appear in the LHS of a macro arm TokenTree::MetaVarExpr(..) => {} - TokenTree::Delimited(_, ref del) => { + TokenTree::Delimited(.., ref del) => { for tt in &del.tts { check_binders(sess, node_id, tt, macros, binders, ops, valid); } @@ -353,7 +353,7 @@ fn check_occurrences( }; check_ops_is_prefix(sess, node_id, macros, binders, ops, dl.entire(), name); } - TokenTree::Delimited(_, ref del) => { + TokenTree::Delimited(.., ref del) => { check_nested_occurrences(sess, node_id, &del.tts, macros, binders, ops, valid); } TokenTree::Sequence(_, ref seq) => { @@ -435,8 +435,8 @@ fn check_nested_occurrences( // We check that the meta-variable is correctly used. check_occurrences(sess, node_id, tt, macros, binders, ops, valid); } - (NestedMacroState::MacroRulesNotName, TokenTree::Delimited(_, del)) - | (NestedMacroState::MacroName, TokenTree::Delimited(_, del)) + (NestedMacroState::MacroRulesNotName, TokenTree::Delimited(.., del)) + | (NestedMacroState::MacroName, TokenTree::Delimited(.., del)) if del.delim == Delimiter::Brace => { let macro_rules = state == NestedMacroState::MacroRulesNotName; @@ -466,7 +466,7 @@ fn check_nested_occurrences( // We check that the meta-variable is correctly used. check_occurrences(sess, node_id, tt, macros, binders, ops, valid); } - (NestedMacroState::MacroName, TokenTree::Delimited(_, del)) + (NestedMacroState::MacroName, TokenTree::Delimited(.., del)) if del.delim == Delimiter::Parenthesis => { state = NestedMacroState::MacroNameParen; @@ -481,7 +481,7 @@ fn check_nested_occurrences( valid, ); } - (NestedMacroState::MacroNameParen, TokenTree::Delimited(_, del)) + (NestedMacroState::MacroNameParen, TokenTree::Delimited(.., del)) if del.delim == Delimiter::Brace => { state = NestedMacroState::Empty; diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index 965beb9bf84..b248a1fe349 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -184,7 +184,7 @@ pub(super) fn compute_locs(matcher: &[TokenTree]) -> Vec<MatcherLoc> { TokenTree::Token(token) => { locs.push(MatcherLoc::Token { token: token.clone() }); } - TokenTree::Delimited(span, delimited) => { + TokenTree::Delimited(span, _, delimited) => { let open_token = Token::new(token::OpenDelim(delimited.delim), span.open); let close_token = Token::new(token::CloseDelim(delimited.delim), span.close); @@ -335,7 +335,7 @@ pub(super) fn count_metavar_decls(matcher: &[TokenTree]) -> usize { .map(|tt| match tt { TokenTree::MetaVarDecl(..) => 1, TokenTree::Sequence(_, seq) => seq.num_captures, - TokenTree::Delimited(_, delim) => count_metavar_decls(&delim.tts), + TokenTree::Delimited(.., delim) => count_metavar_decls(&delim.tts), TokenTree::Token(..) => 0, TokenTree::MetaVar(..) | TokenTree::MetaVarExpr(..) => unreachable!(), }) diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 19734394382..393eec3997b 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -207,7 +207,7 @@ fn expand_macro<'cx>( match try_success_result { Ok((i, named_matches)) => { let (rhs, rhs_span): (&mbe::Delimited, DelimSpan) = match &rhses[i] { - mbe::TokenTree::Delimited(span, delimited) => (&delimited, *span), + mbe::TokenTree::Delimited(span, _, delimited) => (&delimited, *span), _ => cx.span_bug(sp, "malformed macro rhs"), }; let arm_span = rhses[i].span(); @@ -589,7 +589,7 @@ pub fn compile_declarative_macro( .map(|lhs| { // Ignore the delimiters around the matcher. match lhs { - mbe::TokenTree::Delimited(_, delimited) => { + mbe::TokenTree::Delimited(.., delimited) => { mbe::macro_parser::compute_locs(&delimited.tts) } _ => sess.diagnostic().span_bug(def.span, "malformed macro lhs"), @@ -615,7 +615,7 @@ pub fn compile_declarative_macro( fn check_lhs_nt_follows(sess: &ParseSess, def: &ast::Item, lhs: &mbe::TokenTree) -> bool { // lhs is going to be like TokenTree::Delimited(...), where the // entire lhs is those tts. Or, it can be a "bare sequence", not wrapped in parens. - if let mbe::TokenTree::Delimited(_, delimited) = lhs { + if let mbe::TokenTree::Delimited(.., delimited) = lhs { check_matcher(sess, def, &delimited.tts) } else { let msg = "invalid macro matcher; matchers must be contained in balanced delimiters"; @@ -668,7 +668,7 @@ fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[mbe::TokenTree]) -> bool { | TokenTree::MetaVar(..) | TokenTree::MetaVarDecl(..) | TokenTree::MetaVarExpr(..) => (), - TokenTree::Delimited(_, del) => { + TokenTree::Delimited(.., del) => { if !check_lhs_no_empty_seq(sess, &del.tts) { return false; } @@ -709,14 +709,14 @@ fn check_matcher(sess: &ParseSess, def: &ast::Item, matcher: &[mbe::TokenTree]) fn has_compile_error_macro(rhs: &mbe::TokenTree) -> bool { match rhs { - mbe::TokenTree::Delimited(_sp, d) => { + mbe::TokenTree::Delimited(.., d) => { let has_compile_error = d.tts.array_windows::<3>().any(|[ident, bang, args]| { if let mbe::TokenTree::Token(ident) = ident && let TokenKind::Ident(ident, _) = ident.kind && ident == sym::compile_error && let mbe::TokenTree::Token(bang) = bang && let TokenKind::Not = bang.kind - && let mbe::TokenTree::Delimited(_, del) = args + && let mbe::TokenTree::Delimited(.., del) = args && del.delim != Delimiter::Invisible { true @@ -773,7 +773,7 @@ impl<'tt> FirstSets<'tt> { | TokenTree::MetaVarExpr(..) => { first.replace_with(TtHandle::TtRef(tt)); } - TokenTree::Delimited(span, delimited) => { + TokenTree::Delimited(span, _, delimited) => { build_recur(sets, &delimited.tts); first.replace_with(TtHandle::from_token_kind( token::OpenDelim(delimited.delim), @@ -842,7 +842,7 @@ impl<'tt> FirstSets<'tt> { first.add_one(TtHandle::TtRef(tt)); return first; } - TokenTree::Delimited(span, delimited) => { + TokenTree::Delimited(span, _, delimited) => { first.add_one(TtHandle::from_token_kind( token::OpenDelim(delimited.delim), span.open, @@ -1087,7 +1087,7 @@ fn check_matcher_core<'tt>( suffix_first = build_suffix_first(); } } - TokenTree::Delimited(span, d) => { + TokenTree::Delimited(span, _, d) => { let my_suffix = TokenSet::singleton(TtHandle::from_token_kind( token::CloseDelim(d.delim), span.close, diff --git a/compiler/rustc_expand/src/mbe/metavar_expr.rs b/compiler/rustc_expand/src/mbe/metavar_expr.rs index 7cb279a9812..c29edc3dc9f 100644 --- a/compiler/rustc_expand/src/mbe/metavar_expr.rs +++ b/compiler/rustc_expand/src/mbe/metavar_expr.rs @@ -35,7 +35,7 @@ impl MetaVarExpr { ) -> PResult<'sess, MetaVarExpr> { let mut tts = input.trees(); let ident = parse_ident(&mut tts, sess, outer_span)?; - let Some(TokenTree::Delimited(_, Delimiter::Parenthesis, args)) = tts.next() else { + let Some(TokenTree::Delimited(.., Delimiter::Parenthesis, args)) = tts.next() else { let msg = "meta-variable expression parameter must be wrapped in parentheses"; return Err(sess.span_diagnostic.struct_span_err(ident.span, msg)); }; diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 6a99412fc5b..ab9fb20b364 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -151,7 +151,7 @@ fn parse_tree<'a>( // during parsing. let mut next = outer_trees.next(); let mut trees: Box<dyn Iterator<Item = &tokenstream::TokenTree>>; - if let Some(tokenstream::TokenTree::Delimited(_, Delimiter::Invisible, tts)) = next { + if let Some(tokenstream::TokenTree::Delimited(.., Delimiter::Invisible, tts)) = next { trees = Box::new(tts.trees()); next = trees.next(); } else { @@ -160,7 +160,7 @@ fn parse_tree<'a>( match next { // `tree` is followed by a delimited set of token trees. - Some(&tokenstream::TokenTree::Delimited(delim_span, delim, ref tts)) => { + Some(&tokenstream::TokenTree::Delimited(delim_span, _, delim, ref tts)) => { if parsing_patterns { if delim != Delimiter::Parenthesis { span_dollar_dollar_or_metavar_in_the_lhs_err( @@ -258,8 +258,9 @@ fn parse_tree<'a>( // `tree` is the beginning of a delimited set of tokens (e.g., `(` or `{`). We need to // descend into the delimited set and further parse it. - &tokenstream::TokenTree::Delimited(span, delim, ref tts) => TokenTree::Delimited( + &tokenstream::TokenTree::Delimited(span, spacing, delim, ref tts) => TokenTree::Delimited( span, + spacing, Delimited { delim, tts: parse(tts, parsing_patterns, sess, node_id, features, edition), diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index bc03fc0d1b1..18707cebcd5 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -7,7 +7,7 @@ use crate::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, MatchedTokenTree, use crate::mbe::{self, MetaVarExpr}; use rustc_ast::mut_visit::{self, MutVisitor}; use rustc_ast::token::{self, Delimiter, Token, TokenKind}; -use rustc_ast::tokenstream::{DelimSpan, Spacing, TokenStream, TokenTree}; +use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{pluralize, PResult}; use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed}; @@ -31,14 +31,24 @@ impl MutVisitor for Marker { /// An iterator over the token trees in a delimited token tree (`{ ... }`) or a sequence (`$(...)`). enum Frame<'a> { - Delimited { tts: &'a [mbe::TokenTree], idx: usize, delim: Delimiter, span: DelimSpan }, - Sequence { tts: &'a [mbe::TokenTree], idx: usize, sep: Option<Token> }, + Delimited { + tts: &'a [mbe::TokenTree], + idx: usize, + delim: Delimiter, + span: DelimSpan, + spacing: DelimSpacing, + }, + Sequence { + tts: &'a [mbe::TokenTree], + idx: usize, + sep: Option<Token>, + }, } impl<'a> Frame<'a> { /// Construct a new frame around the delimited set of tokens. - fn new(src: &'a mbe::Delimited, span: DelimSpan) -> Frame<'a> { - Frame::Delimited { tts: &src.tts, idx: 0, delim: src.delim, span } + fn new(src: &'a mbe::Delimited, span: DelimSpan, spacing: DelimSpacing) -> Frame<'a> { + Frame::Delimited { tts: &src.tts, idx: 0, delim: src.delim, span, spacing } } } @@ -89,8 +99,10 @@ pub(super) fn transcribe<'a>( } // We descend into the RHS (`src`), expanding things as we go. This stack contains the things - // we have yet to expand/are still expanding. We start the stack off with the whole RHS. - let mut stack: SmallVec<[Frame<'_>; 1]> = smallvec![Frame::new(src, src_span)]; + // we have yet to expand/are still expanding. We start the stack off with the whole RHS. The + // choice of spacing values doesn't matter. + let mut stack: SmallVec<[Frame<'_>; 1]> = + smallvec![Frame::new(src, src_span, DelimSpacing::new(Spacing::Alone, Spacing::Alone))]; // As we descend in the RHS, we will need to be able to match nested sequences of matchers. // `repeats` keeps track of where we are in matching at each level, with the last element being @@ -144,14 +156,19 @@ pub(super) fn transcribe<'a>( // We are done processing a Delimited. If this is the top-level delimited, we are // done. Otherwise, we unwind the result_stack to append what we have produced to // any previous results. - Frame::Delimited { delim, span, .. } => { + Frame::Delimited { delim, span, mut spacing, .. } => { + // Hack to force-insert a space after `]` in certain case. + // See discussion of the `hex-literal` crate in #114571. + if delim == Delimiter::Bracket { + spacing.close = Spacing::Alone; + } if result_stack.is_empty() { // No results left to compute! We are back at the top-level. return Ok(TokenStream::new(result)); } // Step back into the parent Delimited. - let tree = TokenTree::Delimited(span, delim, TokenStream::new(result)); + let tree = TokenTree::Delimited(span, spacing, delim, TokenStream::new(result)); result = result_stack.pop().unwrap(); result.push(tree); } @@ -240,7 +257,7 @@ pub(super) fn transcribe<'a>( // with modified syntax context. (I believe this supports nested macros). marker.visit_span(&mut sp); marker.visit_ident(&mut original_ident); - result.push(TokenTree::token_alone(token::Dollar, sp)); + result.push(TokenTree::token_joint_hidden(token::Dollar, sp)); result.push(TokenTree::Token( Token::from_ast_ident(original_ident), Spacing::Alone, @@ -258,13 +275,14 @@ pub(super) fn transcribe<'a>( // We will produce all of the results of the inside of the `Delimited` and then we will // jump back out of the Delimited, pop the result_stack and add the new results back to // the previous results (from outside the Delimited). - mbe::TokenTree::Delimited(mut span, delimited) => { + mbe::TokenTree::Delimited(mut span, spacing, delimited) => { mut_visit::visit_delim_span(&mut span, &mut marker); stack.push(Frame::Delimited { tts: &delimited.tts, delim: delimited.delim, idx: 0, span, + spacing: *spacing, }); result_stack.push(mem::take(&mut result)); } @@ -374,7 +392,7 @@ fn lockstep_iter_size( ) -> LockstepIterSize { use mbe::TokenTree; match tree { - TokenTree::Delimited(_, delimited) => { + TokenTree::Delimited(.., delimited) => { delimited.tts.iter().fold(LockstepIterSize::Unconstrained, |size, tt| { size.with(lockstep_iter_size(tt, interpolations, repeats)) }) diff --git a/compiler/rustc_expand/src/parse/tests.rs b/compiler/rustc_expand/src/parse/tests.rs index bdc20882a9d..7a888250ca1 100644 --- a/compiler/rustc_expand/src/parse/tests.rs +++ b/compiler/rustc_expand/src/parse/tests.rs @@ -4,7 +4,7 @@ use crate::tests::{ use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Token}; -use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; +use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; use rustc_ast::visit; use rustc_ast::{self as ast, PatKind}; use rustc_ast_pretty::pprust::item_to_string; @@ -77,14 +77,14 @@ fn string_to_tts_macro() { TokenTree::Token(Token { kind: token::Ident(name_macro_rules, false), .. }, _), TokenTree::Token(Token { kind: token::Not, .. }, _), TokenTree::Token(Token { kind: token::Ident(name_zip, false), .. }, _), - TokenTree::Delimited(_, macro_delim, macro_tts), + TokenTree::Delimited(.., macro_delim, macro_tts), ] if name_macro_rules == &kw::MacroRules && name_zip.as_str() == "zip" => { let tts = ¯o_tts.trees().collect::<Vec<_>>(); match &tts[..] { [ - TokenTree::Delimited(_, first_delim, first_tts), + TokenTree::Delimited(.., first_delim, first_tts), TokenTree::Token(Token { kind: token::FatArrow, .. }, _), - TokenTree::Delimited(_, second_delim, second_tts), + TokenTree::Delimited(.., second_delim, second_tts), ] if macro_delim == &Delimiter::Parenthesis => { let tts = &first_tts.trees().collect::<Vec<_>>(); match &tts[..] { @@ -116,27 +116,36 @@ fn string_to_tts_macro() { #[test] fn string_to_tts_1() { create_default_session_globals_then(|| { - let tts = string_to_stream("fn a (b : i32) { b; }".to_string()); + let tts = string_to_stream("fn a(b: i32) { b; }".to_string()); let expected = TokenStream::new(vec![ TokenTree::token_alone(token::Ident(kw::Fn, false), sp(0, 2)), - TokenTree::token_alone(token::Ident(Symbol::intern("a"), false), sp(3, 4)), + TokenTree::token_joint_hidden(token::Ident(Symbol::intern("a"), false), sp(3, 4)), TokenTree::Delimited( - DelimSpan::from_pair(sp(5, 6), sp(13, 14)), + DelimSpan::from_pair(sp(4, 5), sp(11, 12)), + // `JointHidden` because the `(` is followed immediately by + // `b`, `Alone` because the `)` is followed by whitespace. + DelimSpacing::new(Spacing::JointHidden, Spacing::Alone), Delimiter::Parenthesis, TokenStream::new(vec![ - TokenTree::token_alone(token::Ident(Symbol::intern("b"), false), sp(6, 7)), - TokenTree::token_alone(token::Colon, sp(8, 9)), - TokenTree::token_alone(token::Ident(sym::i32, false), sp(10, 13)), + TokenTree::token_joint(token::Ident(Symbol::intern("b"), false), sp(5, 6)), + TokenTree::token_alone(token::Colon, sp(6, 7)), + // `JointHidden` because the `i32` is immediately followed by the `)`. + TokenTree::token_joint_hidden(token::Ident(sym::i32, false), sp(8, 11)), ]) .into(), ), TokenTree::Delimited( - DelimSpan::from_pair(sp(15, 16), sp(20, 21)), + DelimSpan::from_pair(sp(13, 14), sp(18, 19)), + // First `Alone` because the `{` is followed by whitespace, + // second `Alone` because the `}` is followed immediately by + // EOF. + DelimSpacing::new(Spacing::Alone, Spacing::Alone), Delimiter::Brace, TokenStream::new(vec![ - TokenTree::token_joint(token::Ident(Symbol::intern("b"), false), sp(17, 18)), - TokenTree::token_alone(token::Semi, sp(18, 19)), + TokenTree::token_joint(token::Ident(Symbol::intern("b"), false), sp(15, 16)), + // `Alone` because the `;` is followed by whitespace. + TokenTree::token_alone(token::Semi, sp(16, 17)), ]) .into(), ), diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index b057a645f81..5308e338d7f 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -5,7 +5,7 @@ use pm::bridge::{ use pm::{Delimiter, Level}; use rustc_ast as ast; use rustc_ast::token; -use rustc_ast::tokenstream::{self, Spacing::*, TokenStream}; +use rustc_ast::tokenstream::{self, DelimSpacing, Spacing, TokenStream}; use rustc_ast::util::literal::escape_byte_str_symbol; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashMap; @@ -98,7 +98,7 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre while let Some(tree) = cursor.next() { let (Token { kind, span }, joint) = match tree.clone() { - tokenstream::TokenTree::Delimited(span, delim, tts) => { + tokenstream::TokenTree::Delimited(span, _, delim, tts) => { let delimiter = pm::Delimiter::from_internal(delim); trees.push(TokenTree::Group(Group { delimiter, @@ -111,7 +111,22 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre })); continue; } - tokenstream::TokenTree::Token(token, spacing) => (token, spacing == Joint), + tokenstream::TokenTree::Token(token, spacing) => { + // Do not be tempted to check here that the `spacing` + // values are "correct" w.r.t. the token stream (e.g. that + // `Spacing::Joint` is actually followed by a `Punct` token + // tree). Because the problem in #76399 was introduced that + // way. + // + // This is where the `Hidden` in `JointHidden` applies, + // because the jointness is effectively hidden from proc + // macros. + let joint = match spacing { + Spacing::Alone | Spacing::JointHidden => false, + Spacing::Joint => true, + }; + (token, joint) + } }; // Split the operator into one or more `Punct`s, one per character. @@ -133,7 +148,8 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre } else { span }; - TokenTree::Punct(Punct { ch, joint: if is_final { joint } else { true }, span }) + let joint = if is_final { joint } else { true }; + TokenTree::Punct(Punct { ch, joint, span }) })); }; @@ -268,6 +284,11 @@ impl ToInternal<SmallVec<[tokenstream::TokenTree; 2]>> fn to_internal(self) -> SmallVec<[tokenstream::TokenTree; 2]> { use rustc_ast::token::*; + // The code below is conservative, using `token_alone`/`Spacing::Alone` + // in most places. When the resulting code is pretty-printed by + // `print_tts` it ends up with spaces between most tokens, which is + // safe but ugly. It's hard in general to do better when working at the + // token level. let (tree, rustc) = self; match tree { TokenTree::Punct(Punct { ch, joint, span }) => { @@ -296,6 +317,11 @@ impl ToInternal<SmallVec<[tokenstream::TokenTree; 2]>> b'\'' => SingleQuote, _ => unreachable!(), }; + // We never produce `token::Spacing::JointHidden` here, which + // means the pretty-printing of code produced by proc macros is + // ugly, with lots of whitespace between tokens. This is + // unavoidable because `proc_macro::Spacing` only applies to + // `Punct` token trees. smallvec![if joint { tokenstream::TokenTree::token_joint(kind, span) } else { @@ -305,6 +331,7 @@ impl ToInternal<SmallVec<[tokenstream::TokenTree; 2]>> TokenTree::Group(Group { delimiter, stream, span: DelimSpan { open, close, .. } }) => { smallvec![tokenstream::TokenTree::Delimited( tokenstream::DelimSpan { open, close }, + DelimSpacing::new(Spacing::Alone, Spacing::Alone), delimiter.to_internal(), stream.unwrap_or_default(), )] @@ -322,7 +349,7 @@ impl ToInternal<SmallVec<[tokenstream::TokenTree; 2]>> let minus = BinOp(BinOpToken::Minus); let symbol = Symbol::intern(&symbol.as_str()[1..]); let integer = TokenKind::lit(token::Integer, symbol, suffix); - let a = tokenstream::TokenTree::token_alone(minus, span); + let a = tokenstream::TokenTree::token_joint_hidden(minus, span); let b = tokenstream::TokenTree::token_alone(integer, span); smallvec![a, b] } @@ -335,7 +362,7 @@ impl ToInternal<SmallVec<[tokenstream::TokenTree; 2]>> let minus = BinOp(BinOpToken::Minus); let symbol = Symbol::intern(&symbol.as_str()[1..]); let float = TokenKind::lit(token::Float, symbol, suffix); - let a = tokenstream::TokenTree::token_alone(minus, span); + let a = tokenstream::TokenTree::token_joint_hidden(minus, span); let b = tokenstream::TokenTree::token_alone(float, span); smallvec![a, b] } @@ -546,7 +573,10 @@ impl server::TokenStream for Rustc<'_, '_> { Ok(Self::TokenStream::from_iter([ // FIXME: The span of the `-` token is lost when // parsing, so we cannot faithfully recover it here. - tokenstream::TokenTree::token_alone(token::BinOp(token::Minus), e.span), + tokenstream::TokenTree::token_joint_hidden( + token::BinOp(token::Minus), + e.span, + ), tokenstream::TokenTree::token_alone(token::Literal(*token_lit), e.span), ])) } diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 94e79144593..4993112089a 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -5,7 +5,7 @@ use rustc_span::symbol::sym; macro_rules! declare_features { ($( - $(#[doc = $doc:tt])* (accepted, $feature:ident, $ver:expr, $issue:expr, None), + $(#[doc = $doc:tt])* (accepted, $feature:ident, $ver:expr, $issue:expr), )+) => { /// Formerly unstable features that have now been accepted (stabilized). pub const ACCEPTED_FEATURES: &[Feature] = &[ @@ -13,7 +13,6 @@ macro_rules! declare_features { name: sym::$feature, since: $ver, issue: to_nonzero($issue), - edition: None, }),+ ]; } @@ -27,10 +26,10 @@ declare_features! ( /// A temporary feature gate used to enable parser extensions needed /// to bootstrap fix for #5723. - (accepted, issue_5723_bootstrap, "1.0.0", None, None), + (accepted, issue_5723_bootstrap, "1.0.0", None), /// These are used to test this portion of the compiler, /// they don't actually mean anything. - (accepted, test_accepted_feature, "1.0.0", None, None), + (accepted, test_accepted_feature, "1.0.0", None), // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! // Features are listed in alphabetical order. Tidy will fail if you don't keep it this way. // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! @@ -44,338 +43,338 @@ declare_features! ( // ------------------------------------------------------------------------- /// Allows `#[target_feature(...)]` on aarch64 platforms - (accepted, aarch64_target_feature, "1.61.0", Some(44839), None), + (accepted, aarch64_target_feature, "1.61.0", Some(44839)), /// Allows using the `efiapi` ABI. - (accepted, abi_efiapi, "1.68.0", Some(65815), None), + (accepted, abi_efiapi, "1.68.0", Some(65815)), /// Allows the sysV64 ABI to be specified on all platforms /// instead of just the platforms on which it is the C ABI. - (accepted, abi_sysv64, "1.24.0", Some(36167), None), + (accepted, abi_sysv64, "1.24.0", Some(36167)), /// Allows using the `thiscall` ABI. - (accepted, abi_thiscall, "1.73.0", None, None), + (accepted, abi_thiscall, "1.73.0", None), /// Allows using ADX intrinsics from `core::arch::{x86, x86_64}`. - (accepted, adx_target_feature, "1.61.0", Some(44839), None), + (accepted, adx_target_feature, "1.61.0", Some(44839)), /// Allows explicit discriminants on non-unit enum variants. - (accepted, arbitrary_enum_discriminant, "1.66.0", Some(60553), None), + (accepted, arbitrary_enum_discriminant, "1.66.0", Some(60553)), /// Allows using `sym` operands in inline assembly. - (accepted, asm_sym, "1.66.0", Some(93333), None), + (accepted, asm_sym, "1.66.0", Some(93333)), /// Allows the definition of associated constants in `trait` or `impl` blocks. - (accepted, associated_consts, "1.20.0", Some(29646), None), + (accepted, associated_consts, "1.20.0", Some(29646)), /// Allows using associated `type`s in `trait`s. - (accepted, associated_types, "1.0.0", None, None), + (accepted, associated_types, "1.0.0", None), /// Allows free and inherent `async fn`s, `async` blocks, and `<expr>.await` expressions. - (accepted, async_await, "1.39.0", Some(50547), None), + (accepted, async_await, "1.39.0", Some(50547)), /// Allows async functions to be declared, implemented, and used in traits. - (accepted, async_fn_in_trait, "1.75.0", Some(91611), None), + (accepted, async_fn_in_trait, "1.75.0", Some(91611)), /// Allows all literals in attribute lists and values of key-value pairs. - (accepted, attr_literals, "1.30.0", Some(34981), None), + (accepted, attr_literals, "1.30.0", Some(34981)), /// Allows overloading augmented assignment operations like `a += b`. - (accepted, augmented_assignments, "1.8.0", Some(28235), None), + (accepted, augmented_assignments, "1.8.0", Some(28235)), /// Allows mixing bind-by-move in patterns and references to those identifiers in guards. - (accepted, bind_by_move_pattern_guards, "1.39.0", Some(15287), None), + (accepted, bind_by_move_pattern_guards, "1.39.0", Some(15287)), /// Allows bindings in the subpattern of a binding pattern. /// For example, you can write `x @ Some(y)`. - (accepted, bindings_after_at, "1.56.0", Some(65490), None), + (accepted, bindings_after_at, "1.56.0", Some(65490)), /// Allows empty structs and enum variants with braces. - (accepted, braced_empty_structs, "1.8.0", Some(29720), None), + (accepted, braced_empty_structs, "1.8.0", Some(29720)), /// Allows `c"foo"` literals. - (accepted, c_str_literals, "CURRENT_RUSTC_VERSION", Some(105723), None), + (accepted, c_str_literals, "CURRENT_RUSTC_VERSION", Some(105723)), /// Allows `#[cfg_attr(predicate, multiple, attributes, here)]`. - (accepted, cfg_attr_multi, "1.33.0", Some(54881), None), + (accepted, cfg_attr_multi, "1.33.0", Some(54881)), /// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests. - (accepted, cfg_doctest, "1.40.0", Some(62210), None), + (accepted, cfg_doctest, "1.40.0", Some(62210)), /// Enables `#[cfg(panic = "...")]` config key. - (accepted, cfg_panic, "1.60.0", Some(77443), None), + (accepted, cfg_panic, "1.60.0", Some(77443)), /// Allows `cfg(target_feature = "...")`. - (accepted, cfg_target_feature, "1.27.0", Some(29717), None), + (accepted, cfg_target_feature, "1.27.0", Some(29717)), /// Allows `cfg(target_vendor = "...")`. - (accepted, cfg_target_vendor, "1.33.0", Some(29718), None), + (accepted, cfg_target_vendor, "1.33.0", Some(29718)), /// Allows implementing `Clone` for closures where possible (RFC 2132). - (accepted, clone_closures, "1.26.0", Some(44490), None), + (accepted, clone_closures, "1.26.0", Some(44490)), /// Allows coercing non capturing closures to function pointers. - (accepted, closure_to_fn_coercion, "1.19.0", Some(39817), None), + (accepted, closure_to_fn_coercion, "1.19.0", Some(39817)), /// Allows using the CMPXCHG16B target feature. - (accepted, cmpxchg16b_target_feature, "1.69.0", Some(44839), None), + (accepted, cmpxchg16b_target_feature, "1.69.0", Some(44839)), /// Allows usage of the `compile_error!` macro. - (accepted, compile_error, "1.20.0", Some(40872), None), + (accepted, compile_error, "1.20.0", Some(40872)), /// Allows `impl Trait` in function return types. - (accepted, conservative_impl_trait, "1.26.0", Some(34511), None), + (accepted, conservative_impl_trait, "1.26.0", Some(34511)), /// Allows calling constructor functions in `const fn`. - (accepted, const_constructor, "1.40.0", Some(61456), None), + (accepted, const_constructor, "1.40.0", Some(61456)), /// Allows using and casting function pointers in a `const fn`. - (accepted, const_fn_fn_ptr_basics, "1.61.0", Some(57563), None), + (accepted, const_fn_fn_ptr_basics, "1.61.0", Some(57563)), /// Allows trait bounds in `const fn`. - (accepted, const_fn_trait_bound, "1.61.0", Some(93706), None), + (accepted, const_fn_trait_bound, "1.61.0", Some(93706)), /// Allows calling `transmute` in const fn - (accepted, const_fn_transmute, "1.56.0", Some(53605), None), + (accepted, const_fn_transmute, "1.56.0", Some(53605)), /// Allows accessing fields of unions inside `const` functions. - (accepted, const_fn_union, "1.56.0", Some(51909), None), + (accepted, const_fn_union, "1.56.0", Some(51909)), /// Allows unsizing coercions in `const fn`. - (accepted, const_fn_unsize, "1.54.0", Some(64992), None), + (accepted, const_fn_unsize, "1.54.0", Some(64992)), /// Allows const generics to have default values (e.g. `struct Foo<const N: usize = 3>(...);`). - (accepted, const_generics_defaults, "1.59.0", Some(44580), None), + (accepted, const_generics_defaults, "1.59.0", Some(44580)), /// Allows the use of `if` and `match` in constants. - (accepted, const_if_match, "1.46.0", Some(49146), None), + (accepted, const_if_match, "1.46.0", Some(49146)), /// Allows argument and return position `impl Trait` in a `const fn`. - (accepted, const_impl_trait, "1.61.0", Some(77463), None), + (accepted, const_impl_trait, "1.61.0", Some(77463)), /// Allows indexing into constant arrays. - (accepted, const_indexing, "1.26.0", Some(29947), None), + (accepted, const_indexing, "1.26.0", Some(29947)), /// Allows let bindings, assignments and destructuring in `const` functions and constants. /// As long as control flow is not implemented in const eval, `&&` and `||` may not be used /// at the same time as let bindings. - (accepted, const_let, "1.33.0", Some(48821), None), + (accepted, const_let, "1.33.0", Some(48821)), /// Allows the use of `loop` and `while` in constants. - (accepted, const_loop, "1.46.0", Some(52000), None), + (accepted, const_loop, "1.46.0", Some(52000)), /// Allows panicking during const eval (producing compile-time errors). - (accepted, const_panic, "1.57.0", Some(51999), None), + (accepted, const_panic, "1.57.0", Some(51999)), /// Allows dereferencing raw pointers during const eval. - (accepted, const_raw_ptr_deref, "1.58.0", Some(51911), None), + (accepted, const_raw_ptr_deref, "1.58.0", Some(51911)), /// Allows implementing `Copy` for closures where possible (RFC 2132). - (accepted, copy_closures, "1.26.0", Some(44490), None), + (accepted, copy_closures, "1.26.0", Some(44490)), /// Allows `crate` in paths. - (accepted, crate_in_paths, "1.30.0", Some(45477), None), + (accepted, crate_in_paths, "1.30.0", Some(45477)), /// Allows using `#[debugger_visualizer]` attribute. - (accepted, debugger_visualizer, "1.71.0", Some(95939), None), + (accepted, debugger_visualizer, "1.71.0", Some(95939)), /// Allows rustc to inject a default alloc_error_handler - (accepted, default_alloc_error_handler, "1.68.0", Some(66741), None), + (accepted, default_alloc_error_handler, "1.68.0", Some(66741)), /// Allows using assigning a default type to type parameters in algebraic data type definitions. - (accepted, default_type_params, "1.0.0", None, None), + (accepted, default_type_params, "1.0.0", None), /// Allows `#[deprecated]` attribute. - (accepted, deprecated, "1.9.0", Some(29935), None), + (accepted, deprecated, "1.9.0", Some(29935)), /// Allows `#[derive(Default)]` and `#[default]` on enums. - (accepted, derive_default_enum, "1.62.0", Some(86985), None), + (accepted, derive_default_enum, "1.62.0", Some(86985)), /// Allows the use of destructuring assignments. - (accepted, destructuring_assignment, "1.59.0", Some(71126), None), + (accepted, destructuring_assignment, "1.59.0", Some(71126)), /// Allows `#[doc(alias = "...")]`. - (accepted, doc_alias, "1.48.0", Some(50146), None), + (accepted, doc_alias, "1.48.0", Some(50146)), /// Allows `..` in tuple (struct) patterns. - (accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627), None), + (accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627)), /// Allows `..=` in patterns (RFC 1192). - (accepted, dotdoteq_in_patterns, "1.26.0", Some(28237), None), + (accepted, dotdoteq_in_patterns, "1.26.0", Some(28237)), /// Allows `Drop` types in constants (RFC 1440). - (accepted, drop_types_in_const, "1.22.0", Some(33156), None), + (accepted, drop_types_in_const, "1.22.0", Some(33156)), /// Allows using `dyn Trait` as a syntax for trait objects. - (accepted, dyn_trait, "1.27.0", Some(44662), None), + (accepted, dyn_trait, "1.27.0", Some(44662)), /// Allows integer match exhaustiveness checking (RFC 2591). - (accepted, exhaustive_integer_patterns, "1.33.0", Some(50907), None), + (accepted, exhaustive_integer_patterns, "1.33.0", Some(50907)), /// Allows explicit generic arguments specification with `impl Trait` present. - (accepted, explicit_generic_args_with_impl_trait, "1.63.0", Some(83701), None), + (accepted, explicit_generic_args_with_impl_trait, "1.63.0", Some(83701)), /// Allows arbitrary expressions in key-value attributes at parse time. - (accepted, extended_key_value_attributes, "1.54.0", Some(78835), None), + (accepted, extended_key_value_attributes, "1.54.0", Some(78835)), /// Allows resolving absolute paths as paths from other crates. - (accepted, extern_absolute_paths, "1.30.0", Some(44660), None), + (accepted, extern_absolute_paths, "1.30.0", Some(44660)), /// Allows `extern crate foo as bar;`. This puts `bar` into extern prelude. - (accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None), + (accepted, extern_crate_item_prelude, "1.31.0", Some(55599)), /// Allows `extern crate self as foo;`. /// This puts local crate root into extern prelude under name `foo`. - (accepted, extern_crate_self, "1.34.0", Some(56409), None), + (accepted, extern_crate_self, "1.34.0", Some(56409)), /// Allows access to crate names passed via `--extern` through prelude. - (accepted, extern_prelude, "1.30.0", Some(44660), None), + (accepted, extern_prelude, "1.30.0", Some(44660)), /// Allows using F16C intrinsics from `core::arch::{x86, x86_64}`. - (accepted, f16c_target_feature, "1.68.0", Some(44839), None), + (accepted, f16c_target_feature, "1.68.0", Some(44839)), /// Allows field shorthands (`x` meaning `x: x`) in struct literal expressions. - (accepted, field_init_shorthand, "1.17.0", Some(37340), None), + (accepted, field_init_shorthand, "1.17.0", Some(37340)), /// Allows `#[must_use]` on functions, and introduces must-use operators (RFC 1940). - (accepted, fn_must_use, "1.27.0", Some(43302), None), + (accepted, fn_must_use, "1.27.0", Some(43302)), /// Allows capturing variables in scope using format_args! - (accepted, format_args_capture, "1.58.0", Some(67984), None), + (accepted, format_args_capture, "1.58.0", Some(67984)), /// Allows associated types to be generic, e.g., `type Foo<T>;` (RFC 1598). - (accepted, generic_associated_types, "1.65.0", Some(44265), None), + (accepted, generic_associated_types, "1.65.0", Some(44265)), /// Allows attributes on lifetime/type formal parameters in generics (RFC 1327). - (accepted, generic_param_attrs, "1.27.0", Some(48848), None), + (accepted, generic_param_attrs, "1.27.0", Some(48848)), /// Allows the `#[global_allocator]` attribute. - (accepted, global_allocator, "1.28.0", Some(27389), None), + (accepted, global_allocator, "1.28.0", Some(27389)), // FIXME: explain `globs`. - (accepted, globs, "1.0.0", None, None), + (accepted, globs, "1.0.0", None), /// Allows using `..=X` as a pattern. - (accepted, half_open_range_patterns, "1.66.0", Some(67264), None), + (accepted, half_open_range_patterns, "1.66.0", Some(67264)), /// Allows using the `u128` and `i128` types. - (accepted, i128_type, "1.26.0", Some(35118), None), + (accepted, i128_type, "1.26.0", Some(35118)), /// Allows the use of `if let` expressions. - (accepted, if_let, "1.0.0", None, None), + (accepted, if_let, "1.0.0", None), /// Allows top level or-patterns (`p | q`) in `if let` and `while let`. - (accepted, if_while_or_patterns, "1.33.0", Some(48215), None), + (accepted, if_while_or_patterns, "1.33.0", Some(48215)), /// Allows lifetime elision in `impl` headers. For example: /// + `impl<I:Iterator> Iterator for &mut Iterator` /// + `impl Debug for Foo<'_>` - (accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None), + (accepted, impl_header_lifetime_elision, "1.31.0", Some(15872)), /// Allows referencing `Self` and projections in impl-trait. - (accepted, impl_trait_projections, "1.74.0", Some(103532), None), + (accepted, impl_trait_projections, "1.74.0", Some(103532)), /// Allows using `a..=b` and `..=b` as inclusive range syntaxes. - (accepted, inclusive_range_syntax, "1.26.0", Some(28237), None), + (accepted, inclusive_range_syntax, "1.26.0", Some(28237)), /// Allows inferring outlives requirements (RFC 2093). - (accepted, infer_outlives_requirements, "1.30.0", Some(44493), None), + (accepted, infer_outlives_requirements, "1.30.0", Some(44493)), /// Allows irrefutable patterns in `if let` and `while let` statements (RFC 2086). - (accepted, irrefutable_let_patterns, "1.33.0", Some(44495), None), + (accepted, irrefutable_let_patterns, "1.33.0", Some(44495)), /// Allows `#[instruction_set(_)]` attribute. - (accepted, isa_attribute, "1.67.0", Some(74727), None), + (accepted, isa_attribute, "1.67.0", Some(74727)), /// Allows some increased flexibility in the name resolution rules, /// especially around globs and shadowing (RFC 1560). - (accepted, item_like_imports, "1.15.0", Some(35120), None), + (accepted, item_like_imports, "1.15.0", Some(35120)), /// Allows `'a: { break 'a; }`. - (accepted, label_break_value, "1.65.0", Some(48594), None), + (accepted, label_break_value, "1.65.0", Some(48594)), /// Allows `let...else` statements. - (accepted, let_else, "1.65.0", Some(87335), None), + (accepted, let_else, "1.65.0", Some(87335)), /// Allows `break {expr}` with a value inside `loop`s. - (accepted, loop_break_value, "1.19.0", Some(37339), None), + (accepted, loop_break_value, "1.19.0", Some(37339)), /// Allows use of `?` as the Kleene "at most one" operator in macros. - (accepted, macro_at_most_once_rep, "1.32.0", Some(48075), None), + (accepted, macro_at_most_once_rep, "1.32.0", Some(48075)), /// Allows macro attributes to observe output of `#[derive]`. - (accepted, macro_attributes_in_derive_output, "1.57.0", Some(81119), None), + (accepted, macro_attributes_in_derive_output, "1.57.0", Some(81119)), /// Allows use of the `:lifetime` macro fragment specifier. - (accepted, macro_lifetime_matcher, "1.27.0", Some(34303), None), + (accepted, macro_lifetime_matcher, "1.27.0", Some(34303)), /// Allows use of the `:literal` macro fragment specifier (RFC 1576). - (accepted, macro_literal_matcher, "1.32.0", Some(35625), None), + (accepted, macro_literal_matcher, "1.32.0", Some(35625)), /// Allows `macro_rules!` items. - (accepted, macro_rules, "1.0.0", None, None), + (accepted, macro_rules, "1.0.0", None), /// Allows use of the `:vis` macro fragment specifier - (accepted, macro_vis_matcher, "1.30.0", Some(41022), None), + (accepted, macro_vis_matcher, "1.30.0", Some(41022)), /// Allows macro invocations in `extern {}` blocks. - (accepted, macros_in_extern, "1.40.0", Some(49476), None), + (accepted, macros_in_extern, "1.40.0", Some(49476)), /// Allows '|' at beginning of match arms (RFC 1925). - (accepted, match_beginning_vert, "1.25.0", Some(44101), None), + (accepted, match_beginning_vert, "1.25.0", Some(44101)), /// Allows default match binding modes (RFC 2005). - (accepted, match_default_bindings, "1.26.0", Some(42640), None), + (accepted, match_default_bindings, "1.26.0", Some(42640)), /// Allows `impl Trait` with multiple unrelated lifetimes. - (accepted, member_constraints, "1.54.0", Some(61997), None), + (accepted, member_constraints, "1.54.0", Some(61997)), /// Allows the definition of `const fn` functions. - (accepted, min_const_fn, "1.31.0", Some(53555), None), + (accepted, min_const_fn, "1.31.0", Some(53555)), /// The smallest useful subset of const generics. - (accepted, min_const_generics, "1.51.0", Some(74878), None), + (accepted, min_const_generics, "1.51.0", Some(74878)), /// Allows calling `const unsafe fn` inside `unsafe` blocks in `const fn` functions. - (accepted, min_const_unsafe_fn, "1.33.0", Some(55607), None), + (accepted, min_const_unsafe_fn, "1.33.0", Some(55607)), /// Allows using `Self` and associated types in struct expressions and patterns. - (accepted, more_struct_aliases, "1.16.0", Some(37544), None), + (accepted, more_struct_aliases, "1.16.0", Some(37544)), /// Allows using the MOVBE target feature. - (accepted, movbe_target_feature, "1.70.0", Some(44839), None), + (accepted, movbe_target_feature, "1.70.0", Some(44839)), /// Allows patterns with concurrent by-move and by-ref bindings. /// For example, you can write `Foo(a, ref b)` where `a` is by-move and `b` is by-ref. - (accepted, move_ref_pattern, "1.49.0", Some(68354), None), + (accepted, move_ref_pattern, "1.49.0", Some(68354)), /// Allows specifying modifiers in the link attribute: `#[link(modifiers = "...")]` - (accepted, native_link_modifiers, "1.61.0", Some(81490), None), + (accepted, native_link_modifiers, "1.61.0", Some(81490)), /// Allows specifying the bundle link modifier - (accepted, native_link_modifiers_bundle, "1.63.0", Some(81490), None), + (accepted, native_link_modifiers_bundle, "1.63.0", Some(81490)), /// Allows specifying the verbatim link modifier - (accepted, native_link_modifiers_verbatim, "1.67.0", Some(81490), None), + (accepted, native_link_modifiers_verbatim, "1.67.0", Some(81490)), /// Allows specifying the whole-archive link modifier - (accepted, native_link_modifiers_whole_archive, "1.61.0", Some(81490), None), + (accepted, native_link_modifiers_whole_archive, "1.61.0", Some(81490)), /// Allows using non lexical lifetimes (RFC 2094). - (accepted, nll, "1.63.0", Some(43234), None), + (accepted, nll, "1.63.0", Some(43234)), /// Allows using `#![no_std]`. - (accepted, no_std, "1.6.0", None, None), + (accepted, no_std, "1.6.0", None), /// Allows defining identifiers beyond ASCII. - (accepted, non_ascii_idents, "1.53.0", Some(55467), None), + (accepted, non_ascii_idents, "1.53.0", Some(55467)), /// Allows future-proofing enums/structs with the `#[non_exhaustive]` attribute (RFC 2008). - (accepted, non_exhaustive, "1.40.0", Some(44109), None), + (accepted, non_exhaustive, "1.40.0", Some(44109)), /// Allows `foo.rs` as an alternative to `foo/mod.rs`. - (accepted, non_modrs_mods, "1.30.0", Some(44660), None), + (accepted, non_modrs_mods, "1.30.0", Some(44660)), /// Allows the use of or-patterns (e.g., `0 | 1`). - (accepted, or_patterns, "1.53.0", Some(54883), None), + (accepted, or_patterns, "1.53.0", Some(54883)), /// Allows using `+bundle,+whole-archive` link modifiers with native libs. - (accepted, packed_bundled_libs, "1.74.0", Some(108081), None), + (accepted, packed_bundled_libs, "1.74.0", Some(108081)), /// Allows annotating functions conforming to `fn(&PanicInfo) -> !` with `#[panic_handler]`. /// This defines the behavior of panics. - (accepted, panic_handler, "1.30.0", Some(44489), None), + (accepted, panic_handler, "1.30.0", Some(44489)), /// Allows attributes in formal function parameters. - (accepted, param_attrs, "1.39.0", Some(60406), None), + (accepted, param_attrs, "1.39.0", Some(60406)), /// Allows parentheses in patterns. - (accepted, pattern_parentheses, "1.31.0", Some(51087), None), + (accepted, pattern_parentheses, "1.31.0", Some(51087)), /// Allows procedural macros in `proc-macro` crates. - (accepted, proc_macro, "1.29.0", Some(38356), None), + (accepted, proc_macro, "1.29.0", Some(38356)), /// Allows multi-segment paths in attributes and derives. - (accepted, proc_macro_path_invoc, "1.30.0", Some(38356), None), + (accepted, proc_macro_path_invoc, "1.30.0", Some(38356)), /// Allows `pub(restricted)` visibilities (RFC 1422). - (accepted, pub_restricted, "1.18.0", Some(32409), None), + (accepted, pub_restricted, "1.18.0", Some(32409)), /// Allows use of the postfix `?` operator in expressions. - (accepted, question_mark, "1.13.0", Some(31436), None), + (accepted, question_mark, "1.13.0", Some(31436)), /// Allows the use of raw-dylibs (RFC 2627). - (accepted, raw_dylib, "1.71.0", Some(58713), None), + (accepted, raw_dylib, "1.71.0", Some(58713)), /// Allows keywords to be escaped for use as identifiers. - (accepted, raw_identifiers, "1.30.0", Some(48589), None), + (accepted, raw_identifiers, "1.30.0", Some(48589)), /// Allows relaxing the coherence rules such that /// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted. - (accepted, re_rebalance_coherence, "1.41.0", Some(55437), None), + (accepted, re_rebalance_coherence, "1.41.0", Some(55437)), /// Allows numeric fields in struct expressions and patterns. - (accepted, relaxed_adts, "1.19.0", Some(35626), None), + (accepted, relaxed_adts, "1.19.0", Some(35626)), /// Lessens the requirements for structs to implement `Unsize`. - (accepted, relaxed_struct_unsize, "1.58.0", Some(81793), None), + (accepted, relaxed_struct_unsize, "1.58.0", Some(81793)), /// Allows `repr(align(16))` struct attribute (RFC 1358). - (accepted, repr_align, "1.25.0", Some(33626), None), + (accepted, repr_align, "1.25.0", Some(33626)), /// Allows using `#[repr(align(X))]` on enums with equivalent semantics /// to wrapping an enum in a wrapper struct with `#[repr(align(X))]`. - (accepted, repr_align_enum, "1.37.0", Some(57996), None), + (accepted, repr_align_enum, "1.37.0", Some(57996)), /// Allows `#[repr(packed(N))]` attribute on structs. - (accepted, repr_packed, "1.33.0", Some(33158), None), + (accepted, repr_packed, "1.33.0", Some(33158)), /// Allows `#[repr(transparent)]` attribute on newtype structs. - (accepted, repr_transparent, "1.28.0", Some(43036), None), + (accepted, repr_transparent, "1.28.0", Some(43036)), /// Allows return-position `impl Trait` in traits. - (accepted, return_position_impl_trait_in_trait, "1.75.0", Some(91611), None), + (accepted, return_position_impl_trait_in_trait, "1.75.0", Some(91611)), /// Allows code like `let x: &'static u32 = &42` to work (RFC 1414). - (accepted, rvalue_static_promotion, "1.21.0", Some(38865), None), + (accepted, rvalue_static_promotion, "1.21.0", Some(38865)), /// Allows `Self` in type definitions (RFC 2300). - (accepted, self_in_typedefs, "1.32.0", Some(49303), None), + (accepted, self_in_typedefs, "1.32.0", Some(49303)), /// Allows `Self` struct constructor (RFC 2302). - (accepted, self_struct_ctor, "1.32.0", Some(51994), None), + (accepted, self_struct_ctor, "1.32.0", Some(51994)), /// Allows using subslice patterns, `[a, .., b]` and `[a, xs @ .., b]`. - (accepted, slice_patterns, "1.42.0", Some(62254), None), + (accepted, slice_patterns, "1.42.0", Some(62254)), /// Allows use of `&foo[a..b]` as a slicing syntax. - (accepted, slicing_syntax, "1.0.0", None, None), + (accepted, slicing_syntax, "1.0.0", None), /// Allows elision of `'static` lifetimes in `static`s and `const`s. - (accepted, static_in_const, "1.17.0", Some(35897), None), + (accepted, static_in_const, "1.17.0", Some(35897)), /// Allows the definition recursive static items. - (accepted, static_recursion, "1.17.0", Some(29719), None), + (accepted, static_recursion, "1.17.0", Some(29719)), /// Allows attributes on struct literal fields. - (accepted, struct_field_attributes, "1.20.0", Some(38814), None), + (accepted, struct_field_attributes, "1.20.0", Some(38814)), /// Allows struct variants `Foo { baz: u8, .. }` in enums (RFC 418). - (accepted, struct_variant, "1.0.0", None, None), + (accepted, struct_variant, "1.0.0", None), /// Allows `#[target_feature(...)]`. - (accepted, target_feature, "1.27.0", None, None), + (accepted, target_feature, "1.27.0", None), /// Allows `fn main()` with return types which implements `Termination` (RFC 1937). - (accepted, termination_trait, "1.26.0", Some(43301), None), + (accepted, termination_trait, "1.26.0", Some(43301)), /// Allows `#[test]` functions where the return type implements `Termination` (RFC 1937). - (accepted, termination_trait_test, "1.27.0", Some(48854), None), + (accepted, termination_trait_test, "1.27.0", Some(48854)), /// Allows attributes scoped to tools. - (accepted, tool_attributes, "1.30.0", Some(44690), None), + (accepted, tool_attributes, "1.30.0", Some(44690)), /// Allows scoped lints. - (accepted, tool_lints, "1.31.0", Some(44690), None), + (accepted, tool_lints, "1.31.0", Some(44690)), /// Allows `#[track_caller]` to be used which provides /// accurate caller location reporting during panic (RFC 2091). - (accepted, track_caller, "1.46.0", Some(47809), None), + (accepted, track_caller, "1.46.0", Some(47809)), /// Allows dyn upcasting trait objects via supertraits. /// Dyn upcasting is casting, e.g., `dyn Foo -> dyn Bar` where `Foo: Bar`. - (accepted, trait_upcasting, "CURRENT_RUSTC_VERSION", Some(65991), None), + (accepted, trait_upcasting, "CURRENT_RUSTC_VERSION", Some(65991)), /// Allows #[repr(transparent)] on univariant enums (RFC 2645). - (accepted, transparent_enums, "1.42.0", Some(60405), None), + (accepted, transparent_enums, "1.42.0", Some(60405)), /// Allows indexing tuples. - (accepted, tuple_indexing, "1.0.0", None, None), + (accepted, tuple_indexing, "1.0.0", None), /// Allows paths to enum variants on type aliases including `Self`. - (accepted, type_alias_enum_variants, "1.37.0", Some(49683), None), + (accepted, type_alias_enum_variants, "1.37.0", Some(49683)), /// Allows macros to appear in the type position. - (accepted, type_macros, "1.13.0", Some(27245), None), + (accepted, type_macros, "1.13.0", Some(27245)), /// Allows `const _: TYPE = VALUE`. - (accepted, underscore_const_names, "1.37.0", Some(54912), None), + (accepted, underscore_const_names, "1.37.0", Some(54912)), /// Allows `use path as _;` and `extern crate c as _;`. - (accepted, underscore_imports, "1.33.0", Some(48216), None), + (accepted, underscore_imports, "1.33.0", Some(48216)), /// Allows `'_` placeholder lifetimes. - (accepted, underscore_lifetimes, "1.26.0", Some(44524), None), + (accepted, underscore_lifetimes, "1.26.0", Some(44524)), /// Allows `use x::y;` to search `x` in the current scope. - (accepted, uniform_paths, "1.32.0", Some(53130), None), + (accepted, uniform_paths, "1.32.0", Some(53130)), /// Allows `impl Trait` in function arguments. - (accepted, universal_impl_trait, "1.26.0", Some(34511), None), + (accepted, universal_impl_trait, "1.26.0", Some(34511)), /// Allows arbitrary delimited token streams in non-macro attributes. - (accepted, unrestricted_attribute_tokens, "1.34.0", Some(55208), None), + (accepted, unrestricted_attribute_tokens, "1.34.0", Some(55208)), /// The `unsafe_op_in_unsafe_fn` lint (allowed by default): no longer treat an unsafe function as an unsafe block. - (accepted, unsafe_block_in_unsafe_fn, "1.52.0", Some(71668), None), + (accepted, unsafe_block_in_unsafe_fn, "1.52.0", Some(71668)), /// Allows importing and reexporting macros with `use`, /// enables macro modularization in general. - (accepted, use_extern_macros, "1.30.0", Some(35896), None), + (accepted, use_extern_macros, "1.30.0", Some(35896)), /// Allows nested groups in `use` items (RFC 2128). - (accepted, use_nested_groups, "1.25.0", Some(44494), None), + (accepted, use_nested_groups, "1.25.0", Some(44494)), /// Allows `#[used]` to preserve symbols (see llvm.compiler.used). - (accepted, used, "1.30.0", Some(40289), None), + (accepted, used, "1.30.0", Some(40289)), /// Allows the use of `while let` expressions. - (accepted, while_let, "1.0.0", None, None), + (accepted, while_let, "1.0.0", None), /// Allows `#![windows_subsystem]`. - (accepted, windows_subsystem, "1.18.0", Some(37499), None), + (accepted, windows_subsystem, "1.18.0", Some(37499)), // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! // Features are listed in alphabetical order. Tidy will fail if you don't keep it this way. // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! diff --git a/compiler/rustc_feature/src/lib.rs b/compiler/rustc_feature/src/lib.rs index 73d51d9f80e..cd1d9b13daa 100644 --- a/compiler/rustc_feature/src/lib.rs +++ b/compiler/rustc_feature/src/lib.rs @@ -26,7 +26,7 @@ mod unstable; #[cfg(test)] mod tests; -use rustc_span::{edition::Edition, symbol::Symbol}; +use rustc_span::symbol::Symbol; use std::num::NonZeroU32; #[derive(Debug, Clone)] @@ -34,7 +34,6 @@ pub struct Feature { pub name: Symbol, pub since: &'static str, issue: Option<NonZeroU32>, - pub edition: Option<Edition>, } #[derive(Copy, Clone, Debug)] diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index c0d3fc3fae0..0d9b8b344cf 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -10,7 +10,7 @@ pub struct RemovedFeature { macro_rules! declare_features { ($( - $(#[doc = $doc:tt])* (removed, $feature:ident, $ver:expr, $issue:expr, None, $reason:expr), + $(#[doc = $doc:tt])* (removed, $feature:ident, $ver:expr, $issue:expr, $reason:expr), )+) => { /// Formerly unstable features that have now been removed. pub const REMOVED_FEATURES: &[RemovedFeature] = &[ @@ -19,7 +19,6 @@ macro_rules! declare_features { name: sym::$feature, since: $ver, issue: to_nonzero($issue), - edition: None, }, reason: $reason }),+ @@ -33,176 +32,178 @@ declare_features! ( // feature-group-start: removed features // ------------------------------------------------------------------------- - (removed, advanced_slice_patterns, "1.0.0", Some(62254), None, + (removed, advanced_slice_patterns, "1.0.0", Some(62254), Some("merged into `#![feature(slice_patterns)]`")), - (removed, allocator, "1.0.0", None, None, None), + (removed, allocator, "1.0.0", None, None), /// Allows a test to fail without failing the whole suite. - (removed, allow_fail, "1.19.0", Some(46488), None, Some("removed due to no clear use cases")), - (removed, await_macro, "1.38.0", Some(50547), None, + (removed, allow_fail, "1.19.0", Some(46488), Some("removed due to no clear use cases")), + (removed, await_macro, "1.38.0", Some(50547), Some("subsumed by `.await` syntax")), /// Allows using the `box $expr` syntax. - (removed, box_syntax, "1.70.0", Some(49733), None, Some("replaced with `#[rustc_box]`")), + (removed, box_syntax, "1.70.0", Some(49733), Some("replaced with `#[rustc_box]`")), /// Allows capturing disjoint fields in a closure/coroutine (RFC 2229). - (removed, capture_disjoint_fields, "1.49.0", Some(53488), None, Some("stabilized in Rust 2021")), + (removed, capture_disjoint_fields, "1.49.0", Some(53488), Some("stabilized in Rust 2021")), /// Allows comparing raw pointers during const eval. - (removed, const_compare_raw_pointers, "1.46.0", Some(53020), None, + (removed, const_compare_raw_pointers, "1.46.0", Some(53020), Some("cannot be allowed in const eval in any meaningful way")), /// Allows limiting the evaluation steps of const expressions - (removed, const_eval_limit, "1.43.0", Some(67217), None, Some("removed the limit entirely")), + (removed, const_eval_limit, "1.43.0", Some(67217), Some("removed the limit entirely")), /// Allows non-trivial generic constants which have to be manually propagated upwards. - (removed, const_evaluatable_checked, "1.48.0", Some(76560), None, Some("renamed to `generic_const_exprs`")), + (removed, const_evaluatable_checked, "1.48.0", Some(76560), Some("renamed to `generic_const_exprs`")), /// Allows the definition of `const` functions with some advanced features. - (removed, const_fn, "1.54.0", Some(57563), None, + (removed, const_fn, "1.54.0", Some(57563), Some("split into finer-grained feature gates")), /// Allows const generic types (e.g. `struct Foo<const N: usize>(...);`). - (removed, const_generics, "1.34.0", Some(44580), None, + (removed, const_generics, "1.34.0", Some(44580), Some("removed in favor of `#![feature(adt_const_params)]` and `#![feature(generic_const_exprs)]`")), /// Allows `[x; N]` where `x` is a constant (RFC 2203). - (removed, const_in_array_repeat_expressions, "1.37.0", Some(49147), None, + (removed, const_in_array_repeat_expressions, "1.37.0", Some(49147), Some("removed due to causing promotable bugs")), /// Allows casting raw pointers to `usize` during const eval. - (removed, const_raw_ptr_to_usize_cast, "1.55.0", Some(51910), None, + (removed, const_raw_ptr_to_usize_cast, "1.55.0", Some(51910), Some("at compile-time, pointers do not have an integer value, so these casts cannot be properly supported")), /// Allows `T: ?const Trait` syntax in bounds. - (removed, const_trait_bound_opt_out, "1.42.0", Some(67794), None, + (removed, const_trait_bound_opt_out, "1.42.0", Some(67794), Some("Removed in favor of `~const` bound in #![feature(const_trait_impl)]")), /// Allows using `crate` as visibility modifier, synonymous with `pub(crate)`. - (removed, crate_visibility_modifier, "1.63.0", Some(53120), None, Some("removed in favor of `pub(crate)`")), + (removed, crate_visibility_modifier, "1.63.0", Some(53120), Some("removed in favor of `pub(crate)`")), /// Allows using custom attributes (RFC 572). - (removed, custom_attribute, "1.0.0", Some(29642), None, + (removed, custom_attribute, "1.0.0", Some(29642), Some("removed in favor of `#![register_tool]` and `#![register_attr]`")), /// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`. - (removed, custom_derive, "1.32.0", Some(29644), None, + (removed, custom_derive, "1.32.0", Some(29644), Some("subsumed by `#[proc_macro_derive]`")), /// Allows using `#[doc(keyword = "...")]`. - (removed, doc_keyword, "1.28.0", Some(51315), None, + (removed, doc_keyword, "1.28.0", Some(51315), Some("merged into `#![feature(rustdoc_internals)]`")), /// Allows using `doc(primitive)` without a future-incompat warning. - (removed, doc_primitive, "1.56.0", Some(88070), None, + (removed, doc_primitive, "1.56.0", Some(88070), Some("merged into `#![feature(rustdoc_internals)]`")), /// Allows `#[doc(spotlight)]`. /// The attribute was renamed to `#[doc(notable_trait)]` /// and the feature to `doc_notable_trait`. - (removed, doc_spotlight, "1.22.0", Some(45040), None, + (removed, doc_spotlight, "1.22.0", Some(45040), Some("renamed to `doc_notable_trait`")), /// Allows using `#[unsafe_destructor_blind_to_params]` (RFC 1238). - (removed, dropck_parametricity, "1.38.0", Some(28498), None, None), + (removed, dropck_parametricity, "1.38.0", Some(28498), None), /// Allows defining `existential type`s. - (removed, existential_type, "1.38.0", Some(63063), None, + (removed, existential_type, "1.38.0", Some(63063), Some("removed in favor of `#![feature(type_alias_impl_trait)]`")), /// Paths of the form: `extern::foo::bar` - (removed, extern_in_paths, "1.33.0", Some(55600), None, + (removed, extern_in_paths, "1.33.0", Some(55600), Some("subsumed by `::foo::bar` paths")), /// Allows `#[doc(include = "some-file")]`. - (removed, external_doc, "1.54.0", Some(44732), None, + (removed, external_doc, "1.54.0", Some(44732), Some("use #[doc = include_str!(\"filename\")] instead, which handles macro invocations")), /// Allows generators to be cloned. - (removed, generator_clone, "1.65.0", Some(95360), None, Some("renamed to `coroutine_clone`")), + (removed, generator_clone, "1.65.0", Some(95360), Some("renamed to `coroutine_clone`")), /// Allows defining generators. - (removed, generators, "1.21.0", Some(43122), None, Some("renamed to `coroutines`")), + (removed, generators, "1.21.0", Some(43122), Some("renamed to `coroutines`")), /// Allows `impl Trait` in bindings (`let`, `const`, `static`). - (removed, impl_trait_in_bindings, "1.55.0", Some(63065), None, + (removed, impl_trait_in_bindings, "1.55.0", Some(63065), Some("the implementation was not maintainable, the feature may get reintroduced once the current refactorings are done")), - (removed, import_shadowing, "1.0.0", None, None, None), + (removed, import_shadowing, "1.0.0", None, None), /// Allows in-band quantification of lifetime bindings (e.g., `fn foo(x: &'a u8) -> &'a u8`). - (removed, in_band_lifetimes, "1.23.0", Some(44524), None, + (removed, in_band_lifetimes, "1.23.0", Some(44524), Some("removed due to unsolved ergonomic questions and added lifetime resolution complexity")), /// Allows inferring `'static` outlives requirements (RFC 2093). - (removed, infer_static_outlives_requirements, "1.63.0", Some(54185), None, + (removed, infer_static_outlives_requirements, "1.63.0", Some(54185), Some("removed as it caused some confusion and discussion was inactive for years")), /// Lazily evaluate constants. This allows constants to depend on type parameters. - (removed, lazy_normalization_consts, "1.46.0", Some(72219), None, Some("superseded by `generic_const_exprs`")), + (removed, lazy_normalization_consts, "1.46.0", Some(72219), Some("superseded by `generic_const_exprs`")), /// Allows using the `#[link_args]` attribute. - (removed, link_args, "1.53.0", Some(29596), None, + (removed, link_args, "1.53.0", Some(29596), Some("removed in favor of using `-C link-arg=ARG` on command line, \ which is available from cargo build scripts with `cargo:rustc-link-arg` now")), - (removed, macro_reexport, "1.0.0", Some(29638), None, + (removed, macro_reexport, "1.0.0", Some(29638), Some("subsumed by `pub use`")), /// Allows using `#[main]` to replace the entrypoint `#[lang = "start"]` calls. - (removed, main, "1.53.0", Some(29634), None, None), - (removed, managed_boxes, "1.0.0", None, None, None), + (removed, main, "1.53.0", Some(29634), None), + (removed, managed_boxes, "1.0.0", None, None), /// Allows the use of type alias impl trait in function return positions - (removed, min_type_alias_impl_trait, "1.56.0", Some(63063), None, + (removed, min_type_alias_impl_trait, "1.56.0", Some(63063), Some("removed in favor of full type_alias_impl_trait")), - (removed, needs_allocator, "1.4.0", Some(27389), None, + (removed, needs_allocator, "1.4.0", Some(27389), Some("subsumed by `#![feature(allocator_internals)]`")), /// Allows use of unary negate on unsigned integers, e.g., -e for e: u8 - (removed, negate_unsigned, "1.0.0", Some(29645), None, None), + (removed, negate_unsigned, "1.0.0", Some(29645), None), /// Allows `#[no_coverage]` on functions. /// The feature was renamed to `coverage_attribute` and the attribute to `#[coverage(on|off)]` - (removed, no_coverage, "1.74.0", Some(84605), None, Some("renamed to `coverage_attribute`")), + (removed, no_coverage, "1.74.0", Some(84605), Some("renamed to `coverage_attribute`")), /// Allows `#[no_debug]`. - (removed, no_debug, "1.43.0", Some(29721), None, Some("removed due to lack of demand")), + (removed, no_debug, "1.43.0", Some(29721), Some("removed due to lack of demand")), /// Note: this feature was previously recorded in a separate /// `STABLE_REMOVED` list because it, uniquely, was once stable but was /// then removed. But there was no utility storing it separately, so now /// it's in this list. - (removed, no_stack_check, "1.0.0", None, None, None), + (removed, no_stack_check, "1.0.0", None, None), /// Allows using `#[on_unimplemented(..)]` on traits. /// (Moved to `rustc_attrs`.) - (removed, on_unimplemented, "1.40.0", None, None, None), + (removed, on_unimplemented, "1.40.0", None, None), /// A way to temporarily opt out of opt-in copy. This will *never* be accepted. - (removed, opt_out_copy, "1.0.0", None, None, None), + (removed, opt_out_copy, "1.0.0", None, None), /// Allows features specific to OIBIT (now called auto traits). /// Renamed to `auto_traits`. - (removed, optin_builtin_traits, "1.0.0", Some(13231), None, + (removed, optin_builtin_traits, "1.0.0", Some(13231), Some("renamed to `auto_traits`")), /// Allows overlapping impls of marker traits. - (removed, overlapping_marker_traits, "1.42.0", Some(29864), None, + (removed, overlapping_marker_traits, "1.42.0", Some(29864), Some("removed in favor of `#![feature(marker_trait_attr)]`")), - (removed, panic_implementation, "1.28.0", Some(44489), None, + (removed, panic_implementation, "1.28.0", Some(44489), Some("subsumed by `#[panic_handler]`")), /// Allows using `#![plugin(myplugin)]`. - (removed, plugin, "1.75.0", Some(29597), None, + (removed, plugin, "1.75.0", Some(29597), Some("plugins are no longer supported")), /// Allows using `#[plugin_registrar]` on functions. - (removed, plugin_registrar, "1.54.0", Some(29597), None, + (removed, plugin_registrar, "1.54.0", Some(29597), Some("plugins are no longer supported")), /// Allows exhaustive integer pattern matching with `usize::MAX`/`isize::MIN`/`isize::MAX`. - (removed, precise_pointer_size_matching, "1.32.0", Some(56354), None, + (removed, precise_pointer_size_matching, "1.32.0", Some(56354), Some("removed in favor of half-open ranges")), - (removed, proc_macro_expr, "1.27.0", Some(54727), None, + (removed, proc_macro_expr, "1.27.0", Some(54727), Some("subsumed by `#![feature(proc_macro_hygiene)]`")), - (removed, proc_macro_gen, "1.27.0", Some(54727), None, + (removed, proc_macro_gen, "1.27.0", Some(54727), Some("subsumed by `#![feature(proc_macro_hygiene)]`")), - (removed, proc_macro_mod, "1.27.0", Some(54727), None, + (removed, proc_macro_mod, "1.27.0", Some(54727), Some("subsumed by `#![feature(proc_macro_hygiene)]`")), - (removed, proc_macro_non_items, "1.27.0", Some(54727), None, + (removed, proc_macro_non_items, "1.27.0", Some(54727), Some("subsumed by `#![feature(proc_macro_hygiene)]`")), - (removed, pub_macro_rules, "1.53.0", Some(78855), None, + (removed, pub_macro_rules, "1.53.0", Some(78855), Some("removed due to being incomplete, in particular it does not work across crates")), - (removed, pushpop_unsafe, "1.2.0", None, None, None), - (removed, quad_precision_float, "1.0.0", None, None, None), - (removed, quote, "1.33.0", Some(29601), None, None), - (removed, reflect, "1.0.0", Some(27749), None, None), + (removed, pushpop_unsafe, "1.2.0", None, None), + (removed, quad_precision_float, "1.0.0", None, None), + (removed, quote, "1.33.0", Some(29601), None), + (removed, reflect, "1.0.0", Some(27749), None), /// Allows using the `#[register_attr]` attribute. - (removed, register_attr, "1.65.0", Some(66080), None, + (removed, register_attr, "1.65.0", Some(66080), Some("removed in favor of `#![register_tool]`")), + (removed, rust_2018_preview, "CURRENT_RUSTC_VERSION", None, + Some("2018 Edition preview is no longer relevant")), /// Allows using the macros: /// + `__diagnostic_used` /// + `__register_diagnostic` /// +`__build_diagnostic_array` - (removed, rustc_diagnostic_macros, "1.38.0", None, None, None), + (removed, rustc_diagnostic_macros, "1.38.0", None, None), /// Allows identifying crates that contain sanitizer runtimes. - (removed, sanitizer_runtime, "1.17.0", None, None, None), - (removed, simd, "1.0.0", Some(27731), None, + (removed, sanitizer_runtime, "1.17.0", None, None), + (removed, simd, "1.0.0", Some(27731), Some("removed in favor of `#[repr(simd)]`")), /// Allows `#[link(kind = "static-nobundle", ...)]`. - (removed, static_nobundle, "1.16.0", Some(37403), None, + (removed, static_nobundle, "1.16.0", Some(37403), Some(r#"subsumed by `#[link(kind = "static", modifiers = "-bundle", ...)]`"#)), - (removed, struct_inherit, "1.0.0", None, None, None), - (removed, test_removed_feature, "1.0.0", None, None, None), + (removed, struct_inherit, "1.0.0", None, None), + (removed, test_removed_feature, "1.0.0", None, None), /// Allows using items which are missing stability attributes - (removed, unmarked_api, "1.0.0", None, None, None), - (removed, unsafe_no_drop_flag, "1.0.0", None, None, None), + (removed, unmarked_api, "1.0.0", None, None), + (removed, unsafe_no_drop_flag, "1.0.0", None, None), /// Allows `union` fields that don't implement `Copy` as long as they don't have any drop glue. - (removed, untagged_unions, "1.13.0", Some(55149), None, + (removed, untagged_unions, "1.13.0", Some(55149), Some("unions with `Copy` and `ManuallyDrop` fields are stable; there is no intent to stabilize more")), /// Allows `#[unwind(..)]`. /// /// Permits specifying whether a function should permit unwinding or abort on unwind. - (removed, unwind_attributes, "1.56.0", Some(58760), None, Some("use the C-unwind ABI instead")), - (removed, visible_private_types, "1.0.0", None, None, None), + (removed, unwind_attributes, "1.56.0", Some(58760), Some("use the C-unwind ABI instead")), + (removed, visible_private_types, "1.0.0", None, None), // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! // Features are listed in alphabetical order. Tidy will fail if you don't keep it this way. // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 365a16e6838..bbf5e031175 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -3,7 +3,6 @@ use super::{to_nonzero, Feature}; use rustc_data_structures::fx::FxHashSet; -use rustc_span::edition::Edition; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; @@ -33,7 +32,7 @@ macro_rules! status_to_enum { macro_rules! declare_features { ($( - $(#[doc = $doc:tt])* ($status:ident, $feature:ident, $ver:expr, $issue:expr, $edition:expr), + $(#[doc = $doc:tt])* ($status:ident, $feature:ident, $ver:expr, $issue:expr), )+) => { /// Unstable language features that are being implemented or being /// considered for acceptance (stabilization) or removal. @@ -43,7 +42,6 @@ macro_rules! declare_features { name: sym::$feature, since: $ver, issue: to_nonzero($issue), - edition: $edition, }, // Sets this feature's corresponding bool within `features`. set_enabled: |features| features.$feature = true, @@ -102,8 +100,7 @@ macro_rules! declare_features { self.declared_features.contains(&feature) } - /// Is the given feature active, i.e. declared or automatically - /// enabled due to the edition? + /// Is the given feature active (enabled by the user)? /// /// Panics if the symbol doesn't correspond to a declared feature. pub fn active(&self, feature: Symbol) -> bool { @@ -179,58 +176,56 @@ declare_features! ( // no-tracking-issue-start /// Allows using the `unadjusted` ABI; perma-unstable. - (internal, abi_unadjusted, "1.16.0", None, None), + (internal, abi_unadjusted, "1.16.0", None), /// Allows using the `vectorcall` ABI. - (unstable, abi_vectorcall, "1.7.0", None, None), + (unstable, abi_vectorcall, "1.7.0", None), /// Allows using `#![needs_allocator]`, an implementation detail of `#[global_allocator]`. - (internal, allocator_internals, "1.20.0", None, None), + (internal, allocator_internals, "1.20.0", None), /// Allows using `#[allow_internal_unsafe]`. This is an /// attribute on `macro_rules!` and can't use the attribute handling /// below (it has to be checked before expansion possibly makes /// macros disappear). - (internal, allow_internal_unsafe, "1.0.0", None, None), + (internal, allow_internal_unsafe, "1.0.0", None), /// Allows using `#[allow_internal_unstable]`. This is an /// attribute on `macro_rules!` and can't use the attribute handling /// below (it has to be checked before expansion possibly makes /// macros disappear). - (internal, allow_internal_unstable, "1.0.0", None, None), + (internal, allow_internal_unstable, "1.0.0", None), /// Allows using anonymous lifetimes in argument-position impl-trait. - (unstable, anonymous_lifetime_in_impl_trait, "1.63.0", None, None), + (unstable, anonymous_lifetime_in_impl_trait, "1.63.0", None), /// Allows identifying the `compiler_builtins` crate. - (internal, compiler_builtins, "1.13.0", None, None), + (internal, compiler_builtins, "1.13.0", None), /// Allows writing custom MIR - (internal, custom_mir, "1.65.0", None, None), + (internal, custom_mir, "1.65.0", None), /// Outputs useful `assert!` messages - (unstable, generic_assert, "1.63.0", None, None), + (unstable, generic_assert, "1.63.0", None), /// Allows using the `rust-intrinsic`'s "ABI". - (internal, intrinsics, "1.0.0", None, None), + (internal, intrinsics, "1.0.0", None), /// Allows using `#[lang = ".."]` attribute for linking items to special compiler logic. - (internal, lang_items, "1.0.0", None, None), + (internal, lang_items, "1.0.0", None), /// Changes `impl Trait` to capture all lifetimes in scope. - (unstable, lifetime_capture_rules_2024, "CURRENT_RUSTC_VERSION", None, None), + (unstable, lifetime_capture_rules_2024, "CURRENT_RUSTC_VERSION", None), /// Allows `#[link(..., cfg(..))]`; perma-unstable per #37406 - (unstable, link_cfg, "1.14.0", None, None), + (unstable, link_cfg, "1.14.0", None), /// Allows the `multiple_supertrait_upcastable` lint. - (unstable, multiple_supertrait_upcastable, "1.69.0", None, None), + (unstable, multiple_supertrait_upcastable, "1.69.0", None), /// Allow negative trait bounds. This is an internal-only feature for testing the trait solver! - (incomplete, negative_bounds, "1.71.0", None, None), + (incomplete, negative_bounds, "1.71.0", None), /// Allows using `#[omit_gdb_pretty_printer_section]`. - (internal, omit_gdb_pretty_printer_section, "1.5.0", None, None), + (internal, omit_gdb_pretty_printer_section, "1.5.0", None), /// Allows using `#[prelude_import]` on glob `use` items. - (internal, prelude_import, "1.2.0", None, None), + (internal, prelude_import, "1.2.0", None), /// Used to identify crates that contain the profiler runtime. - (internal, profiler_runtime, "1.18.0", None, None), + (internal, profiler_runtime, "1.18.0", None), /// Allows using `rustc_*` attributes (RFC 572). - (internal, rustc_attrs, "1.0.0", None, None), + (internal, rustc_attrs, "1.0.0", None), /// Allows using the `#[stable]` and `#[unstable]` attributes. - (internal, staged_api, "1.0.0", None, None), - /// Added for testing E0705; perma-unstable. - (internal, test_2018_feature, "1.31.0", None, Some(Edition::Edition2018)), + (internal, staged_api, "1.0.0", None), /// Added for testing unstable lints; perma-unstable. - (internal, test_unstable_lint, "1.60.0", None, None), + (internal, test_unstable_lint, "1.60.0", None), /// Use for stable + negative coherence and strict coherence depending on trait's /// rustc_strict_coherence value. - (unstable, with_negative_coherence, "1.60.0", None, None), + (unstable, with_negative_coherence, "1.60.0", None), // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! // Features are listed in alphabetical order. Tidy will fail if you don't keep it this way. // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! @@ -246,44 +241,44 @@ declare_features! ( /// Allows features specific to auto traits. /// Renamed from `optin_builtin_traits`. - (unstable, auto_traits, "1.50.0", Some(13231), None), + (unstable, auto_traits, "1.50.0", Some(13231)), /// Allows using `box` in patterns (RFC 469). - (unstable, box_patterns, "1.0.0", Some(29641), None), + (unstable, box_patterns, "1.0.0", Some(29641)), /// Allows `#[doc(notable_trait)]`. /// Renamed from `doc_spotlight`. - (unstable, doc_notable_trait, "1.52.0", Some(45040), None), + (unstable, doc_notable_trait, "1.52.0", Some(45040)), /// Allows using the `may_dangle` attribute (RFC 1327). - (unstable, dropck_eyepatch, "1.10.0", Some(34761), None), + (unstable, dropck_eyepatch, "1.10.0", Some(34761)), /// Allows using the `#[fundamental]` attribute. - (unstable, fundamental, "1.0.0", Some(29635), None), + (unstable, fundamental, "1.0.0", Some(29635)), /// Allows using `#[link_name="llvm.*"]`. - (internal, link_llvm_intrinsics, "1.0.0", Some(29602), None), + (internal, link_llvm_intrinsics, "1.0.0", Some(29602)), /// Allows using the `#[linkage = ".."]` attribute. - (unstable, linkage, "1.0.0", Some(29603), None), + (unstable, linkage, "1.0.0", Some(29603)), /// Allows declaring with `#![needs_panic_runtime]` that a panic runtime is needed. - (internal, needs_panic_runtime, "1.10.0", Some(32837), None), + (internal, needs_panic_runtime, "1.10.0", Some(32837)), /// Allows using the `#![panic_runtime]` attribute. - (internal, panic_runtime, "1.10.0", Some(32837), None), + (internal, panic_runtime, "1.10.0", Some(32837)), /// Allows `extern "platform-intrinsic" { ... }`. - (internal, platform_intrinsics, "1.4.0", Some(27731), None), + (internal, platform_intrinsics, "1.4.0", Some(27731)), /// Allows using `#[rustc_allow_const_fn_unstable]`. /// This is an attribute on `const fn` for the same /// purpose as `#[allow_internal_unstable]`. - (internal, rustc_allow_const_fn_unstable, "1.49.0", Some(69399), None), + (internal, rustc_allow_const_fn_unstable, "1.49.0", Some(69399)), /// Allows using compiler's own crates. - (unstable, rustc_private, "1.0.0", Some(27812), None), + (unstable, rustc_private, "1.0.0", Some(27812)), /// Allows using internal rustdoc features like `doc(keyword)`. - (internal, rustdoc_internals, "1.58.0", Some(90418), None), + (internal, rustdoc_internals, "1.58.0", Some(90418)), /// Allows using the `rustdoc::missing_doc_code_examples` lint - (unstable, rustdoc_missing_doc_code_examples, "1.31.0", Some(101730), None), + (unstable, rustdoc_missing_doc_code_examples, "1.31.0", Some(101730)), /// Allows using `#[start]` on a function indicating that it is the program entrypoint. - (unstable, start, "1.0.0", Some(29633), None), + (unstable, start, "1.0.0", Some(29633)), /// Allows using `#[structural_match]` which indicates that a type is structurally matchable. /// FIXME: Subsumed by trait `StructuralPartialEq`, cannot move to removed until a library /// feature with the same name exists. - (unstable, structural_match, "1.8.0", Some(31434), None), + (unstable, structural_match, "1.8.0", Some(31434)), /// Allows using the `rust-call` ABI. - (unstable, unboxed_closures, "1.0.0", Some(29625), None), + (unstable, unboxed_closures, "1.0.0", Some(29625)), // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! // Features are listed in alphabetical order. Tidy will fail if you don't keep it this way. // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! @@ -299,21 +294,21 @@ declare_features! ( // FIXME: Document these and merge with the list below. // Unstable `#[target_feature]` directives. - (unstable, aarch64_ver_target_feature, "1.27.0", Some(44839), None), - (unstable, arm_target_feature, "1.27.0", Some(44839), None), - (unstable, avx512_target_feature, "1.27.0", Some(44839), None), - (unstable, bpf_target_feature, "1.54.0", Some(44839), None), - (unstable, csky_target_feature, "1.73.0", Some(44839), None), - (unstable, ermsb_target_feature, "1.49.0", Some(44839), None), - (unstable, hexagon_target_feature, "1.27.0", Some(44839), None), - (unstable, loongarch_target_feature, "1.73.0", Some(44839), None), - (unstable, mips_target_feature, "1.27.0", Some(44839), None), - (unstable, powerpc_target_feature, "1.27.0", Some(44839), None), - (unstable, riscv_target_feature, "1.45.0", Some(44839), None), - (unstable, rtm_target_feature, "1.35.0", Some(44839), None), - (unstable, sse4a_target_feature, "1.27.0", Some(44839), None), - (unstable, tbm_target_feature, "1.27.0", Some(44839), None), - (unstable, wasm_target_feature, "1.30.0", Some(44839), None), + (unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)), + (unstable, arm_target_feature, "1.27.0", Some(44839)), + (unstable, avx512_target_feature, "1.27.0", Some(44839)), + (unstable, bpf_target_feature, "1.54.0", Some(44839)), + (unstable, csky_target_feature, "1.73.0", Some(44839)), + (unstable, ermsb_target_feature, "1.49.0", Some(44839)), + (unstable, hexagon_target_feature, "1.27.0", Some(44839)), + (unstable, loongarch_target_feature, "1.73.0", Some(44839)), + (unstable, mips_target_feature, "1.27.0", Some(44839)), + (unstable, powerpc_target_feature, "1.27.0", Some(44839)), + (unstable, riscv_target_feature, "1.45.0", Some(44839)), + (unstable, rtm_target_feature, "1.35.0", Some(44839)), + (unstable, sse4a_target_feature, "1.27.0", Some(44839)), + (unstable, tbm_target_feature, "1.27.0", Some(44839)), + (unstable, wasm_target_feature, "1.30.0", Some(44839)), // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! // Features are listed in alphabetical order. Tidy will fail if you don't keep it this way. // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! @@ -327,295 +322,295 @@ declare_features! ( // ------------------------------------------------------------------------- /// Allows using the `amdgpu-kernel` ABI. - (unstable, abi_amdgpu_kernel, "1.29.0", Some(51575), None), + (unstable, abi_amdgpu_kernel, "1.29.0", Some(51575)), /// Allows `extern "avr-interrupt" fn()` and `extern "avr-non-blocking-interrupt" fn()`. - (unstable, abi_avr_interrupt, "1.45.0", Some(69664), None), + (unstable, abi_avr_interrupt, "1.45.0", Some(69664)), /// Allows `extern "C-cmse-nonsecure-call" fn()`. - (unstable, abi_c_cmse_nonsecure_call, "1.51.0", Some(81391), None), + (unstable, abi_c_cmse_nonsecure_call, "1.51.0", Some(81391)), /// Allows `extern "msp430-interrupt" fn()`. - (unstable, abi_msp430_interrupt, "1.16.0", Some(38487), None), + (unstable, abi_msp430_interrupt, "1.16.0", Some(38487)), /// Allows `extern "ptx-*" fn()`. - (unstable, abi_ptx, "1.15.0", Some(38788), None), + (unstable, abi_ptx, "1.15.0", Some(38788)), /// Allows `extern "riscv-interrupt-m" fn()` and `extern "riscv-interrupt-s" fn()`. - (unstable, abi_riscv_interrupt, "1.73.0", Some(111889), None), + (unstable, abi_riscv_interrupt, "1.73.0", Some(111889)), /// Allows `extern "x86-interrupt" fn()`. - (unstable, abi_x86_interrupt, "1.17.0", Some(40180), None), + (unstable, abi_x86_interrupt, "1.17.0", Some(40180)), /// Allows additional const parameter types, such as `&'static str` or user defined types - (incomplete, adt_const_params, "1.56.0", Some(95174), None), + (incomplete, adt_const_params, "1.56.0", Some(95174)), /// Allows defining an `#[alloc_error_handler]`. - (unstable, alloc_error_handler, "1.29.0", Some(51540), None), + (unstable, alloc_error_handler, "1.29.0", Some(51540)), /// Allows trait methods with arbitrary self types. - (unstable, arbitrary_self_types, "1.23.0", Some(44874), None), + (unstable, arbitrary_self_types, "1.23.0", Some(44874)), /// Allows using `const` operands in inline assembly. - (unstable, asm_const, "1.58.0", Some(93332), None), + (unstable, asm_const, "1.58.0", Some(93332)), /// Enables experimental inline assembly support for additional architectures. - (unstable, asm_experimental_arch, "1.58.0", Some(93335), None), + (unstable, asm_experimental_arch, "1.58.0", Some(93335)), /// Allows the `may_unwind` option in inline assembly. - (unstable, asm_unwind, "1.58.0", Some(93334), None), + (unstable, asm_unwind, "1.58.0", Some(93334)), /// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`. - (unstable, associated_const_equality, "1.58.0", Some(92827), None), + (unstable, associated_const_equality, "1.58.0", Some(92827)), /// Allows the user of associated type bounds. - (unstable, associated_type_bounds, "1.34.0", Some(52662), None), + (unstable, associated_type_bounds, "1.34.0", Some(52662)), /// Allows associated type defaults. - (unstable, associated_type_defaults, "1.2.0", Some(29661), None), + (unstable, associated_type_defaults, "1.2.0", Some(29661)), /// Allows `async || body` closures. - (unstable, async_closure, "1.37.0", Some(62290), None), + (unstable, async_closure, "1.37.0", Some(62290)), /// Allows `#[track_caller]` on async functions. - (unstable, async_fn_track_caller, "1.73.0", Some(110011), None), + (unstable, async_fn_track_caller, "1.73.0", Some(110011)), /// Allows builtin # foo() syntax - (unstable, builtin_syntax, "1.71.0", Some(110680), None), + (unstable, builtin_syntax, "1.71.0", Some(110680)), /// Treat `extern "C"` function as nounwind. - (unstable, c_unwind, "1.52.0", Some(74990), None), + (unstable, c_unwind, "1.52.0", Some(74990)), /// Allows using C-variadics. - (unstable, c_variadic, "1.34.0", Some(44930), None), + (unstable, c_variadic, "1.34.0", Some(44930)), /// Allows the use of `#[cfg(overflow_checks)` to check if integer overflow behaviour. - (unstable, cfg_overflow_checks, "1.71.0", Some(111466), None), + (unstable, cfg_overflow_checks, "1.71.0", Some(111466)), /// Provides the relocation model information as cfg entry - (unstable, cfg_relocation_model, "1.73.0", Some(114929), None), + (unstable, cfg_relocation_model, "1.73.0", Some(114929)), /// Allows the use of `#[cfg(sanitize = "option")]`; set when -Zsanitizer is used. - (unstable, cfg_sanitize, "1.41.0", Some(39699), None), + (unstable, cfg_sanitize, "1.41.0", Some(39699)), /// Allows `cfg(target_abi = "...")`. - (unstable, cfg_target_abi, "1.55.0", Some(80970), None), + (unstable, cfg_target_abi, "1.55.0", Some(80970)), /// Allows `cfg(target(abi = "..."))`. - (unstable, cfg_target_compact, "1.63.0", Some(96901), None), + (unstable, cfg_target_compact, "1.63.0", Some(96901)), /// Allows `cfg(target_has_atomic_load_store = "...")`. - (unstable, cfg_target_has_atomic, "1.60.0", Some(94039), None), + (unstable, cfg_target_has_atomic, "1.60.0", Some(94039)), /// Allows `cfg(target_has_atomic_equal_alignment = "...")`. - (unstable, cfg_target_has_atomic_equal_alignment, "1.60.0", Some(93822), None), + (unstable, cfg_target_has_atomic_equal_alignment, "1.60.0", Some(93822)), /// Allows `cfg(target_thread_local)`. - (unstable, cfg_target_thread_local, "1.7.0", Some(29594), None), + (unstable, cfg_target_thread_local, "1.7.0", Some(29594)), /// Allow conditional compilation depending on rust version - (unstable, cfg_version, "1.45.0", Some(64796), None), + (unstable, cfg_version, "1.45.0", Some(64796)), /// Allows to use the `#[cfi_encoding = ""]` attribute. - (unstable, cfi_encoding, "1.71.0", Some(89653), None), + (unstable, cfi_encoding, "1.71.0", Some(89653)), /// Allows `for<...>` on closures and coroutines. - (unstable, closure_lifetime_binder, "1.64.0", Some(97362), None), + (unstable, closure_lifetime_binder, "1.64.0", Some(97362)), /// Allows `#[track_caller]` on closures and coroutines. - (unstable, closure_track_caller, "1.57.0", Some(87417), None), + (unstable, closure_track_caller, "1.57.0", Some(87417)), /// Allows to use the `#[cmse_nonsecure_entry]` attribute. - (unstable, cmse_nonsecure_entry, "1.48.0", Some(75835), None), + (unstable, cmse_nonsecure_entry, "1.48.0", Some(75835)), /// Allows use of the `#[collapse_debuginfo]` attribute. - (unstable, collapse_debuginfo, "1.65.0", Some(100758), None), + (unstable, collapse_debuginfo, "1.65.0", Some(100758)), /// Allows `async {}` expressions in const contexts. - (unstable, const_async_blocks, "1.53.0", Some(85368), None), + (unstable, const_async_blocks, "1.53.0", Some(85368)), /// Allows `const || {}` closures in const contexts. - (incomplete, const_closures, "1.68.0", Some(106003), None), + (incomplete, const_closures, "1.68.0", Some(106003)), /// Allows the definition of `const extern fn` and `const unsafe extern fn`. - (unstable, const_extern_fn, "1.40.0", Some(64926), None), + (unstable, const_extern_fn, "1.40.0", Some(64926)), /// Allows basic arithmetic on floating point types in a `const fn`. - (unstable, const_fn_floating_point_arithmetic, "1.48.0", Some(57241), None), + (unstable, const_fn_floating_point_arithmetic, "1.48.0", Some(57241)), /// Allows `for _ in _` loops in const contexts. - (unstable, const_for, "1.56.0", Some(87575), None), + (unstable, const_for, "1.56.0", Some(87575)), /// Allows using `&mut` in constant functions. - (unstable, const_mut_refs, "1.41.0", Some(57349), None), + (unstable, const_mut_refs, "1.41.0", Some(57349)), /// Be more precise when looking for live drops in a const context. - (unstable, const_precise_live_drops, "1.46.0", Some(73255), None), + (unstable, const_precise_live_drops, "1.46.0", Some(73255)), /// Allows references to types with interior mutability within constants - (unstable, const_refs_to_cell, "1.51.0", Some(80384), None), + (unstable, const_refs_to_cell, "1.51.0", Some(80384)), /// Allows `impl const Trait for T` syntax. - (unstable, const_trait_impl, "1.42.0", Some(67792), None), + (unstable, const_trait_impl, "1.42.0", Some(67792)), /// Allows the `?` operator in const contexts. - (unstable, const_try, "1.56.0", Some(74935), None), + (unstable, const_try, "1.56.0", Some(74935)), /// Allows coroutines to be cloned. - (unstable, coroutine_clone, "1.65.0", Some(95360), None), + (unstable, coroutine_clone, "1.65.0", Some(95360)), /// Allows defining coroutines. - (unstable, coroutines, "1.21.0", Some(43122), None), + (unstable, coroutines, "1.21.0", Some(43122)), /// Allows function attribute `#[coverage(on/off)]`, to control coverage /// instrumentation of that function. - (unstable, coverage_attribute, "1.74.0", Some(84605), None), + (unstable, coverage_attribute, "1.74.0", Some(84605)), /// Allows users to provide classes for fenced code block using `class:classname`. - (unstable, custom_code_classes_in_docs, "1.74.0", Some(79483), None), + (unstable, custom_code_classes_in_docs, "1.74.0", Some(79483)), /// Allows non-builtin attributes in inner attribute position. - (unstable, custom_inner_attributes, "1.30.0", Some(54726), None), + (unstable, custom_inner_attributes, "1.30.0", Some(54726)), /// Allows custom test frameworks with `#![test_runner]` and `#[test_case]`. - (unstable, custom_test_frameworks, "1.30.0", Some(50297), None), + (unstable, custom_test_frameworks, "1.30.0", Some(50297)), /// Allows declarative macros 2.0 (`macro`). - (unstable, decl_macro, "1.17.0", Some(39412), None), + (unstable, decl_macro, "1.17.0", Some(39412)), /// Allows default type parameters to influence type inference. - (unstable, default_type_parameter_fallback, "1.3.0", Some(27336), None), + (unstable, default_type_parameter_fallback, "1.3.0", Some(27336)), /// Allows using `#[deprecated_safe]` to deprecate the safeness of a function or trait - (unstable, deprecated_safe, "1.61.0", Some(94978), None), + (unstable, deprecated_safe, "1.61.0", Some(94978)), /// Allows having using `suggestion` in the `#[deprecated]` attribute. - (unstable, deprecated_suggestion, "1.61.0", Some(94785), None), + (unstable, deprecated_suggestion, "1.61.0", Some(94785)), /// Allows using the `#[diagnostic]` attribute tool namespace - (unstable, diagnostic_namespace, "1.73.0", Some(111996), None), + (unstable, diagnostic_namespace, "1.73.0", Some(111996)), /// Controls errors in trait implementations. - (unstable, do_not_recommend, "1.67.0", Some(51992), None), + (unstable, do_not_recommend, "1.67.0", Some(51992)), /// Tells rustdoc to automatically generate `#[doc(cfg(...))]`. - (unstable, doc_auto_cfg, "1.58.0", Some(43781), None), + (unstable, doc_auto_cfg, "1.58.0", Some(43781)), /// Allows `#[doc(cfg(...))]`. - (unstable, doc_cfg, "1.21.0", Some(43781), None), + (unstable, doc_cfg, "1.21.0", Some(43781)), /// Allows `#[doc(cfg_hide(...))]`. - (unstable, doc_cfg_hide, "1.57.0", Some(43781), None), + (unstable, doc_cfg_hide, "1.57.0", Some(43781)), /// Allows `#[doc(masked)]`. - (unstable, doc_masked, "1.21.0", Some(44027), None), + (unstable, doc_masked, "1.21.0", Some(44027)), /// Allows `dyn* Trait` objects. - (incomplete, dyn_star, "1.65.0", Some(102425), None), + (incomplete, dyn_star, "1.65.0", Some(102425)), // Uses generic effect parameters for ~const bounds - (unstable, effects, "1.72.0", Some(102090), None), + (unstable, effects, "1.72.0", Some(102090)), /// Allows `X..Y` patterns. - (unstable, exclusive_range_pattern, "1.11.0", Some(37854), None), + (unstable, exclusive_range_pattern, "1.11.0", Some(37854)), /// Allows exhaustive pattern matching on types that contain uninhabited types. - (unstable, exhaustive_patterns, "1.13.0", Some(51085), None), + (unstable, exhaustive_patterns, "1.13.0", Some(51085)), /// Allows explicit tail calls via `become` expression. - (incomplete, explicit_tail_calls, "1.72.0", Some(112788), None), + (incomplete, explicit_tail_calls, "1.72.0", Some(112788)), /// Allows using `efiapi`, `sysv64` and `win64` as calling convention /// for functions with varargs. - (unstable, extended_varargs_abi_support, "1.65.0", Some(100189), None), + (unstable, extended_varargs_abi_support, "1.65.0", Some(100189)), /// Allows defining `extern type`s. - (unstable, extern_types, "1.23.0", Some(43467), None), + (unstable, extern_types, "1.23.0", Some(43467)), /// Allows the use of `#[ffi_const]` on foreign functions. - (unstable, ffi_const, "1.45.0", Some(58328), None), + (unstable, ffi_const, "1.45.0", Some(58328)), /// Allows the use of `#[ffi_pure]` on foreign functions. - (unstable, ffi_pure, "1.45.0", Some(58329), None), + (unstable, ffi_pure, "1.45.0", Some(58329)), /// Allows using `#[ffi_returns_twice]` on foreign functions. - (unstable, ffi_returns_twice, "1.34.0", Some(58314), None), + (unstable, ffi_returns_twice, "1.34.0", Some(58314)), /// Allows using `#[repr(align(...))]` on function items - (unstable, fn_align, "1.53.0", Some(82232), None), + (unstable, fn_align, "1.53.0", Some(82232)), /// Support delegating implementation of functions to other already implemented functions. - (incomplete, fn_delegation, "CURRENT_RUSTC_VERSION", Some(118212), None), + (incomplete, fn_delegation, "CURRENT_RUSTC_VERSION", Some(118212)), /// Allows defining gen blocks and `gen fn`. - (unstable, gen_blocks, "1.75.0", Some(117078), None), + (unstable, gen_blocks, "1.75.0", Some(117078)), /// Infer generic args for both consts and types. - (unstable, generic_arg_infer, "1.55.0", Some(85077), None), + (unstable, generic_arg_infer, "1.55.0", Some(85077)), /// An extension to the `generic_associated_types` feature, allowing incomplete features. - (incomplete, generic_associated_types_extended, "1.61.0", Some(95451), None), + (incomplete, generic_associated_types_extended, "1.61.0", Some(95451)), /// Allows non-trivial generic constants which have to have wfness manually propagated to callers - (incomplete, generic_const_exprs, "1.56.0", Some(76560), None), + (incomplete, generic_const_exprs, "1.56.0", Some(76560)), /// Allows generic parameters and where-clauses on free & associated const items. - (incomplete, generic_const_items, "1.73.0", Some(113521), None), + (incomplete, generic_const_items, "1.73.0", Some(113521)), /// Allows using `..=X` as a patterns in slices. - (unstable, half_open_range_patterns_in_slices, "1.66.0", Some(67264), None), + (unstable, half_open_range_patterns_in_slices, "1.66.0", Some(67264)), /// Allows `if let` guard in match arms. - (unstable, if_let_guard, "1.47.0", Some(51114), None), + (unstable, if_let_guard, "1.47.0", Some(51114)), /// Allows `impl Trait` to be used inside associated types (RFC 2515). - (unstable, impl_trait_in_assoc_type, "1.70.0", Some(63063), None), + (unstable, impl_trait_in_assoc_type, "1.70.0", Some(63063)), /// Allows `impl Trait` as output type in `Fn` traits in return position of functions. - (unstable, impl_trait_in_fn_trait_return, "1.64.0", Some(99697), None), + (unstable, impl_trait_in_fn_trait_return, "1.64.0", Some(99697)), /// Allows using imported `main` function - (unstable, imported_main, "1.53.0", Some(28937), None), + (unstable, imported_main, "1.53.0", Some(28937)), /// Allows associated types in inherent impls. - (incomplete, inherent_associated_types, "1.52.0", Some(8995), None), + (incomplete, inherent_associated_types, "1.52.0", Some(8995)), /// Allow anonymous constants from an inline `const` block - (unstable, inline_const, "1.49.0", Some(76001), None), + (unstable, inline_const, "1.49.0", Some(76001)), /// Allow anonymous constants from an inline `const` block in pattern position - (incomplete, inline_const_pat, "1.58.0", Some(76001), None), + (incomplete, inline_const_pat, "1.58.0", Some(76001)), /// Allows using `pointer` and `reference` in intra-doc links - (unstable, intra_doc_pointers, "1.51.0", Some(80896), None), + (unstable, intra_doc_pointers, "1.51.0", Some(80896)), // Allows setting the threshold for the `large_assignments` lint. - (unstable, large_assignments, "1.52.0", Some(83518), None), + (unstable, large_assignments, "1.52.0", Some(83518)), /// Allow to have type alias types for inter-crate use. - (incomplete, lazy_type_alias, "1.72.0", Some(112792), None), + (incomplete, lazy_type_alias, "1.72.0", Some(112792)), /// Allows `if/while p && let q = r && ...` chains. - (unstable, let_chains, "1.37.0", Some(53667), None), + (unstable, let_chains, "1.37.0", Some(53667)), /// Allows using `#[link(kind = "link-arg", name = "...")]` /// to pass custom arguments to the linker. - (unstable, link_arg_attribute, "CURRENT_RUSTC_VERSION", Some(99427), None), + (unstable, link_arg_attribute, "CURRENT_RUSTC_VERSION", Some(99427)), /// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check. - (unstable, lint_reasons, "1.31.0", Some(54503), None), + (unstable, lint_reasons, "1.31.0", Some(54503)), /// Give access to additional metadata about declarative macro meta-variables. - (unstable, macro_metavar_expr, "1.61.0", Some(83527), None), + (unstable, macro_metavar_expr, "1.61.0", Some(83527)), /// Allows `#[marker]` on certain traits allowing overlapping implementations. - (unstable, marker_trait_attr, "1.30.0", Some(29864), None), + (unstable, marker_trait_attr, "1.30.0", Some(29864)), /// A minimal, sound subset of specialization intended to be used by the /// standard library until the soundness issues with specialization /// are fixed. - (unstable, min_specialization, "1.7.0", Some(31844), None), + (unstable, min_specialization, "1.7.0", Some(31844)), /// Allows qualified paths in struct expressions, struct patterns and tuple struct patterns. - (unstable, more_qualified_paths, "1.54.0", Some(86935), None), + (unstable, more_qualified_paths, "1.54.0", Some(86935)), /// Allows the `#[must_not_suspend]` attribute. - (unstable, must_not_suspend, "1.57.0", Some(83310), None), + (unstable, must_not_suspend, "1.57.0", Some(83310)), /// Allows using `#[naked]` on functions. - (unstable, naked_functions, "1.9.0", Some(32408), None), + (unstable, naked_functions, "1.9.0", Some(32408)), /// Allows specifying the as-needed link modifier - (unstable, native_link_modifiers_as_needed, "1.53.0", Some(81490), None), + (unstable, native_link_modifiers_as_needed, "1.53.0", Some(81490)), /// Allow negative trait implementations. - (unstable, negative_impls, "1.44.0", Some(68318), None), + (unstable, negative_impls, "1.44.0", Some(68318)), /// Allows the `!` pattern. - (incomplete, never_patterns, "CURRENT_RUSTC_VERSION", Some(118155), None), + (incomplete, never_patterns, "CURRENT_RUSTC_VERSION", Some(118155)), /// Allows the `!` type. Does not imply 'exhaustive_patterns' (below) any more. - (unstable, never_type, "1.13.0", Some(35121), None), + (unstable, never_type, "1.13.0", Some(35121)), /// Allows diverging expressions to fall back to `!` rather than `()`. - (unstable, never_type_fallback, "1.41.0", Some(65992), None), + (unstable, never_type_fallback, "1.41.0", Some(65992)), /// Allows `#![no_core]`. - (unstable, no_core, "1.3.0", Some(29639), None), + (unstable, no_core, "1.3.0", Some(29639)), /// Allows the use of `no_sanitize` attribute. - (unstable, no_sanitize, "1.42.0", Some(39699), None), + (unstable, no_sanitize, "1.42.0", Some(39699)), /// Allows using the `non_exhaustive_omitted_patterns` lint. - (unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554), None), + (unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)), /// Allows `for<T>` binders in where-clauses - (incomplete, non_lifetime_binders, "1.69.0", Some(108185), None), + (incomplete, non_lifetime_binders, "1.69.0", Some(108185)), /// Allows making `dyn Trait` well-formed even if `Trait` is not object safe. /// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and /// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden. - (unstable, object_safe_for_dispatch, "1.40.0", Some(43561), None), + (unstable, object_safe_for_dispatch, "1.40.0", Some(43561)), /// Allows using enums in offset_of! - (unstable, offset_of_enum, "1.75.0", Some(106655), None), + (unstable, offset_of_enum, "1.75.0", Some(106655)), /// Allows using `#[optimize(X)]`. - (unstable, optimize_attribute, "1.34.0", Some(54882), None), + (unstable, optimize_attribute, "1.34.0", Some(54882)), /// Allows macro attributes on expressions, statements and non-inline modules. - (unstable, proc_macro_hygiene, "1.30.0", Some(54727), None), + (unstable, proc_macro_hygiene, "1.30.0", Some(54727)), /// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions. - (unstable, raw_ref_op, "1.41.0", Some(64490), None), + (unstable, raw_ref_op, "1.41.0", Some(64490)), /// Allows using the `#[register_tool]` attribute. - (unstable, register_tool, "1.41.0", Some(66079), None), + (unstable, register_tool, "1.41.0", Some(66079)), /// Allows the `#[repr(i128)]` attribute for enums. - (incomplete, repr128, "1.16.0", Some(56071), None), + (incomplete, repr128, "1.16.0", Some(56071)), /// Allows `repr(simd)` and importing the various simd intrinsics. - (unstable, repr_simd, "1.4.0", Some(27731), None), + (unstable, repr_simd, "1.4.0", Some(27731)), /// Allows bounding the return type of AFIT/RPITIT. - (incomplete, return_type_notation, "1.70.0", Some(109417), None), + (incomplete, return_type_notation, "1.70.0", Some(109417)), /// Allows `extern "rust-cold"`. - (unstable, rust_cold_cc, "1.63.0", Some(97544), None), + (unstable, rust_cold_cc, "1.63.0", Some(97544)), /// Allows the use of SIMD types in functions declared in `extern` blocks. - (unstable, simd_ffi, "1.0.0", Some(27731), None), + (unstable, simd_ffi, "1.0.0", Some(27731)), /// Allows specialization of implementations (RFC 1210). - (incomplete, specialization, "1.7.0", Some(31844), None), + (incomplete, specialization, "1.7.0", Some(31844)), /// Allows attributes on expressions and non-item statements. - (unstable, stmt_expr_attributes, "1.6.0", Some(15701), None), + (unstable, stmt_expr_attributes, "1.6.0", Some(15701)), /// Allows lints part of the strict provenance effort. - (unstable, strict_provenance, "1.61.0", Some(95228), None), + (unstable, strict_provenance, "1.61.0", Some(95228)), /// Allows string patterns to dereference values to match them. - (unstable, string_deref_patterns, "1.67.0", Some(87121), None), + (unstable, string_deref_patterns, "1.67.0", Some(87121)), /// Allows the use of `#[target_feature]` on safe functions. - (unstable, target_feature_11, "1.45.0", Some(69098), None), + (unstable, target_feature_11, "1.45.0", Some(69098)), /// Allows using `#[thread_local]` on `static` items. - (unstable, thread_local, "1.0.0", Some(29594), None), + (unstable, thread_local, "1.0.0", Some(29594)), /// Allows defining `trait X = A + B;` alias items. - (unstable, trait_alias, "1.24.0", Some(41517), None), + (unstable, trait_alias, "1.24.0", Some(41517)), /// Allows for transmuting between arrays with sizes that contain generic consts. - (unstable, transmute_generic_consts, "1.70.0", Some(109929), None), + (unstable, transmute_generic_consts, "1.70.0", Some(109929)), /// Allows #[repr(transparent)] on unions (RFC 2645). - (unstable, transparent_unions, "1.37.0", Some(60405), None), + (unstable, transparent_unions, "1.37.0", Some(60405)), /// Allows inconsistent bounds in where clauses. - (unstable, trivial_bounds, "1.28.0", Some(48214), None), + (unstable, trivial_bounds, "1.28.0", Some(48214)), /// Allows using `try {...}` expressions. - (unstable, try_blocks, "1.29.0", Some(31436), None), + (unstable, try_blocks, "1.29.0", Some(31436)), /// Allows `impl Trait` to be used inside type aliases (RFC 2515). - (unstable, type_alias_impl_trait, "1.38.0", Some(63063), None), + (unstable, type_alias_impl_trait, "1.38.0", Some(63063)), /// Allows the use of type ascription in expressions. - (unstable, type_ascription, "1.6.0", Some(23416), None), + (unstable, type_ascription, "1.6.0", Some(23416)), /// Allows creation of instances of a struct by moving fields that have /// not changed from prior instances of the same struct (RFC #2528) - (unstable, type_changing_struct_update, "1.58.0", Some(86555), None), + (unstable, type_changing_struct_update, "1.58.0", Some(86555)), /// Allows using type privacy lints (`private_interfaces`, `private_bounds`, `unnameable_types`). - (unstable, type_privacy_lints, "1.72.0", Some(48054), None), + (unstable, type_privacy_lints, "1.72.0", Some(48054)), /// Enables rustc to generate code that instructs libstd to NOT ignore SIGPIPE. - (unstable, unix_sigpipe, "1.65.0", Some(97889), None), + (unstable, unix_sigpipe, "1.65.0", Some(97889)), /// Allows unnamed fields of struct and union type - (incomplete, unnamed_fields, "1.74.0", Some(49804), None), + (incomplete, unnamed_fields, "1.74.0", Some(49804)), /// Allows unsized fn parameters. - (unstable, unsized_fn_params, "1.49.0", Some(48055), None), + (unstable, unsized_fn_params, "1.49.0", Some(48055)), /// Allows unsized rvalues at arguments and parameters. - (incomplete, unsized_locals, "1.30.0", Some(48055), None), + (incomplete, unsized_locals, "1.30.0", Some(48055)), /// Allows unsized tuple coercion. - (unstable, unsized_tuple_coercion, "1.20.0", Some(42877), None), + (unstable, unsized_tuple_coercion, "1.20.0", Some(42877)), /// Allows using the `#[used(linker)]` (or `#[used(compiler)]`) attribute. - (unstable, used_with_arg, "1.60.0", Some(93798), None), + (unstable, used_with_arg, "1.60.0", Some(93798)), /// Allows `extern "wasm" fn` - (unstable, wasm_abi, "1.53.0", Some(83788), None), + (unstable, wasm_abi, "1.53.0", Some(83788)), /// Allows `do yeet` expressions - (unstable, yeet_expr, "1.62.0", Some(96373), None), + (unstable, yeet_expr, "1.62.0", Some(96373)), // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! // Features are listed in alphabetical order. Tidy will fail if you don't keep it this way. // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 930e29f2389..32eb67ba3a1 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1835,7 +1835,7 @@ impl KeywordIdents { self.check_ident_token(cx, UnderMacro(true), ident); } } - TokenTree::Delimited(_, _, tts) => self.check_tokens(cx, tts), + TokenTree::Delimited(.., tts) => self.check_tokens(cx, tts), } } } diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 92df2da8710..b1dc1f98777 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -67,7 +67,7 @@ pub(crate) fn parse_token_trees<'a>( let (stream, res, unmatched_delims) = tokentrees::TokenTreesReader::parse_all_token_trees(string_reader); match res { - Ok(()) if unmatched_delims.is_empty() => Ok(stream), + Ok(_open_spacing) if unmatched_delims.is_empty() => Ok(stream), _ => { // Return error if there are unmatched delimiters or unclosed delimiters. // We emit delimiter mismatch errors first, then emit the unclosing delimiter mismatch diff --git a/compiler/rustc_parse/src/lexer/tokentrees.rs b/compiler/rustc_parse/src/lexer/tokentrees.rs index e646f5dfd85..8cbadc26635 100644 --- a/compiler/rustc_parse/src/lexer/tokentrees.rs +++ b/compiler/rustc_parse/src/lexer/tokentrees.rs @@ -3,7 +3,7 @@ use super::diagnostics::same_indentation_level; use super::diagnostics::TokenTreeDiagInfo; use super::{StringReader, UnmatchedDelim}; use rustc_ast::token::{self, Delimiter, Token}; -use rustc_ast::tokenstream::{DelimSpan, Spacing, TokenStream, TokenTree}; +use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; use rustc_ast_pretty::pprust::token_to_string; use rustc_errors::{Applicability, PErr}; use rustc_span::symbol::kw; @@ -25,54 +25,46 @@ impl<'a> TokenTreesReader<'a> { token: Token::dummy(), diag_info: TokenTreeDiagInfo::default(), }; - let (stream, res) = tt_reader.parse_token_trees(/* is_delimited */ false); + let (_open_spacing, stream, res) = + tt_reader.parse_token_trees(/* is_delimited */ false); (stream, res, tt_reader.diag_info.unmatched_delims) } - // Parse a stream of tokens into a list of `TokenTree`s. + // Parse a stream of tokens into a list of `TokenTree`s. The `Spacing` in + // the result is that of the opening delimiter. fn parse_token_trees( &mut self, is_delimited: bool, - ) -> (TokenStream, Result<(), Vec<PErr<'a>>>) { - self.token = self.string_reader.next_token().0; + ) -> (Spacing, TokenStream, Result<(), Vec<PErr<'a>>>) { + // Move past the opening delimiter. + let (_, open_spacing) = self.bump(false); + let mut buf = Vec::new(); loop { match self.token.kind { token::OpenDelim(delim) => { buf.push(match self.parse_token_tree_open_delim(delim) { Ok(val) => val, - Err(errs) => return (TokenStream::new(buf), Err(errs)), + Err(errs) => return (open_spacing, TokenStream::new(buf), Err(errs)), }) } token::CloseDelim(delim) => { return ( + open_spacing, TokenStream::new(buf), if is_delimited { Ok(()) } else { Err(vec![self.close_delim_err(delim)]) }, ); } token::Eof => { return ( + open_spacing, TokenStream::new(buf), if is_delimited { Err(vec![self.eof_err()]) } else { Ok(()) }, ); } _ => { - // Get the next normal token. This might require getting multiple adjacent - // single-char tokens and joining them together. - let (this_spacing, next_tok) = loop { - let (next_tok, is_next_tok_preceded_by_whitespace) = - self.string_reader.next_token(); - if is_next_tok_preceded_by_whitespace { - break (Spacing::Alone, next_tok); - } else if let Some(glued) = self.token.glue(&next_tok) { - self.token = glued; - } else { - let this_spacing = - if next_tok.is_punct() { Spacing::Joint } else { Spacing::Alone }; - break (this_spacing, next_tok); - } - }; - let this_tok = std::mem::replace(&mut self.token, next_tok); + // Get the next normal token. + let (this_tok, this_spacing) = self.bump(true); buf.push(TokenTree::Token(this_tok, this_spacing)); } } @@ -116,7 +108,7 @@ impl<'a> TokenTreesReader<'a> { // Parse the token trees within the delimiters. // We stop at any delimiter so we can try to recover if the user // uses an incorrect delimiter. - let (tts, res) = self.parse_token_trees(/* is_delimited */ true); + let (open_spacing, tts, res) = self.parse_token_trees(/* is_delimited */ true); if let Err(errs) = res { return Err(self.unclosed_delim_err(tts, errs)); } @@ -125,7 +117,7 @@ impl<'a> TokenTreesReader<'a> { let delim_span = DelimSpan::from_pair(pre_span, self.token.span); let sm = self.string_reader.sess.source_map(); - match self.token.kind { + let close_spacing = match self.token.kind { // Correct delimiter. token::CloseDelim(close_delim) if close_delim == open_delim => { let (open_brace, open_brace_span) = self.diag_info.open_braces.pop().unwrap(); @@ -147,7 +139,7 @@ impl<'a> TokenTreesReader<'a> { } // Move past the closing delimiter. - self.token = self.string_reader.next_token().0; + self.bump(false).1 } // Incorrect delimiter. token::CloseDelim(close_delim) => { @@ -191,18 +183,50 @@ impl<'a> TokenTreesReader<'a> { // bar(baz( // } // Incorrect delimiter but matches the earlier `{` if !self.diag_info.open_braces.iter().any(|&(b, _)| b == close_delim) { - self.token = self.string_reader.next_token().0; + self.bump(false).1 + } else { + // The choice of value here doesn't matter. + Spacing::Alone } } token::Eof => { // Silently recover, the EOF token will be seen again // and an error emitted then. Thus we don't pop from - // self.open_braces here. + // self.open_braces here. The choice of spacing value here + // doesn't matter. + Spacing::Alone } _ => unreachable!(), - } + }; + + let spacing = DelimSpacing::new(open_spacing, close_spacing); - Ok(TokenTree::Delimited(delim_span, open_delim, tts)) + Ok(TokenTree::Delimited(delim_span, spacing, open_delim, tts)) + } + + // Move on to the next token, returning the current token and its spacing. + // Will glue adjacent single-char tokens together if `glue` is set. + fn bump(&mut self, glue: bool) -> (Token, Spacing) { + let (this_spacing, next_tok) = loop { + let (next_tok, is_next_tok_preceded_by_whitespace) = self.string_reader.next_token(); + + if is_next_tok_preceded_by_whitespace { + break (Spacing::Alone, next_tok); + } else if glue && let Some(glued) = self.token.glue(&next_tok) { + self.token = glued; + } else { + let this_spacing = if next_tok.is_punct() { + Spacing::Joint + } else if next_tok.kind == token::Eof { + Spacing::Alone + } else { + Spacing::JointHidden + }; + break (this_spacing, next_tok); + } + }; + let this_tok = std::mem::replace(&mut self.token, next_tok); + (this_tok, this_spacing) } fn unclosed_delim_err(&mut self, tts: TokenStream, mut errs: Vec<PErr<'a>>) -> Vec<PErr<'a>> { diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs index c66a7176aab..5e8447030f1 100644 --- a/compiler/rustc_parse/src/parser/attr_wrapper.rs +++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs @@ -1,7 +1,7 @@ use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor, TrailingToken}; use rustc_ast::token::{self, Delimiter, Token, TokenKind}; -use rustc_ast::tokenstream::{AttrTokenStream, AttributesData, ToAttrTokenStream}; -use rustc_ast::tokenstream::{AttrTokenTree, DelimSpan, LazyAttrTokenStream, Spacing}; +use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree, AttributesData, DelimSpacing}; +use rustc_ast::tokenstream::{DelimSpan, LazyAttrTokenStream, Spacing, ToAttrTokenStream}; use rustc_ast::{self as ast}; use rustc_ast::{AttrVec, Attribute, HasAttrs, HasTokens}; use rustc_errors::PResult; @@ -389,7 +389,7 @@ fn make_token_stream( #[derive(Debug)] struct FrameData { // This is `None` for the first frame, `Some` for all others. - open_delim_sp: Option<(Delimiter, Span)>, + open_delim_sp: Option<(Delimiter, Span, Spacing)>, inner: Vec<AttrTokenTree>, } let mut stack = vec![FrameData { open_delim_sp: None, inner: vec![] }]; @@ -397,21 +397,23 @@ fn make_token_stream( while let Some((token, spacing)) = token_and_spacing { match token { FlatToken::Token(Token { kind: TokenKind::OpenDelim(delim), span }) => { - stack.push(FrameData { open_delim_sp: Some((delim, span)), inner: vec![] }); + stack + .push(FrameData { open_delim_sp: Some((delim, span, spacing)), inner: vec![] }); } FlatToken::Token(Token { kind: TokenKind::CloseDelim(delim), span }) => { let frame_data = stack .pop() .unwrap_or_else(|| panic!("Token stack was empty for token: {token:?}")); - let (open_delim, open_sp) = frame_data.open_delim_sp.unwrap(); + let (open_delim, open_sp, open_spacing) = frame_data.open_delim_sp.unwrap(); assert_eq!( open_delim, delim, "Mismatched open/close delims: open={open_delim:?} close={span:?}" ); let dspan = DelimSpan::from_pair(open_sp, span); + let dspacing = DelimSpacing::new(open_spacing, spacing); let stream = AttrTokenStream::new(frame_data.inner); - let delimited = AttrTokenTree::Delimited(dspan, delim, stream); + let delimited = AttrTokenTree::Delimited(dspan, dspacing, delim, stream); stack .last_mut() .unwrap_or_else(|| panic!("Bottom token frame is missing for token: {token:?}")) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 406a6def019..3c0627526be 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2276,7 +2276,7 @@ impl<'a> Parser<'a> { } if self.token.kind == TokenKind::Semi - && matches!(self.token_cursor.stack.last(), Some((_, Delimiter::Parenthesis, _))) + && matches!(self.token_cursor.stack.last(), Some((.., Delimiter::Parenthesis))) && self.may_recover() { // It is likely that the closure body is a block but where the diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 7a306823ed4..2baedb2766f 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -20,7 +20,7 @@ pub use path::PathStyle; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Nonterminal, Token, TokenKind}; -use rustc_ast::tokenstream::{AttributesData, DelimSpan, Spacing}; +use rustc_ast::tokenstream::{AttributesData, DelimSpacing, DelimSpan, Spacing}; use rustc_ast::tokenstream::{TokenStream, TokenTree, TokenTreeCursor}; use rustc_ast::util::case::Case; use rustc_ast::AttrId; @@ -130,7 +130,7 @@ pub struct Parser<'a> { pub sess: &'a ParseSess, /// The current token. pub token: Token, - /// The spacing for the current token + /// The spacing for the current token. pub token_spacing: Spacing, /// The previous token. pub prev_token: Token, @@ -240,7 +240,7 @@ struct TokenCursor { // Token streams surrounding the current one. The delimiters for stack[n]'s // tokens are in `stack[n-1]`. `stack[0]` (when present) has no delimiters // because it's the outermost token stream which never has delimiters. - stack: Vec<(TokenTreeCursor, Delimiter, DelimSpan)>, + stack: Vec<(TokenTreeCursor, DelimSpan, DelimSpacing, Delimiter)>, } impl TokenCursor { @@ -264,24 +264,31 @@ impl TokenCursor { )); return (token.clone(), spacing); } - &TokenTree::Delimited(sp, delim, ref tts) => { + &TokenTree::Delimited(sp, spacing, delim, ref tts) => { let trees = tts.clone().into_trees(); - self.stack.push((mem::replace(&mut self.tree_cursor, trees), delim, sp)); + self.stack.push(( + mem::replace(&mut self.tree_cursor, trees), + sp, + spacing, + delim, + )); if delim != Delimiter::Invisible { - return (Token::new(token::OpenDelim(delim), sp.open), Spacing::Alone); + return (Token::new(token::OpenDelim(delim), sp.open), spacing.open); } // No open delimiter to return; continue on to the next iteration. } }; - } else if let Some((tree_cursor, delim, span)) = self.stack.pop() { + } else if let Some((tree_cursor, span, spacing, delim)) = self.stack.pop() { // We have exhausted this token stream. Move back to its parent token stream. self.tree_cursor = tree_cursor; if delim != Delimiter::Invisible { - return (Token::new(token::CloseDelim(delim), span.close), Spacing::Alone); + return (Token::new(token::CloseDelim(delim), span.close), spacing.close); } // No close delimiter to return; continue on to the next iteration. } else { - // We have exhausted the outermost token stream. + // We have exhausted the outermost token stream. The use of + // `Spacing::Alone` is arbitrary and immaterial, because the + // `Eof` token's spacing is never used. return (Token::new(token::Eof, DUMMY_SP), Spacing::Alone); } } @@ -699,8 +706,8 @@ impl<'a> Parser<'a> { // is not needed (we'll capture the entire 'glued' token), // and `bump` will set this field to `None` self.break_last_token = true; - // Use the spacing of the glued token as the spacing - // of the unglued second token. + // Use the spacing of the glued token as the spacing of the + // unglued second token. self.bump_with((Token::new(second, second_span), self.token_spacing)); true } @@ -1068,7 +1075,7 @@ impl<'a> Parser<'a> { return looker(&self.token); } - if let Some(&(_, delim, span)) = self.token_cursor.stack.last() + if let Some(&(_, span, _, delim)) = self.token_cursor.stack.last() && delim != Delimiter::Invisible { // We are not in the outermost token stream, and the token stream @@ -1077,7 +1084,7 @@ impl<'a> Parser<'a> { let tree_cursor = &self.token_cursor.tree_cursor; let all_normal = (0..dist).all(|i| { let token = tree_cursor.look_ahead(i); - !matches!(token, Some(TokenTree::Delimited(_, Delimiter::Invisible, _))) + !matches!(token, Some(TokenTree::Delimited(.., Delimiter::Invisible, _))) }); if all_normal { // There were no skipped delimiters. Do lookahead by plain indexing. @@ -1086,7 +1093,7 @@ impl<'a> Parser<'a> { // Indexing stayed within the current token stream. match tree { TokenTree::Token(token, _) => looker(token), - TokenTree::Delimited(dspan, delim, _) => { + TokenTree::Delimited(dspan, _, delim, _) => { looker(&Token::new(token::OpenDelim(*delim), dspan.open)) } } @@ -1264,7 +1271,7 @@ impl<'a> Parser<'a> { || self.check(&token::OpenDelim(Delimiter::Brace)); delimited.then(|| { - let TokenTree::Delimited(dspan, delim, tokens) = self.parse_token_tree() else { + let TokenTree::Delimited(dspan, _, delim, tokens) = self.parse_token_tree() else { unreachable!() }; DelimArgs { dspan, delim, tokens } @@ -1288,7 +1295,7 @@ impl<'a> Parser<'a> { token::OpenDelim(..) => { // Grab the tokens within the delimiters. let stream = self.token_cursor.tree_cursor.stream.clone(); - let (_, delim, span) = *self.token_cursor.stack.last().unwrap(); + let (_, span, spacing, delim) = *self.token_cursor.stack.last().unwrap(); // Advance the token cursor through the entire delimited // sequence. After getting the `OpenDelim` we are *within* the @@ -1308,12 +1315,13 @@ impl<'a> Parser<'a> { // Consume close delimiter self.bump(); - TokenTree::Delimited(span, delim, stream) + TokenTree::Delimited(span, spacing, delim, stream) } token::CloseDelim(_) | token::Eof => unreachable!(), _ => { + let prev_spacing = self.token_spacing; self.bump(); - TokenTree::Token(self.prev_token.clone(), Spacing::Alone) + TokenTree::Token(self.prev_token.clone(), prev_spacing) } } } diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index ef465f371d2..8dc9a29c2ad 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -8,7 +8,7 @@ use crate::search_paths::SearchPath; use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind}; use crate::{lint, HashStableContext}; use crate::{EarlyErrorHandler, Session}; -use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; +use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey}; use rustc_errors::emitter::HumanReadableErrorType; use rustc_errors::{ColorConfig, DiagnosticArgValue, HandlerFlags, IntoDiagnosticArg}; @@ -1114,6 +1114,7 @@ impl Default for Options { pretty: None, working_dir: RealFileName::LocalPath(std::env::current_dir().unwrap()), color: ColorConfig::Auto, + logical_env: FxIndexMap::default(), } } } @@ -1246,46 +1247,85 @@ pub const fn default_lib_output() -> CrateType { } fn default_configuration(sess: &Session) -> Cfg { - // NOTE: This should be kept in sync with `CheckCfg::fill_well_known` below. - let end = &sess.target.endian; - let arch = &sess.target.arch; - let wordsz = sess.target.pointer_width as u64; - let os = &sess.target.os; - let env = &sess.target.env; - let abi = &sess.target.abi; - let relocation_model = sess.target.relocation_model.desc_symbol(); - let vendor = &sess.target.vendor; - let min_atomic_width = sess.target.min_atomic_width(); - let max_atomic_width = sess.target.max_atomic_width(); - let atomic_cas = sess.target.atomic_cas; - let layout = sess.target.parse_data_layout().unwrap_or_else(|err| { - sess.emit_fatal(err); - }); - let mut ret = Cfg::default(); - ret.reserve(7); // the minimum number of insertions - // Target bindings. - ret.insert((sym::target_os, Some(Symbol::intern(os)))); - for fam in sess.target.families.as_ref() { - ret.insert((sym::target_family, Some(Symbol::intern(fam)))); - if fam == "windows" { - ret.insert((sym::windows, None)); - } else if fam == "unix" { - ret.insert((sym::unix, None)); - } - } - ret.insert((sym::target_arch, Some(Symbol::intern(arch)))); - ret.insert((sym::target_endian, Some(Symbol::intern(end.as_str())))); - ret.insert((sym::target_pointer_width, Some(sym::integer(wordsz)))); - ret.insert((sym::target_env, Some(Symbol::intern(env)))); - ret.insert((sym::target_abi, Some(Symbol::intern(abi)))); + + macro_rules! ins_none { + ($key:expr) => { + ret.insert(($key, None)); + }; + } + macro_rules! ins_str { + ($key:expr, $val_str:expr) => { + ret.insert(($key, Some(Symbol::intern($val_str)))); + }; + } + macro_rules! ins_sym { + ($key:expr, $val_sym:expr) => { + ret.insert(($key, Some($val_sym))); + }; + } + + // Symbols are inserted in alphabetical order as much as possible. + // The exceptions are where control flow forces things out of order. + // + // Run `rustc --print cfg` to see the configuration in practice. + // + // NOTE: These insertions should be kept in sync with + // `CheckCfg::fill_well_known` below. + + if sess.opts.debug_assertions { + ins_none!(sym::debug_assertions); + } + + if sess.overflow_checks() { + ins_none!(sym::overflow_checks); + } + + ins_sym!(sym::panic, sess.panic_strategy().desc_symbol()); + + // JUSTIFICATION: before wrapper fn is available + #[allow(rustc::bad_opt_access)] + if sess.opts.crate_types.contains(&CrateType::ProcMacro) { + ins_none!(sym::proc_macro); + } + if sess.is_nightly_build() { - ret.insert((sym::relocation_model, Some(relocation_model))); + ins_sym!(sym::relocation_model, sess.target.relocation_model.desc_symbol()); } - ret.insert((sym::target_vendor, Some(Symbol::intern(vendor)))); - if sess.opts.unstable_opts.has_thread_local.unwrap_or(sess.target.has_thread_local) { - ret.insert((sym::target_thread_local, None)); + + for mut s in sess.opts.unstable_opts.sanitizer { + // KASAN is still ASAN under the hood, so it uses the same attribute. + if s == SanitizerSet::KERNELADDRESS { + s = SanitizerSet::ADDRESS; + } + ins_str!(sym::sanitize, &s.to_string()); + } + + if sess.is_sanitizer_cfi_generalize_pointers_enabled() { + ins_none!(sym::sanitizer_cfi_generalize_pointers); + } + if sess.is_sanitizer_cfi_normalize_integers_enabled() { + ins_none!(sym::sanitizer_cfi_normalize_integers); + } + + ins_str!(sym::target_abi, &sess.target.abi); + ins_str!(sym::target_arch, &sess.target.arch); + ins_str!(sym::target_endian, sess.target.endian.as_str()); + ins_str!(sym::target_env, &sess.target.env); + + for family in sess.target.families.as_ref() { + ins_str!(sym::target_family, family); + if family == "windows" { + ins_none!(sym::windows); + } else if family == "unix" { + ins_none!(sym::unix); + } } + + // `target_has_atomic*` + let layout = sess.target.parse_data_layout().unwrap_or_else(|err| { + sess.emit_fatal(err); + }); let mut has_atomic = false; for (i, align) in [ (8, layout.i8_align.abi), @@ -1294,63 +1334,46 @@ fn default_configuration(sess: &Session) -> Cfg { (64, layout.i64_align.abi), (128, layout.i128_align.abi), ] { - if i >= min_atomic_width && i <= max_atomic_width { - has_atomic = true; + if i >= sess.target.min_atomic_width() && i <= sess.target.max_atomic_width() { + if !has_atomic { + has_atomic = true; + if sess.is_nightly_build() { + if sess.target.atomic_cas { + ins_none!(sym::target_has_atomic); + } + ins_none!(sym::target_has_atomic_load_store); + } + } let mut insert_atomic = |sym, align: Align| { - ret.insert((sym::target_has_atomic_load_store, Some(sym))); - if atomic_cas { - ret.insert((sym::target_has_atomic, Some(sym))); + if sess.target.atomic_cas { + ins_sym!(sym::target_has_atomic, sym); } if align.bits() == i { - ret.insert((sym::target_has_atomic_equal_alignment, Some(sym))); + ins_sym!(sym::target_has_atomic_equal_alignment, sym); } + ins_sym!(sym::target_has_atomic_load_store, sym); }; insert_atomic(sym::integer(i), align); - if wordsz == i { + if sess.target.pointer_width as u64 == i { insert_atomic(sym::ptr, layout.pointer_align.abi); } } } - if sess.is_nightly_build() && has_atomic { - ret.insert((sym::target_has_atomic_load_store, None)); - if atomic_cas { - ret.insert((sym::target_has_atomic, None)); - } - } - - let panic_strategy = sess.panic_strategy(); - ret.insert((sym::panic, Some(panic_strategy.desc_symbol()))); - for mut s in sess.opts.unstable_opts.sanitizer { - // KASAN should use the same attribute name as ASAN, as it's still ASAN - // under the hood - if s == SanitizerSet::KERNELADDRESS { - s = SanitizerSet::ADDRESS; - } + ins_str!(sym::target_os, &sess.target.os); + ins_sym!(sym::target_pointer_width, sym::integer(sess.target.pointer_width)); - let symbol = Symbol::intern(&s.to_string()); - ret.insert((sym::sanitize, Some(symbol))); + if sess.opts.unstable_opts.has_thread_local.unwrap_or(sess.target.has_thread_local) { + ins_none!(sym::target_thread_local); } - if sess.is_sanitizer_cfi_generalize_pointers_enabled() { - ret.insert((sym::sanitizer_cfi_generalize_pointers, None)); - } + ins_str!(sym::target_vendor, &sess.target.vendor); - if sess.is_sanitizer_cfi_normalize_integers_enabled() { - ret.insert((sym::sanitizer_cfi_normalize_integers, None)); + // If the user wants a test runner, then add the test cfg. + if sess.is_test_crate() { + ins_none!(sym::test); } - if sess.opts.debug_assertions { - ret.insert((sym::debug_assertions, None)); - } - if sess.overflow_checks() { - ret.insert((sym::overflow_checks, None)); - } - // JUSTIFICATION: before wrapper fn is available - #[allow(rustc::bad_opt_access)] - if sess.opts.crate_types.contains(&CrateType::ProcMacro) { - ret.insert((sym::proc_macro, None)); - } ret } @@ -1421,90 +1444,71 @@ impl CheckCfg { ExpectedValues::Some(values) }; - // NOTE: This should be kept in sync with `default_configuration` + macro_rules! ins { + ($name:expr, $values:expr) => { + self.expecteds.entry($name).or_insert_with($values) + }; + } + + // Symbols are inserted in alphabetical order as much as possible. + // The exceptions are where control flow forces things out of order. + // + // NOTE: This should be kept in sync with `default_configuration`. + // Note that symbols inserted conditionally in `default_configuration` + // are inserted unconditionally here. // // When adding a new config here you should also update // `tests/ui/check-cfg/well-known-values.rs`. - let panic_values = &PanicStrategy::all(); + ins!(sym::debug_assertions, no_values); - let atomic_values = &[ - sym::ptr, - sym::integer(8usize), - sym::integer(16usize), - sym::integer(32usize), - sym::integer(64usize), - sym::integer(128usize), - ]; + // These three are never set by rustc, but we set them anyway: they + // should not trigger a lint because `cargo doc`, `cargo test`, and + // `cargo miri run` (respectively) can set them. + ins!(sym::doc, no_values); + ins!(sym::doctest, no_values); + ins!(sym::miri, no_values); + + ins!(sym::overflow_checks, no_values); + + ins!(sym::panic, empty_values).extend(&PanicStrategy::all()); + + ins!(sym::proc_macro, no_values); + + ins!(sym::relocation_model, empty_values).extend(RelocModel::all()); let sanitize_values = SanitizerSet::all() .into_iter() .map(|sanitizer| Symbol::intern(sanitizer.as_str().unwrap())); + ins!(sym::sanitize, empty_values).extend(sanitize_values); - let relocation_model_values = RelocModel::all(); - - // Unknown possible values: - // - `target_feature` - for name in [sym::target_feature] { - self.expecteds.entry(name).or_insert(ExpectedValues::Any); - } - - // No-values - for name in [ - sym::doc, - sym::miri, - sym::unix, - sym::test, - sym::doctest, - sym::windows, - sym::proc_macro, - sym::debug_assertions, - sym::overflow_checks, - sym::target_thread_local, - ] { - self.expecteds.entry(name).or_insert_with(no_values); - } - - // Pre-defined values - self.expecteds.entry(sym::panic).or_insert_with(empty_values).extend(panic_values); - self.expecteds.entry(sym::sanitize).or_insert_with(empty_values).extend(sanitize_values); - self.expecteds - .entry(sym::target_has_atomic) - .or_insert_with(no_values) - .extend(atomic_values); - self.expecteds - .entry(sym::target_has_atomic_load_store) - .or_insert_with(no_values) - .extend(atomic_values); - self.expecteds - .entry(sym::target_has_atomic_equal_alignment) - .or_insert_with(no_values) - .extend(atomic_values); - self.expecteds - .entry(sym::relocation_model) - .or_insert_with(empty_values) - .extend(relocation_model_values); - - // Target specific values + ins!(sym::sanitizer_cfi_generalize_pointers, no_values); + ins!(sym::sanitizer_cfi_normalize_integers, no_values); + + // rustc_codegen_ssa has a list of known target features and their + // stability, but we should allow any target feature as a new target or + // rustc version may introduce new target features. + ins!(sym::target_feature, || ExpectedValues::Any); + + // sym::target_* { const VALUES: [&Symbol; 8] = [ - &sym::target_os, - &sym::target_family, + &sym::target_abi, &sym::target_arch, &sym::target_endian, &sym::target_env, - &sym::target_abi, - &sym::target_vendor, + &sym::target_family, + &sym::target_os, &sym::target_pointer_width, + &sym::target_vendor, ]; // Initialize (if not already initialized) for &e in VALUES { - let entry = self.expecteds.entry(e); if !self.exhaustive_values { - entry.or_insert(ExpectedValues::Any); + ins!(e, || ExpectedValues::Any); } else { - entry.or_insert_with(empty_values); + ins!(e, empty_values); } } @@ -1512,14 +1516,14 @@ impl CheckCfg { // Get all values map at once otherwise it would be costly. // (8 values * 220 targets ~= 1760 times, at the time of writing this comment). let [ - values_target_os, - values_target_family, + values_target_abi, values_target_arch, values_target_endian, values_target_env, - values_target_abi, - values_target_vendor, + values_target_family, + values_target_os, values_target_pointer_width, + values_target_vendor, ] = self .expecteds .get_many_mut(VALUES) @@ -1530,31 +1534,49 @@ impl CheckCfg { .map(|target| Target::expect_builtin(&TargetTriple::from_triple(target))) .chain(iter::once(current_target.clone())) { - values_target_os.insert(Symbol::intern(&target.options.os)); - values_target_family.extend( - target.options.families.iter().map(|family| Symbol::intern(family)), - ); + values_target_abi.insert(Symbol::intern(&target.options.abi)); values_target_arch.insert(Symbol::intern(&target.arch)); values_target_endian.insert(Symbol::intern(target.options.endian.as_str())); values_target_env.insert(Symbol::intern(&target.options.env)); - values_target_abi.insert(Symbol::intern(&target.options.abi)); - values_target_vendor.insert(Symbol::intern(&target.options.vendor)); + values_target_family.extend( + target.options.families.iter().map(|family| Symbol::intern(family)), + ); + values_target_os.insert(Symbol::intern(&target.options.os)); values_target_pointer_width.insert(sym::integer(target.pointer_width)); + values_target_vendor.insert(Symbol::intern(&target.options.vendor)); } } } + + let atomic_values = &[ + sym::ptr, + sym::integer(8usize), + sym::integer(16usize), + sym::integer(32usize), + sym::integer(64usize), + sym::integer(128usize), + ]; + for sym in [ + sym::target_has_atomic, + sym::target_has_atomic_equal_alignment, + sym::target_has_atomic_load_store, + ] { + ins!(sym, no_values).extend(atomic_values); + } + + ins!(sym::target_thread_local, no_values); + + ins!(sym::test, no_values); + + ins!(sym::unix, no_values); + ins!(sym::windows, no_values); } } pub fn build_configuration(sess: &Session, mut user_cfg: Cfg) -> Cfg { // Combine the configuration requested by the session (command line) with // some default and generated configuration items. - let default_cfg = default_configuration(sess); - // If the user wants a test runner, then add the test cfg. - if sess.is_test_crate() { - user_cfg.insert((sym::test, None)); - } - user_cfg.extend(default_cfg.iter().cloned()); + user_cfg.extend(default_configuration(sess).into_iter()); user_cfg } @@ -1813,6 +1835,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> { "Remap source names in all output (compiler messages and output files)", "FROM=TO", ), + opt::multi("", "env", "Inject an environment variable", "VAR=VALUE"), ]); opts } @@ -2592,6 +2615,23 @@ fn parse_remap_path_prefix( mapping } +fn parse_logical_env( + handler: &mut EarlyErrorHandler, + matches: &getopts::Matches, +) -> FxIndexMap<String, String> { + let mut vars = FxIndexMap::default(); + + for arg in matches.opt_strs("env") { + if let Some((name, val)) = arg.split_once('=') { + vars.insert(name.to_string(), val.to_string()); + } else { + handler.early_error(format!("`--env`: specify value for variable `{arg}`")); + } + } + + vars +} + // JUSTIFICATION: before wrapper fn is available #[allow(rustc::bad_opt_access)] pub fn build_session_options( @@ -2830,6 +2870,8 @@ pub fn build_session_options( handler.early_error("can't dump dependency graph without `-Z query-dep-graph`"); } + let logical_env = parse_logical_env(handler, matches); + // Try to find a directory containing the Rust `src`, for more details see // the doc comment on the `real_rust_source_base_dir` field. let tmp_buf; @@ -2910,6 +2952,7 @@ pub fn build_session_options( pretty, working_dir, color, + logical_env, } } @@ -3184,6 +3227,7 @@ pub(crate) mod dep_tracking { }; use crate::lint; use crate::utils::NativeLib; + use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::stable_hasher::Hash64; use rustc_errors::LanguageIdentifier; use rustc_feature::UnstableFeatures; @@ -3342,6 +3386,21 @@ pub(crate) mod dep_tracking { } } + impl<T: DepTrackingHash, V: DepTrackingHash> DepTrackingHash for FxIndexMap<T, V> { + fn hash( + &self, + hasher: &mut DefaultHasher, + error_format: ErrorOutputType, + for_crate_hash: bool, + ) { + Hash::hash(&self.len(), hasher); + for (key, value) in self.iter() { + DepTrackingHash::hash(key, hasher, error_format, for_crate_hash); + DepTrackingHash::hash(value, hasher, error_format, for_crate_hash); + } + } + } + impl DepTrackingHash for OutputTypes { fn hash( &self, diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index b1cf43f471a..d666c5d4d70 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -3,6 +3,7 @@ use crate::config::*; use crate::search_paths::SearchPath; use crate::utils::NativeLib; use crate::{lint, EarlyErrorHandler}; +use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::profiling::TimePassesFormat; use rustc_data_structures::stable_hasher::Hash64; use rustc_errors::ColorConfig; @@ -150,6 +151,9 @@ top_level_options!( target_triple: TargetTriple [TRACKED], + /// Effective logical environment used by `env!`/`option_env!` macros + logical_env: FxIndexMap<String, String> [TRACKED], + test: bool [TRACKED], error_format: ErrorOutputType [UNTRACKED], diagnostic_width: Option<usize> [UNTRACKED], diff --git a/compiler/rustc_span/src/edition.rs b/compiler/rustc_span/src/edition.rs index 608b8c24bde..78ac61fa31d 100644 --- a/compiler/rustc_span/src/edition.rs +++ b/compiler/rustc_span/src/edition.rs @@ -1,4 +1,3 @@ -use crate::symbol::{sym, Symbol}; use std::fmt; use std::str::FromStr; @@ -58,15 +57,6 @@ impl Edition { } } - pub fn feature_name(self) -> Symbol { - match self { - Edition::Edition2015 => sym::rust_2015_preview, - Edition::Edition2018 => sym::rust_2018_preview, - Edition::Edition2021 => sym::rust_2021_preview, - Edition::Edition2024 => sym::rust_2024_preview, - } - } - pub fn is_stable(self) -> bool { match self { Edition::Edition2015 => true, diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 9ad76b74c38..f3c5138716d 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1350,13 +1350,10 @@ symbols! { rtm_target_feature, rust, rust_2015, - rust_2015_preview, rust_2018, rust_2018_preview, rust_2021, - rust_2021_preview, rust_2024, - rust_2024_preview, rust_begin_unwind, rust_cold_cc, rust_eh_catch_typeinfo, diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index f30c40de698..d896873fadd 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -433,7 +433,21 @@ fn layout_of_uncached<'tcx>( .size .checked_mul(e_len, dl) .ok_or_else(|| error(cx, LayoutError::SizeOverflow(ty)))?; - let align = dl.vector_align(size); + + let (abi, align) = if def.repr().packed() && !e_len.is_power_of_two() { + // Non-power-of-two vectors have padding up to the next power-of-two. + // If we're a packed repr, remove the padding while keeping the alignment as close + // to a vector as possible. + ( + Abi::Aggregate { sized: true }, + AbiAndPrefAlign { + abi: Align::max_for_offset(size), + pref: dl.vector_align(size).pref, + }, + ) + } else { + (Abi::Vector { element: e_abi, count: e_len }, dl.vector_align(size)) + }; let size = size.align_to(align.abi); // Compute the placement of the vector fields: @@ -446,7 +460,7 @@ fn layout_of_uncached<'tcx>( tcx.mk_layout(LayoutS { variants: Variants::Single { index: FIRST_VARIANT }, fields, - abi: Abi::Vector { element: e_abi, count: e_len }, + abi, largest_niche: e_ly.largest_niche, size, align, diff --git a/config.example.toml b/config.example.toml index b103e9890d2..14e0b9d521f 100644 --- a/config.example.toml +++ b/config.example.toml @@ -30,7 +30,7 @@ # # If `change-id` does not match the version that is currently running, # `x.py` will prompt you to update it and check the related PR for more details. -change-id = 117813 +change-id = 118703 # ============================================================================= # Tweaking how LLVM is compiled diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index e5d7e964381..588f9b865b0 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -330,7 +330,7 @@ mod prim_never {} /// the future ("reserved"); some will never be a character ("noncharacters"); and some may be given /// different meanings by different users ("private use"). /// -/// `char` is guaranteed to have the same size and alignment as `u32` on all +/// `char` is guaranteed to have the same size, alignment, and function call ABI as `u32` on all /// platforms. /// ``` /// use std::alloc::Layout; @@ -1557,6 +1557,7 @@ mod prim_ref {} /// Pointee>::Metadata`). /// - `usize` is ABI-compatible with the `uN` integer type of the same size, and likewise `isize` is /// ABI-compatible with the `iN` integer type of the same size. +/// - `char` is ABI-compatible with `u32`. /// - Any two `fn` (function pointer) types are ABI-compatible with each other if they have the same /// ABI string or the ABI string only differs in a trailing `-unwind`, independent of the rest of /// their signature. (This means you can pass `fn()` to a function expecting `fn(i32)`, and the @@ -1585,9 +1586,9 @@ mod prim_ref {} /// since it is not portable and not a stable guarantee. /// /// Noteworthy cases of types *not* being ABI-compatible in general are: -/// * `bool` vs `u8`, and `i32` vs `u32`: on some targets, the calling conventions for these types -/// differ in terms of what they guarantee for the remaining bits in the register that are not -/// used by the value. +/// * `bool` vs `u8`, `i32` vs `u32`, `char` vs `i32`: on some targets, the calling conventions for +/// these types differ in terms of what they guarantee for the remaining bits in the register that +/// are not used by the value. /// * `i32` vs `f32` are not compatible either, as has already been mentioned above. /// * `struct Foo(u32)` and `u32` are not compatible (without `repr(transparent)`) since structs are /// aggregate types and often passed in a different way than primitives like `i32`. diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index d3f1fba9369..7ebb6810b3e 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -925,13 +925,12 @@ impl !Sync for Punct {} pub enum Spacing { /// A `Punct` token can join with the following token to form a multi-character operator. /// - /// In token streams constructed using proc macro interfaces `Joint` punctuation tokens can be - /// followed by any other tokens. \ - /// However, in token streams parsed from source code compiler will only set spacing to `Joint` - /// in the following cases: - /// - A `Punct` is immediately followed by another `Punct` without a whitespace. \ - /// E.g. `+` is `Joint` in `+=` and `++`. - /// - A single quote `'` is immediately followed by an identifier without a whitespace. \ + /// In token streams constructed using proc macro interfaces, `Joint` punctuation tokens can be + /// followed by any other tokens. However, in token streams parsed from source code, the + /// compiler will only set spacing to `Joint` in the following cases. + /// - When a `Punct` is immediately followed by another `Punct` without a whitespace. E.g. `+` + /// is `Joint` in `+=` and `++`. + /// - When a single quote `'` is immediately followed by an identifier without a whitespace. /// E.g. `'` is `Joint` in `'lifetime`. /// /// This list may be extended in the future to enable more token combinations. @@ -939,11 +938,10 @@ pub enum Spacing { Joint, /// A `Punct` token cannot join with the following token to form a multi-character operator. /// - /// `Alone` punctuation tokens can be followed by any other tokens. \ - /// In token streams parsed from source code compiler will set spacing to `Alone` in all cases - /// not covered by the conditions for `Joint` above. \ - /// E.g. `+` is `Alone` in `+ =`, `+ident` and `+()`. - /// In particular, token not followed by anything will also be marked as `Alone`. + /// `Alone` punctuation tokens can be followed by any other tokens. In token streams parsed + /// from source code, the compiler will set spacing to `Alone` in all cases not covered by the + /// conditions for `Joint` above. E.g. `+` is `Alone` in `+ =`, `+ident` and `+()`. In + /// particular, tokens not followed by anything will be marked as `Alone`. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] Alone, } @@ -978,8 +976,8 @@ impl Punct { } /// Returns the spacing of this punctuation character, indicating whether it can be potentially - /// combined into a multi-character operator with the following token (`Joint`), or the operator - /// has certainly ended (`Alone`). + /// combined into a multi-character operator with the following token (`Joint`), or whether the + /// operator has definitely ended (`Alone`). #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn spacing(&self) -> Spacing { if self.0.joint { Spacing::Joint } else { Spacing::Alone } diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 3eaeb73eecb..5a9e78f19d6 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -894,7 +894,6 @@ define_config! { define_config! { struct Dist { sign_folder: Option<String> = "sign-folder", - gpg_password_file: Option<String> = "gpg-password-file", upload_addr: Option<String> = "upload-addr", src_tarball: Option<bool> = "src-tarball", missing_tools: Option<bool> = "missing-tools", @@ -1070,7 +1069,6 @@ define_config! { debuginfo_level_tools: Option<DebuginfoLevel> = "debuginfo-level-tools", debuginfo_level_tests: Option<DebuginfoLevel> = "debuginfo-level-tests", split_debuginfo: Option<String> = "split-debuginfo", - run_dsymutil: Option<bool> = "run-dsymutil", backtrace: Option<bool> = "backtrace", incremental: Option<bool> = "incremental", parallel_compiler: Option<bool> = "parallel-compiler", @@ -1349,12 +1347,56 @@ impl Config { config.changelog_seen = toml.changelog_seen; config.change_id = toml.change_id; - let build = toml.build.unwrap_or_default(); - if let Some(file_build) = build.build { + let Build { + build, + host, + target, + build_dir, + cargo, + rustc, + rustfmt, + docs, + compiler_docs, + library_docs_private_items, + docs_minification, + submodules, + gdb, + nodejs, + npm, + python, + reuse, + locked_deps, + vendor, + full_bootstrap, + extended, + tools, + verbose, + sanitizers, + profiler, + cargo_native_static, + low_priority, + configure_args, + local_rebuild, + print_step_timings, + print_step_rusage, + check_stage, + doc_stage, + build_stage, + test_stage, + install_stage, + dist_stage, + bench_stage, + patch_binaries_for_nix, + // This field is only used by bootstrap.py + metrics: _, + android_ndk, + } = toml.build.unwrap_or_default(); + + if let Some(file_build) = build { config.build = TargetSelection::from_user(&file_build); }; - set(&mut config.out, flags.build_dir.or_else(|| build.build_dir.map(PathBuf::from))); + set(&mut config.out, flags.build_dir.or_else(|| build_dir.map(PathBuf::from))); // NOTE: Bootstrap spawns various commands with different working directories. // To avoid writing to random places on the file system, `config.out` needs to be an absolute path. if !config.out.is_absolute() { @@ -1362,7 +1404,7 @@ impl Config { config.out = crate::utils::helpers::absolute(&config.out); } - config.initial_rustc = if let Some(rustc) = build.rustc { + config.initial_rustc = if let Some(rustc) = rustc { if !flags.skip_stage0_validation { config.check_build_rustc_version(&rustc); } @@ -1372,8 +1414,7 @@ impl Config { config.out.join(config.build.triple).join("stage0/bin/rustc") }; - config.initial_cargo = build - .cargo + config.initial_cargo = cargo .map(|cargo| { t!(PathBuf::from(cargo).canonicalize(), "`initial_cargo` not found on disk") }) @@ -1388,14 +1429,14 @@ impl Config { config.hosts = if let Some(TargetSelectionList(arg_host)) = flags.host { arg_host - } else if let Some(file_host) = build.host { + } else if let Some(file_host) = host { file_host.iter().map(|h| TargetSelection::from_user(h)).collect() } else { vec![config.build] }; config.targets = if let Some(TargetSelectionList(arg_target)) = flags.target { arg_target - } else if let Some(file_target) = build.target { + } else if let Some(file_target) = target { file_target.iter().map(|h| TargetSelection::from_user(h)).collect() } else { // If target is *not* configured, then default to the host @@ -1403,43 +1444,44 @@ impl Config { config.hosts.clone() }; - config.nodejs = build.nodejs.map(PathBuf::from); - config.npm = build.npm.map(PathBuf::from); - config.gdb = build.gdb.map(PathBuf::from); - config.python = build.python.map(PathBuf::from); - config.reuse = build.reuse.map(PathBuf::from); - config.submodules = build.submodules; - config.android_ndk = build.android_ndk; - set(&mut config.low_priority, build.low_priority); - set(&mut config.compiler_docs, build.compiler_docs); - set(&mut config.library_docs_private_items, build.library_docs_private_items); - set(&mut config.docs_minification, build.docs_minification); - set(&mut config.docs, build.docs); - set(&mut config.locked_deps, build.locked_deps); - set(&mut config.vendor, build.vendor); - set(&mut config.full_bootstrap, build.full_bootstrap); - set(&mut config.extended, build.extended); - config.tools = build.tools; - set(&mut config.verbose, build.verbose); - set(&mut config.sanitizers, build.sanitizers); - set(&mut config.profiler, build.profiler); - set(&mut config.cargo_native_static, build.cargo_native_static); - set(&mut config.configure_args, build.configure_args); - set(&mut config.local_rebuild, build.local_rebuild); - set(&mut config.print_step_timings, build.print_step_timings); - set(&mut config.print_step_rusage, build.print_step_rusage); - config.patch_binaries_for_nix = build.patch_binaries_for_nix; + config.nodejs = nodejs.map(PathBuf::from); + config.npm = npm.map(PathBuf::from); + config.gdb = gdb.map(PathBuf::from); + config.python = python.map(PathBuf::from); + config.reuse = reuse.map(PathBuf::from); + config.submodules = submodules; + config.android_ndk = android_ndk; + set(&mut config.low_priority, low_priority); + set(&mut config.compiler_docs, compiler_docs); + set(&mut config.library_docs_private_items, library_docs_private_items); + set(&mut config.docs_minification, docs_minification); + set(&mut config.docs, docs); + set(&mut config.locked_deps, locked_deps); + set(&mut config.vendor, vendor); + set(&mut config.full_bootstrap, full_bootstrap); + set(&mut config.extended, extended); + config.tools = tools; + set(&mut config.verbose, verbose); + set(&mut config.sanitizers, sanitizers); + set(&mut config.profiler, profiler); + set(&mut config.cargo_native_static, cargo_native_static); + set(&mut config.configure_args, configure_args); + set(&mut config.local_rebuild, local_rebuild); + set(&mut config.print_step_timings, print_step_timings); + set(&mut config.print_step_rusage, print_step_rusage); + config.patch_binaries_for_nix = patch_binaries_for_nix; config.verbose = cmp::max(config.verbose, flags.verbose as usize); if let Some(install) = toml.install { - config.prefix = install.prefix.map(PathBuf::from); - config.sysconfdir = install.sysconfdir.map(PathBuf::from); - config.datadir = install.datadir.map(PathBuf::from); - config.docdir = install.docdir.map(PathBuf::from); - set(&mut config.bindir, install.bindir.map(PathBuf::from)); - config.libdir = install.libdir.map(PathBuf::from); - config.mandir = install.mandir.map(PathBuf::from); + let Install { prefix, sysconfdir, docdir, bindir, libdir, mandir, datadir } = install; + config.prefix = prefix.map(PathBuf::from); + config.sysconfdir = sysconfdir.map(PathBuf::from); + config.datadir = datadir.map(PathBuf::from); + config.docdir = docdir.map(PathBuf::from); + set(&mut config.bindir, bindir.map(PathBuf::from)); + config.libdir = libdir.map(PathBuf::from); + config.mandir = mandir.map(PathBuf::from); } // Store off these values as options because if they're not provided @@ -1462,9 +1504,63 @@ impl Config { let mut omit_git_hash = None; if let Some(rust) = toml.rust { - set(&mut config.channel, rust.channel); - - config.download_rustc_commit = config.download_ci_rustc_commit(rust.download_rustc); + let Rust { + optimize: optimize_toml, + debug: debug_toml, + codegen_units, + codegen_units_std, + debug_assertions: debug_assertions_toml, + debug_assertions_std: debug_assertions_std_toml, + overflow_checks: overflow_checks_toml, + overflow_checks_std: overflow_checks_std_toml, + debug_logging: debug_logging_toml, + debuginfo_level: debuginfo_level_toml, + debuginfo_level_rustc: debuginfo_level_rustc_toml, + debuginfo_level_std: debuginfo_level_std_toml, + debuginfo_level_tools: debuginfo_level_tools_toml, + debuginfo_level_tests: debuginfo_level_tests_toml, + split_debuginfo, + backtrace, + incremental, + parallel_compiler, + default_linker, + channel, + description, + musl_root, + rpath, + verbose_tests, + optimize_tests, + codegen_tests, + omit_git_hash: omit_git_hash_toml, + dist_src, + save_toolstates, + codegen_backends, + lld, + llvm_tools, + deny_warnings, + backtrace_on_ice, + verify_llvm_ir, + thin_lto_import_instr_limit, + remap_debuginfo, + jemalloc, + test_compare_mode, + llvm_libunwind, + control_flow_guard, + ehcont_guard, + new_symbol_mangling, + profile_generate, + profile_use, + download_rustc, + lto, + validate_mir_opts, + stack_protector, + strip, + lld_mode, + } = rust; + + set(&mut config.channel, channel); + + config.download_rustc_commit = config.download_ci_rustc_commit(download_rustc); // This list is incomplete, please help by expanding it! if config.download_rustc_commit.is_some() { // We need the channel used by the downloaded compiler to match the one we set for rustdoc; @@ -1481,44 +1577,43 @@ impl Config { } } - debug = rust.debug; - debug_assertions = rust.debug_assertions; - debug_assertions_std = rust.debug_assertions_std; - overflow_checks = rust.overflow_checks; - overflow_checks_std = rust.overflow_checks_std; - debug_logging = rust.debug_logging; - debuginfo_level = rust.debuginfo_level; - debuginfo_level_rustc = rust.debuginfo_level_rustc; - debuginfo_level_std = rust.debuginfo_level_std; - debuginfo_level_tools = rust.debuginfo_level_tools; - debuginfo_level_tests = rust.debuginfo_level_tests; - - config.rust_split_debuginfo = rust - .split_debuginfo + debug = debug_toml; + debug_assertions = debug_assertions_toml; + debug_assertions_std = debug_assertions_std_toml; + overflow_checks = overflow_checks_toml; + overflow_checks_std = overflow_checks_std_toml; + debug_logging = debug_logging_toml; + debuginfo_level = debuginfo_level_toml; + debuginfo_level_rustc = debuginfo_level_rustc_toml; + debuginfo_level_std = debuginfo_level_std_toml; + debuginfo_level_tools = debuginfo_level_tools_toml; + debuginfo_level_tests = debuginfo_level_tests_toml; + + config.rust_split_debuginfo = split_debuginfo .as_deref() .map(SplitDebuginfo::from_str) .map(|v| v.expect("invalid value for rust.split_debuginfo")) .unwrap_or(SplitDebuginfo::default_for_platform(&config.build.triple)); - optimize = rust.optimize; - omit_git_hash = rust.omit_git_hash; - config.rust_new_symbol_mangling = rust.new_symbol_mangling; - set(&mut config.rust_optimize_tests, rust.optimize_tests); - set(&mut config.codegen_tests, rust.codegen_tests); - set(&mut config.rust_rpath, rust.rpath); - set(&mut config.rust_strip, rust.strip); - config.rust_stack_protector = rust.stack_protector; - set(&mut config.jemalloc, rust.jemalloc); - set(&mut config.test_compare_mode, rust.test_compare_mode); - set(&mut config.backtrace, rust.backtrace); - config.description = rust.description; - set(&mut config.rust_dist_src, rust.dist_src); - set(&mut config.verbose_tests, rust.verbose_tests); + optimize = optimize_toml; + omit_git_hash = omit_git_hash_toml; + config.rust_new_symbol_mangling = new_symbol_mangling; + set(&mut config.rust_optimize_tests, optimize_tests); + set(&mut config.codegen_tests, codegen_tests); + set(&mut config.rust_rpath, rpath); + set(&mut config.rust_strip, strip); + config.rust_stack_protector = stack_protector; + set(&mut config.jemalloc, jemalloc); + set(&mut config.test_compare_mode, test_compare_mode); + set(&mut config.backtrace, backtrace); + config.description = description; + set(&mut config.rust_dist_src, dist_src); + set(&mut config.verbose_tests, verbose_tests); // in the case "false" is set explicitly, do not overwrite the command line args - if let Some(true) = rust.incremental { + if let Some(true) = incremental { config.incremental = true; } - set(&mut config.lld_mode, rust.lld_mode); - set(&mut config.lld_enabled, rust.lld); + set(&mut config.lld_mode, lld_mode); + set(&mut config.lld_enabled, lld); if matches!(config.lld_mode, LldMode::SelfContained) && !config.lld_enabled @@ -1529,32 +1624,30 @@ impl Config { ); } - set(&mut config.llvm_tools_enabled, rust.llvm_tools); - config.rustc_parallel = rust - .parallel_compiler - .unwrap_or(config.channel == "dev" || config.channel == "nightly"); - config.rustc_default_linker = rust.default_linker; - config.musl_root = rust.musl_root.map(PathBuf::from); - config.save_toolstates = rust.save_toolstates.map(PathBuf::from); + set(&mut config.llvm_tools_enabled, llvm_tools); + config.rustc_parallel = + parallel_compiler.unwrap_or(config.channel == "dev" || config.channel == "nightly"); + config.rustc_default_linker = default_linker; + config.musl_root = musl_root.map(PathBuf::from); + config.save_toolstates = save_toolstates.map(PathBuf::from); set( &mut config.deny_warnings, match flags.warnings { Warnings::Deny => Some(true), Warnings::Warn => Some(false), - Warnings::Default => rust.deny_warnings, + Warnings::Default => deny_warnings, }, ); - set(&mut config.backtrace_on_ice, rust.backtrace_on_ice); - set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir); - config.rust_thin_lto_import_instr_limit = rust.thin_lto_import_instr_limit; - set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo); - set(&mut config.control_flow_guard, rust.control_flow_guard); - set(&mut config.ehcont_guard, rust.ehcont_guard); - config.llvm_libunwind_default = rust - .llvm_libunwind - .map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")); - - if let Some(ref backends) = rust.codegen_backends { + set(&mut config.backtrace_on_ice, backtrace_on_ice); + set(&mut config.rust_verify_llvm_ir, verify_llvm_ir); + config.rust_thin_lto_import_instr_limit = thin_lto_import_instr_limit; + set(&mut config.rust_remap_debuginfo, remap_debuginfo); + set(&mut config.control_flow_guard, control_flow_guard); + set(&mut config.ehcont_guard, ehcont_guard); + config.llvm_libunwind_default = + llvm_libunwind.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")); + + if let Some(ref backends) = codegen_backends { let available_backends = vec!["llvm", "cranelift", "gcc"]; config.rust_codegen_backends = backends.iter().map(|s| { @@ -1572,16 +1665,13 @@ impl Config { }).collect(); } - config.rust_codegen_units = rust.codegen_units.map(threads_from_config); - config.rust_codegen_units_std = rust.codegen_units_std.map(threads_from_config); - config.rust_profile_use = flags.rust_profile_use.or(rust.profile_use); - config.rust_profile_generate = flags.rust_profile_generate.or(rust.profile_generate); - config.rust_lto = rust - .lto - .as_deref() - .map(|value| RustcLto::from_str(value).unwrap()) - .unwrap_or_default(); - config.rust_validate_mir_opts = rust.validate_mir_opts; + config.rust_codegen_units = codegen_units.map(threads_from_config); + config.rust_codegen_units_std = codegen_units_std.map(threads_from_config); + config.rust_profile_use = flags.rust_profile_use.or(profile_use); + config.rust_profile_generate = flags.rust_profile_generate.or(profile_generate); + config.rust_lto = + lto.as_deref().map(|value| RustcLto::from_str(value).unwrap()).unwrap_or_default(); + config.rust_validate_mir_opts = validate_mir_opts; } else { config.rust_profile_use = flags.rust_profile_use; config.rust_profile_generate = flags.rust_profile_generate; @@ -1595,43 +1685,71 @@ impl Config { config.rust_info = GitInfo::new(config.omit_git_hash, &config.src); if let Some(llvm) = toml.llvm { - match llvm.ccache { + let Llvm { + optimize: optimize_toml, + thin_lto, + release_debuginfo, + assertions, + tests, + plugins, + ccache, + static_libstdcpp, + ninja, + targets, + experimental_targets, + link_jobs, + link_shared, + version_suffix, + clang_cl, + cflags, + cxxflags, + ldflags, + use_libcxx, + use_linker, + allow_old_toolchain, + polly, + clang, + enable_warnings, + download_ci_llvm, + build_config, + } = llvm; + match ccache { Some(StringOrBool::String(ref s)) => config.ccache = Some(s.to_string()), Some(StringOrBool::Bool(true)) => { config.ccache = Some("ccache".to_string()); } Some(StringOrBool::Bool(false)) | None => {} } - set(&mut config.ninja_in_file, llvm.ninja); - llvm_assertions = llvm.assertions; - llvm_tests = llvm.tests; - llvm_plugins = llvm.plugins; - set(&mut config.llvm_optimize, llvm.optimize); - set(&mut config.llvm_thin_lto, llvm.thin_lto); - set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo); - set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp); - if let Some(v) = llvm.link_shared { + set(&mut config.ninja_in_file, ninja); + llvm_assertions = assertions; + llvm_tests = tests; + llvm_plugins = plugins; + set(&mut config.llvm_optimize, optimize_toml); + set(&mut config.llvm_thin_lto, thin_lto); + set(&mut config.llvm_release_debuginfo, release_debuginfo); + set(&mut config.llvm_static_stdcpp, static_libstdcpp); + if let Some(v) = link_shared { config.llvm_link_shared.set(Some(v)); } - config.llvm_targets = llvm.targets.clone(); - config.llvm_experimental_targets = llvm.experimental_targets.clone(); - config.llvm_link_jobs = llvm.link_jobs; - config.llvm_version_suffix = llvm.version_suffix.clone(); - config.llvm_clang_cl = llvm.clang_cl.clone(); - - config.llvm_cflags = llvm.cflags.clone(); - config.llvm_cxxflags = llvm.cxxflags.clone(); - config.llvm_ldflags = llvm.ldflags.clone(); - set(&mut config.llvm_use_libcxx, llvm.use_libcxx); - config.llvm_use_linker = llvm.use_linker.clone(); - config.llvm_allow_old_toolchain = llvm.allow_old_toolchain.unwrap_or(false); - config.llvm_polly = llvm.polly.unwrap_or(false); - config.llvm_clang = llvm.clang.unwrap_or(false); - config.llvm_enable_warnings = llvm.enable_warnings.unwrap_or(false); - config.llvm_build_config = llvm.build_config.clone().unwrap_or(Default::default()); + config.llvm_targets = targets.clone(); + config.llvm_experimental_targets = experimental_targets.clone(); + config.llvm_link_jobs = link_jobs; + config.llvm_version_suffix = version_suffix.clone(); + config.llvm_clang_cl = clang_cl.clone(); + + config.llvm_cflags = cflags.clone(); + config.llvm_cxxflags = cxxflags.clone(); + config.llvm_ldflags = ldflags.clone(); + set(&mut config.llvm_use_libcxx, use_libcxx); + config.llvm_use_linker = use_linker.clone(); + config.llvm_allow_old_toolchain = allow_old_toolchain.unwrap_or(false); + config.llvm_polly = polly.unwrap_or(false); + config.llvm_clang = clang.unwrap_or(false); + config.llvm_enable_warnings = enable_warnings.unwrap_or(false); + config.llvm_build_config = build_config.clone().unwrap_or(Default::default()); let asserts = llvm_assertions.unwrap_or(false); - config.llvm_from_ci = config.parse_download_ci_llvm(llvm.download_ci_llvm, asserts); + config.llvm_from_ci = config.parse_download_ci_llvm(download_ci_llvm, asserts); if config.llvm_from_ci { // None of the LLVM options, except assertions, are supported @@ -1640,31 +1758,31 @@ impl Config { // explicitly set. The defaults and CI defaults don't // necessarily match but forcing people to match (somewhat // arbitrary) CI configuration locally seems bad/hard. - check_ci_llvm!(llvm.optimize); - check_ci_llvm!(llvm.thin_lto); - check_ci_llvm!(llvm.release_debuginfo); + check_ci_llvm!(optimize_toml); + check_ci_llvm!(thin_lto); + check_ci_llvm!(release_debuginfo); // CI-built LLVM can be either dynamic or static. We won't know until we download it. - check_ci_llvm!(llvm.link_shared); - check_ci_llvm!(llvm.static_libstdcpp); - check_ci_llvm!(llvm.targets); - check_ci_llvm!(llvm.experimental_targets); - check_ci_llvm!(llvm.link_jobs); - check_ci_llvm!(llvm.clang_cl); - check_ci_llvm!(llvm.version_suffix); - check_ci_llvm!(llvm.cflags); - check_ci_llvm!(llvm.cxxflags); - check_ci_llvm!(llvm.ldflags); - check_ci_llvm!(llvm.use_libcxx); - check_ci_llvm!(llvm.use_linker); - check_ci_llvm!(llvm.allow_old_toolchain); - check_ci_llvm!(llvm.polly); - check_ci_llvm!(llvm.clang); - check_ci_llvm!(llvm.build_config); - check_ci_llvm!(llvm.plugins); + check_ci_llvm!(link_shared); + check_ci_llvm!(static_libstdcpp); + check_ci_llvm!(targets); + check_ci_llvm!(experimental_targets); + check_ci_llvm!(link_jobs); + check_ci_llvm!(clang_cl); + check_ci_llvm!(version_suffix); + check_ci_llvm!(cflags); + check_ci_llvm!(cxxflags); + check_ci_llvm!(ldflags); + check_ci_llvm!(use_libcxx); + check_ci_llvm!(use_linker); + check_ci_llvm!(allow_old_toolchain); + check_ci_llvm!(polly); + check_ci_llvm!(clang); + check_ci_llvm!(build_config); + check_ci_llvm!(plugins); } // NOTE: can never be hit when downloading from CI, since we call `check_ci_llvm!(thin_lto)` above. - if config.llvm_thin_lto && llvm.link_shared.is_none() { + if config.llvm_thin_lto && link_shared.is_none() { // If we're building with ThinLTO on, by default we want to link // to LLVM shared, to avoid re-doing ThinLTO (which happens in // the link step) with each stage. @@ -1730,17 +1848,26 @@ impl Config { build_target.llvm_filecheck = Some(ci_llvm_bin.join(exe("FileCheck", config.build))); } - if let Some(t) = toml.dist { - config.dist_sign_folder = t.sign_folder.map(PathBuf::from); - config.dist_upload_addr = t.upload_addr; - config.dist_compression_formats = t.compression_formats; - set(&mut config.dist_compression_profile, t.compression_profile); - set(&mut config.rust_dist_src, t.src_tarball); - set(&mut config.missing_tools, t.missing_tools); - set(&mut config.dist_include_mingw_linker, t.include_mingw_linker) + if let Some(dist) = toml.dist { + let Dist { + sign_folder, + upload_addr, + src_tarball, + missing_tools, + compression_formats, + compression_profile, + include_mingw_linker, + } = dist; + config.dist_sign_folder = sign_folder.map(PathBuf::from); + config.dist_upload_addr = upload_addr; + config.dist_compression_formats = compression_formats; + set(&mut config.dist_compression_profile, compression_profile); + set(&mut config.rust_dist_src, src_tarball); + set(&mut config.missing_tools, missing_tools); + set(&mut config.dist_include_mingw_linker, include_mingw_linker) } - if let Some(r) = build.rustfmt { + if let Some(r) = rustfmt { *config.initial_rustfmt.borrow_mut() = if r.exists() { RustfmtState::SystemToolchain(r) } else { @@ -1781,20 +1908,20 @@ impl Config { let download_rustc = config.download_rustc_commit.is_some(); // See https://github.com/rust-lang/compiler-team/issues/326 config.stage = match config.cmd { - Subcommand::Check { .. } => flags.stage.or(build.check_stage).unwrap_or(0), + Subcommand::Check { .. } => flags.stage.or(check_stage).unwrap_or(0), // `download-rustc` only has a speed-up for stage2 builds. Default to stage2 unless explicitly overridden. Subcommand::Doc { .. } => { - flags.stage.or(build.doc_stage).unwrap_or(if download_rustc { 2 } else { 0 }) + flags.stage.or(doc_stage).unwrap_or(if download_rustc { 2 } else { 0 }) } Subcommand::Build { .. } => { - flags.stage.or(build.build_stage).unwrap_or(if download_rustc { 2 } else { 1 }) + flags.stage.or(build_stage).unwrap_or(if download_rustc { 2 } else { 1 }) } Subcommand::Test { .. } => { - flags.stage.or(build.test_stage).unwrap_or(if download_rustc { 2 } else { 1 }) + flags.stage.or(test_stage).unwrap_or(if download_rustc { 2 } else { 1 }) } - Subcommand::Bench { .. } => flags.stage.or(build.bench_stage).unwrap_or(2), - Subcommand::Dist { .. } => flags.stage.or(build.dist_stage).unwrap_or(2), - Subcommand::Install { .. } => flags.stage.or(build.install_stage).unwrap_or(2), + Subcommand::Bench { .. } => flags.stage.or(bench_stage).unwrap_or(2), + Subcommand::Dist { .. } => flags.stage.or(dist_stage).unwrap_or(2), + Subcommand::Install { .. } => flags.stage.or(install_stage).unwrap_or(2), // These are all bootstrap tools, which don't depend on the compiler. // The stage we pass shouldn't matter, but use 0 just in case. Subcommand::Clean { .. } diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index af3b238dfc3..8b53a61542e 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -91,4 +91,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Info, summary: "The `rust.use-lld` configuration now has different options ('external'/true or 'self-contained'), and its behaviour has changed.", }, + ChangeInfo { + change_id: 118703, + severity: ChangeSeverity::Info, + summary: "Removed rust.run_dsymutil and dist.gpg_password_file config options, as they were unused.", + }, ]; diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index e563a83c5c4..133792d85e8 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -15,7 +15,8 @@ use std::sync::OnceLock; use std::time::{Instant, SystemTime, UNIX_EPOCH}; use crate::core::builder::Builder; -use crate::core::config::{Config, LldMode, TargetSelection}; +use crate::core::config::{Config, TargetSelection}; +use crate::LldMode; pub use crate::utils::dylib::{dylib_path, dylib_path_var}; @@ -513,16 +514,7 @@ pub fn linker_flags( ) -> Vec<String> { let mut args = vec![]; if !builder.is_lld_direct_linker(target) && builder.config.lld_mode.is_used() { - match builder.config.lld_mode { - LldMode::External => { - args.push("-Clinker-flavor=gnu-lld-cc".to_string()); - } - LldMode::SelfContained => { - args.push("-Clinker-flavor=gnu-lld-cc".to_string()); - args.push("-Clink-self-contained=+linker".to_string()); - } - LldMode::Unused => {} - } + args.push(String::from("-Clink-arg=-fuse-ld=lld")); if matches!(lld_threads, LldThreads::No) { args.push(format!( diff --git a/src/doc/unstable-book/src/compiler-flags/env.md b/src/doc/unstable-book/src/compiler-flags/env.md new file mode 100644 index 00000000000..df0547dd24b --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/env.md @@ -0,0 +1,26 @@ +# `env` + +The tracking issue for this feature is: [#118372](https://github.com/rust-lang/rust/issues/118372). + +------------------------ + +This option flag allows to specify environment variables value at compile time to be +used by `env!` and `option_env!` macros. + +When retrieving an environment variable value, the one specified by `--env` will take +precedence. For example, if you want have `PATH=a` in your environment and pass: + +```bash +rustc --env PATH=env +``` + +Then you will have: + +```rust,no_run +assert_eq!(env!("PATH"), "env"); +``` + +Please note that on Windows, environment variables are case insensitive but case +preserving whereas `rustc`'s environment variables are case sensitive. For example, +having `Path` in your environment (case insensitive) is different than using +`rustc --env Path=...` (case sensitive). diff --git a/src/librustdoc/clean/render_macro_matchers.rs b/src/librustdoc/clean/render_macro_matchers.rs index 66d10f2368b..605f9e496c7 100644 --- a/src/librustdoc/clean/render_macro_matchers.rs +++ b/src/librustdoc/clean/render_macro_matchers.rs @@ -40,7 +40,7 @@ pub(super) fn render_macro_matcher(tcx: TyCtxt<'_>, matcher: &TokenTree) -> Stri printer.zerobreak(); printer.ibox(0); match matcher { - TokenTree::Delimited(_span, _delim, tts) => print_tts(&mut printer, tts), + TokenTree::Delimited(_span, _spacing, _delim, tts) => print_tts(&mut printer, tts), // Matcher which is not a Delimited is unexpected and should've failed // to compile, but we render whatever it is wrapped in parens. TokenTree::Token(..) => print_tt(&mut printer, matcher), @@ -97,7 +97,7 @@ fn print_tt(printer: &mut Printer<'_>, tt: &TokenTree) { printer.hardbreak() } } - TokenTree::Delimited(_span, delim, tts) => { + TokenTree::Delimited(_span, _spacing, delim, tts) => { let open_delim = printer.token_kind_to_string(&token::OpenDelim(*delim)); printer.word(open_delim); if !tts.is_empty() { @@ -158,7 +158,7 @@ fn print_tts(printer: &mut Printer<'_>, tts: &TokenStream) { (_, token::Pound) => (true, Pound), (_, _) => (true, Other), }, - TokenTree::Delimited(_, delim, _) => match (state, delim) { + TokenTree::Delimited(.., delim, _) => match (state, delim) { (Dollar, Delimiter::Parenthesis) => (false, DollarParen), (Pound | PoundBang, Delimiter::Bracket) => (false, Other), (Ident, Delimiter::Parenthesis | Delimiter::Bracket) => (false, Other), diff --git a/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs b/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs index d4828778be2..b1aa472aa03 100644 --- a/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs +++ b/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs @@ -92,7 +92,7 @@ fn contains_unhygienic_crate_reference(tts: &TokenStream) -> Option<Span> { { return Some(span); } - if let TokenTree::Delimited(_, _, tts) = &curr { + if let TokenTree::Delimited(.., tts) = &curr { let span = contains_unhygienic_crate_reference(tts); if span.is_some() { return span; diff --git a/src/tools/miri/tests/pass/function_calls/abi_compat.rs b/src/tools/miri/tests/pass/function_calls/abi_compat.rs index b24fe56cad6..14fd2d333d4 100644 --- a/src/tools/miri/tests/pass/function_calls/abi_compat.rs +++ b/src/tools/miri/tests/pass/function_calls/abi_compat.rs @@ -71,6 +71,8 @@ fn main() { test_abi_compat(0isize, 0i64); } test_abi_compat(42u32, num::NonZeroU32::new(1).unwrap()); + // - `char` and `u32`. + test_abi_compat(42u32, 'x'); // - Reference/pointer types with the same pointee. test_abi_compat(&0u32, &0u32 as *const u32); test_abi_compat(&mut 0u32 as *mut u32, Box::new(0u32)); @@ -81,7 +83,7 @@ fn main() { test_abi_compat(main as fn(), id::<i32> as fn(i32) -> i32); // - 1-ZST test_abi_compat((), [0u8; 0]); - // - Guaranteed null-pointer-optimizations. + // - Guaranteed null-pointer-optimizations (RFC 3391). test_abi_compat(&0u32 as *const u32, Some(&0u32)); test_abi_compat(main as fn(), Some(main as fn())); test_abi_compat(0u32, Some(num::NonZeroU32::new(1).unwrap())); @@ -103,6 +105,8 @@ fn main() { test_abi_newtype::<Option<num::NonZeroU32>>(); // Extra test for assumptions made by arbitrary-self-dyn-receivers. + // This is interesting since these types are not `repr(transparent)`. So this is not part of our + // public ABI guarantees, but is relied on by the compiler. let rc = Rc::new(0); let rc_ptr: *mut i32 = unsafe { mem::transmute_copy(&rc) }; test_abi_compat(rc, rc_ptr); diff --git a/src/tools/rustfmt/src/macros.rs b/src/tools/rustfmt/src/macros.rs index 76553466e48..b4c58d2fefb 100644 --- a/src/tools/rustfmt/src/macros.rs +++ b/src/tools/rustfmt/src/macros.rs @@ -708,7 +708,7 @@ struct MacroArgParser { fn last_tok(tt: &TokenTree) -> Token { match *tt { TokenTree::Token(ref t, _) => t.clone(), - TokenTree::Delimited(delim_span, delim, _) => Token { + TokenTree::Delimited(delim_span, _, delim, _) => Token { kind: TokenKind::CloseDelim(delim), span: delim_span.close, }, @@ -925,7 +925,7 @@ impl MacroArgParser { self.add_meta_variable(&mut iter)?; } TokenTree::Token(ref t, _) => self.update_buffer(t), - &TokenTree::Delimited(_delimited_span, delimited, ref tts) => { + &TokenTree::Delimited(_dspan, _spacing, delimited, ref tts) => { if !self.buf.is_empty() { if next_space(&self.last_tok.kind) == SpaceState::Always { self.add_separator(); @@ -1167,7 +1167,7 @@ impl<'a> MacroParser<'a> { let tok = self.toks.next()?; let (lo, args_paren_kind) = match tok { TokenTree::Token(..) => return None, - &TokenTree::Delimited(delimited_span, d, _) => (delimited_span.open.lo(), d), + &TokenTree::Delimited(delimited_span, _, d, _) => (delimited_span.open.lo(), d), }; let args = TokenStream::new(vec![tok.clone()]); match self.toks.next()? { diff --git a/src/tools/rustfmt/tests/source/issue-2927-2.rs b/src/tools/rustfmt/tests/source/issue-2927-2.rs index d87761fdc9c..07afef38cf5 100644 --- a/src/tools/rustfmt/tests/source/issue-2927-2.rs +++ b/src/tools/rustfmt/tests/source/issue-2927-2.rs @@ -1,5 +1,5 @@ // rustfmt-edition: 2015 -#![feature(rust_2018_preview, uniform_paths)] +#![feature(uniform_paths)] use futures::prelude::*; use http_03::cli::Cli; use hyper::{service::service_fn_ok, Body, Response, Server}; diff --git a/src/tools/rustfmt/tests/source/issue-2927.rs b/src/tools/rustfmt/tests/source/issue-2927.rs index a7df32084f3..c7ec7bb0855 100644 --- a/src/tools/rustfmt/tests/source/issue-2927.rs +++ b/src/tools/rustfmt/tests/source/issue-2927.rs @@ -1,5 +1,5 @@ // rustfmt-edition: 2018 -#![feature(rust_2018_preview, uniform_paths)] +#![feature(uniform_paths)] use futures::prelude::*; use http_03::cli::Cli; use hyper::{service::service_fn_ok, Body, Response, Server}; diff --git a/src/tools/rustfmt/tests/target/issue-2927-2.rs b/src/tools/rustfmt/tests/target/issue-2927-2.rs index e895783ba8b..46e0bf0e989 100644 --- a/src/tools/rustfmt/tests/target/issue-2927-2.rs +++ b/src/tools/rustfmt/tests/target/issue-2927-2.rs @@ -1,5 +1,5 @@ // rustfmt-edition: 2015 -#![feature(rust_2018_preview, uniform_paths)] +#![feature(uniform_paths)] use futures::prelude::*; use http_03::cli::Cli; use hyper::{service::service_fn_ok, Body, Response, Server}; diff --git a/src/tools/rustfmt/tests/target/issue-2927.rs b/src/tools/rustfmt/tests/target/issue-2927.rs index 3267be28d7b..56afc2d3e40 100644 --- a/src/tools/rustfmt/tests/target/issue-2927.rs +++ b/src/tools/rustfmt/tests/target/issue-2927.rs @@ -1,5 +1,5 @@ // rustfmt-edition: 2018 -#![feature(rust_2018_preview, uniform_paths)] +#![feature(uniform_paths)] use ::log::{error, info, log}; use futures::prelude::*; use http_03::cli::Cli; diff --git a/tests/pretty/cast-lt.pp b/tests/pretty/cast-lt.pp index e6c4d195691..61cd8f59712 100644 --- a/tests/pretty/cast-lt.pp +++ b/tests/pretty/cast-lt.pp @@ -8,6 +8,6 @@ extern crate std; // pretty-mode:expanded // pp-exact:cast-lt.pp -macro_rules! negative { ($e : expr) => { $e < 0 } } +macro_rules! negative { ($e:expr) => { $e < 0 } } fn main() { (1 as i32) < 0; } diff --git a/tests/run-make/rustc-macro-dep-files/foo.rs b/tests/run-make/rustc-macro-dep-files/foo.rs index 66db1a21736..00b1c26d43f 100644 --- a/tests/run-make/rustc-macro-dep-files/foo.rs +++ b/tests/run-make/rustc-macro-dep-files/foo.rs @@ -7,6 +7,6 @@ use proc_macro::TokenStream; #[proc_macro_derive(A)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); - assert!(input.contains("struct A ;")); + assert!(input.contains("struct A;")); "struct B;".parse().unwrap() } diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index d5f05313078..c6bba7186da 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -263,6 +263,13 @@ test_abi_compatible!(box_ptr, Box<i32>, *const i32); test_abi_compatible!(nonnull_ptr, NonNull<i32>, *const i32); test_abi_compatible!(fn_fn, fn(), fn(i32) -> i32); +// Compatibility of integer types. +test_abi_compatible!(char_uint, char, u32); +#[cfg(target_pointer_width = "32")] +test_abi_compatible!(isize_int, isize, i32); +#[cfg(target_pointer_width = "64")] +test_abi_compatible!(isize_int, isize, i64); + // Compatibility of 1-ZST. test_abi_compatible!(zst_unit, Zst, ()); #[cfg(not(any(target_arch = "sparc64")))] diff --git a/tests/ui/async-await/issues/issue-60674.stdout b/tests/ui/async-await/issues/issue-60674.stdout index 6f980e60664..df129b033d2 100644 --- a/tests/ui/async-await/issues/issue-60674.stdout +++ b/tests/ui/async-await/issues/issue-60674.stdout @@ -1,3 +1,3 @@ -async fn f(mut x : u8) {} -async fn g((mut x, y, mut z) : (u8, u8, u8)) {} -async fn g(mut x : u8, (a, mut b, c) : (u8, u8, u8), y : u8) {} +async fn f(mut x: u8) {} +async fn g((mut x, y, mut z): (u8, u8, u8)) {} +async fn g(mut x: u8, (a, mut b, c): (u8, u8, u8), y: u8) {} diff --git a/tests/ui/check-cfg/allow-same-level.stderr b/tests/ui/check-cfg/allow-same-level.stderr index 19d9443d477..652efc3f591 100644 --- a/tests/ui/check-cfg/allow-same-level.stderr +++ b/tests/ui/check-cfg/allow-same-level.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `FALSE` LL | #[cfg(FALSE)] | ^^^^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/compact-names.stderr b/tests/ui/check-cfg/compact-names.stderr index ffde972a25e..d3bfb9f7100 100644 --- a/tests/ui/check-cfg/compact-names.stderr +++ b/tests/ui/check-cfg/compact-names.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `target_architecture` LL | #[cfg(target(os = "linux", architecture = "arm"))] | ^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr index 9efc77fb43f..9501c134bac 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_names_values.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_names_values.stderr index 971abb1a21a..e37a222f52a 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_names_values.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_names_values.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index 4549482abcb..ea204eaff1b 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index 4549482abcb..ea204eaff1b 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` diff --git a/tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr b/tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr index 7d01c73cc09..b5c8cad275f 100644 --- a/tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr +++ b/tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/exhaustive-names.stderr b/tests/ui/check-cfg/exhaustive-names.stderr index 866595b1213..c5f6d537c5e 100644 --- a/tests/ui/check-cfg/exhaustive-names.stderr +++ b/tests/ui/check-cfg/exhaustive-names.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/mix.cfg.stderr b/tests/ui/check-cfg/mix.cfg.stderr index 21c0c7da1dd..046d40f36b0 100644 --- a/tests/ui/check-cfg/mix.cfg.stderr +++ b/tests/ui/check-cfg/mix.cfg.stderr @@ -36,7 +36,7 @@ warning: unexpected `cfg` condition name: `uu` LL | #[cfg_attr(uu, test)] | ^^ | - = help: expected names are: `cfg`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `names_values`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `cfg`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `names_values`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` warning: unexpected `cfg` condition name: `widnows` --> $DIR/mix.rs:43:10 diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr index eefdbd6af30..25b8f95ae2f 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -36,7 +36,7 @@ warning: unexpected `cfg` condition name: `uu` LL | #[cfg_attr(uu, test)] | ^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` warning: unexpected `cfg` condition name: `widnows` --> $DIR/mix.rs:40:10 diff --git a/tests/ui/check-cfg/stmt-no-ice.stderr b/tests/ui/check-cfg/stmt-no-ice.stderr index 3fb3ae27ec4..c2483fe4a06 100644 --- a/tests/ui/check-cfg/stmt-no-ice.stderr +++ b/tests/ui/check-cfg/stmt-no-ice.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `crossbeam_loom` LL | #[cfg(crossbeam_loom)] | ^^^^^^^^^^^^^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/well-known-names.stderr b/tests/ui/check-cfg/well-known-names.stderr index a986e61bcdc..6040663074d 100644 --- a/tests/ui/check-cfg/well-known-names.stderr +++ b/tests/ui/check-cfg/well-known-names.stderr @@ -16,7 +16,7 @@ warning: unexpected `cfg` condition name: `features` LL | #[cfg(features = "foo")] | ^^^^^^^^^^^^^^^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` warning: unexpected `cfg` condition name: `feature` --> $DIR/well-known-names.rs:17:7 diff --git a/tests/ui/codegen/const-bool-bitcast.rs b/tests/ui/codegen/const-bool-bitcast.rs new file mode 100644 index 00000000000..24ae76b9029 --- /dev/null +++ b/tests/ui/codegen/const-bool-bitcast.rs @@ -0,0 +1,15 @@ +// This is a regression test for https://github.com/rust-lang/rust/issues/118047 +// build-pass +// compile-flags: -Zmir-opt-level=0 -Zmir-enable-passes=+DataflowConstProp + +#![crate_type = "lib"] + +pub struct State { + inner: bool +} + +pub fn make() -> State { + State { + inner: true + } +} diff --git a/tests/ui/editions/edition-feature-ok.rs b/tests/ui/editions/edition-feature-ok.rs deleted file mode 100644 index 69242fd715c..00000000000 --- a/tests/ui/editions/edition-feature-ok.rs +++ /dev/null @@ -1,5 +0,0 @@ -// check-pass - -#![feature(rust_2018_preview)] - -fn main() {} diff --git a/tests/ui/editions/edition-feature-redundant.rs b/tests/ui/editions/edition-feature-redundant.rs deleted file mode 100644 index 1049a2da8fd..00000000000 --- a/tests/ui/editions/edition-feature-redundant.rs +++ /dev/null @@ -1,7 +0,0 @@ -// edition:2018 -// check-pass - -#![feature(rust_2018_preview)] -//~^ WARN the feature `rust_2018_preview` is included in the Rust 2018 edition - -fn main() {} diff --git a/tests/ui/editions/edition-feature-redundant.stderr b/tests/ui/editions/edition-feature-redundant.stderr deleted file mode 100644 index b11e616d7f2..00000000000 --- a/tests/ui/editions/edition-feature-redundant.stderr +++ /dev/null @@ -1,9 +0,0 @@ -warning[E0705]: the feature `rust_2018_preview` is included in the Rust 2018 edition - --> $DIR/edition-feature-redundant.rs:4:12 - | -LL | #![feature(rust_2018_preview)] - | ^^^^^^^^^^^^^^^^^ - -warning: 1 warning emitted - -For more information about this error, try `rustc --explain E0705`. diff --git a/tests/ui/editions/epoch-gate-feature.rs b/tests/ui/editions/epoch-gate-feature.rs deleted file mode 100644 index 5f7feb5347b..00000000000 --- a/tests/ui/editions/epoch-gate-feature.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass - -#![allow(dead_code)] -#![allow(unused_variables)] -// Checks if the correct registers are being used to pass arguments -// when the sysv64 ABI is specified. - -#![feature(rust_2018_preview)] - -pub trait Foo {} - -// should compile without the dyn trait feature flag -fn foo(x: &dyn Foo) {} - -pub fn main() {} diff --git a/tests/ui/error-codes/E0705.rs b/tests/ui/error-codes/E0705.rs deleted file mode 100644 index 05abcb629b1..00000000000 --- a/tests/ui/error-codes/E0705.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass - -// This is a stub feature that doesn't control anything, so to make tidy happy, -// gate-test-test_2018_feature - -#![feature(test_2018_feature)] -//~^ WARN the feature `test_2018_feature` is included in the Rust 2018 edition -#![feature(rust_2018_preview)] - -fn main() {} diff --git a/tests/ui/error-codes/E0705.stderr b/tests/ui/error-codes/E0705.stderr deleted file mode 100644 index 6fa843158bb..00000000000 --- a/tests/ui/error-codes/E0705.stderr +++ /dev/null @@ -1,9 +0,0 @@ -warning[E0705]: the feature `test_2018_feature` is included in the Rust 2018 edition - --> $DIR/E0705.rs:6:12 - | -LL | #![feature(test_2018_feature)] - | ^^^^^^^^^^^^^^^^^ - -warning: 1 warning emitted - -For more information about this error, try `rustc --explain E0705`. diff --git a/tests/ui/extenv/extenv-env-overload.rs b/tests/ui/extenv/extenv-env-overload.rs new file mode 100644 index 00000000000..b82bb2fe966 --- /dev/null +++ b/tests/ui/extenv/extenv-env-overload.rs @@ -0,0 +1,9 @@ +// run-pass +// rustc-env:MY_VAR=tadam +// compile-flags: --env MY_VAR=123abc -Zunstable-options + +// This test ensures that variables provided with `--env` take precedence over +// variables from environment. +fn main() { + assert_eq!(env!("MY_VAR"), "123abc"); +} diff --git a/tests/ui/extenv/extenv-env.rs b/tests/ui/extenv/extenv-env.rs new file mode 100644 index 00000000000..9fda52b8941 --- /dev/null +++ b/tests/ui/extenv/extenv-env.rs @@ -0,0 +1,5 @@ +// compile-flags: --env FOO=123abc -Zunstable-options +// run-pass +fn main() { + assert_eq!(env!("FOO"), "123abc"); +} diff --git a/tests/ui/extenv/extenv-not-env.rs b/tests/ui/extenv/extenv-not-env.rs new file mode 100644 index 00000000000..d6c4a43b003 --- /dev/null +++ b/tests/ui/extenv/extenv-not-env.rs @@ -0,0 +1,7 @@ +// run-pass +// rustc-env:MY_ENV=/ +// Ensures that variables not defined through `--env` are still available. + +fn main() { + assert!(!env!("MY_ENV").is_empty()); +} diff --git a/tests/ui/feature-gates/env-flag.rs b/tests/ui/feature-gates/env-flag.rs new file mode 100644 index 00000000000..9dfda2584fb --- /dev/null +++ b/tests/ui/feature-gates/env-flag.rs @@ -0,0 +1,3 @@ +// compile-flags: --env A=B + +fn main() {} diff --git a/tests/ui/feature-gates/env-flag.stderr b/tests/ui/feature-gates/env-flag.stderr new file mode 100644 index 00000000000..5cb18cef9fb --- /dev/null +++ b/tests/ui/feature-gates/env-flag.stderr @@ -0,0 +1,2 @@ +error: the `-Z unstable-options` flag must also be passed to enable the flag `env` + diff --git a/tests/ui/hygiene/unpretty-debug.stdout b/tests/ui/hygiene/unpretty-debug.stdout index 51c21043db8..3d686f95df9 100644 --- a/tests/ui/hygiene/unpretty-debug.stdout +++ b/tests/ui/hygiene/unpretty-debug.stdout @@ -8,7 +8,7 @@ #![feature /* 0#0 */(no_core)] #![no_core /* 0#0 */] -macro_rules! foo /* 0#0 */ { ($x : ident) => { y + $x } } +macro_rules! foo /* 0#0 */ { ($x: ident) => { y + $x } } fn bar /* 0#0 */() { let x /* 0#0 */ = 1; diff --git a/tests/ui/infinite/issue-41731-infinite-macro-print.stderr b/tests/ui/infinite/issue-41731-infinite-macro-print.stderr index e30b2039d69..71510816d0b 100644 --- a/tests/ui/infinite/issue-41731-infinite-macro-print.stderr +++ b/tests/ui/infinite/issue-41731-infinite-macro-print.stderr @@ -14,13 +14,13 @@ LL | stack!("overflow"); | ^^^^^^^^^^^^^^^^^^ | = note: expanding `stack! { "overflow" }` - = note: to `print! (stack! ("overflow")) ;` + = note: to `print! (stack! ("overflow"));` = note: expanding `print! { stack! ("overflow") }` - = note: to `{ $crate :: io :: _print($crate :: format_args! (stack! ("overflow"))) ; }` + = note: to `{ $crate :: io :: _print($crate :: format_args! (stack! ("overflow"))); }` = note: expanding `stack! { "overflow" }` - = note: to `print! (stack! ("overflow")) ;` + = note: to `print! (stack! ("overflow"));` = note: expanding `print! { stack! ("overflow") }` - = note: to `{ $crate :: io :: _print($crate :: format_args! (stack! ("overflow"))) ; }` + = note: to `{ $crate :: io :: _print($crate :: format_args! (stack! ("overflow"))); }` error: format argument must be a string literal --> $DIR/issue-41731-infinite-macro-print.rs:14:5 diff --git a/tests/ui/infinite/issue-41731-infinite-macro-println.stderr b/tests/ui/infinite/issue-41731-infinite-macro-println.stderr index 66b466dafa0..645176d45cb 100644 --- a/tests/ui/infinite/issue-41731-infinite-macro-println.stderr +++ b/tests/ui/infinite/issue-41731-infinite-macro-println.stderr @@ -14,13 +14,13 @@ LL | stack!("overflow"); | ^^^^^^^^^^^^^^^^^^ | = note: expanding `stack! { "overflow" }` - = note: to `println! (stack! ("overflow")) ;` + = note: to `println! (stack! ("overflow"));` = note: expanding `println! { stack! ("overflow") }` - = note: to `{ $crate :: io :: _print($crate :: format_args_nl! (stack! ("overflow"))) ; }` + = note: to `{ $crate :: io :: _print($crate :: format_args_nl! (stack! ("overflow"))); }` = note: expanding `stack! { "overflow" }` - = note: to `println! (stack! ("overflow")) ;` + = note: to `println! (stack! ("overflow"));` = note: expanding `println! { stack! ("overflow") }` - = note: to `{ $crate :: io :: _print($crate :: format_args_nl! (stack! ("overflow"))) ; }` + = note: to `{ $crate :: io :: _print($crate :: format_args_nl! (stack! ("overflow"))); }` error: format argument must be a string literal --> $DIR/issue-41731-infinite-macro-println.rs:14:5 diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index c0eb7f01fdb..d65f7a8ea8c 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -59,19 +59,13 @@ fn test_block() { c1!(block, [ {} ], "{}"); c1!(block, [ { true } ], "{ true }"); c1!(block, [ { return } ], "{ return }"); - c2!(block, [ { - return; - } ], - "{ return; }", - "{ return ; }" - ); - c2!(block, + c1!(block, [ { return; } ], "{ return; }"); + c1!(block, [ { let _; true } ], - "{ let _; true }", - "{ let _ ; true }" + "{ let _; true }" ); } @@ -88,17 +82,18 @@ fn test_expr() { // ExprKind::Call c1!(expr, [ f() ], "f()"); - c2!(expr, [ f::<u8>() ], "f::<u8>()", "f :: < u8 > ()"); - c2!(expr, [ f::<1>() ], "f::<1>()", "f :: < 1 > ()"); - c2!(expr, [ f::<'a, u8, 1>() ], "f::<'a, u8, 1>()", "f :: < 'a, u8, 1 > ()"); + c1!(expr, [ f::<u8>() ], "f::<u8>()"); + c2!(expr, [ f :: < u8>( ) ], "f::<u8>()", "f :: < u8>()"); + c1!(expr, [ f::<1>() ], "f::<1>()"); + c1!(expr, [ f::<'a, u8, 1>() ], "f::<'a, u8, 1>()"); c1!(expr, [ f(true) ], "f(true)"); c2!(expr, [ f(true,) ], "f(true)", "f(true,)"); - c2!(expr, [ ()() ], "()()", "() ()"); + c1!(expr, [ ()() ], "()()"); // ExprKind::MethodCall c1!(expr, [ x.f() ], "x.f()"); - c2!(expr, [ x.f::<u8>() ], "x.f::<u8>()", "x.f :: < u8 > ()"); - c2!(expr, [ x.collect::<Vec<_>>() ], "x.collect::<Vec<_>>()", "x.collect :: < Vec < _ >> ()"); + c1!(expr, [ x.f::<u8>() ], "x.f::<u8>()"); + c1!(expr, [ x.collect::<Vec<_>>() ], "x.collect::<Vec<_>>()"); // ExprKind::Tup c1!(expr, [ () ], "()"); @@ -110,18 +105,14 @@ fn test_expr() { c1!(expr, [ true || false ], "true || false"); c1!(expr, [ true || false && false ], "true || false && false"); c1!(expr, [ a < 1 && 2 < b && c > 3 && 4 > d ], "a < 1 && 2 < b && c > 3 && 4 > d"); - c2!(expr, [ a & b & !c ], "a & b & !c", "a & b &! c"); // FIXME - c2!(expr, - [ a + b * c - d + -1 * -2 - -3], - "a + b * c - d + -1 * -2 - -3", - "a + b * c - d + - 1 * - 2 - - 3" - ); - c2!(expr, [ x = !y ], "x = !y", "x =! y"); // FIXME + c2!(expr, [ a & b & !c ], "a & b & !c", "a & b &!c"); // FIXME + c1!(expr, [ a + b * c - d + -1 * -2 - -3], "a + b * c - d + -1 * -2 - -3"); + c2!(expr, [ x = !y ], "x = !y", "x =!y"); // FIXME // ExprKind::Unary - c2!(expr, [ *expr ], "*expr", "* expr"); - c2!(expr, [ !expr ], "!expr", "! expr"); - c2!(expr, [ -expr ], "-expr", "- expr"); + c1!(expr, [ *expr ], "*expr"); + c1!(expr, [ !expr ], "!expr"); + c1!(expr, [ -expr ], "-expr"); // ExprKind::Lit c1!(expr, [ 'x' ], "'x'"); @@ -130,7 +121,7 @@ fn test_expr() { // ExprKind::Cast c1!(expr, [ expr as T ], "expr as T"); - c2!(expr, [ expr as T<u8> ], "expr as T<u8>", "expr as T < u8 >"); + c1!(expr, [ expr as T<u8> ], "expr as T<u8>"); // ExprKind::Type: there is no syntax for type ascription. @@ -139,12 +130,8 @@ fn test_expr() { // ExprKind::If c1!(expr, [ if true {} ], "if true {}"); - c2!(expr, [ if !true {} ], "if !true {}", "if! true {}"); // FIXME - c2!(expr, - [ if ::std::blah() { } else { } ], - "if ::std::blah() {} else {}", - "if :: std :: blah() {} else {}" - ); + c2!(expr, [ if !true {} ], "if !true {}", "if!true {}"); // FIXME + c1!(expr, [ if ::std::blah() { } else { } ], "if ::std::blah() {} else {}"); c1!(expr, [ if let true = true {} else {} ], "if let true = true {} else {}"); c1!(expr, [ if true { @@ -159,7 +146,7 @@ fn test_expr() { } ], "if true {} else if false {} else {}" ); - c2!(expr, + c1!(expr, [ if true { return; } else if false { @@ -167,22 +154,21 @@ fn test_expr() { } else { 0 } ], - "if true { return; } else if false { 0 } else { 0 }", - "if true { return ; } else if false { 0 } else { 0 }" + "if true { return; } else if false { 0 } else { 0 }" ); // ExprKind::While c1!(expr, [ while true {} ], "while true {}"); - c2!(expr, [ 'a: while true {} ], "'a: while true {}", "'a : while true {}"); + c1!(expr, [ 'a: while true {} ], "'a: while true {}"); c1!(expr, [ while let true = true {} ], "while let true = true {}"); // ExprKind::ForLoop c1!(expr, [ for _ in x {} ], "for _ in x {}"); - c2!(expr, [ 'a: for _ in x {} ], "'a: for _ in x {}", "'a : for _ in x {}"); + c1!(expr, [ 'a: for _ in x {} ], "'a: for _ in x {}"); // ExprKind::Loop c1!(expr, [ loop {} ], "loop {}"); - c2!(expr, [ 'a: loop {} ], "'a: loop {}", "'a : loop {}"); + c1!(expr, [ 'a: loop {} ], "'a: loop {}"); // ExprKind::Match c1!(expr, [ match self {} ], "match self {}"); @@ -202,8 +188,8 @@ fn test_expr() { // ExprKind::Closure c1!(expr, [ || {} ], "|| {}"); - c2!(expr, [ |x| {} ], "|x| {}", "| x | {}"); - c2!(expr, [ |x: u8| {} ], "|x: u8| {}", "| x : u8 | {}"); + c1!(expr, [ |x| {} ], "|x| {}"); + c1!(expr, [ |x: u8| {} ], "|x: u8| {}"); c1!(expr, [ || () ], "|| ()"); c1!(expr, [ move || self ], "move || self"); c1!(expr, [ async || self ], "async || self"); @@ -218,7 +204,7 @@ fn test_expr() { // ExprKind::Block c1!(expr, [ {} ], "{}"); c1!(expr, [ unsafe {} ], "unsafe {}"); - c2!(expr, [ 'a: {} ], "'a: {}", "'a : {}"); + c1!(expr, [ 'a: {} ], "'a: {}"); c1!(expr, [ #[attr] {} ], "#[attr] {}"); c2!(expr, [ @@ -229,7 +215,7 @@ fn test_expr() { "{\n\ \x20 #![attr]\n\ }", - "{ #! [attr] }" + "{ #![attr] }" ); // ExprKind::Async @@ -253,34 +239,35 @@ fn test_expr() { c1!(expr, [ expr.0 ], "expr.0"); // ExprKind::Index - c2!(expr, [ expr[true] ], "expr[true]", "expr [true]"); + c1!(expr, [ expr[true] ], "expr[true]"); // ExprKind::Range c1!(expr, [ .. ], ".."); - c2!(expr, [ ..hi ], "..hi", ".. hi"); - c2!(expr, [ lo.. ], "lo..", "lo .."); - c2!(expr, [ lo..hi ], "lo..hi", "lo .. hi"); - c2!(expr, [ ..=hi ], "..=hi", "..= hi"); - c2!(expr, [ lo..=hi ], "lo..=hi", "lo ..= hi"); - c2!(expr, [ -2..=-1 ], "-2..=-1", "- 2 ..= - 1"); + c1!(expr, [ ..hi ], "..hi"); + c1!(expr, [ lo.. ], "lo.."); + c1!(expr, [ lo..hi ], "lo..hi"); + c2!(expr, [ lo .. hi ], "lo..hi", "lo .. hi"); + c1!(expr, [ ..=hi ], "..=hi"); + c1!(expr, [ lo..=hi ], "lo..=hi"); + c1!(expr, [ -2..=-1 ], "-2..=-1"); // ExprKind::Underscore // FIXME: todo // ExprKind::Path c1!(expr, [ thing ], "thing"); - c2!(expr, [ m::thing ], "m::thing", "m :: thing"); - c2!(expr, [ self::thing ], "self::thing", "self :: thing"); - c2!(expr, [ crate::thing ], "crate::thing", "crate :: thing"); - c2!(expr, [ Self::thing ], "Self::thing", "Self :: thing"); - c2!(expr, [ <Self as T>::thing ], "<Self as T>::thing", "< Self as T > :: thing"); - c2!(expr, [ Self::<'static> ], "Self::<'static>", "Self :: < 'static >"); + c1!(expr, [ m::thing ], "m::thing"); + c1!(expr, [ self::thing ], "self::thing"); + c1!(expr, [ crate::thing ], "crate::thing"); + c1!(expr, [ Self::thing ], "Self::thing"); + c1!(expr, [ <Self as T>::thing ], "<Self as T>::thing"); + c1!(expr, [ Self::<'static> ], "Self::<'static>"); // ExprKind::AddrOf - c2!(expr, [ &expr ], "&expr", "& expr"); - c2!(expr, [ &mut expr ], "&mut expr", "& mut expr"); - c2!(expr, [ &raw const expr ], "&raw const expr", "& raw const expr"); - c2!(expr, [ &raw mut expr ], "&raw mut expr", "& raw mut expr"); + c1!(expr, [ &expr ], "&expr"); + c1!(expr, [ &mut expr ], "&mut expr"); + c1!(expr, [ &raw const expr ], "&raw const expr"); + c1!(expr, [ &raw mut expr ], "&raw mut expr"); // ExprKind::Break c1!(expr, [ break ], "break"); @@ -301,38 +288,30 @@ fn test_expr() { // ExprKind::OffsetOf: untestable because this test works pre-expansion. // ExprKind::MacCall - c2!(expr, [ mac!(...) ], "mac!(...)", "mac! (...)"); - c2!(expr, [ mac![...] ], "mac![...]", "mac! [...]"); + c1!(expr, [ mac!(...) ], "mac!(...)"); + c1!(expr, [ mac![...] ], "mac![...]"); c1!(expr, [ mac! { ... } ], "mac! { ... }"); // ExprKind::Struct c1!(expr, [ Struct {} ], "Struct {}"); - c2!(expr, - [ <Struct as Trait>::Type {} ], - "<Struct as Trait>::Type {}", - "< Struct as Trait > :: Type {}" - ); + c1!(expr, [ <Struct as Trait>::Type {} ], "<Struct as Trait>::Type {}"); c1!(expr, [ Struct { .. } ], "Struct { .. }"); - c2!(expr, [ Struct { ..base } ], "Struct { ..base }", "Struct { .. base }"); + c1!(expr, [ Struct { ..base } ], "Struct { ..base }"); c1!(expr, [ Struct { x } ], "Struct { x }"); c1!(expr, [ Struct { x, .. } ], "Struct { x, .. }"); - c2!(expr, [ Struct { x, ..base } ], "Struct { x, ..base }", "Struct { x, .. base }"); - c2!(expr, [ Struct { x: true } ], "Struct { x: true }", "Struct { x : true }"); - c2!(expr, [ Struct { x: true, .. } ], "Struct { x: true, .. }", "Struct { x : true, .. }"); - c2!(expr, - [ Struct { x: true, ..base } ], - "Struct { x: true, ..base }", - "Struct { x : true, .. base }" - ); + c1!(expr, [ Struct { x, ..base } ], "Struct { x, ..base }"); + c1!(expr, [ Struct { x: true } ], "Struct { x: true }"); + c1!(expr, [ Struct { x: true, .. } ], "Struct { x: true, .. }"); + c1!(expr, [ Struct { x: true, ..base } ], "Struct { x: true, ..base }"); // ExprKind::Repeat - c2!(expr, [ [(); 0] ], "[(); 0]", "[() ; 0]"); + c1!(expr, [ [(); 0] ], "[(); 0]"); // ExprKind::Paren c1!(expr, [ (expr) ], "(expr)"); // ExprKind::Try - c2!(expr, [ expr? ], "expr?", "expr ?"); + c1!(expr, [ expr? ], "expr?"); // ExprKind::Yield c1!(expr, [ yield ], "yield"); @@ -356,51 +335,42 @@ fn test_expr() { #[test] fn test_item() { // ItemKind::ExternCrate - c2!(item, [ extern crate std; ], "extern crate std;", "extern crate std ;"); - c2!(item, - [ pub extern crate self as std; ], - "pub extern crate self as std;", - "pub extern crate self as std ;" - ); + c1!(item, [ extern crate std; ], "extern crate std;"); + c1!(item, [ pub extern crate self as std; ], "pub extern crate self as std;"); // ItemKind::Use c2!(item, [ pub use crate::{a, b::c}; ], "pub use crate::{a, b::c};", - "pub use crate :: { a, b :: c } ;" + "pub use crate::{ a, b::c };" // FIXME ); - c2!(item, [ pub use A::*; ], "pub use A::*;", "pub use A :: * ;"); + c1!(item, [ pub use A::*; ], "pub use A::*;"); // ItemKind::Static - c2!(item, [ pub static S: () = {}; ], "pub static S: () = {};", "pub static S : () = {} ;"); - c2!(item, [ static mut S: () = {}; ], "static mut S: () = {};", "static mut S : () = {} ;"); - c2!(item, [ static S: (); ], "static S: ();", "static S : () ;"); - c2!(item, [ static mut S: (); ], "static mut S: ();", "static mut S : () ;"); + c1!(item, [ pub static S: () = {}; ], "pub static S: () = {};"); + c1!(item, [ static mut S: () = {}; ], "static mut S: () = {};"); + c1!(item, [ static S: (); ], "static S: ();"); + c1!(item, [ static mut S: (); ], "static mut S: ();"); // ItemKind::Const - c2!(item, [ pub const S: () = {}; ], "pub const S: () = {};", "pub const S : () = {} ;"); - c2!(item, [ const S: (); ], "const S: ();", "const S : () ;"); + c1!(item, [ pub const S: () = {}; ], "pub const S: () = {};"); + c1!(item, [ const S: (); ], "const S: ();"); // ItemKind::Fn c1!(item, [ pub default const async unsafe extern "C" fn f() {} ], "pub default const async unsafe extern \"C\" fn f() {}" ); - c2!(item, - [ fn g<T>(t: Vec<Vec<Vec<T>>>) {} ], - "fn g<T>(t: Vec<Vec<Vec<T>>>) {}", - "fn g < T > (t : Vec < Vec < Vec < T >> >) {}" - ); - c2!(item, + c1!(item, [ fn g<T>(t: Vec<Vec<Vec<T>>>) {} ], "fn g<T>(t: Vec<Vec<Vec<T>>>) {}"); + c1!(item, [ fn h<'a>(t: &'a Vec<Cell<dyn D>>) {} ], - "fn h<'a>(t: &'a Vec<Cell<dyn D>>) {}", - "fn h < 'a > (t : & 'a Vec < Cell < dyn D >>) {}" + "fn h<'a>(t: &'a Vec<Cell<dyn D>>) {}" ); // ItemKind::Mod - c2!(item, [ pub mod m; ], "pub mod m;", "pub mod m ;"); + c1!(item, [ pub mod m; ], "pub mod m;"); c1!(item, [ mod m {} ], "mod m {}"); - c2!(item, [ unsafe mod m; ], "unsafe mod m;", "unsafe mod m ;"); + c1!(item, [ unsafe mod m; ], "unsafe mod m;"); c1!(item, [ unsafe mod m {} ], "unsafe mod m {}"); // ItemKind::ForeignMod @@ -423,7 +393,7 @@ fn test_item() { = T; ], "pub default type Type<'a>: Bound where Self: 'a = T;", - "pub default type Type < 'a > : Bound where Self : 'a, = T ;" + "pub default type Type<'a>: Bound where Self: 'a, = T;" ); // ItemKind::Enum @@ -456,13 +426,13 @@ fn test_item() { \x20 t: T,\n\ \x20 },\n\ }", - "enum Enum < T > where T : 'a, { Unit, Tuple(T), Struct { t : T }, }" + "enum Enum<T> where T: 'a, { Unit, Tuple(T), Struct { t: T }, }" ); // ItemKind::Struct - c2!(item, [ pub struct Unit; ], "pub struct Unit;", "pub struct Unit ;"); - c2!(item, [ struct Tuple(); ], "struct Tuple();", "struct Tuple() ;"); - c2!(item, [ struct Tuple(T); ], "struct Tuple(T);", "struct Tuple(T) ;"); + c1!(item, [ pub struct Unit; ], "pub struct Unit;"); + c1!(item, [ struct Tuple(); ], "struct Tuple();"); + c1!(item, [ struct Tuple(T); ], "struct Tuple(T);"); c1!(item, [ struct Struct {} ], "struct Struct {}"); c2!(item, [ @@ -476,7 +446,7 @@ fn test_item() { "struct Struct<T> where T: 'a {\n\ \x20 t: T,\n\ }", - "struct Struct < T > where T : 'a, { t : T, }" + "struct Struct<T> where T: 'a, { t: T, }" ); // ItemKind::Union @@ -490,7 +460,7 @@ fn test_item() { "union Union<T> where T: 'a {\n\ \x20 t: T,\n\ }", - "union Union < T > where T : 'a { t : T, }" + "union Union<T> where T: 'a { t: T, }" ); // ItemKind::Trait @@ -504,30 +474,25 @@ fn test_item() { } ], "trait Trait<'a>: Sized where Self: 'a {}", - "trait Trait < 'a > : Sized where Self : 'a, {}" + "trait Trait<'a>: Sized where Self: 'a, {}" ); // ItemKind::TraitAlias - c2!(item, + c1!(item, [ pub trait Trait<T> = Sized where T: 'a; ], - "pub trait Trait<T> = Sized where T: 'a;", - "pub trait Trait < T > = Sized where T : 'a ;" + "pub trait Trait<T> = Sized where T: 'a;" ); // ItemKind::Impl c1!(item, [ pub impl Struct {} ], "pub impl Struct {}"); - c2!(item, [ impl<T> Struct<T> {} ], "impl<T> Struct<T> {}", "impl < T > Struct < T > {}"); + c1!(item, [ impl<T> Struct<T> {} ], "impl<T> Struct<T> {}"); c1!(item, [ pub impl Trait for Struct {} ], "pub impl Trait for Struct {}"); - c2!(item, - [ impl<T> const Trait for T {} ], - "impl<T> const Trait for T {}", - "impl < T > const Trait for T {}" - ); - c2!(item, [ impl ~const Struct {} ], "impl ~const Struct {}", "impl ~ const Struct {}"); + c1!(item, [ impl<T> const Trait for T {} ], "impl<T> const Trait for T {}"); + c1!(item, [ impl ~const Struct {} ], "impl ~const Struct {}"); // ItemKind::MacCall - c2!(item, [ mac!(...); ], "mac!(...);", "mac! (...) ;"); - c2!(item, [ mac![...]; ], "mac![...];", "mac! [...] ;"); + c1!(item, [ mac!(...); ], "mac!(...);"); + c1!(item, [ mac![...]; ], "mac![...];"); c1!(item, [ mac! { ... } ], "mac! { ... }"); // ItemKind::MacroDef @@ -537,7 +502,7 @@ fn test_item() { () => {}; } ], - "macro_rules! stringify { () => {} ; }" + "macro_rules! stringify { () => {}; }" ); c2!(item, [ pub macro stringify() {} ], @@ -551,7 +516,7 @@ fn test_meta() { c1!(meta, [ k ], "k"); c1!(meta, [ k = "v" ], "k = \"v\""); c1!(meta, [ list(k1, k2 = "v") ], "list(k1, k2 = \"v\")"); - c2!(meta, [ serde::k ], "serde::k", "serde :: k"); + c1!(meta, [ serde::k ], "serde::k"); } #[test] @@ -568,42 +533,35 @@ fn test_pat() { // PatKind::Struct c1!(pat, [ Struct {} ], "Struct {}"); - c2!(pat, [ Struct::<u8> {} ], "Struct::<u8> {}", "Struct :: < u8 > {}"); - c2!(pat, [ Struct::<'static> {} ], "Struct::<'static> {}", "Struct :: < 'static > {}"); + c1!(pat, [ Struct::<u8> {} ], "Struct::<u8> {}"); + c2!(pat, [ Struct ::< u8 > {} ], "Struct::<u8> {}", "Struct ::< u8 > {}"); + c1!(pat, [ Struct::<'static> {} ], "Struct::<'static> {}"); c1!(pat, [ Struct { x } ], "Struct { x }"); - c2!(pat, [ Struct { x: _x } ], "Struct { x: _x }", "Struct { x : _x }"); + c1!(pat, [ Struct { x: _x } ], "Struct { x: _x }"); c1!(pat, [ Struct { .. } ], "Struct { .. }"); c1!(pat, [ Struct { x, .. } ], "Struct { x, .. }"); - c2!(pat, [ Struct { x: _x, .. } ], "Struct { x: _x, .. }", "Struct { x : _x, .. }"); - c2!(pat, - [ <Struct as Trait>::Type {} ], - "<Struct as Trait>::Type {}", - "< Struct as Trait > :: Type {}" - ); + c1!(pat, [ Struct { x: _x, .. } ], "Struct { x: _x, .. }"); + c1!(pat, [ <Struct as Trait>::Type {} ], "<Struct as Trait>::Type {}"); // PatKind::TupleStruct c1!(pat, [ Tuple() ], "Tuple()"); - c2!(pat, [ Tuple::<u8>() ], "Tuple::<u8>()", "Tuple :: < u8 > ()"); - c2!(pat, [ Tuple::<'static>() ], "Tuple::<'static>()", "Tuple :: < 'static > ()"); + c1!(pat, [ Tuple::<u8>() ], "Tuple::<u8>()"); + c1!(pat, [ Tuple::<'static>() ], "Tuple::<'static>()"); c1!(pat, [ Tuple(x) ], "Tuple(x)"); c1!(pat, [ Tuple(..) ], "Tuple(..)"); c1!(pat, [ Tuple(x, ..) ], "Tuple(x, ..)"); - c2!(pat, - [ <Struct as Trait>::Type() ], - "<Struct as Trait>::Type()", - "< Struct as Trait > :: Type()" - ); + c1!(pat, [ <Struct as Trait>::Type() ], "<Struct as Trait>::Type()"); // PatKind::Or c1!(pat, [ true | false ], "true | false"); c2!(pat, [ | true ], "true", "| true"); - c2!(pat, [ |true| false ], "true | false", "| true | false"); + c2!(pat, [ |true| false ], "true | false", "|true| false"); // PatKind::Path - c2!(pat, [ crate::Path ], "crate::Path", "crate :: Path"); - c2!(pat, [ Path::<u8> ], "Path::<u8>", "Path :: < u8 >"); - c2!(pat, [ Path::<'static> ], "Path::<'static>", "Path :: < 'static >"); - c2!(pat, [ <Struct as Trait>::Type ], "<Struct as Trait>::Type", "< Struct as Trait > :: Type"); + c1!(pat, [ crate::Path ], "crate::Path"); + c1!(pat, [ Path::<u8> ], "Path::<u8>"); + c1!(pat, [ Path::<'static> ], "Path::<'static>"); + c1!(pat, [ <Struct as Trait>::Type ], "<Struct as Trait>::Type"); // PatKind::Tuple c1!(pat, [ () ], "()"); @@ -614,18 +572,18 @@ fn test_pat() { c1!(pat, [ box pat ], "box pat"); // PatKind::Ref - c2!(pat, [ &pat ], "&pat", "& pat"); - c2!(pat, [ &mut pat ], "&mut pat", "& mut pat"); + c1!(pat, [ &pat ], "&pat"); + c1!(pat, [ &mut pat ], "&mut pat"); // PatKind::Lit c1!(pat, [ 1_000_i8 ], "1_000_i8"); // PatKind::Range - c2!(pat, [ ..1 ], "..1", ".. 1"); - c2!(pat, [ 0.. ], "0..", "0 .."); - c2!(pat, [ 0..1 ], "0..1", "0 .. 1"); - c2!(pat, [ 0..=1 ], "0..=1", "0 ..= 1"); - c2!(pat, [ -2..=-1 ], "-2..=-1", "- 2 ..= - 1"); + c1!(pat, [ ..1 ], "..1"); + c1!(pat, [ 0.. ], "0.."); + c1!(pat, [ 0..1 ], "0..1"); + c1!(pat, [ 0..=1 ], "0..=1"); + c1!(pat, [ -2..=-1 ], "-2..=-1"); // PatKind::Slice c1!(pat, [ [] ], "[]"); @@ -644,20 +602,20 @@ fn test_pat() { c1!(pat, [ (pat) ], "(pat)"); // PatKind::MacCall - c2!(pat, [ mac!(...) ], "mac!(...)", "mac! (...)"); - c2!(pat, [ mac![...] ], "mac![...]", "mac! [...]"); + c1!(pat, [ mac!(...) ], "mac!(...)"); + c1!(pat, [ mac![...] ], "mac![...]"); c1!(pat, [ mac! { ... } ], "mac! { ... }"); } #[test] fn test_path() { c1!(path, [ thing ], "thing"); - c2!(path, [ m::thing ], "m::thing", "m :: thing"); - c2!(path, [ self::thing ], "self::thing", "self :: thing"); - c2!(path, [ crate::thing ], "crate::thing", "crate :: thing"); - c2!(path, [ Self::thing ], "Self::thing", "Self :: thing"); - c2!(path, [ Self<'static> ], "Self<'static>", "Self < 'static >"); - c2!(path, [ Self::<'static> ], "Self<'static>", "Self :: < 'static >"); + c1!(path, [ m::thing ], "m::thing"); + c1!(path, [ self::thing ], "self::thing"); + c1!(path, [ crate::thing ], "crate::thing"); + c1!(path, [ Self::thing ], "Self::thing"); + c1!(path, [ Self<'static> ], "Self<'static>"); + c2!(path, [ Self::<'static> ], "Self<'static>", "Self::<'static>"); c1!(path, [ Self() ], "Self()"); c1!(path, [ Self() -> () ], "Self() -> ()"); } @@ -667,16 +625,16 @@ fn test_stmt() { // StmtKind::Local c2!(stmt, [ let _ ], "let _;", "let _"); c2!(stmt, [ let x = true ], "let x = true;", "let x = true"); - c2!(stmt, [ let x: bool = true ], "let x: bool = true;", "let x : bool = true"); + c2!(stmt, [ let x: bool = true ], "let x: bool = true;", "let x: bool = true"); c2!(stmt, [ let (a, b) = (1, 2) ], "let (a, b) = (1, 2);", "let(a, b) = (1, 2)"); // FIXME c2!(stmt, [ let (a, b): (u32, u32) = (1, 2) ], "let (a, b): (u32, u32) = (1, 2);", - "let(a, b) : (u32, u32) = (1, 2)" + "let(a, b): (u32, u32) = (1, 2)" // FIXME ); // StmtKind::Item - c2!(stmt, [ struct S; ], "struct S;", "struct S ;"); + c1!(stmt, [ struct S; ], "struct S;"); c1!(stmt, [ struct S {} ], "struct S {}"); // StmtKind::Expr @@ -689,8 +647,8 @@ fn test_stmt() { c1!(stmt, [ ; ], ";"); // StmtKind::MacCall - c2!(stmt, [ mac!(...) ], "mac!(...)", "mac! (...)"); - c2!(stmt, [ mac![...] ], "mac![...]", "mac! [...]"); + c1!(stmt, [ mac!(...) ], "mac!(...)"); + c1!(stmt, [ mac![...] ], "mac![...]"); c1!(stmt, [ mac! { ... } ], "mac! { ... }"); } @@ -700,26 +658,27 @@ fn test_ty() { c1!(ty, [ [T] ], "[T]"); // TyKind::Array - c2!(ty, [ [T; 0] ], "[T; 0]", "[T ; 0]"); + c1!(ty, [ [T; 0] ], "[T; 0]"); // TyKind::Ptr - c2!(ty, [ *const T ], "*const T", "* const T"); - c2!(ty, [ *mut T ], "*mut T", "* mut T"); + c1!(ty, [ *const T ], "*const T"); + c1!(ty, [ *mut T ], "*mut T"); // TyKind::Ref - c2!(ty, [ &T ], "&T", "& T"); - c2!(ty, [ &mut T ], "&mut T", "& mut T"); - c2!(ty, [ &'a T ], "&'a T", "& 'a T"); - c2!(ty, [ &'a mut [T] ], "&'a mut [T]", "& 'a mut [T]"); - c2!(ty, [ &A<B<C<D<E>>>> ], "&A<B<C<D<E>>>>", "& A < B < C < D < E >> >>"); + c1!(ty, [ &T ], "&T"); + c1!(ty, [ &mut T ], "&mut T"); + c1!(ty, [ &'a T ], "&'a T"); + c1!(ty, [ &'a mut [T] ], "&'a mut [T]"); + c1!(ty, [ &A<B<C<D<E>>>> ], "&A<B<C<D<E>>>>"); + c2!(ty, [ &A<B<C<D<E> > > > ], "&A<B<C<D<E>>>>", "&A<B<C<D<E> > > >"); // TyKind::BareFn c1!(ty, [ fn() ], "fn()"); c1!(ty, [ fn() -> () ], "fn() -> ()"); c1!(ty, [ fn(u8) ], "fn(u8)"); - c2!(ty, [ fn(x: u8) ], "fn(x: u8)", "fn(x : u8)"); - c2!(ty, [ for<> fn() ], "fn()", "for < > fn()"); - c2!(ty, [ for<'a> fn() ], "for<'a> fn()", "for < 'a > fn()"); + c1!(ty, [ fn(x: u8) ], "fn(x: u8)"); + c2!(ty, [ for<> fn() ], "fn()", "for<> fn()"); + c1!(ty, [ for<'a> fn() ], "for<'a> fn()"); // TyKind::Never c1!(ty, [ ! ], "!"); @@ -735,28 +694,28 @@ fn test_ty() { // TyKind::Path c1!(ty, [ T ], "T"); - c2!(ty, [ Ref<'a> ], "Ref<'a>", "Ref < 'a >"); - c2!(ty, [ PhantomData<T> ], "PhantomData<T>", "PhantomData < T >"); - c2!(ty, [ PhantomData::<T> ], "PhantomData<T>", "PhantomData :: < T >"); + c1!(ty, [ Ref<'a> ], "Ref<'a>"); + c1!(ty, [ PhantomData<T> ], "PhantomData<T>"); + c2!(ty, [ PhantomData::<T> ], "PhantomData<T>", "PhantomData::<T>"); c2!(ty, [ Fn() -> ! ], "Fn() -> !", "Fn() ->!"); c2!(ty, [ Fn(u8) -> ! ], "Fn(u8) -> !", "Fn(u8) ->!"); // FIXME - c2!(ty, [ <Struct as Trait>::Type ], "<Struct as Trait>::Type", "< Struct as Trait > :: Type"); + c1!(ty, [ <Struct as Trait>::Type ], "<Struct as Trait>::Type"); // TyKind::TraitObject c1!(ty, [ dyn Send ], "dyn Send"); c1!(ty, [ dyn Send + 'a ], "dyn Send + 'a"); c1!(ty, [ dyn 'a + Send ], "dyn 'a + Send"); - c2!(ty, [ dyn ?Sized ], "dyn ?Sized", "dyn ? Sized"); - c2!(ty, [ dyn ~const Clone ], "dyn ~const Clone", "dyn ~ const Clone"); - c2!(ty, [ dyn for<'a> Send ], "dyn for<'a> Send", "dyn for < 'a > Send"); + c1!(ty, [ dyn ?Sized ], "dyn ?Sized"); + c1!(ty, [ dyn ~const Clone ], "dyn ~const Clone"); + c1!(ty, [ dyn for<'a> Send ], "dyn for<'a> Send"); // TyKind::ImplTrait c1!(ty, [ impl Send ], "impl Send"); c1!(ty, [ impl Send + 'a ], "impl Send + 'a"); c1!(ty, [ impl 'a + Send ], "impl 'a + Send"); - c2!(ty, [ impl ?Sized ], "impl ?Sized", "impl ? Sized"); - c2!(ty, [ impl ~const Clone ], "impl ~const Clone", "impl ~ const Clone"); - c2!(ty, [ impl for<'a> Send ], "impl for<'a> Send", "impl for < 'a > Send"); + c1!(ty, [ impl ?Sized ], "impl ?Sized"); + c1!(ty, [ impl ~const Clone ], "impl ~const Clone"); + c1!(ty, [ impl for<'a> Send ], "impl for<'a> Send"); // TyKind::Paren c1!(ty, [ (T) ], "(T)"); @@ -769,8 +728,8 @@ fn test_ty() { // TyKind::ImplicitSelf: there is no syntax for this. // TyKind::MacCall - c2!(ty, [ mac!(...) ], "mac!(...)", "mac! (...)"); - c2!(ty, [ mac![...] ], "mac![...]", "mac! [...]"); + c1!(ty, [ mac!(...) ], "mac!(...)"); + c1!(ty, [ mac![...] ], "mac![...]"); c1!(ty, [ mac! { ... } ], "mac! { ... }"); // TyKind::Err: untestable. @@ -791,13 +750,13 @@ fn test_vis() { c2!(vis, [ pub(in crate) ], "pub(in crate) ", "pub(in crate)"); c2!(vis, [ pub(in self) ], "pub(in self) ", "pub(in self)"); c2!(vis, [ pub(in super) ], "pub(in super) ", "pub(in super)"); - c2!(vis, [ pub(in path::to) ], "pub(in path::to) ", "pub(in path :: to)"); - c2!(vis, [ pub(in ::path::to) ], "pub(in ::path::to) ", "pub(in :: path :: to)"); - c2!(vis, [ pub(in self::path::to) ], "pub(in self::path::to) ", "pub(in self :: path :: to)"); + c2!(vis, [ pub(in path::to) ], "pub(in path::to) ", "pub(in path::to)"); + c2!(vis, [ pub(in ::path::to) ], "pub(in ::path::to) ", "pub(in ::path::to)"); + c2!(vis, [ pub(in self::path::to) ], "pub(in self::path::to) ", "pub(in self::path::to)"); c2!(vis, [ pub(in super::path::to) ], "pub(in super::path::to) ", - "pub(in super :: path :: to)" + "pub(in super::path::to)" ); // VisibilityKind::Inherited @@ -815,7 +774,7 @@ macro_rules! p { #[test] fn test_punct() { - // For all these cases, we must preserve spaces between the tokens. + // For all these cases, we should preserve spaces between the tokens. // Otherwise, any old proc macro that parses pretty-printed code might glue // together tokens that shouldn't be glued. p!([ = = < < <= <= == == != != >= >= > > ], "= = < < <= <= == == != != >= >= > >"); @@ -828,10 +787,7 @@ fn test_punct() { p!([ + + += += - - -= -= * * *= *= / / /= /= ], "+ + += += - - -= -= * * *= *= / / /= /="); p!([ % % %= %= ^ ^ ^= ^= << << <<= <<= >> >> >>= >>= ], "% % %= %= ^ ^ ^= ^= << << <<= <<= >> >> >>= >>="); - - // For these one we must insert spaces between adjacent tokens, again due - // to proc macros. - p!([ +! ?= |> >>@ --> <-- $$ =====> ], "+! ? = | > >> @ - -> <- - $$== == =>"); // FIXME - p!([ ,; ;, ** @@ $+$ >< <> ?? +== ], ", ; ;, * * @ @ $+ $> < < > ? ? += ="); // FIXME - p!([ :#!@|$=&*,+;*~? ], ": #! @ | $= & *, + ; * ~ ?"); // FIXME + p!([ +! ?= |> >>@ --> <-- $$ =====> ], "+! ?= |> >>@ --> <-- $$=====>"); + p!([ ,; ;, ** @@ $+$ >< <> ?? +== ], ",; ;, ** @@ $+$>< <> ?? +=="); // FIXME: `$ >` -> `$>` + p!([ :#!@|$=&*,+;*~? ], ":#!@|$=&*,+;*~?"); } diff --git a/tests/ui/macros/syntax-extension-source-utils.rs b/tests/ui/macros/syntax-extension-source-utils.rs index f41faddddf6..aa894c83910 100644 --- a/tests/ui/macros/syntax-extension-source-utils.rs +++ b/tests/ui/macros/syntax-extension-source-utils.rs @@ -17,7 +17,7 @@ pub fn main() { assert_eq!(column!(), 16); assert_eq!(indirect_line!(), 18); assert!((file!().ends_with("syntax-extension-source-utils.rs"))); - assert_eq!(stringify!((2*3) + 5).to_string(), "(2 * 3) + 5".to_string()); + assert_eq!(stringify!((2*3) + 5).to_string(), "(2*3) + 5".to_string()); assert!(include!("syntax-extension-source-utils-files/includeme.\ fragment").to_string() == "victory robot 6".to_string()); @@ -32,5 +32,5 @@ pub fn main() { // The Windows tests are wrapped in an extra module for some reason assert!((m1::m2::where_am_i().ends_with("m1::m2"))); - assert_eq!((35, "(2 * 3) + 5"), (line!(), stringify!((2*3) + 5))); + assert_eq!((35, "(2*3) + 5"), (line!(), stringify!((2*3) + 5))); } diff --git a/tests/ui/macros/trace-macro.stderr b/tests/ui/macros/trace-macro.stderr index 43272248c28..dac4cc12f84 100644 --- a/tests/ui/macros/trace-macro.stderr +++ b/tests/ui/macros/trace-macro.stderr @@ -5,5 +5,5 @@ LL | println!("Hello, World!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expanding `println! { "Hello, World!" }` - = note: to `{ $crate :: io :: _print($crate :: format_args_nl! ("Hello, World!")) ; }` + = note: to `{ $crate :: io :: _print($crate :: format_args_nl! ("Hello, World!")); }` diff --git a/tests/ui/macros/trace_faulty_macros.stderr b/tests/ui/macros/trace_faulty_macros.stderr index 6a89d3bfd09..81047c7a21a 100644 --- a/tests/ui/macros/trace_faulty_macros.stderr +++ b/tests/ui/macros/trace_faulty_macros.stderr @@ -20,7 +20,7 @@ LL | my_faulty_macro!(); | ^^^^^^^^^^^^^^^^^^ | = note: expanding `my_faulty_macro! { }` - = note: to `my_faulty_macro! (bcd) ;` + = note: to `my_faulty_macro! (bcd);` = note: expanding `my_faulty_macro! { bcd }` error: recursion limit reached while expanding `my_recursive_macro!` @@ -42,13 +42,13 @@ LL | my_recursive_macro!(); | ^^^^^^^^^^^^^^^^^^^^^ | = note: expanding `my_recursive_macro! { }` - = note: to `my_recursive_macro! () ;` + = note: to `my_recursive_macro! ();` = note: expanding `my_recursive_macro! { }` - = note: to `my_recursive_macro! () ;` + = note: to `my_recursive_macro! ();` = note: expanding `my_recursive_macro! { }` - = note: to `my_recursive_macro! () ;` + = note: to `my_recursive_macro! ();` = note: expanding `my_recursive_macro! { }` - = note: to `my_recursive_macro! () ;` + = note: to `my_recursive_macro! ();` error: expected expression, found pattern `A { a: a, b: 0, c: _, .. }` --> $DIR/trace_faulty_macros.rs:16:9 @@ -98,7 +98,7 @@ LL | let a = pat_macro!(); | ^^^^^^^^^^^^ | = note: expanding `pat_macro! { }` - = note: to `pat_macro! (A { a : a, b : 0, c : _, .. }) ;` + = note: to `pat_macro! (A { a : a, b : 0, c : _, .. });` = note: expanding `pat_macro! { A { a : a, b : 0, c : _, .. } }` = note: to `A { a: a, b: 0, c: _, .. }` @@ -108,7 +108,7 @@ note: trace_macro LL | test!(let x = 1+1); | ^^^^^^^^^^^^^^^^^^ | - = note: expanding `test! { let x = 1 + 1 }` + = note: expanding `test! { let x = 1+1 }` = note: to `test! ((x, 1 + 1))` = note: expanding `test! { (x, 1 + 1) }` = note: to `let x = 1 + 1 ;` diff --git a/tests/ui/proc-macro/allowed-attr-stmt-expr.stdout b/tests/ui/proc-macro/allowed-attr-stmt-expr.stdout index 4f8730053ee..8459f4e6305 100644 --- a/tests/ui/proc-macro/allowed-attr-stmt-expr.stdout +++ b/tests/ui/proc-macro/allowed-attr-stmt-expr.stdout @@ -1,4 +1,5 @@ -PRINT-ATTR INPUT (DISPLAY): struct ItemWithSemi ; +PRINT-ATTR INPUT (DISPLAY): struct ItemWithSemi; +PRINT-ATTR RE-COLLECTED (DISPLAY): struct ItemWithSemi ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", @@ -45,7 +46,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/allowed-attr-stmt-expr.rs:53:27: 53:29 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[expect_let] let string = "Hello, world!" ; +PRINT-ATTR INPUT (DISPLAY): #[expect_let] let string = "Hello, world!"; +PRINT-ATTR RE-COLLECTED (DISPLAY): #[expect_let] let string = "Hello, world!" ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', @@ -87,7 +89,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/allowed-attr-stmt-expr.rs:57:33: 57:34 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro! ("{}", string) ; +PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro!("{}", string); +PRINT-ATTR RE-COLLECTED (DISPLAY): #[expect_my_macro_stmt] my_macro! ("{}", string) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', @@ -140,7 +143,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/allowed-attr-stmt-expr.rs:61:28: 61:29 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): second_make_stmt! (#[allow(dead_code)] struct Bar {}) ; +PRINT-ATTR INPUT (DISPLAY): second_make_stmt!(#[allow(dead_code)] struct Bar {}); +PRINT-ATTR RE-COLLECTED (DISPLAY): second_make_stmt! (#[allow(dead_code)] struct Bar {}) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "second_make_stmt", @@ -288,7 +292,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/allowed-attr-stmt-expr.rs:68:18: 68:20 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct NonBracedStruct ; +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct NonBracedStruct; +PRINT-ATTR RE-COLLECTED (DISPLAY): #[rustc_dummy] struct NonBracedStruct ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', diff --git a/tests/ui/proc-macro/attr-complex-fn.stdout b/tests/ui/proc-macro/attr-complex-fn.stdout index b12eb587fc7..7c23d1ecae4 100644 --- a/tests/ui/proc-macro/attr-complex-fn.stdout +++ b/tests/ui/proc-macro/attr-complex-fn.stdout @@ -1,4 +1,5 @@ -PRINT-ATTR INPUT (DISPLAY): fn foo < T : MyTrait < MyStruct < { true } >> > () {} +PRINT-ATTR INPUT (DISPLAY): fn foo<T: MyTrait<MyStruct<{ true }>>>() {} +PRINT-ATTR RE-COLLECTED (DISPLAY): fn foo < T : MyTrait < MyStruct < { true } >>> () {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "fn", @@ -76,7 +77,9 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/attr-complex-fn.rs:19:42: 19:44 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): impl < T > MyTrait < T > for MyStruct < { true } > { #! [rustc_dummy] } +PRINT-ATTR INPUT (DISPLAY): impl<T> MyTrait<T> for MyStruct<{ true }> { #![rustc_dummy] } +PRINT-ATTR RE-COLLECTED (DISPLAY): impl < T > MyTrait < T > for MyStruct < { true } > { #![rustc_dummy] } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): impl < T > MyTrait < T > for MyStruct < { true } > { #! [rustc_dummy] } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "impl", diff --git a/tests/ui/proc-macro/attr-stmt-expr.stdout b/tests/ui/proc-macro/attr-stmt-expr.stdout index c6d77e0ed0c..5e09198bbd4 100644 --- a/tests/ui/proc-macro/attr-stmt-expr.stdout +++ b/tests/ui/proc-macro/attr-stmt-expr.stdout @@ -29,7 +29,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/attr-stmt-expr.rs:45:27: 45:29 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[expect_let] let string = "Hello, world!" ; +PRINT-ATTR INPUT (DISPLAY): #[expect_let] let string = "Hello, world!"; +PRINT-ATTR RE-COLLECTED (DISPLAY): #[expect_let] let string = "Hello, world!" ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', @@ -71,7 +72,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/attr-stmt-expr.rs:49:33: 49:34 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro! ("{}", string) ; +PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro!("{}", string); +PRINT-ATTR RE-COLLECTED (DISPLAY): #[expect_my_macro_stmt] my_macro! ("{}", string) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', @@ -124,7 +126,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/attr-stmt-expr.rs:53:28: 53:29 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): second_make_stmt! (#[allow(dead_code)] struct Bar {}) ; +PRINT-ATTR INPUT (DISPLAY): second_make_stmt!(#[allow(dead_code)] struct Bar {}); +PRINT-ATTR RE-COLLECTED (DISPLAY): second_make_stmt! (#[allow(dead_code)] struct Bar {}) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "second_make_stmt", diff --git a/tests/ui/proc-macro/attribute-after-derive.stdout b/tests/ui/proc-macro/attribute-after-derive.stdout index 1b17d60476a..6d9531df8ca 100644 --- a/tests/ui/proc-macro/attribute-after-derive.stdout +++ b/tests/ui/proc-macro/attribute-after-derive.stdout @@ -1,4 +1,5 @@ -PRINT-ATTR INPUT (DISPLAY): #[derive(Print)] struct AttributeDerive { #[cfg(FALSE)] field : u8, } +PRINT-ATTR INPUT (DISPLAY): #[derive(Print)] struct AttributeDerive { #[cfg(FALSE)] field: u8, } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): #[derive(Print)] struct AttributeDerive { #[cfg(FALSE)] field : u8, } PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', @@ -130,7 +131,8 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: $DIR/attribute-after-derive.rs:23:24: 26:2 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): struct DeriveAttribute { #[cfg(FALSE)] field : u8, } +PRINT-ATTR INPUT (DISPLAY): struct DeriveAttribute { #[cfg(FALSE)] field: u8, } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): struct DeriveAttribute { #[cfg(FALSE)] field : u8, } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", diff --git a/tests/ui/proc-macro/attribute-spans-preserved.stdout b/tests/ui/proc-macro/attribute-spans-preserved.stdout index cf9a97491f0..190098d0211 100644 --- a/tests/ui/proc-macro/attribute-spans-preserved.stdout +++ b/tests/ui/proc-macro/attribute-spans-preserved.stdout @@ -1 +1 @@ -fn main() { let y : u32 = "z" ; { let x : u32 = "y" ; } } +fn main() { let y : u32 = "z" ; { let x: u32 = "y"; } } diff --git a/tests/ui/proc-macro/auxiliary/attr-stmt-expr-rpass.rs b/tests/ui/proc-macro/auxiliary/attr-stmt-expr-rpass.rs index 5b386b46bb7..76346d9a172 100644 --- a/tests/ui/proc-macro/auxiliary/attr-stmt-expr-rpass.rs +++ b/tests/ui/proc-macro/auxiliary/attr-stmt-expr-rpass.rs @@ -10,14 +10,14 @@ use proc_macro::TokenStream; #[proc_macro_attribute] pub fn expect_let(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "let string = \"Hello, world!\" ;"); + assert_eq!(item.to_string(), "let string = \"Hello, world!\";"); item } #[proc_macro_attribute] pub fn expect_print_stmt(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "println! (\"{}\", string) ;"); + assert_eq!(item.to_string(), "println!(\"{}\", string);"); item } @@ -31,7 +31,7 @@ pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream { #[proc_macro_attribute] pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "println! (\"{}\", string)"); + assert_eq!(item.to_string(), "println!(\"{}\", string)"); item } @@ -40,7 +40,6 @@ pub fn no_output(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string().is_empty()); assert!(!item.to_string().is_empty()); "".parse().unwrap() - } #[proc_macro_attribute] diff --git a/tests/ui/proc-macro/auxiliary/attr-stmt-expr.rs b/tests/ui/proc-macro/auxiliary/attr-stmt-expr.rs index 4d6dc06b4a4..7a29894bbcf 100644 --- a/tests/ui/proc-macro/auxiliary/attr-stmt-expr.rs +++ b/tests/ui/proc-macro/auxiliary/attr-stmt-expr.rs @@ -31,7 +31,7 @@ pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream { #[proc_macro_attribute] pub fn expect_my_macro_expr(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "my_macro! (\"{}\", string)"); + assert_eq!(item.to_string(), "my_macro!(\"{}\", string)"); item } diff --git a/tests/ui/proc-macro/auxiliary/derive-a.rs b/tests/ui/proc-macro/auxiliary/derive-a.rs index 79a3864bf99..cd2be5fd84d 100644 --- a/tests/ui/proc-macro/auxiliary/derive-a.rs +++ b/tests/ui/proc-macro/auxiliary/derive-a.rs @@ -10,6 +10,6 @@ use proc_macro::TokenStream; #[proc_macro_derive(A)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); - assert!(input.contains("struct A ;")); + assert!(input.contains("struct A;")); "".parse().unwrap() } diff --git a/tests/ui/proc-macro/auxiliary/derive-atob.rs b/tests/ui/proc-macro/auxiliary/derive-atob.rs index 207b7fd3203..e78e5bb8f4c 100644 --- a/tests/ui/proc-macro/auxiliary/derive-atob.rs +++ b/tests/ui/proc-macro/auxiliary/derive-atob.rs @@ -10,6 +10,6 @@ use proc_macro::TokenStream; #[proc_macro_derive(AToB)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); - assert_eq!(input, "struct A ;"); + assert_eq!(input, "struct A;"); "struct B;".parse().unwrap() } diff --git a/tests/ui/proc-macro/auxiliary/derive-b-rpass.rs b/tests/ui/proc-macro/auxiliary/derive-b-rpass.rs index 641a95f78c1..3e6af67a9f4 100644 --- a/tests/ui/proc-macro/auxiliary/derive-b-rpass.rs +++ b/tests/ui/proc-macro/auxiliary/derive-b-rpass.rs @@ -10,7 +10,7 @@ use proc_macro::TokenStream; #[proc_macro_derive(B, attributes(B, C))] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); - assert!(input.contains("#[B [arbitrary tokens]]")); + assert!(input.contains("#[B[arbitrary tokens]]")); assert!(input.contains("struct B {")); assert!(input.contains("#[C]")); "".parse().unwrap() diff --git a/tests/ui/proc-macro/auxiliary/derive-ctod.rs b/tests/ui/proc-macro/auxiliary/derive-ctod.rs index 2efe5a91340..dbf44ed1b05 100644 --- a/tests/ui/proc-macro/auxiliary/derive-ctod.rs +++ b/tests/ui/proc-macro/auxiliary/derive-ctod.rs @@ -10,6 +10,6 @@ use proc_macro::TokenStream; #[proc_macro_derive(CToD)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); - assert_eq!(input, "struct C ;"); + assert_eq!(input, "struct C;"); "struct D;".parse().unwrap() } diff --git a/tests/ui/proc-macro/auxiliary/derive-same-struct.rs b/tests/ui/proc-macro/auxiliary/derive-same-struct.rs index 7598d632cb6..ce7a50d2381 100644 --- a/tests/ui/proc-macro/auxiliary/derive-same-struct.rs +++ b/tests/ui/proc-macro/auxiliary/derive-same-struct.rs @@ -10,12 +10,12 @@ use proc_macro::TokenStream; #[proc_macro_derive(AToB)] pub fn derive1(input: TokenStream) -> TokenStream { println!("input1: {:?}", input.to_string()); - assert_eq!(input.to_string(), "struct A ;"); + assert_eq!(input.to_string(), "struct A;"); "#[derive(BToC)] struct B;".parse().unwrap() } #[proc_macro_derive(BToC)] pub fn derive2(input: TokenStream) -> TokenStream { - assert_eq!(input.to_string(), "struct B ;"); + assert_eq!(input.to_string(), "struct B;"); "struct C;".parse().unwrap() } diff --git a/tests/ui/proc-macro/auxiliary/derive-union.rs b/tests/ui/proc-macro/auxiliary/derive-union.rs index 05883170c6c..d950e1e773c 100644 --- a/tests/ui/proc-macro/auxiliary/derive-union.rs +++ b/tests/ui/proc-macro/auxiliary/derive-union.rs @@ -12,7 +12,7 @@ pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); assert!(input.contains("#[repr(C)]")); assert!(input.contains("union Test {")); - assert!(input.contains("a : u8,")); + assert!(input.contains("a: u8,")); assert!(input.contains("}")); "".parse().unwrap() } diff --git a/tests/ui/proc-macro/auxiliary/expand-with-a-macro.rs b/tests/ui/proc-macro/auxiliary/expand-with-a-macro.rs index d779d57af14..5155a4b8558 100644 --- a/tests/ui/proc-macro/auxiliary/expand-with-a-macro.rs +++ b/tests/ui/proc-macro/auxiliary/expand-with-a-macro.rs @@ -11,7 +11,7 @@ use proc_macro::TokenStream; #[proc_macro_derive(A)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); - assert!(input.contains("struct A ;")); + assert!(input.contains("struct A;")); r#" impl A { fn a(&self) { diff --git a/tests/ui/proc-macro/auxiliary/issue-79825.rs b/tests/ui/proc-macro/auxiliary/issue-79825.rs index 930891b1d43..69cf5904f90 100644 --- a/tests/ui/proc-macro/auxiliary/issue-79825.rs +++ b/tests/ui/proc-macro/auxiliary/issue-79825.rs @@ -8,7 +8,7 @@ use proc_macro::TokenStream; #[proc_macro_attribute] pub fn assert_input(args: TokenStream, input: TokenStream) -> TokenStream { - assert_eq!(input.to_string(), "trait Alias = Sized ;"); + assert_eq!(input.to_string(), "trait Alias = Sized;"); assert!(args.is_empty()); TokenStream::new() } diff --git a/tests/ui/proc-macro/capture-macro-rules-invoke.stdout b/tests/ui/proc-macro/capture-macro-rules-invoke.stdout index 01d71ff989b..71e34119ba7 100644 --- a/tests/ui/proc-macro/capture-macro-rules-invoke.stdout +++ b/tests/ui/proc-macro/capture-macro-rules-invoke.stdout @@ -14,6 +14,8 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ PRINT-BANG INPUT (DISPLAY): 1 + 1, { "a" }, let a = 1;, String, my_name, 'a, my_val = 30, std::option::Option, pub(in some::path) , [a b c], -30 PRINT-BANG RE-COLLECTED (DISPLAY): 1 + 1, { "a" }, let a = 1, String, my_name, 'a, my_val = 30, +std::option::Option, pub(in some::path), [a b c], -30 +PRINT-BANG DEEP-RE-COLLECTED (DISPLAY): 1 + 1, { "a" }, let a = 1, String, my_name, 'a, my_val = 30, std :: option :: Option, pub(in some :: path), [a b c], - 30 PRINT-BANG INPUT (DEBUG): TokenStream [ Group { diff --git a/tests/ui/proc-macro/capture-unglued-token.stdout b/tests/ui/proc-macro/capture-unglued-token.stdout index a0d2178f000..84b7ca35524 100644 --- a/tests/ui/proc-macro/capture-unglued-token.stdout +++ b/tests/ui/proc-macro/capture-unglued-token.stdout @@ -1,5 +1,5 @@ PRINT-BANG INPUT (DISPLAY): Vec<u8> -PRINT-BANG RE-COLLECTED (DISPLAY): Vec < u8 > +PRINT-BANG DEEP-RE-COLLECTED (DISPLAY): Vec < u8 > PRINT-BANG INPUT (DEBUG): TokenStream [ Group { delimiter: None, diff --git a/tests/ui/proc-macro/cfg-eval-inner.stdout b/tests/ui/proc-macro/cfg-eval-inner.stdout index 9d25def587c..43ae47c201f 100644 --- a/tests/ui/proc-macro/cfg-eval-inner.stdout +++ b/tests/ui/proc-macro/cfg-eval-inner.stdout @@ -1,4 +1,16 @@ -PRINT-ATTR INPUT (DISPLAY): impl Foo < +PRINT-ATTR INPUT (DISPLAY): impl +Foo<[u8; +{ + #![rustc_dummy(cursed_inner)] #![allow(unused)] struct Inner + { field: [u8; { #![rustc_dummy(another_cursed_inner)] 1 }] } 0 +}]> { #![rustc_dummy(evaluated_attr)] fn bar() {} } +PRINT-ATTR RE-COLLECTED (DISPLAY): impl Foo < +[u8; +{ + #![rustc_dummy(cursed_inner)] #![allow(unused)] struct Inner + { field: [u8; { #![rustc_dummy(another_cursed_inner)] 1 }] } 0 +}] > { #![rustc_dummy(evaluated_attr)] fn bar() {} } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): impl Foo < [u8 ; { #! [rustc_dummy(cursed_inner)] #! [allow(unused)] struct Inner @@ -35,7 +47,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ stream: TokenStream [ Punct { ch: '#', - spacing: Alone, + spacing: Joint, span: $DIR/cfg-eval-inner.rs:19:5: 19:6 (#0), }, Punct { @@ -130,7 +142,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ stream: TokenStream [ Punct { ch: '#', - spacing: Alone, + spacing: Joint, span: $DIR/cfg-eval-inner.rs:23:13: 23:14 (#0), }, Punct { @@ -195,7 +207,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ stream: TokenStream [ Punct { ch: '#', - spacing: Alone, + spacing: Joint, span: $DIR/cfg-eval-inner.rs:32:5: 32:6 (#0), }, Punct { diff --git a/tests/ui/proc-macro/cfg-eval.stdout b/tests/ui/proc-macro/cfg-eval.stdout index 6732caf08dd..e26e16f5a8c 100644 --- a/tests/ui/proc-macro/cfg-eval.stdout +++ b/tests/ui/proc-macro/cfg-eval.stdout @@ -1,4 +1,5 @@ -PRINT-ATTR INPUT (DISPLAY): struct S1 { #[cfg(all())] #[allow()] field_true : u8, } +PRINT-ATTR INPUT (DISPLAY): struct S1 { #[cfg(all())] #[allow()] field_true: u8, } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): struct S1 { #[cfg(all())] #[allow()] field_true : u8, } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", diff --git a/tests/ui/proc-macro/custom-attr-only-one-derive.rs b/tests/ui/proc-macro/custom-attr-only-one-derive.rs index 2cd5b487301..901394384d5 100644 --- a/tests/ui/proc-macro/custom-attr-only-one-derive.rs +++ b/tests/ui/proc-macro/custom-attr-only-one-derive.rs @@ -1,8 +1,6 @@ // run-pass // aux-build:custom-attr-only-one-derive.rs -#![feature(rust_2018_preview)] - #[macro_use] extern crate custom_attr_only_one_derive; diff --git a/tests/ui/proc-macro/derive-same-struct.stdout b/tests/ui/proc-macro/derive-same-struct.stdout index 7478d974140..77605de5e33 100644 --- a/tests/ui/proc-macro/derive-same-struct.stdout +++ b/tests/ui/proc-macro/derive-same-struct.stdout @@ -1 +1 @@ -input1: "struct A ;" +input1: "struct A;" diff --git a/tests/ui/proc-macro/doc-comment-preserved.stdout b/tests/ui/proc-macro/doc-comment-preserved.stdout index f4160d7da80..b0ea180d9bd 100644 --- a/tests/ui/proc-macro/doc-comment-preserved.stdout +++ b/tests/ui/proc-macro/doc-comment-preserved.stdout @@ -5,7 +5,7 @@ PRINT-BANG INPUT (DISPLAY): /** * DOC * ******* */ - pub struct S ; + pub struct S; PRINT-BANG RE-COLLECTED (DISPLAY): #[doc = "\n*******\n* DOC *\n* DOC *\n* DOC *\n*******\n"] pub struct S ; PRINT-BANG INPUT (DEBUG): TokenStream [ Punct { diff --git a/tests/ui/proc-macro/dollar-crate-issue-57089.stdout b/tests/ui/proc-macro/dollar-crate-issue-57089.stdout index de4f0c000b6..7f97ac9dbc2 100644 --- a/tests/ui/proc-macro/dollar-crate-issue-57089.stdout +++ b/tests/ui/proc-macro/dollar-crate-issue-57089.stdout @@ -1,4 +1,5 @@ -PRINT-BANG INPUT (DISPLAY): struct M($crate :: S) ; +PRINT-BANG INPUT (DISPLAY): struct M($crate :: S); +PRINT-BANG RE-COLLECTED (DISPLAY): struct M($crate :: S) ; PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "struct", @@ -38,7 +39,8 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/dollar-crate-issue-57089.rs:17:32: 17:33 (#3), }, ] -PRINT-ATTR INPUT (DISPLAY): struct A($crate :: S) ; +PRINT-ATTR INPUT (DISPLAY): struct A($crate :: S); +PRINT-ATTR RE-COLLECTED (DISPLAY): struct A($crate :: S) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", diff --git a/tests/ui/proc-macro/dollar-crate-issue-62325.stdout b/tests/ui/proc-macro/dollar-crate-issue-62325.stdout index c7e72bf4ff5..96161049e30 100644 --- a/tests/ui/proc-macro/dollar-crate-issue-62325.stdout +++ b/tests/ui/proc-macro/dollar-crate-issue-62325.stdout @@ -1,4 +1,5 @@ -PRINT-ATTR INPUT (DISPLAY): struct A(identity! ($crate :: S)) ; +PRINT-ATTR INPUT (DISPLAY): struct A(identity! ($crate :: S)); +PRINT-ATTR RE-COLLECTED (DISPLAY): struct A(identity! ($crate :: S)) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", @@ -53,7 +54,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/dollar-crate-issue-62325.rs:19:35: 19:36 (#3), }, ] -PRINT-ATTR INPUT (DISPLAY): struct B(identity! ($crate :: S)) ; +PRINT-ATTR INPUT (DISPLAY): struct B(identity! ($crate :: S)); +PRINT-ATTR RE-COLLECTED (DISPLAY): struct B(identity! ($crate :: S)) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", diff --git a/tests/ui/proc-macro/dollar-crate.stdout b/tests/ui/proc-macro/dollar-crate.stdout index 0f5f87ceca2..a6bdab00441 100644 --- a/tests/ui/proc-macro/dollar-crate.stdout +++ b/tests/ui/proc-macro/dollar-crate.stdout @@ -1,4 +1,5 @@ -PRINT-BANG INPUT (DISPLAY): struct M($crate :: S) ; +PRINT-BANG INPUT (DISPLAY): struct M($crate :: S); +PRINT-BANG RE-COLLECTED (DISPLAY): struct M($crate :: S) ; PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "struct", @@ -38,7 +39,8 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/dollar-crate.rs:20:36: 20:37 (#3), }, ] -PRINT-ATTR INPUT (DISPLAY): struct A($crate :: S) ; +PRINT-ATTR INPUT (DISPLAY): struct A($crate :: S); +PRINT-ATTR RE-COLLECTED (DISPLAY): struct A($crate :: S) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", @@ -78,7 +80,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/dollar-crate.rs:24:32: 24:33 (#3), }, ] -PRINT-DERIVE INPUT (DISPLAY): struct D($crate :: S) ; +PRINT-DERIVE INPUT (DISPLAY): struct D($crate :: S); +PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D($crate :: S) ; PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "struct", @@ -118,7 +121,8 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: $DIR/dollar-crate.rs:27:32: 27:33 (#3), }, ] -PRINT-BANG INPUT (DISPLAY): struct M($crate :: S) ; +PRINT-BANG INPUT (DISPLAY): struct M($crate :: S); +PRINT-BANG RE-COLLECTED (DISPLAY): struct M($crate :: S) ; PRINT-BANG INPUT (DEBUG): TokenStream [ Ident { ident: "struct", @@ -158,7 +162,8 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/auxiliary/dollar-crate-external.rs:7:32: 7:33 (#14), }, ] -PRINT-ATTR INPUT (DISPLAY): struct A($crate :: S) ; +PRINT-ATTR INPUT (DISPLAY): struct A($crate :: S); +PRINT-ATTR RE-COLLECTED (DISPLAY): struct A($crate :: S) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", @@ -198,7 +203,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/auxiliary/dollar-crate-external.rs:11:28: 11:29 (#14), }, ] -PRINT-DERIVE INPUT (DISPLAY): struct D($crate :: S) ; +PRINT-DERIVE INPUT (DISPLAY): struct D($crate :: S); +PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D($crate :: S) ; PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "struct", diff --git a/tests/ui/proc-macro/expand-to-derive.stdout b/tests/ui/proc-macro/expand-to-derive.stdout index 39f00918329..9f03a469aeb 100644 --- a/tests/ui/proc-macro/expand-to-derive.stdout +++ b/tests/ui/proc-macro/expand-to-derive.stdout @@ -1,6 +1,11 @@ PRINT-DERIVE INPUT (DISPLAY): struct Foo { field : + [bool ; { #[rustc_dummy] struct Inner { other_inner_field: u8, } 0 }] +} +PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): struct Foo +{ + field : [bool ; { #[rustc_dummy] struct Inner { other_inner_field : u8, } 0 }] } PRINT-DERIVE INPUT (DEBUG): TokenStream [ diff --git a/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout b/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout index 40181efc0b8..eda2f433bce 100644 --- a/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout +++ b/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout @@ -122,7 +122,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #3 bytes(306..355), }, ] -PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { 0; } ; 0 }, } +PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { 0; }; 0 }, } PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): enum E { V = { let _ = { 0 } ; 0 }, } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { @@ -202,7 +202,8 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #7 bytes(430..483), }, ] -PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { {} } ; 0 }, } +PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { {} }; 0 }, } +PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): enum E { V = { let _ = { {} } ; 0 }, } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "enum", @@ -280,7 +281,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #11 bytes(430..483), }, ] -PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { PATH; } ; 0 }, } +PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { PATH; }; 0 }, } PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): enum E { V = { let _ = { PATH } ; 0 }, } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { @@ -358,7 +359,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #15 bytes(430..483), }, ] -PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { 0 + 1; } ; 0 }, } +PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { 0 + 1; }; 0 }, } PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): enum E { V = { let _ = { 0 + 1 } ; 0 }, } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { @@ -449,7 +450,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #19 bytes(430..483), }, ] -PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { PATH + 1; } ; 0 }, } +PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { PATH + 1; }; 0 }, } PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): enum E { V = { let _ = { PATH + 1 } ; 0 }, } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { diff --git a/tests/ui/proc-macro/inert-attribute-order.stdout b/tests/ui/proc-macro/inert-attribute-order.stdout index cc215545952..86b27217974 100644 --- a/tests/ui/proc-macro/inert-attribute-order.stdout +++ b/tests/ui/proc-macro/inert-attribute-order.stdout @@ -1,7 +1,11 @@ PRINT-ATTR INPUT (DISPLAY): /// 1 -#[rustfmt :: attr2] #[doc = "3"] #[doc = "4"] #[rustfmt :: attr5] /// 6 -#[print_attr(nodebug)] struct S ; -PRINT-ATTR RE-COLLECTED (DISPLAY): #[doc = " 1"] #[rustfmt :: attr2] #[doc = "3"] #[doc = "4"] +#[rustfmt::attr2] #[doc = "3"] #[doc = "4"] #[rustfmt::attr5] /// 6 +#[print_attr(nodebug)] struct S; +PRINT-ATTR RE-COLLECTED (DISPLAY): #[doc = " 1"] #[rustfmt::attr2] #[doc = "3"] #[doc = "4"] #[rustfmt::attr5] +#[doc = " 6"] #[print_attr(nodebug)] struct S ; +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): #[doc = " 1"] #[rustfmt :: attr2] #[doc = "3"] #[doc = "4"] #[rustfmt :: attr5] #[doc = " 6"] #[print_attr(nodebug)] struct S ; -PRINT-ATTR INPUT (DISPLAY): #[doc = " 1"] #[rustfmt :: attr2] #[doc = "3"] #[doc = "4"] +PRINT-ATTR INPUT (DISPLAY): #[doc = " 1"] #[rustfmt::attr2] #[doc = "3"] #[doc = "4"] #[rustfmt::attr5] +#[doc = " 6"] struct S ; +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): #[doc = " 1"] #[rustfmt :: attr2] #[doc = "3"] #[doc = "4"] #[rustfmt :: attr5] #[doc = " 6"] struct S ; diff --git a/tests/ui/proc-macro/inner-attr-non-inline-mod.stdout b/tests/ui/proc-macro/inner-attr-non-inline-mod.stdout index 6261d82e2d0..aaec40669e6 100644 --- a/tests/ui/proc-macro/inner-attr-non-inline-mod.stdout +++ b/tests/ui/proc-macro/inner-attr-non-inline-mod.stdout @@ -1,4 +1,5 @@ -PRINT-ATTR INPUT (DISPLAY): #[deny(unused_attributes)] mod module_with_attrs { #! [rustfmt :: skip] } +PRINT-ATTR INPUT (DISPLAY): #[deny(unused_attributes)] mod module_with_attrs { #![rustfmt::skip] } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): #[deny(unused_attributes)] mod module_with_attrs { #! [rustfmt :: skip] } PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', diff --git a/tests/ui/proc-macro/inner-attrs.stdout b/tests/ui/proc-macro/inner-attrs.stdout index ee8adf0b4a9..037ec044e42 100644 --- a/tests/ui/proc-macro/inner-attrs.stdout +++ b/tests/ui/proc-macro/inner-attrs.stdout @@ -6,6 +6,8 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ }, ] PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(second)] fn foo() +{ #![print_target_and_args(third)] #![print_target_and_args(fourth)] } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): #[print_target_and_args(second)] fn foo() { #! [print_target_and_args(third)] #! [print_target_and_args(fourth)] } PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { @@ -121,6 +123,8 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ }, ] PRINT-ATTR INPUT (DISPLAY): fn foo() +{ #![print_target_and_args(third)] #![print_target_and_args(fourth)] } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): fn foo() { #! [print_target_and_args(third)] #! [print_target_and_args(fourth)] } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { @@ -210,7 +214,8 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/inner-attrs.rs:20:30: 20:35 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): fn foo() { #! [print_target_and_args(fourth)] } +PRINT-ATTR INPUT (DISPLAY): fn foo() { #![print_target_and_args(fourth)] } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): fn foo() { #! [print_target_and_args(fourth)] } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "fn", @@ -298,6 +303,8 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ }, ] PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(mod_second)] mod inline_mod +{ #![print_target_and_args(mod_third)] #![print_target_and_args(mod_fourth)] } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): #[print_target_and_args(mod_second)] mod inline_mod { #! [print_target_and_args(mod_third)] #! [print_target_and_args(mod_fourth)] @@ -411,6 +418,8 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ }, ] PRINT-ATTR INPUT (DISPLAY): mod inline_mod +{ #![print_target_and_args(mod_third)] #![print_target_and_args(mod_fourth)] } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): mod inline_mod { #! [print_target_and_args(mod_third)] #! [print_target_and_args(mod_fourth)] @@ -498,7 +507,8 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/inner-attrs.rs:27:30: 27:39 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): mod inline_mod { #! [print_target_and_args(mod_fourth)] } +PRINT-ATTR INPUT (DISPLAY): mod inline_mod { #![print_target_and_args(mod_fourth)] } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): mod inline_mod { #! [print_target_and_args(mod_fourth)] } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "mod", @@ -569,6 +579,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ }, ] PRINT-DERIVE INPUT (DISPLAY): struct MyDerivePrint +{ field: [u8; { match true { _ => { #![rustc_dummy(third)] true } }; 0 }] } +PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): struct MyDerivePrint { field : [u8 ; { match true { _ => { #! [rustc_dummy(third)] true } } ; 0 }] @@ -639,7 +651,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ stream: TokenStream [ Punct { ch: '#', - spacing: Alone, + spacing: Joint, span: $DIR/inner-attrs.rs:40:17: 40:18 (#0), }, Punct { @@ -705,7 +717,9 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/inner-attrs.rs:49:29: 49:40 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): (3, 4, { #! [cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }) ; +PRINT-ATTR INPUT (DISPLAY): (3, 4, { #![cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }); +PRINT-ATTR RE-COLLECTED (DISPLAY): (3, 4, { #![cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }) ; +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): (3, 4, { #! [cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Group { delimiter: Parenthesis, @@ -819,7 +833,9 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/inner-attrs.rs:56:29: 56:40 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): (3, 4, { #! [cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }) ; +PRINT-ATTR INPUT (DISPLAY): (3, 4, { #![cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }); +PRINT-ATTR RE-COLLECTED (DISPLAY): (3, 4, { #![cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }) ; +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): (3, 4, { #! [cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Group { delimiter: Parenthesis, diff --git a/tests/ui/proc-macro/issue-75734-pp-paren.stdout b/tests/ui/proc-macro/issue-75734-pp-paren.stdout index 2f7c013e958..ee135366fb6 100644 --- a/tests/ui/proc-macro/issue-75734-pp-paren.stdout +++ b/tests/ui/proc-macro/issue-75734-pp-paren.stdout @@ -1,4 +1,5 @@ -PRINT-ATTR INPUT (DISPLAY): fn main() { & | _ : u8 | {} ; mul_2! (1 + 1) ; } +PRINT-ATTR INPUT (DISPLAY): fn main() { &|_: u8| {}; mul_2!(1 + 1); } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): fn main() { &| _ : u8 | {} ; mul_2! (1 + 1) ; } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "fn", diff --git a/tests/ui/proc-macro/issue-75930-derive-cfg.stdout b/tests/ui/proc-macro/issue-75930-derive-cfg.stdout index 31a1c44b6df..47f26451d1c 100644 --- a/tests/ui/proc-macro/issue-75930-derive-cfg.stdout +++ b/tests/ui/proc-macro/issue-75930-derive-cfg.stdout @@ -1,5 +1,53 @@ PRINT-ATTR INPUT (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[derive(Print)] #[print_helper(b)] -struct Foo < #[cfg(FALSE)] A, B > +struct Foo<#[cfg(FALSE)] A, B> +{ + #[cfg(FALSE)] first: String, #[cfg_attr(FALSE, deny(warnings))] second: + bool, third: + [u8; + { + #[cfg(FALSE)] struct Bar; #[cfg(not(FALSE))] struct Inner; + #[cfg(FALSE)] let a = 25; match true + { + #[cfg(FALSE)] true => {}, #[cfg_attr(not(FALSE), allow(warnings))] + false => {}, _ => {} + }; #[print_helper(should_be_removed)] fn removed_fn() + { #![cfg(FALSE)] } #[print_helper(c)] #[cfg(not(FALSE))] fn kept_fn() + { #![cfg(not(FALSE))] let my_val = true; } enum TupleEnum + { + Foo(#[cfg(FALSE)] u8, #[cfg(FALSE)] bool, #[cfg(not(FALSE))] i32, + #[cfg(FALSE)] String, u8) + } struct + TupleStruct(#[cfg(FALSE)] String, #[cfg(not(FALSE))] i32, + #[cfg(FALSE)] bool, u8); fn plain_removed_fn() + { #![cfg_attr(not(FALSE), cfg(FALSE))] } 0 + }], #[print_helper(d)] fourth: B +} +PRINT-ATTR RE-COLLECTED (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[derive(Print)] #[print_helper(b)] +struct Foo <#[cfg(FALSE)] A, B > +{ + #[cfg(FALSE)] first: String, #[cfg_attr(FALSE, deny(warnings))] second: + bool, third: + [u8; + { + #[cfg(FALSE)] struct Bar; #[cfg(not(FALSE))] struct Inner; + #[cfg(FALSE)] let a = 25; match true + { + #[cfg(FALSE)] true => {}, #[cfg_attr(not(FALSE), allow(warnings))] + false => {}, _ => {} + }; #[print_helper(should_be_removed)] fn removed_fn() + { #![cfg(FALSE)] } #[print_helper(c)] #[cfg(not(FALSE))] fn kept_fn() + { #![cfg(not(FALSE))] let my_val = true; } enum TupleEnum + { + Foo(#[cfg(FALSE)] u8, #[cfg(FALSE)] bool, #[cfg(not(FALSE))] i32, + #[cfg(FALSE)] String, u8) + } struct + TupleStruct(#[cfg(FALSE)] String, #[cfg(not(FALSE))] i32, + #[cfg(FALSE)] bool, u8); fn plain_removed_fn() + { #![cfg_attr(not(FALSE), cfg(FALSE))] } 0 + }], #[print_helper(d)] fourth: B +} +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[derive(Print)] #[print_helper(b)] +struct Foo <#[cfg(FALSE)] A, B > { #[cfg(FALSE)] first : String, #[cfg_attr(FALSE, deny(warnings))] second : bool, third : @@ -1272,7 +1320,20 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/issue-75930-derive-cfg.rs:55:32: 102:2 (#0), }, ] -PRINT-DERIVE INPUT (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[print_helper(b)] struct Foo < B > +PRINT-DERIVE INPUT (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[print_helper(b)] struct Foo <B > +{ + second: bool, third: + [u8; + { + #[cfg(not(FALSE))] struct Inner; match true + { #[allow(warnings)] false => {}, _ => {} }; #[print_helper(c)] + #[cfg(not(FALSE))] fn kept_fn() + { #![cfg(not(FALSE))] let my_val = true; } enum TupleEnum + { Foo(#[cfg(not(FALSE))] i32, u8) } struct + TupleStruct(#[cfg(not(FALSE))] i32, u8); 0 + }], #[print_helper(d)] fourth: B +} +PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[print_helper(b)] struct Foo <B > { second : bool, third : [u8 ; diff --git a/tests/ui/proc-macro/issue-78675-captured-inner-attrs.stdout b/tests/ui/proc-macro/issue-78675-captured-inner-attrs.stdout index ae5e9400809..37ecf3a8df3 100644 --- a/tests/ui/proc-macro/issue-78675-captured-inner-attrs.stdout +++ b/tests/ui/proc-macro/issue-78675-captured-inner-attrs.stdout @@ -46,7 +46,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ stream: TokenStream [ Punct { ch: '#', - spacing: Alone, + spacing: Joint, span: $DIR/issue-78675-captured-inner-attrs.rs:28:9: 28:16 (#0), }, Punct { diff --git a/tests/ui/proc-macro/keep-expr-tokens.stdout b/tests/ui/proc-macro/keep-expr-tokens.stdout index fcd72a0e017..8e4d4785e2e 100644 --- a/tests/ui/proc-macro/keep-expr-tokens.stdout +++ b/tests/ui/proc-macro/keep-expr-tokens.stdout @@ -1,4 +1,5 @@ -PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] { 1 + 1 ; } +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] { 1 +1; } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): #[rustc_dummy] { 1 + 1 ; } PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', diff --git a/tests/ui/proc-macro/macro-rules-derive-cfg.stdout b/tests/ui/proc-macro/macro-rules-derive-cfg.stdout index aee0f966d0f..89817a1efdc 100644 --- a/tests/ui/proc-macro/macro-rules-derive-cfg.stdout +++ b/tests/ui/proc-macro/macro-rules-derive-cfg.stdout @@ -4,6 +4,15 @@ PRINT-DERIVE INPUT (DISPLAY): struct Foo [bool ; { let a = #[rustc_dummy(first)] #[rustc_dummy(second)] + { #![allow(unused)] 30 }; 0 + }] +} +PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): struct Foo +{ + val : + [bool ; + { + let a = #[rustc_dummy(first)] #[rustc_dummy(second)] { #! [allow(unused)] 30 } ; 0 }] } @@ -111,7 +120,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ stream: TokenStream [ Punct { ch: '#', - spacing: Alone, + spacing: Joint, span: $DIR/macro-rules-derive-cfg.rs:27:5: 27:6 (#0), }, Punct { diff --git a/tests/ui/proc-macro/meta-macro-hygiene.stdout b/tests/ui/proc-macro/meta-macro-hygiene.stdout index eeb7179e6fd..6d10cc604c2 100644 --- a/tests/ui/proc-macro/meta-macro-hygiene.stdout +++ b/tests/ui/proc-macro/meta-macro-hygiene.stdout @@ -32,13 +32,13 @@ macro_rules! produce_it */ { () => { - meta_macro :: print_def_site! ($crate :: dummy! ()) ; + meta_macro::print_def_site!($crate::dummy!()); // `print_def_site!` will respan the `$crate` identifier // with `Span::def_site()`. This should cause it to resolve // relative to `meta_macro`, *not* `make_macro` (despite // the fact that `print_def_site` is produced by a // `macro_rules!` macro in `make_macro`). - } ; + }; } fn main /* 0#0 */() { ; } diff --git a/tests/ui/proc-macro/nested-derive-cfg.stdout b/tests/ui/proc-macro/nested-derive-cfg.stdout index 9a562c971c8..c94808c3c0f 100644 --- a/tests/ui/proc-macro/nested-derive-cfg.stdout +++ b/tests/ui/proc-macro/nested-derive-cfg.stdout @@ -1,4 +1,6 @@ PRINT-DERIVE INPUT (DISPLAY): struct Foo +{ my_array: [bool; { struct Inner { non_removed_inner_field: usize } 0 }] } +PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): struct Foo { my_array : [bool ; { struct Inner { non_removed_inner_field : usize } 0 }] } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { diff --git a/tests/ui/proc-macro/nonterminal-expansion.stdout b/tests/ui/proc-macro/nonterminal-expansion.stdout index b2557af18ca..c671f623925 100644 --- a/tests/ui/proc-macro/nonterminal-expansion.stdout +++ b/tests/ui/proc-macro/nonterminal-expansion.stdout @@ -1,5 +1,5 @@ PRINT-ATTR_ARGS INPUT (DISPLAY): a, line!(), b -PRINT-ATTR_ARGS RE-COLLECTED (DISPLAY): a, line! (), b +PRINT-ATTR_ARGS DEEP-RE-COLLECTED (DISPLAY): a, line! (), b PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ Ident { ident: "a", diff --git a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout index c437853ac72..5c70e780f74 100644 --- a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout +++ b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout @@ -1,5 +1,5 @@ PRINT-BANG INPUT (DISPLAY): struct S; -PRINT-BANG RE-COLLECTED (DISPLAY): struct S ; +PRINT-BANG DEEP-RE-COLLECTED (DISPLAY): struct S ; PRINT-BANG INPUT (DEBUG): TokenStream [ Group { delimiter: None, @@ -51,11 +51,11 @@ macro_rules! outer /* 0#0 */ { - ($item : item) => + ($item:item) => { - macro inner() { print_bang! { $item } } inner! () ; + macro inner() { print_bang! { $item } } inner!(); - } ; + }; } struct S /* 0#0 */; diff --git a/tests/ui/proc-macro/pretty-print-tts.stdout b/tests/ui/proc-macro/pretty-print-tts.stdout index f52e97a8604..fbe8640a01a 100644 --- a/tests/ui/proc-macro/pretty-print-tts.stdout +++ b/tests/ui/proc-macro/pretty-print-tts.stdout @@ -1,4 +1,5 @@ -PRINT-BANG INPUT (DISPLAY): { #! [rustc_dummy] let a = "hello".len() ; matches! (a, 5) ; } +PRINT-BANG INPUT (DISPLAY): { #![rustc_dummy] let a = "hello".len(); matches!(a, 5); } +PRINT-BANG DEEP-RE-COLLECTED (DISPLAY): { #! [rustc_dummy] let a = "hello".len() ; matches! (a, 5) ; } PRINT-BANG INPUT (DEBUG): TokenStream [ Group { delimiter: Brace, diff --git a/tests/ui/proc-macro/trailing-plus.stdout b/tests/ui/proc-macro/trailing-plus.stdout index b90057cd6d5..b20401190d8 100644 --- a/tests/ui/proc-macro/trailing-plus.stdout +++ b/tests/ui/proc-macro/trailing-plus.stdout @@ -1,4 +1,5 @@ -PRINT-ATTR INPUT (DISPLAY): fn foo < T > () where T : Copy + {} +PRINT-ATTR INPUT (DISPLAY): fn foo<T>() where T: Copy + {} +PRINT-ATTR RE-COLLECTED (DISPLAY): fn foo < T > () where T : Copy + {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "fn", diff --git a/tests/ui/proc-macro/weird-braces.stdout b/tests/ui/proc-macro/weird-braces.stdout index 9bf56221734..7da769ef0d2 100644 --- a/tests/ui/proc-macro/weird-braces.stdout +++ b/tests/ui/proc-macro/weird-braces.stdout @@ -5,7 +5,18 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/weird-braces.rs:16:25: 16:36 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(second_outer)] impl Bar < { 1 > 0 } > for Foo < +PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(second_outer)] impl Bar<{ 1 > 0 }> for Foo<{ true }> +{ + #![print_target_and_args(first_inner)] + #![print_target_and_args(second_inner)] +} +PRINT-ATTR RE-COLLECTED (DISPLAY): #[print_target_and_args(second_outer)] impl Bar < { 1 > 0 } > for Foo < +{ true } > +{ + #![print_target_and_args(first_inner)] + #![print_target_and_args(second_inner)] +} +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): #[print_target_and_args(second_outer)] impl Bar < { 1 > 0 } > for Foo < { true } > { #! [print_target_and_args(first_inner)] #! @@ -180,7 +191,17 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/weird-braces.rs:17:25: 17:37 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > +PRINT-ATTR INPUT (DISPLAY): impl Bar<{ 1 > 0 }> for Foo<{ true }> +{ + #![print_target_and_args(first_inner)] + #![print_target_and_args(second_inner)] +} +PRINT-ATTR RE-COLLECTED (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > +{ + #![print_target_and_args(first_inner)] + #![print_target_and_args(second_inner)] +} +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > { #! [print_target_and_args(first_inner)] #! [print_target_and_args(second_inner)] @@ -329,7 +350,11 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/weird-braces.rs:19:30: 19:41 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > +PRINT-ATTR INPUT (DISPLAY): impl Bar<{ 1 > 0 }> for Foo<{ true }> +{ #![print_target_and_args(second_inner)] } +PRINT-ATTR RE-COLLECTED (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > +{ #![print_target_and_args(second_inner)] } +PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > { #! [print_target_and_args(second_inner)] } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { @@ -445,7 +470,8 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/weird-braces.rs:20:30: 20:42 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > {} +PRINT-ATTR INPUT (DISPLAY): impl Bar<{ 1 > 0 }> for Foo<{ true }> {} +PRINT-ATTR RE-COLLECTED (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "impl", diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr index a20a6062c13..1a26f34a52d 100644 --- a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr @@ -12,7 +12,7 @@ [$DIR/dbg-macro-expected-behavior.rs:42] &a = NoCopy( 1337, ) -[$DIR/dbg-macro-expected-behavior.rs:42] dbg!(& a) = NoCopy( +[$DIR/dbg-macro-expected-behavior.rs:42] dbg!(&a) = NoCopy( 1337, ) [$DIR/dbg-macro-expected-behavior.rs:47] f(&42) = 42 diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/param-attrs.rs b/tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/param-attrs.rs index 82c4120b4c7..67de50a1d92 100644 --- a/tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/param-attrs.rs +++ b/tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/param-attrs.rs @@ -17,27 +17,26 @@ macro_rules! checker { } } -checker!(attr_extern, r#"extern "C" { fn ffi(#[a1] arg1 : i32, #[a2] ...) ; }"#); -checker!(attr_extern_cvar, r#"unsafe extern "C" fn cvar(arg1 : i32, #[a1] mut args : ...) {}"#); -checker!(attr_alias, "type Alias = fn(#[a1] u8, #[a2] ...) ;"); -checker!(attr_free, "fn free(#[a1] arg1 : u8) { let lam = | #[a2] W(x), #[a3] y | () ; }"); -checker!(attr_inherent_1, "fn inherent1(#[a1] self, #[a2] arg1 : u8) {}"); -checker!(attr_inherent_2, "fn inherent2(#[a1] & self, #[a2] arg1 : u8) {}"); -checker!(attr_inherent_3, "fn inherent3 < 'a > (#[a1] & 'a mut self, #[a2] arg1 : u8) {}"); -checker!(attr_inherent_4, "fn inherent4 < 'a > (#[a1] self : Box < Self >, #[a2] arg1 : u8) {}"); -checker!(attr_inherent_issue_64682, "fn inherent5(#[a1] #[a2] arg1 : u8, #[a3] arg2 : u8) {}"); -checker!(attr_trait_1, "fn trait1(#[a1] self, #[a2] arg1 : u8) ;"); -checker!(attr_trait_2, "fn trait2(#[a1] & self, #[a2] arg1 : u8) ;"); -checker!(attr_trait_3, "fn trait3 < 'a > (#[a1] & 'a mut self, #[a2] arg1 : u8) ;"); -checker!(attr_trait_4, r#"fn trait4 < 'a > -(#[a1] self : Box < Self >, #[a2] arg1 : u8, #[a3] Vec < u8 >) ;"#); -checker!(attr_trait_issue_64682, "fn trait5(#[a1] #[a2] arg1 : u8, #[a3] arg2 : u8) ;"); +checker!(attr_extern, r#"extern "C" { fn ffi(#[a1] arg1: i32, #[a2] ...); }"#); +checker!(attr_extern_cvar, r#"unsafe extern "C" fn cvar(arg1: i32, #[a1] mut args: ...) {}"#); +checker!(attr_alias, "type Alias = fn(#[a1] u8, #[a2] ...);"); +checker!(attr_free, "fn free(#[a1] arg1: u8) { let lam = |#[a2] W(x), #[a3] y| (); }"); +checker!(attr_inherent_1, "fn inherent1(#[a1] self, #[a2] arg1: u8) {}"); +checker!(attr_inherent_2, "fn inherent2(#[a1] &self, #[a2] arg1: u8) {}"); +checker!(attr_inherent_3, "fn inherent3<'a>(#[a1] &'a mut self, #[a2] arg1: u8) {}"); +checker!(attr_inherent_4, "fn inherent4<'a>(#[a1] self: Box<Self>, #[a2] arg1: u8) {}"); +checker!(attr_inherent_issue_64682, "fn inherent5(#[a1] #[a2] arg1: u8, #[a3] arg2: u8) {}"); +checker!(attr_trait_1, "fn trait1(#[a1] self, #[a2] arg1: u8);"); +checker!(attr_trait_2, "fn trait2(#[a1] &self, #[a2] arg1: u8);"); +checker!(attr_trait_3, "fn trait3<'a>(#[a1] &'a mut self, #[a2] arg1: u8);"); +checker!(attr_trait_4, r#"fn trait4<'a>(#[a1] self: Box<Self>, #[a2] arg1: u8, #[a3] Vec<u8>);"#); +checker!(attr_trait_issue_64682, "fn trait5(#[a1] #[a2] arg1: u8, #[a3] arg2: u8);"); checker!(rename_params, r#"impl Foo { - fn hello(#[angery(true)] a : i32, #[a2] b : i32, #[what = "how"] c : u32) + fn hello(#[angery(true)] a: i32, #[a2] b: i32, #[what = "how"] c: u32) {} + fn + hello2(#[a1] #[a2] a: i32, #[what = "how"] b: i32, #[angery(true)] c: u32) {} fn - hello2(#[a1] #[a2] a : i32, #[what = "how"] b : i32, #[angery(true)] c : - u32) {} fn - hello_self(#[a1] #[a2] & self, #[a1] #[a2] a : i32, #[what = "how"] b : - i32, #[angery(true)] c : u32) {} + hello_self(#[a1] #[a2] &self, #[a1] #[a2] a: i32, #[what = "how"] b: i32, + #[angery(true)] c: u32) {} }"#); diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed index ede0c2e8eaf..3bfa6d2c254 100644 --- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed +++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed @@ -1,6 +1,5 @@ // run-rustfix -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] mod foo { diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs index 48b091ddb45..14039626545 100644 --- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs +++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs @@ -1,6 +1,5 @@ // run-rustfix -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] mod foo { diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr index c0a322edcd6..036b9ccab4f 100644 --- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr +++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr @@ -1,5 +1,5 @@ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-fully-qualified-paths.rs:19:25 + --> $DIR/edition-lint-fully-qualified-paths.rs:18:25 | LL | let _: <foo::Baz as ::foo::Foo>::Bar = (); | ^^^^^^^^^^ help: use `crate`: `crate::foo::Foo` @@ -7,13 +7,13 @@ LL | let _: <foo::Baz as ::foo::Foo>::Bar = (); = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> note: the lint level is defined here - --> $DIR/edition-lint-fully-qualified-paths.rs:4:9 + --> $DIR/edition-lint-fully-qualified-paths.rs:3:9 | LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-fully-qualified-paths.rs:19:25 + --> $DIR/edition-lint-fully-qualified-paths.rs:18:25 | LL | let _: <foo::Baz as ::foo::Foo>::Bar = (); | ^^^^^^^^^^ help: use `crate`: `crate::foo::Foo` @@ -23,7 +23,7 @@ LL | let _: <foo::Baz as ::foo::Foo>::Bar = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-fully-qualified-paths.rs:25:13 + --> $DIR/edition-lint-fully-qualified-paths.rs:24:13 | LL | let _: <::foo::Baz as foo::Foo>::Bar = (); | ^^^^^^^^^^ help: use `crate`: `crate::foo::Baz` diff --git a/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed b/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed index f25d46ce30d..fd23e9f5562 100644 --- a/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed +++ b/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed @@ -1,6 +1,5 @@ // run-rustfix -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] #![allow(unused_imports)] #![allow(dead_code)] diff --git a/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs b/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs index 9be1680c1ce..f3fb012a584 100644 --- a/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs +++ b/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs @@ -1,6 +1,5 @@ // run-rustfix -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] #![allow(unused_imports)] #![allow(dead_code)] diff --git a/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr b/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr index 041572be844..4174c2fa9ad 100644 --- a/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr +++ b/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr @@ -1,5 +1,5 @@ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-empty-paths.rs:17:5 + --> $DIR/edition-lint-nested-empty-paths.rs:16:5 | LL | use foo::{bar::{baz::{}}}; | ^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}}}` @@ -7,13 +7,13 @@ LL | use foo::{bar::{baz::{}}}; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> note: the lint level is defined here - --> $DIR/edition-lint-nested-empty-paths.rs:4:9 + --> $DIR/edition-lint-nested-empty-paths.rs:3:9 | LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-empty-paths.rs:21:5 + --> $DIR/edition-lint-nested-empty-paths.rs:20:5 | LL | use foo::{bar::{XX, baz::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` @@ -22,7 +22,7 @@ LL | use foo::{bar::{XX, baz::{}}}; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-empty-paths.rs:21:5 + --> $DIR/edition-lint-nested-empty-paths.rs:20:5 | LL | use foo::{bar::{XX, baz::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` @@ -32,7 +32,7 @@ LL | use foo::{bar::{XX, baz::{}}}; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-empty-paths.rs:27:5 + --> $DIR/edition-lint-nested-empty-paths.rs:26:5 | LL | use foo::{bar::{baz::{}, baz1::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` @@ -41,7 +41,7 @@ LL | use foo::{bar::{baz::{}, baz1::{}}}; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-empty-paths.rs:27:5 + --> $DIR/edition-lint-nested-empty-paths.rs:26:5 | LL | use foo::{bar::{baz::{}, baz1::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` diff --git a/tests/ui/rust-2018/edition-lint-nested-paths.fixed b/tests/ui/rust-2018/edition-lint-nested-paths.fixed index a04937ae8ee..0e47e70bb02 100644 --- a/tests/ui/rust-2018/edition-lint-nested-paths.fixed +++ b/tests/ui/rust-2018/edition-lint-nested-paths.fixed @@ -1,6 +1,5 @@ // run-rustfix -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] use crate::foo::{a, b}; diff --git a/tests/ui/rust-2018/edition-lint-nested-paths.rs b/tests/ui/rust-2018/edition-lint-nested-paths.rs index e622a8e24be..d261c10e36d 100644 --- a/tests/ui/rust-2018/edition-lint-nested-paths.rs +++ b/tests/ui/rust-2018/edition-lint-nested-paths.rs @@ -1,6 +1,5 @@ // run-rustfix -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] use foo::{a, b}; diff --git a/tests/ui/rust-2018/edition-lint-nested-paths.stderr b/tests/ui/rust-2018/edition-lint-nested-paths.stderr index 4a70bb7e5c8..d059a2533a9 100644 --- a/tests/ui/rust-2018/edition-lint-nested-paths.stderr +++ b/tests/ui/rust-2018/edition-lint-nested-paths.stderr @@ -1,5 +1,5 @@ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-paths.rs:6:5 + --> $DIR/edition-lint-nested-paths.rs:5:5 | LL | use foo::{a, b}; | ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}` @@ -7,13 +7,13 @@ LL | use foo::{a, b}; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> note: the lint level is defined here - --> $DIR/edition-lint-nested-paths.rs:4:9 + --> $DIR/edition-lint-nested-paths.rs:3:9 | LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-paths.rs:6:5 + --> $DIR/edition-lint-nested-paths.rs:5:5 | LL | use foo::{a, b}; | ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}` @@ -23,7 +23,7 @@ LL | use foo::{a, b}; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-paths.rs:23:13 + --> $DIR/edition-lint-nested-paths.rs:22:13 | LL | use foo::{self as x, c}; | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` @@ -32,7 +32,7 @@ LL | use foo::{self as x, c}; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-paths.rs:23:13 + --> $DIR/edition-lint-nested-paths.rs:22:13 | LL | use foo::{self as x, c}; | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` diff --git a/tests/ui/rust-2018/edition-lint-paths.fixed b/tests/ui/rust-2018/edition-lint-paths.fixed index 47f82c51dae..5057453c926 100644 --- a/tests/ui/rust-2018/edition-lint-paths.fixed +++ b/tests/ui/rust-2018/edition-lint-paths.fixed @@ -1,7 +1,6 @@ // aux-build:edition-lint-paths.rs // run-rustfix -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] #![allow(unused)] diff --git a/tests/ui/rust-2018/edition-lint-paths.rs b/tests/ui/rust-2018/edition-lint-paths.rs index e278983da4a..2c4a070ce83 100644 --- a/tests/ui/rust-2018/edition-lint-paths.rs +++ b/tests/ui/rust-2018/edition-lint-paths.rs @@ -1,7 +1,6 @@ // aux-build:edition-lint-paths.rs // run-rustfix -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] #![allow(unused)] diff --git a/tests/ui/rust-2018/edition-lint-paths.stderr b/tests/ui/rust-2018/edition-lint-paths.stderr index fde17338d98..553a3bfdaa8 100644 --- a/tests/ui/rust-2018/edition-lint-paths.stderr +++ b/tests/ui/rust-2018/edition-lint-paths.stderr @@ -1,5 +1,5 @@ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:12:9 + --> $DIR/edition-lint-paths.rs:11:9 | LL | use bar::Bar; | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` @@ -7,13 +7,13 @@ LL | use bar::Bar; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> note: the lint level is defined here - --> $DIR/edition-lint-paths.rs:5:9 + --> $DIR/edition-lint-paths.rs:4:9 | LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:19:9 + --> $DIR/edition-lint-paths.rs:18:9 | LL | use bar; | ^^^ help: use `crate`: `crate::bar` @@ -22,7 +22,7 @@ LL | use bar; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:25:9 + --> $DIR/edition-lint-paths.rs:24:9 | LL | use {main, Bar as SomethingElse}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` @@ -31,7 +31,7 @@ LL | use {main, Bar as SomethingElse}; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:25:9 + --> $DIR/edition-lint-paths.rs:24:9 | LL | use {main, Bar as SomethingElse}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` @@ -41,7 +41,7 @@ LL | use {main, Bar as SomethingElse}; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:25:9 + --> $DIR/edition-lint-paths.rs:24:9 | LL | use {main, Bar as SomethingElse}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` @@ -51,7 +51,7 @@ LL | use {main, Bar as SomethingElse}; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:40:5 + --> $DIR/edition-lint-paths.rs:39:5 | LL | use bar::Bar; | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` @@ -60,7 +60,7 @@ LL | use bar::Bar; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:52:9 + --> $DIR/edition-lint-paths.rs:51:9 | LL | use *; | ^ help: use `crate`: `crate::*` @@ -69,7 +69,7 @@ LL | use *; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:57:6 + --> $DIR/edition-lint-paths.rs:56:6 | LL | impl ::foo::SomeTrait for u32 {} | ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait` @@ -78,7 +78,7 @@ LL | impl ::foo::SomeTrait for u32 {} = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:62:13 + --> $DIR/edition-lint-paths.rs:61:13 | LL | let x = ::bar::Bar; | ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar` diff --git a/tests/ui/rust-2018/extern-crate-idiomatic.fixed b/tests/ui/rust-2018/extern-crate-idiomatic.fixed index 3111b1dabcb..6a0639099b1 100644 --- a/tests/ui/rust-2018/extern-crate-idiomatic.fixed +++ b/tests/ui/rust-2018/extern-crate-idiomatic.fixed @@ -6,7 +6,6 @@ // The "normal case". Ideally we would remove the `extern crate` here, // but we don't. -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] extern crate edition_lint_paths; diff --git a/tests/ui/rust-2018/extern-crate-idiomatic.rs b/tests/ui/rust-2018/extern-crate-idiomatic.rs index 3111b1dabcb..6a0639099b1 100644 --- a/tests/ui/rust-2018/extern-crate-idiomatic.rs +++ b/tests/ui/rust-2018/extern-crate-idiomatic.rs @@ -6,7 +6,6 @@ // The "normal case". Ideally we would remove the `extern crate` here, // but we don't. -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] extern crate edition_lint_paths; diff --git a/tests/ui/rust-2018/extern-crate-referenced-by-self-path.fixed b/tests/ui/rust-2018/extern-crate-referenced-by-self-path.fixed index 11b9a67ed70..c4a3dd9415c 100644 --- a/tests/ui/rust-2018/extern-crate-referenced-by-self-path.fixed +++ b/tests/ui/rust-2018/extern-crate-referenced-by-self-path.fixed @@ -6,7 +6,6 @@ // rather than being accessed directly. Unless we rewrite that path, // we can't drop the extern crate. -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] extern crate edition_lint_paths; diff --git a/tests/ui/rust-2018/extern-crate-referenced-by-self-path.rs b/tests/ui/rust-2018/extern-crate-referenced-by-self-path.rs index 11b9a67ed70..c4a3dd9415c 100644 --- a/tests/ui/rust-2018/extern-crate-referenced-by-self-path.rs +++ b/tests/ui/rust-2018/extern-crate-referenced-by-self-path.rs @@ -6,7 +6,6 @@ // rather than being accessed directly. Unless we rewrite that path, // we can't drop the extern crate. -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] extern crate edition_lint_paths; diff --git a/tests/ui/rust-2018/extern-crate-rename.fixed b/tests/ui/rust-2018/extern-crate-rename.fixed index ea832ef3e7d..5e2bf64a2e2 100644 --- a/tests/ui/rust-2018/extern-crate-rename.fixed +++ b/tests/ui/rust-2018/extern-crate-rename.fixed @@ -4,7 +4,6 @@ // Oddball: crate is renamed, making it harder for us to rewrite // paths. We don't (and we leave the `extern crate` in place). -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] extern crate edition_lint_paths as my_crate; diff --git a/tests/ui/rust-2018/extern-crate-rename.rs b/tests/ui/rust-2018/extern-crate-rename.rs index b1f617dd884..290fcd6b7db 100644 --- a/tests/ui/rust-2018/extern-crate-rename.rs +++ b/tests/ui/rust-2018/extern-crate-rename.rs @@ -4,7 +4,6 @@ // Oddball: crate is renamed, making it harder for us to rewrite // paths. We don't (and we leave the `extern crate` in place). -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] extern crate edition_lint_paths as my_crate; diff --git a/tests/ui/rust-2018/extern-crate-rename.stderr b/tests/ui/rust-2018/extern-crate-rename.stderr index 36986c89c62..6b251208030 100644 --- a/tests/ui/rust-2018/extern-crate-rename.stderr +++ b/tests/ui/rust-2018/extern-crate-rename.stderr @@ -1,5 +1,5 @@ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/extern-crate-rename.rs:12:5 + --> $DIR/extern-crate-rename.rs:11:5 | LL | use my_crate::foo; | ^^^^^^^^^^^^^ help: use `crate`: `crate::my_crate::foo` @@ -7,7 +7,7 @@ LL | use my_crate::foo; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> note: the lint level is defined here - --> $DIR/extern-crate-rename.rs:8:9 + --> $DIR/extern-crate-rename.rs:7:9 | LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rust-2018/extern-crate-submod.fixed b/tests/ui/rust-2018/extern-crate-submod.fixed index 9b0b0dd8ee1..dd31710414c 100644 --- a/tests/ui/rust-2018/extern-crate-submod.fixed +++ b/tests/ui/rust-2018/extern-crate-submod.fixed @@ -5,7 +5,6 @@ // us to rewrite paths. We don't (and we leave the `extern crate` in // place). -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] mod m { diff --git a/tests/ui/rust-2018/extern-crate-submod.rs b/tests/ui/rust-2018/extern-crate-submod.rs index dfce9128c51..cb0cd7a8331 100644 --- a/tests/ui/rust-2018/extern-crate-submod.rs +++ b/tests/ui/rust-2018/extern-crate-submod.rs @@ -5,7 +5,6 @@ // us to rewrite paths. We don't (and we leave the `extern crate` in // place). -#![feature(rust_2018_preview)] #![deny(absolute_paths_not_starting_with_crate)] mod m { diff --git a/tests/ui/rust-2018/extern-crate-submod.stderr b/tests/ui/rust-2018/extern-crate-submod.stderr index 85e26d72a67..0d45d32d568 100644 --- a/tests/ui/rust-2018/extern-crate-submod.stderr +++ b/tests/ui/rust-2018/extern-crate-submod.stderr @@ -1,5 +1,5 @@ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/extern-crate-submod.rs:19:5 + --> $DIR/extern-crate-submod.rs:18:5 | LL | use m::edition_lint_paths::foo; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::m::edition_lint_paths::foo` @@ -7,7 +7,7 @@ LL | use m::edition_lint_paths::foo; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> note: the lint level is defined here - --> $DIR/extern-crate-submod.rs:9:9 + --> $DIR/extern-crate-submod.rs:8:9 | LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rust-2018/issue-51008-1.rs b/tests/ui/rust-2018/issue-51008-1.rs index 8ae5e827846..da7b8ef65c5 100644 --- a/tests/ui/rust-2018/issue-51008-1.rs +++ b/tests/ui/rust-2018/issue-51008-1.rs @@ -4,8 +4,6 @@ // // run-pass -#![feature(rust_2018_preview)] - trait A { } diff --git a/tests/ui/rust-2018/issue-51008.rs b/tests/ui/rust-2018/issue-51008.rs index b62609e329d..56517b9adee 100644 --- a/tests/ui/rust-2018/issue-51008.rs +++ b/tests/ui/rust-2018/issue-51008.rs @@ -4,8 +4,6 @@ // // run-pass -#![feature(rust_2018_preview)] - trait A { } diff --git a/tests/ui/rust-2018/proc-macro-crate-in-paths.rs b/tests/ui/rust-2018/proc-macro-crate-in-paths.rs index 2d4cb6514ec..37e00a3936e 100644 --- a/tests/ui/rust-2018/proc-macro-crate-in-paths.rs +++ b/tests/ui/rust-2018/proc-macro-crate-in-paths.rs @@ -4,7 +4,6 @@ #![crate_type = "proc-macro"] #![deny(rust_2018_compatibility)] -#![feature(rust_2018_preview)] extern crate proc_macro; diff --git a/tests/ui/rust-2018/suggestions-not-always-applicable.fixed b/tests/ui/rust-2018/suggestions-not-always-applicable.fixed index f5afbad9f78..d9e39a3b748 100644 --- a/tests/ui/rust-2018/suggestions-not-always-applicable.fixed +++ b/tests/ui/rust-2018/suggestions-not-always-applicable.fixed @@ -4,7 +4,6 @@ // rustfix-only-machine-applicable // check-pass -#![feature(rust_2018_preview)] #![warn(rust_2018_compatibility)] extern crate suggestions_not_always_applicable as foo; diff --git a/tests/ui/rust-2018/suggestions-not-always-applicable.rs b/tests/ui/rust-2018/suggestions-not-always-applicable.rs index f5afbad9f78..d9e39a3b748 100644 --- a/tests/ui/rust-2018/suggestions-not-always-applicable.rs +++ b/tests/ui/rust-2018/suggestions-not-always-applicable.rs @@ -4,7 +4,6 @@ // rustfix-only-machine-applicable // check-pass -#![feature(rust_2018_preview)] #![warn(rust_2018_compatibility)] extern crate suggestions_not_always_applicable as foo; diff --git a/tests/ui/simd/repr_packed.rs b/tests/ui/simd/repr_packed.rs new file mode 100644 index 00000000000..df2d59a58b8 --- /dev/null +++ b/tests/ui/simd/repr_packed.rs @@ -0,0 +1,59 @@ +// run-pass + +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd, packed)] +struct Simd<T, const N: usize>([T; N]); + +#[repr(simd)] +struct FullSimd<T, const N: usize>([T; N]); + +fn check_size_align<T, const N: usize>() { + use std::mem; + assert_eq!(mem::size_of::<Simd<T, N>>(), mem::size_of::<[T; N]>()); + assert_eq!(mem::size_of::<Simd<T, N>>() % mem::align_of::<Simd<T, N>>(), 0); +} + +fn check_ty<T>() { + check_size_align::<T, 1>(); + check_size_align::<T, 2>(); + check_size_align::<T, 3>(); + check_size_align::<T, 4>(); + check_size_align::<T, 8>(); + check_size_align::<T, 9>(); + check_size_align::<T, 15>(); +} + +extern "platform-intrinsic" { + fn simd_add<T>(a: T, b: T) -> T; +} + +fn main() { + check_ty::<u8>(); + check_ty::<i16>(); + check_ty::<u32>(); + check_ty::<i64>(); + check_ty::<usize>(); + check_ty::<f32>(); + check_ty::<f64>(); + + unsafe { + // powers-of-two have no padding and work as usual + let x: Simd<f64, 4> = + simd_add(Simd::<f64, 4>([0., 1., 2., 3.]), Simd::<f64, 4>([2., 2., 2., 2.])); + assert_eq!(std::mem::transmute::<_, [f64; 4]>(x), [2., 3., 4., 5.]); + + // non-powers-of-two have padding and need to be expanded to full vectors + fn load<T, const N: usize>(v: Simd<T, N>) -> FullSimd<T, N> { + unsafe { + let mut tmp = core::mem::MaybeUninit::<FullSimd<T, N>>::uninit(); + std::ptr::copy_nonoverlapping(&v as *const _, tmp.as_mut_ptr().cast(), 1); + tmp.assume_init() + } + } + let x: FullSimd<f64, 3> = + simd_add(load(Simd::<f64, 3>([0., 1., 2.])), load(Simd::<f64, 3>([2., 2., 2.]))); + assert_eq!(x.0, [2., 3., 4.]); + } +} diff --git a/tests/ui/tool_lints_2018_preview.rs b/tests/ui/tool_lints_2018_preview.rs index 190f0b99dc8..e467d34376f 100644 --- a/tests/ui/tool_lints_2018_preview.rs +++ b/tests/ui/tool_lints_2018_preview.rs @@ -1,6 +1,5 @@ // run-pass -#![feature(rust_2018_preview)] #![deny(unknown_lints)] #[allow(clippy::almost_swapped)] |
