diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 4ef43735a62c8..db20578fa1d24 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1729,9 +1729,9 @@ pub enum LitFloatType { Unsuffixed, } -/// Literal kind. -/// -/// E.g., `"foo"`, `42`, `12.34`, or `bool`. +/// Note that the entire literal (including the suffix) is considered when +/// deciding the `LitKind`. This means that float literals like `1f32` are +/// classified by this type as `Float`. #[derive(Clone, Encodable, Decodable, Debug, Hash, Eq, PartialEq, HashStable_Generic)] pub enum LitKind { /// A string literal (`"foo"`). The symbol is unescaped, and so may differ @@ -1745,8 +1745,8 @@ pub enum LitKind { Char(char), /// An integer literal (`1`). Int(u128, LitIntType), - /// A float literal (`1f64` or `1E10f64`). Stored as a symbol rather than - /// `f64` so that `LitKind` can impl `Eq` and `Hash`. + /// A float literal (`1.0`, `1f64` or `1E10f64`). Stored as a symbol rather + /// than `f64` so that `LitKind` can impl `Eq` and `Hash`. Float(Symbol, LitFloatType), /// A boolean literal. Bool(bool), diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 83b10d906e297..898b6d53a1c36 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -58,13 +58,16 @@ pub enum Delimiter { Invisible, } +/// Note that the entire literal (including the suffix) is considered when +/// deciding the `LitKind`. This means that float literals like `1f32` are +/// classified by this type as `Float`. #[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] pub enum LitKind { Bool, // AST only, must never appear in a `Token` Byte, Char, - Integer, - Float, + Integer, // e.g. `1`, `1u8` + Float, // e.g. `1.`, `1.0`, `1f32`, `1e3f32` Str, StrRaw(u8), // raw string delimited by `n` hash symbols ByteStr, @@ -77,7 +80,7 @@ pub enum LitKind { pub struct Lit { pub kind: LitKind, pub symbol: Symbol, - pub suffix: Option, + pub suffix: Option, // njn: change to a type? } impl fmt::Display for Lit { @@ -120,19 +123,6 @@ impl LitKind { } } - pub fn descr(self) -> &'static str { - match self { - Bool => panic!("literal token contains `Lit::Bool`"), - Byte => "byte", - Char => "char", - Integer => "integer", - Float => "float", - Str | StrRaw(..) => "string", - ByteStr | ByteStrRaw(..) => "byte string", - Err => "error", - } - } - pub(crate) fn may_have_suffix(self) -> bool { matches!(self, Integer | Float | Err) } diff --git a/compiler/rustc_ast/src/util/literal.rs b/compiler/rustc_ast/src/util/literal.rs index 536b385606c69..ce37cb0176813 100644 --- a/compiler/rustc_ast/src/util/literal.rs +++ b/compiler/rustc_ast/src/util/literal.rs @@ -10,13 +10,10 @@ use rustc_span::Span; use std::ascii; +// njn: how much of this will be left? pub enum LitError { NotLiteral, LexerError, - InvalidSuffix, - InvalidIntSuffix, - InvalidFloatSuffix, - NonDecimalFloat(u32), IntTooLarge, } @@ -24,8 +21,10 @@ impl LitKind { /// Converts literal token into a semantic literal. pub fn from_token_lit(lit: token::Lit) -> Result { let token::Lit { kind, symbol, suffix } = lit; + // njn: could even move the suffix into `kind`... if suffix.is_some() && !kind.may_have_suffix() { - return Err(LitError::InvalidSuffix); + // njn: yuk + return Err(LitError::LexerError); } Ok(match kind { @@ -259,33 +258,23 @@ fn strip_underscores(symbol: Symbol) -> Symbol { symbol } -fn filtered_float_lit( - symbol: Symbol, - suffix: Option, - base: u32, -) -> Result { - debug!("filtered_float_lit: {:?}, {:?}, {:?}", symbol, suffix, base); - if base != 10 { - return Err(LitError::NonDecimalFloat(base)); - } +fn float_lit(symbol: Symbol, suffix: Option) -> Result { + debug!("float_lit: {:?}, {:?}", symbol, suffix); + let symbol = strip_underscores(symbol); + Ok(match suffix { Some(suf) => LitKind::Float( symbol, ast::LitFloatType::Suffixed(match suf { sym::f32 => ast::FloatTy::F32, sym::f64 => ast::FloatTy::F64, - _ => return Err(LitError::InvalidFloatSuffix), + _ => return Err(LitError::LexerError), }), ), None => LitKind::Float(symbol, ast::LitFloatType::Unsuffixed), }) } -fn float_lit(symbol: Symbol, suffix: Option) -> Result { - debug!("float_lit: {:?}, {:?}", symbol, suffix); - filtered_float_lit(strip_underscores(symbol), suffix, 10) -} - fn integer_lit(symbol: Symbol, suffix: Option) -> Result { debug!("integer_lit: {:?}, {:?}", symbol, suffix); let symbol = strip_underscores(symbol); @@ -312,10 +301,11 @@ fn integer_lit(symbol: Symbol, suffix: Option) -> Result ast::LitIntType::Unsigned(ast::UintTy::U32), sym::u64 => ast::LitIntType::Unsigned(ast::UintTy::U64), sym::u128 => ast::LitIntType::Unsigned(ast::UintTy::U128), - // `1f64` and `2f32` etc. are valid float literals, and - // `fxxx` looks more like an invalid float literal than invalid integer literal. - _ if suf.as_str().starts_with('f') => return filtered_float_lit(symbol, suffix, base), - _ => return Err(LitError::InvalidIntSuffix), + _ => + //return Err(LitError::LexerError), // njn: hmm + { + return Ok(ast::LitKind::Err); + } }, _ => ast::LitIntType::Unsuffixed, }; diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index ff29d15f1b525..c00fd0fc85d48 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -962,6 +962,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let lit = if let ExprKind::Lit(lit) = &expr.kind { lit.clone() } else { + // njn: use Lit::from_token_lit here? Lit { token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None), kind: LitKind::Err, diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs index 51515976e4ee9..325d71edb53ec 100644 --- a/compiler/rustc_lexer/src/lib.rs +++ b/compiler/rustc_lexer/src/lib.rs @@ -165,9 +165,13 @@ pub enum DocStyle { Inner, } +// Note that the suffix is *not* considered when deciding the `LiteralKind` in +// this type. This means that float literals like `1f32` are classified by this +// type as `Int`. (Compare against `rustc_ast::token::LitKind` and +// `rustc_ast::ast::LitKind.) #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum LiteralKind { - /// "12_u8", "0o100", "0b120i99" + /// "12_u8", "0o100", "0b120i99", "1f32". Int { base: Base, empty_int: bool }, /// "12.34f32", "0b100.100" Float { base: Base, empty_exponent: bool }, @@ -187,6 +191,19 @@ pub enum LiteralKind { RawByteStr { n_hashes: Option }, } +impl LiteralKind { + pub fn descr(self) -> &'static str { + match self { + Int { .. } => "integer", + Float { .. } => "float", + Char { .. } => "char", + Byte { .. } => "byte", + Str { .. } | RawStr { .. } => "string", + ByteStr { .. } | RawByteStr { .. } => "byte string", + } + } +} + #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum RawStrError { /// Non `#` characters exist between `r` and `"`, e.g. `r##~"abcde"##` diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 462bce16ad717..1bc6f13793132 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -1,3 +1,7 @@ +use crate::errors::{ + InvalidFloatLiteralSuffix, InvalidFloatLiteralWidth, InvalidIntLiteralWidth, + InvalidLiteralSuffix, InvalidNumLiteralBasePrefix, InvalidNumLiteralSuffix, +}; use crate::lexer::unicode_chars::UNICODE_ARRAY; use rustc_ast::ast::{self, AttrStyle}; use rustc_ast::token::{self, CommentKind, Delimiter, Token, TokenKind}; @@ -14,7 +18,7 @@ use rustc_session::lint::builtin::{ }; use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::parse::ParseSess; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::{edition::Edition, BytePos, Pos, Span}; mod tokentrees; @@ -169,10 +173,15 @@ impl<'a> StringReader<'a> { } rustc_lexer::TokenKind::Literal { kind, suffix_start } => { let suffix_start = start + BytePos(suffix_start); - let (kind, symbol) = self.cook_lexer_literal(start, suffix_start, kind); let suffix = if suffix_start < self.pos { - let string = self.str_from(suffix_start); - if string == "_" { + Some(Symbol::intern(self.str_from(suffix_start))) + } else { + None + }; + let (kind, symbol) = + self.cook_lexer_literal(start, suffix_start, self.pos, suffix, kind); + let suffix = suffix.and_then(|suffix| { + if suffix == kw::Underscore { self.sess .span_diagnostic .struct_span_warn( @@ -192,11 +201,9 @@ impl<'a> StringReader<'a> { .emit(); None } else { - Some(Symbol::intern(string)) + Some(suffix) } - } else { - None - }; + }); token::Literal(token::Lit { kind, symbol, suffix }) } rustc_lexer::TokenKind::Lifetime { starts_with_number } => { @@ -360,12 +367,33 @@ impl<'a> StringReader<'a> { token::DocComment(comment_kind, attr_style, Symbol::intern(content)) } + // njn: use LitKind::Err more? fn cook_lexer_literal( &self, start: BytePos, suffix_start: BytePos, + suffix_end: BytePos, + suffix: Option, kind: rustc_lexer::LiteralKind, ) -> (token::LitKind, Symbol) { + // Checks if `s` looks like i32 or u1234 etc. + fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool { + s.len() > 1 && s.starts_with(first_chars) && s[1..].chars().all(|c| c.is_ascii_digit()) + } + + // Try to lowercase the prefix if it's a valid base prefix. + fn fix_base_capitalisation(s: &str) -> Option { + if let Some(stripped) = s.strip_prefix('B') { + Some(format!("0b{stripped}")) + } else if let Some(stripped) = s.strip_prefix('O') { + Some(format!("0o{stripped}")) + } else if let Some(stripped) = s.strip_prefix('X') { + Some(format!("0x{stripped}")) + } else { + None + } + } + // prefix means `"` or `br"` or `r###"`, ... let (lit_kind, mode, prefix_len, postfix_len) = match kind { rustc_lexer::LiteralKind::Char { terminated } => { @@ -436,8 +464,81 @@ impl<'a> StringReader<'a> { .emit(); (token::Integer, sym::integer(0)) } else { - self.validate_int_literal(base, start, suffix_start); - (token::Integer, self.symbol_from_to(start, suffix_start)) + // If it's a literal like `1f32`, change it to a float. + // njn: can this check be even earlier + let kind = if matches!(suffix, Some(sym::f32 | sym::f64)) { + // njn: factor out + // njn: could use .ftl stuff here + match base { + Base::Hexadecimal => self.err_span_( + start, + suffix_start, + "hexadecimal float literal is not supported", + ), + Base::Octal => self.err_span_( + start, + suffix_start, + "octal float literal is not supported", + ), + Base::Binary => self.err_span_( + start, + suffix_start, + "binary float literal is not supported", + ), + _ => (), + } + + token::Float + } else { + self.validate_int_literal(base, start, suffix_start); + + match suffix { + None => {} + Some( + sym::u8 + | sym::u16 + | sym::u32 + | sym::u64 + | sym::u128 + | sym::usize + | sym::i8 + | sym::i16 + | sym::i32 + | sym::i64 + | sym::i128 + | sym::isize, + ) => {} + Some(suffix) => { + let suffix = suffix.as_str(); + let span = self.mk_sp(start, suffix_end); + if looks_like_width_suffix(&['i', 'u'], suffix) { + // If it looks like an integer width, try to be helpful. + self.sess.emit_err(InvalidIntLiteralWidth { + span, + width: suffix[1..].to_string(), + }); + } else if looks_like_width_suffix(&['f'], suffix) { + // If it looks like a float width, try to be helpful. + self.sess.emit_err(InvalidFloatLiteralWidth { + span, + width: suffix[1..].to_string(), + }); + } else if let Some(fixed) = fix_base_capitalisation(suffix) { + // njn: this matches `0X123`, which is good, but also + // `1X123` and `123X123` + self.sess.emit_err(InvalidNumLiteralBasePrefix { span, fixed }); + } else { + self.sess.emit_err(InvalidNumLiteralSuffix { + span, + suffix: suffix.to_string(), // njn: change to Symbol? + }); + } + } + } + + token::Integer + }; + (kind, self.symbol_from_to(start, suffix_start)) }; } rustc_lexer::LiteralKind::Float { base, empty_exponent } => { @@ -445,6 +546,7 @@ impl<'a> StringReader<'a> { self.err_span_(start, self.pos, "expected at least one digit in exponent"); } + // njn: could use .ftl stuff here match base { Base::Hexadecimal => self.err_span_( start, @@ -460,10 +562,42 @@ impl<'a> StringReader<'a> { _ => (), } + // njn: factor out + match suffix { + None => {} + Some(sym::f32 | sym::f64) => {} + Some(suffix) => { + let suffix = suffix.as_str(); + let span = self.mk_sp(start, suffix_end); + if looks_like_width_suffix(&['f'], suffix) { + // If it looks like a width, try to be helpful. + self.sess.emit_err(InvalidFloatLiteralWidth { + span, + width: suffix[1..].to_string(), + }); + } else { + self.sess.emit_err(InvalidFloatLiteralSuffix { + span, + suffix: suffix.to_string(), // njn: change to symbol? + }); + } + } + } + let id = self.symbol_from_to(start, suffix_start); return (token::Float, id); } }; + // Int and float literals are the only ones allowed to have suffixes, + // and they've been handled above. + if let Some(suffix) = suffix { + let span = self.mk_sp(start, suffix_end); + self.sess.emit_err(InvalidLiteralSuffix { + span, + kind: format!("{}", kind.descr()), + suffix, + }); + } let content_start = start + BytePos(prefix_len); let content_end = suffix_start - BytePos(postfix_len); let id = self.symbol_from_to(content_start, content_end); diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index a781748efc52a..b7f216c666792 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -7,25 +7,21 @@ use super::{ }; use crate::errors::{ ArrayBracketsInsteadOfSpaces, ArrayBracketsInsteadOfSpacesSugg, AsyncMoveOrderIncorrect, - BinaryFloatLiteralNotSupported, BracesForStructLiteral, CatchAfterTry, CommaAfterBaseStruct, - ComparisonInterpretedAsGeneric, ComparisonOrShiftInterpretedAsGenericSugg, - DoCatchSyntaxRemoved, DotDotDot, EqFieldInit, ExpectedElseBlock, ExpectedExpressionFoundLet, - FieldExpressionWithGeneric, FloatLiteralRequiresIntegerPart, FoundExprWouldBeStmt, - HexadecimalFloatLiteralNotSupported, IfExpressionMissingCondition, + BracesForStructLiteral, CatchAfterTry, CommaAfterBaseStruct, ComparisonInterpretedAsGeneric, + ComparisonOrShiftInterpretedAsGenericSugg, DoCatchSyntaxRemoved, DotDotDot, EqFieldInit, + ExpectedElseBlock, ExpectedExpressionFoundLet, FieldExpressionWithGeneric, + FloatLiteralRequiresIntegerPart, FoundExprWouldBeStmt, IfExpressionMissingCondition, IfExpressionMissingThenBlock, IfExpressionMissingThenBlockSub, IntLiteralTooLarge, InvalidBlockMacroSegment, InvalidComparisonOperator, InvalidComparisonOperatorSub, - InvalidFloatLiteralSuffix, InvalidFloatLiteralWidth, InvalidIntLiteralWidth, - InvalidInterpolatedExpression, InvalidLiteralSuffix, InvalidLiteralSuffixOnTupleIndex, - InvalidLogicalOperator, InvalidLogicalOperatorSub, InvalidNumLiteralBasePrefix, - InvalidNumLiteralSuffix, LabeledLoopInBreak, LeadingPlusNotSupported, LeftArrowOperator, + InvalidInterpolatedExpression, InvalidLiteralSuffixOnTupleIndex, InvalidLogicalOperator, + InvalidLogicalOperatorSub, LabeledLoopInBreak, LeadingPlusNotSupported, LeftArrowOperator, LifetimeInBorrowExpression, MacroInvocationWithQualifiedPath, MalformedLoopLabel, MatchArmBodyWithoutBraces, MatchArmBodyWithoutBracesSugg, MissingCommaAfterMatchArm, MissingInInForLoop, MissingInInForLoopSub, MissingSemicolonBeforeArray, NoFieldsForFnCall, - NotAsNegationOperator, NotAsNegationOperatorSub, OctalFloatLiteralNotSupported, - OuterAttributeNotAllowedOnIfElse, ParenthesesWithStructFields, - RequireColonAfterLabeledExpression, ShiftInterpretedAsGeneric, StructLiteralNotAllowedHere, - StructLiteralNotAllowedHereSugg, TildeAsUnaryOperator, UnexpectedTokenAfterLabel, - UnexpectedTokenAfterLabelSugg, WrapExpressionInParentheses, + NotAsNegationOperator, NotAsNegationOperatorSub, OuterAttributeNotAllowedOnIfElse, + ParenthesesWithStructFields, RequireColonAfterLabeledExpression, ShiftInterpretedAsGeneric, + StructLiteralNotAllowedHere, StructLiteralNotAllowedHereSugg, TildeAsUnaryOperator, + UnexpectedTokenAfterLabel, UnexpectedTokenAfterLabelSugg, WrapExpressionInParentheses, }; use crate::maybe_recover_from_interpolated_ty_qpath; @@ -1815,12 +1811,14 @@ impl<'a> Parser<'a> { // Attempt to recover `.4` as `0.4`. We don't currently have any syntax where // dot would follow an optional literal, so we do this unconditionally. recovered = self.look_ahead(1, |next_token| { - if let token::Literal(token::Lit { kind: token::Integer, symbol, suffix }) = - next_token.kind + if let token::Literal(token_lit) = next_token.kind + // njn: a bit imprecise with the Float case, matches `.3.3f32` + && matches!(token_lit.kind, token::Integer | token::Float) { if self.token.span.hi() == next_token.span.lo() { - let s = String::from("0.") + symbol.as_str(); - let kind = TokenKind::lit(token::Float, Symbol::intern(&s), suffix); + let s = String::from("0.") + token_lit.symbol.as_str(); + let kind = + TokenKind::lit(token::Float, Symbol::intern(&s), token_lit.suffix); return Some(Token::new(kind, self.token.span.to(next_token.span))); } } @@ -1848,84 +1846,26 @@ impl<'a> Parser<'a> { unreachable!(); }; self.bump(); - self.report_lit_error(err, lit, span); + self.report_lit_error(err, span); // Pack possible quotes and prefixes from the original literal into // the error literal's symbol so they can be pretty-printed faithfully. let suffixless_lit = token::Lit::new(lit.kind, lit.symbol, None); let symbol = Symbol::intern(&suffixless_lit.to_string()); let lit = token::Lit::new(token::Err, symbol, lit.suffix); + // njn: could avoid this call, just build the `Err` Lit directly... Some(Lit::from_token_lit(lit, span).unwrap_or_else(|_| unreachable!())) } } } - fn report_lit_error(&self, err: LitError, lit: token::Lit, span: Span) { - // Checks if `s` looks like i32 or u1234 etc. - fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool { - s.len() > 1 && s.starts_with(first_chars) && s[1..].chars().all(|c| c.is_ascii_digit()) - } - - // Try to lowercase the prefix if it's a valid base prefix. - fn fix_base_capitalisation(s: &str) -> Option { - if let Some(stripped) = s.strip_prefix('B') { - Some(format!("0b{stripped}")) - } else if let Some(stripped) = s.strip_prefix('O') { - Some(format!("0o{stripped}")) - } else if let Some(stripped) = s.strip_prefix('X') { - Some(format!("0x{stripped}")) - } else { - None - } - } - - let token::Lit { kind, suffix, .. } = lit; + fn report_lit_error(&self, err: LitError, span: Span) { match err { // `NotLiteral` is not an error by itself, so we don't report // it and give the parser opportunity to try something else. - LitError::NotLiteral => {} + LitError::NotLiteral => {} // njn: unreachable? // `LexerError` *is* an error, but it was already reported // by lexer, so here we don't report it the second time. LitError::LexerError => {} - LitError::InvalidSuffix => { - if let Some(suffix) = suffix { - self.sess.emit_err(InvalidLiteralSuffix { - span, - kind: format!("{}", kind.descr()), - suffix, - }); - } - } - LitError::InvalidIntSuffix => { - let suf = suffix.expect("suffix error with no suffix"); - let suf = suf.as_str(); - if looks_like_width_suffix(&['i', 'u'], &suf) { - // If it looks like a width, try to be helpful. - self.sess.emit_err(InvalidIntLiteralWidth { span, width: suf[1..].into() }); - } else if let Some(fixed) = fix_base_capitalisation(suf) { - self.sess.emit_err(InvalidNumLiteralBasePrefix { span, fixed }); - } else { - self.sess.emit_err(InvalidNumLiteralSuffix { span, suffix: suf.to_string() }); - } - } - LitError::InvalidFloatSuffix => { - let suf = suffix.expect("suffix error with no suffix"); - let suf = suf.as_str(); - if looks_like_width_suffix(&['f'], suf) { - // If it looks like a width, try to be helpful. - self.sess - .emit_err(InvalidFloatLiteralWidth { span, width: suf[1..].to_string() }); - } else { - self.sess.emit_err(InvalidFloatLiteralSuffix { span, suffix: suf.to_string() }); - } - } - LitError::NonDecimalFloat(base) => { - match base { - 16 => self.sess.emit_err(HexadecimalFloatLiteralNotSupported { span }), - 8 => self.sess.emit_err(OctalFloatLiteralNotSupported { span }), - 2 => self.sess.emit_err(BinaryFloatLiteralNotSupported { span }), - _ => unreachable!(), - }; - } LitError::IntTooLarge => { self.sess.emit_err(IntLiteralTooLarge { span }); } diff --git a/src/test/ui/extenv/issue-55897.stderr b/src/test/ui/extenv/issue-55897.stderr index 63797d4a71bce..bd57b3ec5cc13 100644 --- a/src/test/ui/extenv/issue-55897.stderr +++ b/src/test/ui/extenv/issue-55897.stderr @@ -1,3 +1,9 @@ +error: suffixes on string literals are invalid + --> $DIR/issue-55897.rs:16:22 + | +LL | include!(concat!("NON_EXISTENT"suffix, "/data.rs")); + | ^^^^^^^^^^^^^^^^^^^^ invalid suffix `suffix` + error: environment variable `NON_EXISTENT` not defined --> $DIR/issue-55897.rs:11:22 | @@ -6,12 +12,6 @@ LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs")); | = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) -error: suffixes on string literals are invalid - --> $DIR/issue-55897.rs:16:22 - | -LL | include!(concat!("NON_EXISTENT"suffix, "/data.rs")); - | ^^^^^^^^^^^^^^^^^^^^ invalid suffix `suffix` - error[E0432]: unresolved import `prelude` --> $DIR/issue-55897.rs:1:5 | diff --git a/src/test/ui/lexer/lex-bad-numeric-literals.stderr b/src/test/ui/lexer/lex-bad-numeric-literals.stderr index f05d61603023c..bd92bc2744ebb 100644 --- a/src/test/ui/lexer/lex-bad-numeric-literals.stderr +++ b/src/test/ui/lexer/lex-bad-numeric-literals.stderr @@ -4,6 +4,12 @@ error: octal float literal is not supported LL | 0o1.0; | ^^^^^ +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:3:5 + | +LL | 0o2f32; + | ^^^ + error: octal float literal is not supported --> $DIR/lex-bad-numeric-literals.rs:4:5 | @@ -94,24 +100,30 @@ error[E0768]: no valid digits found for number LL | 0b; | ^^ +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:23:5 + | +LL | 0o123f64; + | ^^^^^ + error: octal float literal is not supported --> $DIR/lex-bad-numeric-literals.rs:24:5 | LL | 0o123.456; | ^^^^^^^^^ +error: binary float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:25:5 + | +LL | 0b101f64; + | ^^^^^ + error: binary float literal is not supported --> $DIR/lex-bad-numeric-literals.rs:26:5 | LL | 0b111.101; | ^^^^^^^^^ -error: octal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:3:5 - | -LL | 0o2f32; - | ^^^^^^ not supported - error: integer literal is too large --> $DIR/lex-bad-numeric-literals.rs:14:5 | @@ -124,18 +136,6 @@ error: integer literal is too large LL | 9900000000000000000000000000999999999999999999999999999999; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: octal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:23:5 - | -LL | 0o123f64; - | ^^^^^^^^ not supported - -error: binary float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:25:5 - | -LL | 0b101f64; - | ^^^^^^^^ not supported - error: aborting due to 23 previous errors For more information about this error, try `rustc --explain E0768`. diff --git a/src/test/ui/parser/issues/issue-59418.rs b/src/test/ui/parser/issues/issue-59418.rs index 0fa191d4a7ef4..c361e2e52e5ad 100644 --- a/src/test/ui/parser/issues/issue-59418.rs +++ b/src/test/ui/parser/issues/issue-59418.rs @@ -3,16 +3,20 @@ struct X(i32,i32,i32); fn main() { let a = X(1, 2, 3); let b = a.1suffix; - //~^ ERROR suffixes on a tuple index are invalid + //~^ ERROR invalid suffix `suffix` for number literal + //~^^ ERROR suffixes on a tuple index are invalid println!("{}", b); let c = (1, 2, 3); let d = c.1suffix; - //~^ ERROR suffixes on a tuple index are invalid + //~^ ERROR invalid suffix `suffix` for number literal + //~^^ ERROR suffixes on a tuple index are invalid println!("{}", d); let s = X { 0suffix: 0, 1: 1, 2: 2 }; - //~^ ERROR suffixes on a tuple index are invalid + //~^ ERROR invalid suffix `suffix` for number literal + //~^^ ERROR suffixes on a tuple index are invalid match s { X { 0suffix: _, .. } => {} - //~^ ERROR suffixes on a tuple index are invalid + //~^ ERROR invalid suffix `suffix` for number literal + //~^^ ERROR suffixes on a tuple index are invalid } } diff --git a/src/test/ui/parser/issues/issue-59418.stderr b/src/test/ui/parser/issues/issue-59418.stderr index 347051e9f921c..7df8285bc4fdf 100644 --- a/src/test/ui/parser/issues/issue-59418.stderr +++ b/src/test/ui/parser/issues/issue-59418.stderr @@ -1,3 +1,35 @@ +error: invalid suffix `suffix` for number literal + --> $DIR/issue-59418.rs:5:15 + | +LL | let b = a.1suffix; + | ^^^^^^^ invalid suffix `suffix` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +error: invalid suffix `suffix` for number literal + --> $DIR/issue-59418.rs:10:15 + | +LL | let d = c.1suffix; + | ^^^^^^^ invalid suffix `suffix` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +error: invalid suffix `suffix` for number literal + --> $DIR/issue-59418.rs:14:17 + | +LL | let s = X { 0suffix: 0, 1: 1, 2: 2 }; + | ^^^^^^^ invalid suffix `suffix` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +error: invalid suffix `suffix` for number literal + --> $DIR/issue-59418.rs:18:13 + | +LL | X { 0suffix: _, .. } => {} + | ^^^^^^^ invalid suffix `suffix` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + error: suffixes on a tuple index are invalid --> $DIR/issue-59418.rs:5:15 | @@ -5,22 +37,22 @@ LL | let b = a.1suffix; | ^^^^^^^ invalid suffix `suffix` error: suffixes on a tuple index are invalid - --> $DIR/issue-59418.rs:9:15 + --> $DIR/issue-59418.rs:10:15 | LL | let d = c.1suffix; | ^^^^^^^ invalid suffix `suffix` error: suffixes on a tuple index are invalid - --> $DIR/issue-59418.rs:12:17 + --> $DIR/issue-59418.rs:14:17 | LL | let s = X { 0suffix: 0, 1: 1, 2: 2 }; | ^^^^^^^ invalid suffix `suffix` error: suffixes on a tuple index are invalid - --> $DIR/issue-59418.rs:15:13 + --> $DIR/issue-59418.rs:18:13 | LL | X { 0suffix: _, .. } => {} | ^^^^^^^ invalid suffix `suffix` -error: aborting due to 4 previous errors +error: aborting due to 8 previous errors diff --git a/src/test/ui/parser/no-binary-float-literal.stderr b/src/test/ui/parser/no-binary-float-literal.stderr index cfd448684590f..e96ef534d1fe9 100644 --- a/src/test/ui/parser/no-binary-float-literal.stderr +++ b/src/test/ui/parser/no-binary-float-literal.stderr @@ -1,14 +1,14 @@ error: binary float literal is not supported - --> $DIR/no-binary-float-literal.rs:4:5 + --> $DIR/no-binary-float-literal.rs:2:5 | -LL | 0b101.010; - | ^^^^^^^^^ +LL | 0b101010f64; + | ^^^^^^^^ error: binary float literal is not supported - --> $DIR/no-binary-float-literal.rs:2:5 + --> $DIR/no-binary-float-literal.rs:4:5 | -LL | 0b101010f64; - | ^^^^^^^^^^^ not supported +LL | 0b101.010; + | ^^^^^^^^^ error: invalid suffix `p4f64` for number literal --> $DIR/no-binary-float-literal.rs:6:5 diff --git a/src/test/ui/parser/no-hex-float-literal.rs b/src/test/ui/parser/no-hex-float-literal.rs index bf11dee08338e..f79b358df4c57 100644 --- a/src/test/ui/parser/no-hex-float-literal.rs +++ b/src/test/ui/parser/no-hex-float-literal.rs @@ -4,6 +4,6 @@ fn main() { 0x567.89; //~^ ERROR hexadecimal float literal is not supported 0xDEAD.BEEFp-2f; - //~^ ERROR invalid suffix `f` for float literal + //~^ ERROR invalid suffix `f` for number literal //~| ERROR `{integer}` is a primitive type and therefore doesn't have fields } diff --git a/src/test/ui/parser/no-hex-float-literal.stderr b/src/test/ui/parser/no-hex-float-literal.stderr index 258ab06d5ee2f..66c851a48fd92 100644 --- a/src/test/ui/parser/no-hex-float-literal.stderr +++ b/src/test/ui/parser/no-hex-float-literal.stderr @@ -4,13 +4,13 @@ error: hexadecimal float literal is not supported LL | 0x567.89; | ^^^^^^^^ -error: invalid suffix `f` for float literal +error: invalid suffix `f` for number literal --> $DIR/no-hex-float-literal.rs:6:18 | LL | 0xDEAD.BEEFp-2f; | ^^ invalid suffix `f` | - = help: valid suffixes are `f32` and `f64` + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/no-hex-float-literal.rs:2:11 diff --git a/src/test/ui/parser/underscore-suffix-for-string.rs b/src/test/ui/parser/underscore-suffix-for-string.rs index 2e0ebe2cfa446..4159f31a6943d 100644 --- a/src/test/ui/parser/underscore-suffix-for-string.rs +++ b/src/test/ui/parser/underscore-suffix-for-string.rs @@ -1,8 +1,12 @@ -// check-pass +// check-fail + +// njn: not sure about the change to this one... fn main() { let _ = "Foo"_; - //~^ WARNING underscore literal suffix is not allowed + //~^ ERROR suffixes on string literals are invalid + //~| NOTE invalid suffix `_` + //~^^^ WARNING underscore literal suffix is not allowed //~| WARNING this was previously accepted //~| NOTE issue #42326 } diff --git a/src/test/ui/parser/underscore-suffix-for-string.stderr b/src/test/ui/parser/underscore-suffix-for-string.stderr index 00c7657f17bd3..dac838ce9d30f 100644 --- a/src/test/ui/parser/underscore-suffix-for-string.stderr +++ b/src/test/ui/parser/underscore-suffix-for-string.stderr @@ -1,5 +1,11 @@ +error: suffixes on string literals are invalid + --> $DIR/underscore-suffix-for-string.rs:6:13 + | +LL | let _ = "Foo"_; + | ^^^^^^ invalid suffix `_` + warning: underscore literal suffix is not allowed - --> $DIR/underscore-suffix-for-string.rs:4:18 + --> $DIR/underscore-suffix-for-string.rs:6:18 | LL | let _ = "Foo"_; | ^ @@ -7,5 +13,5 @@ LL | let _ = "Foo"_; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: see issue #42326 for more information -warning: 1 warning emitted +error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/proc-macro/auxiliary/api/parse.rs b/src/test/ui/proc-macro/auxiliary/api/parse.rs index 27391f8311176..027497617ca95 100644 --- a/src/test/ui/proc-macro/auxiliary/api/parse.rs +++ b/src/test/ui/proc-macro/auxiliary/api/parse.rs @@ -38,8 +38,6 @@ fn test_parse_literal() { assert_eq!("\"\n\"".parse::().unwrap().to_string(), "\"\n\""); assert_eq!("b\"\"".parse::().unwrap().to_string(), "b\"\""); assert_eq!("r##\"\"##".parse::().unwrap().to_string(), "r##\"\"##"); - assert_eq!("10ulong".parse::().unwrap().to_string(), "10ulong"); - assert_eq!("-10ulong".parse::().unwrap().to_string(), "-10ulong"); assert!("true".parse::().is_err()); assert!(".8".parse::().is_err()); diff --git a/src/test/ui/proc-macro/debug/dump-debug-span-debug.rs b/src/test/ui/proc-macro/debug/dump-debug-span-debug.rs index 102bd6b7b1757..88e9289cf4a8e 100644 --- a/src/test/ui/proc-macro/debug/dump-debug-span-debug.rs +++ b/src/test/ui/proc-macro/debug/dump-debug-span-debug.rs @@ -29,18 +29,6 @@ dump_debug! { br##"BR"## 'C' b'B' - - // suffixed literals - 0q - 1.0q - "S"q - b"B"q - r"R"q - r##"R"##q - br"BR"q - br##"BR"##q - 'C'q - b'B'q } fn main() {} diff --git a/src/test/ui/proc-macro/debug/dump-debug-span-debug.stderr b/src/test/ui/proc-macro/debug/dump-debug-span-debug.stderr index fa65cbbf1eae5..f27a17d3214ac 100644 --- a/src/test/ui/proc-macro/debug/dump-debug-span-debug.stderr +++ b/src/test/ui/proc-macro/debug/dump-debug-span-debug.stderr @@ -1,4 +1,4 @@ -TokenStream [Ident { ident: "ident", span: $DIR/dump-debug-span-debug.rs:10:5: 10:10 (#0) }, Ident { ident: "r#ident", span: $DIR/dump-debug-span-debug.rs:11:5: 11:12 (#0) }, Punct { ch: ',', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:12:5: 12:6 (#0) }, Punct { ch: '&', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:13:5: 13:6 (#0) }, Punct { ch: '&', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:13:6: 13:7 (#0) }, Punct { ch: '|', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:14:5: 14:6 (#0) }, Punct { ch: '|', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:14:6: 14:7 (#0) }, Punct { ch: '>', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:14:7: 14:8 (#0) }, Punct { ch: '|', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:15:5: 15:6 (#0) }, Punct { ch: '|', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:15:6: 15:7 (#0) }, Punct { ch: '<', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:15:7: 15:8 (#0) }, Punct { ch: '<', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:15:8: 15:9 (#0) }, Punct { ch: '.', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:16:5: 16:6 (#0) }, Punct { ch: '.', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:16:6: 16:7 (#0) }, Punct { ch: '=', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:16:7: 16:8 (#0) }, Punct { ch: '<', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:17:5: 17:6 (#0) }, Punct { ch: '<', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:17:6: 17:7 (#0) }, Punct { ch: '=', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:17:7: 17:8 (#0) }, Punct { ch: '!', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:17:8: 17:9 (#0) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/dump-debug-span-debug.rs:18:5: 18:7 (#0) }, Group { delimiter: Bracket, stream: TokenStream [Ident { ident: "_", span: $DIR/dump-debug-span-debug.rs:19:6: 19:7 (#0) }], span: $DIR/dump-debug-span-debug.rs:19:5: 19:8 (#0) }, Literal { kind: Integer, symbol: "0", suffix: None, span: $DIR/dump-debug-span-debug.rs:22:5: 22:6 (#0) }, Literal { kind: Float, symbol: "1.0", suffix: None, span: $DIR/dump-debug-span-debug.rs:23:5: 23:8 (#0) }, Literal { kind: Str, symbol: "S", suffix: None, span: $DIR/dump-debug-span-debug.rs:24:5: 24:8 (#0) }, Literal { kind: ByteStr, symbol: "B", suffix: None, span: $DIR/dump-debug-span-debug.rs:25:5: 25:9 (#0) }, Literal { kind: StrRaw(0), symbol: "R", suffix: None, span: $DIR/dump-debug-span-debug.rs:26:5: 26:9 (#0) }, Literal { kind: StrRaw(2), symbol: "R", suffix: None, span: $DIR/dump-debug-span-debug.rs:27:5: 27:13 (#0) }, Literal { kind: ByteStrRaw(0), symbol: "BR", suffix: None, span: $DIR/dump-debug-span-debug.rs:28:5: 28:11 (#0) }, Literal { kind: ByteStrRaw(2), symbol: "BR", suffix: None, span: $DIR/dump-debug-span-debug.rs:29:5: 29:15 (#0) }, Literal { kind: Char, symbol: "C", suffix: None, span: $DIR/dump-debug-span-debug.rs:30:5: 30:8 (#0) }, Literal { kind: Byte, symbol: "B", suffix: None, span: $DIR/dump-debug-span-debug.rs:31:5: 31:9 (#0) }, Literal { kind: Integer, symbol: "0", suffix: Some("q"), span: $DIR/dump-debug-span-debug.rs:34:5: 34:7 (#0) }, Literal { kind: Float, symbol: "1.0", suffix: Some("q"), span: $DIR/dump-debug-span-debug.rs:35:5: 35:9 (#0) }, Literal { kind: Str, symbol: "S", suffix: Some("q"), span: $DIR/dump-debug-span-debug.rs:36:5: 36:9 (#0) }, Literal { kind: ByteStr, symbol: "B", suffix: Some("q"), span: $DIR/dump-debug-span-debug.rs:37:5: 37:10 (#0) }, Literal { kind: StrRaw(0), symbol: "R", suffix: Some("q"), span: $DIR/dump-debug-span-debug.rs:38:5: 38:10 (#0) }, Literal { kind: StrRaw(2), symbol: "R", suffix: Some("q"), span: $DIR/dump-debug-span-debug.rs:39:5: 39:14 (#0) }, Literal { kind: ByteStrRaw(0), symbol: "BR", suffix: Some("q"), span: $DIR/dump-debug-span-debug.rs:40:5: 40:12 (#0) }, Literal { kind: ByteStrRaw(2), symbol: "BR", suffix: Some("q"), span: $DIR/dump-debug-span-debug.rs:41:5: 41:16 (#0) }, Literal { kind: Char, symbol: "C", suffix: Some("q"), span: $DIR/dump-debug-span-debug.rs:42:5: 42:9 (#0) }, Literal { kind: Byte, symbol: "B", suffix: Some("q"), span: $DIR/dump-debug-span-debug.rs:43:5: 43:10 (#0) }] +TokenStream [Ident { ident: "ident", span: $DIR/dump-debug-span-debug.rs:10:5: 10:10 (#0) }, Ident { ident: "r#ident", span: $DIR/dump-debug-span-debug.rs:11:5: 11:12 (#0) }, Punct { ch: ',', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:12:5: 12:6 (#0) }, Punct { ch: '&', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:13:5: 13:6 (#0) }, Punct { ch: '&', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:13:6: 13:7 (#0) }, Punct { ch: '|', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:14:5: 14:6 (#0) }, Punct { ch: '|', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:14:6: 14:7 (#0) }, Punct { ch: '>', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:14:7: 14:8 (#0) }, Punct { ch: '|', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:15:5: 15:6 (#0) }, Punct { ch: '|', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:15:6: 15:7 (#0) }, Punct { ch: '<', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:15:7: 15:8 (#0) }, Punct { ch: '<', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:15:8: 15:9 (#0) }, Punct { ch: '.', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:16:5: 16:6 (#0) }, Punct { ch: '.', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:16:6: 16:7 (#0) }, Punct { ch: '=', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:16:7: 16:8 (#0) }, Punct { ch: '<', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:17:5: 17:6 (#0) }, Punct { ch: '<', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:17:6: 17:7 (#0) }, Punct { ch: '=', spacing: Joint, span: $DIR/dump-debug-span-debug.rs:17:7: 17:8 (#0) }, Punct { ch: '!', spacing: Alone, span: $DIR/dump-debug-span-debug.rs:17:8: 17:9 (#0) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/dump-debug-span-debug.rs:18:5: 18:7 (#0) }, Group { delimiter: Bracket, stream: TokenStream [Ident { ident: "_", span: $DIR/dump-debug-span-debug.rs:19:6: 19:7 (#0) }], span: $DIR/dump-debug-span-debug.rs:19:5: 19:8 (#0) }, Literal { kind: Integer, symbol: "0", suffix: None, span: $DIR/dump-debug-span-debug.rs:22:5: 22:6 (#0) }, Literal { kind: Float, symbol: "1.0", suffix: None, span: $DIR/dump-debug-span-debug.rs:23:5: 23:8 (#0) }, Literal { kind: Str, symbol: "S", suffix: None, span: $DIR/dump-debug-span-debug.rs:24:5: 24:8 (#0) }, Literal { kind: ByteStr, symbol: "B", suffix: None, span: $DIR/dump-debug-span-debug.rs:25:5: 25:9 (#0) }, Literal { kind: StrRaw(0), symbol: "R", suffix: None, span: $DIR/dump-debug-span-debug.rs:26:5: 26:9 (#0) }, Literal { kind: StrRaw(2), symbol: "R", suffix: None, span: $DIR/dump-debug-span-debug.rs:27:5: 27:13 (#0) }, Literal { kind: ByteStrRaw(0), symbol: "BR", suffix: None, span: $DIR/dump-debug-span-debug.rs:28:5: 28:11 (#0) }, Literal { kind: ByteStrRaw(2), symbol: "BR", suffix: None, span: $DIR/dump-debug-span-debug.rs:29:5: 29:15 (#0) }, Literal { kind: Char, symbol: "C", suffix: None, span: $DIR/dump-debug-span-debug.rs:30:5: 30:8 (#0) }, Literal { kind: Byte, symbol: "B", suffix: None, span: $DIR/dump-debug-span-debug.rs:31:5: 31:9 (#0) }] TokenStream [ Ident { ident: "ident", @@ -168,64 +168,4 @@ TokenStream [ suffix: None, span: $DIR/dump-debug-span-debug.rs:31:5: 31:9 (#0), }, - Literal { - kind: Integer, - symbol: "0", - suffix: Some("q"), - span: $DIR/dump-debug-span-debug.rs:34:5: 34:7 (#0), - }, - Literal { - kind: Float, - symbol: "1.0", - suffix: Some("q"), - span: $DIR/dump-debug-span-debug.rs:35:5: 35:9 (#0), - }, - Literal { - kind: Str, - symbol: "S", - suffix: Some("q"), - span: $DIR/dump-debug-span-debug.rs:36:5: 36:9 (#0), - }, - Literal { - kind: ByteStr, - symbol: "B", - suffix: Some("q"), - span: $DIR/dump-debug-span-debug.rs:37:5: 37:10 (#0), - }, - Literal { - kind: StrRaw(0), - symbol: "R", - suffix: Some("q"), - span: $DIR/dump-debug-span-debug.rs:38:5: 38:10 (#0), - }, - Literal { - kind: StrRaw(2), - symbol: "R", - suffix: Some("q"), - span: $DIR/dump-debug-span-debug.rs:39:5: 39:14 (#0), - }, - Literal { - kind: ByteStrRaw(0), - symbol: "BR", - suffix: Some("q"), - span: $DIR/dump-debug-span-debug.rs:40:5: 40:12 (#0), - }, - Literal { - kind: ByteStrRaw(2), - symbol: "BR", - suffix: Some("q"), - span: $DIR/dump-debug-span-debug.rs:41:5: 41:16 (#0), - }, - Literal { - kind: Char, - symbol: "C", - suffix: Some("q"), - span: $DIR/dump-debug-span-debug.rs:42:5: 42:9 (#0), - }, - Literal { - kind: Byte, - symbol: "B", - suffix: Some("q"), - span: $DIR/dump-debug-span-debug.rs:43:5: 43:10 (#0), - }, ] diff --git a/src/test/ui/proc-macro/debug/dump-debug.rs b/src/test/ui/proc-macro/debug/dump-debug.rs index 0ed36b690f49b..f906e80f25bf8 100644 --- a/src/test/ui/proc-macro/debug/dump-debug.rs +++ b/src/test/ui/proc-macro/debug/dump-debug.rs @@ -23,18 +23,6 @@ dump_debug! { br##"BR"## 'C' b'B' - - // suffixed literals - 0q - 1.0q - "S"q - b"B"q - r"R"q - r##"R"##q - br"BR"q - br##"BR"##q - 'C'q - b'B'q } fn main() {} diff --git a/src/test/ui/proc-macro/debug/dump-debug.stderr b/src/test/ui/proc-macro/debug/dump-debug.stderr index db422b6012aea..b4f51a0cfdd74 100644 --- a/src/test/ui/proc-macro/debug/dump-debug.stderr +++ b/src/test/ui/proc-macro/debug/dump-debug.stderr @@ -1,4 +1,4 @@ -TokenStream [Ident { ident: "ident", span: #0 bytes(130..135) }, Ident { ident: "r#ident", span: #0 bytes(151..158) }, Punct { ch: ',', spacing: Alone, span: #0 bytes(176..177) }, Punct { ch: '=', spacing: Joint, span: #0 bytes(203..204) }, Punct { ch: '=', spacing: Joint, span: #0 bytes(204..205) }, Punct { ch: '>', spacing: Alone, span: #0 bytes(205..206) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: #0 bytes(230..232) }, Group { delimiter: Bracket, stream: TokenStream [Ident { ident: "_", span: #0 bytes(258..259) }], span: #0 bytes(257..260) }, Literal { kind: Integer, symbol: "0", suffix: None, span: #0 bytes(315..316) }, Literal { kind: Float, symbol: "1.0", suffix: None, span: #0 bytes(321..324) }, Literal { kind: Str, symbol: "S", suffix: None, span: #0 bytes(329..332) }, Literal { kind: ByteStr, symbol: "B", suffix: None, span: #0 bytes(337..341) }, Literal { kind: StrRaw(0), symbol: "R", suffix: None, span: #0 bytes(346..350) }, Literal { kind: StrRaw(2), symbol: "R", suffix: None, span: #0 bytes(355..363) }, Literal { kind: ByteStrRaw(0), symbol: "BR", suffix: None, span: #0 bytes(368..374) }, Literal { kind: ByteStrRaw(2), symbol: "BR", suffix: None, span: #0 bytes(379..389) }, Literal { kind: Char, symbol: "C", suffix: None, span: #0 bytes(394..397) }, Literal { kind: Byte, symbol: "B", suffix: None, span: #0 bytes(402..406) }, Literal { kind: Integer, symbol: "0", suffix: Some("q"), span: #0 bytes(437..439) }, Literal { kind: Float, symbol: "1.0", suffix: Some("q"), span: #0 bytes(444..448) }, Literal { kind: Str, symbol: "S", suffix: Some("q"), span: #0 bytes(453..457) }, Literal { kind: ByteStr, symbol: "B", suffix: Some("q"), span: #0 bytes(462..467) }, Literal { kind: StrRaw(0), symbol: "R", suffix: Some("q"), span: #0 bytes(472..477) }, Literal { kind: StrRaw(2), symbol: "R", suffix: Some("q"), span: #0 bytes(482..491) }, Literal { kind: ByteStrRaw(0), symbol: "BR", suffix: Some("q"), span: #0 bytes(496..503) }, Literal { kind: ByteStrRaw(2), symbol: "BR", suffix: Some("q"), span: #0 bytes(508..519) }, Literal { kind: Char, symbol: "C", suffix: Some("q"), span: #0 bytes(524..528) }, Literal { kind: Byte, symbol: "B", suffix: Some("q"), span: #0 bytes(533..538) }] +TokenStream [Ident { ident: "ident", span: #0 bytes(130..135) }, Ident { ident: "r#ident", span: #0 bytes(151..158) }, Punct { ch: ',', spacing: Alone, span: #0 bytes(176..177) }, Punct { ch: '=', spacing: Joint, span: #0 bytes(203..204) }, Punct { ch: '=', spacing: Joint, span: #0 bytes(204..205) }, Punct { ch: '>', spacing: Alone, span: #0 bytes(205..206) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: #0 bytes(230..232) }, Group { delimiter: Bracket, stream: TokenStream [Ident { ident: "_", span: #0 bytes(258..259) }], span: #0 bytes(257..260) }, Literal { kind: Integer, symbol: "0", suffix: None, span: #0 bytes(315..316) }, Literal { kind: Float, symbol: "1.0", suffix: None, span: #0 bytes(321..324) }, Literal { kind: Str, symbol: "S", suffix: None, span: #0 bytes(329..332) }, Literal { kind: ByteStr, symbol: "B", suffix: None, span: #0 bytes(337..341) }, Literal { kind: StrRaw(0), symbol: "R", suffix: None, span: #0 bytes(346..350) }, Literal { kind: StrRaw(2), symbol: "R", suffix: None, span: #0 bytes(355..363) }, Literal { kind: ByteStrRaw(0), symbol: "BR", suffix: None, span: #0 bytes(368..374) }, Literal { kind: ByteStrRaw(2), symbol: "BR", suffix: None, span: #0 bytes(379..389) }, Literal { kind: Char, symbol: "C", suffix: None, span: #0 bytes(394..397) }, Literal { kind: Byte, symbol: "B", suffix: None, span: #0 bytes(402..406) }] TokenStream [ Ident { ident: "ident", @@ -103,64 +103,4 @@ TokenStream [ suffix: None, span: #0 bytes(402..406), }, - Literal { - kind: Integer, - symbol: "0", - suffix: Some("q"), - span: #0 bytes(437..439), - }, - Literal { - kind: Float, - symbol: "1.0", - suffix: Some("q"), - span: #0 bytes(444..448), - }, - Literal { - kind: Str, - symbol: "S", - suffix: Some("q"), - span: #0 bytes(453..457), - }, - Literal { - kind: ByteStr, - symbol: "B", - suffix: Some("q"), - span: #0 bytes(462..467), - }, - Literal { - kind: StrRaw(0), - symbol: "R", - suffix: Some("q"), - span: #0 bytes(472..477), - }, - Literal { - kind: StrRaw(2), - symbol: "R", - suffix: Some("q"), - span: #0 bytes(482..491), - }, - Literal { - kind: ByteStrRaw(0), - symbol: "BR", - suffix: Some("q"), - span: #0 bytes(496..503), - }, - Literal { - kind: ByteStrRaw(2), - symbol: "BR", - suffix: Some("q"), - span: #0 bytes(508..519), - }, - Literal { - kind: Char, - symbol: "C", - suffix: Some("q"), - span: #0 bytes(524..528), - }, - Literal { - kind: Byte, - symbol: "B", - suffix: Some("q"), - span: #0 bytes(533..538), - }, ]