diff --git a/compiler/rustc_ast/src/ast_traits.rs b/compiler/rustc_ast/src/ast_traits.rs index 56d8aa98ae515..e1d58fda8e658 100644 --- a/compiler/rustc_ast/src/ast_traits.rs +++ b/compiler/rustc_ast/src/ast_traits.rs @@ -231,13 +231,11 @@ impl HasTokens for Attribute { impl HasTokens for Nonterminal { fn tokens(&self) -> Option<&LazyAttrTokenStream> { match self { - Nonterminal::NtExpr(expr) | Nonterminal::NtLiteral(expr) => expr.tokens(), Nonterminal::NtIdent(..) | Nonterminal::NtLifetime(..) => None, } } fn tokens_mut(&mut self) -> Option<&mut Option> { match self { - Nonterminal::NtExpr(expr) | Nonterminal::NtLiteral(expr) => expr.tokens_mut(), Nonterminal::NtIdent(..) | Nonterminal::NtLifetime(..) => None, } } diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index dcd27e6a589e3..cc6805cf6cc40 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -823,10 +823,8 @@ pub fn visit_token(t: &mut Token, vis: &mut T) { // multiple items there.... pub fn visit_nonterminal(nt: &mut token::Nonterminal, vis: &mut T) { match nt { - token::NtExpr(expr) => vis.visit_expr(expr), token::NtIdent(ident, _is_raw) => vis.visit_ident(ident), token::NtLifetime(ident) => vis.visit_ident(ident), - token::NtLiteral(expr) => vis.visit_expr(expr), } } diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 22eba1340ee7d..07e651d74e0ad 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -4,7 +4,6 @@ pub use Nonterminal::*; pub use TokenKind::*; use crate::ast; -use crate::ptr::P; use crate::util::case::Case; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -134,16 +133,27 @@ impl Lit { } } - /// Keep this in sync with `Token::can_begin_literal_maybe_minus` excluding unary negation. + /// Keep this in sync with `Token::can_begin_literal_maybe_minus` and + /// `Parser::maybe_parse_token_lit` (excluding unary negation). pub fn from_token(token: &Token) -> Option { match token.uninterpolate().kind { Ident(name, IdentIsRaw::No) if name.is_bool_lit() => Some(Lit::new(Bool, name, None)), Literal(token_lit) => Some(token_lit), - Interpolated(ref nt) - if let NtExpr(expr) | NtLiteral(expr) = &nt.0 - && let ast::ExprKind::Lit(token_lit) = expr.kind => - { - Some(token_lit) + OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar(NonterminalKind::Literal))) => { + panic!("njn: FROM_TOKEN (1)"); + // if let NtExpr(expr) | NtLiteral(expr) = &**nt + // && let ast::ExprKind::Lit(token_lit) = expr.kind => + // { + // Some(token_lit) + // } + } + OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar(NonterminalKind::Expr))) => { + panic!("njn: FROM_TOKEN (2)"); + // if let NtExpr(expr) | NtLiteral(expr) = &**nt + // && let ast::ExprKind::Lit(token_lit) = expr.kind => + // { + // Some(token_lit) + // } } _ => None, } @@ -462,6 +472,7 @@ impl Token { Token::new(Ident(ident.name, ident.is_raw_guess().into()), ident.span) } + /// njn: phase this out in favour of Parser::uninterpolated_span /// For interpolated tokens, returns a span of the fragment to which the interpolated /// token refers. For all other tokens this is just a regular span. /// It is particularly important to use this for identifiers and lifetimes @@ -516,7 +527,6 @@ impl Token { PathSep | // global path Lifetime(..) | // labeled loop Pound => true, // expression attributes - Interpolated(ref nt) => matches!(&nt.0, NtLiteral(..) | NtExpr(..)), OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar( NonterminalKind::Block | NonterminalKind::Expr | @@ -543,7 +553,6 @@ impl Token { | DotDot | DotDotDot | DotDotEq // ranges | Lt | BinOp(Shl) // associated path | PathSep => true, // global path - Interpolated(ref nt) => matches!(&nt.0, NtLiteral(..)), OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar( NonterminalKind::Block | NonterminalKind::PatParam { .. } | @@ -584,7 +593,6 @@ impl Token { pub fn can_begin_const_arg(&self) -> bool { match self.kind { OpenDelim(Delimiter::Brace) => true, - Interpolated(ref nt) => matches!(&nt.0, NtExpr(..) | NtLiteral(..)), OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar( NonterminalKind::Expr | NonterminalKind::Block | NonterminalKind::Literal, ))) => true, @@ -627,22 +635,24 @@ impl Token { /// /// In other words, would this token be a valid start of `parse_literal_maybe_minus`? /// - /// Keep this in sync with and `Lit::from_token`, excluding unary negation. + /// Keep this in sync with `Lit::from_token` and + /// `Parser::maybe_parse_token_lit` (excluding unary negation). pub fn can_begin_literal_maybe_minus(&self) -> bool { match self.uninterpolate().kind { Literal(..) | BinOp(Minus) => true, Ident(name, IdentIsRaw::No) if name.is_bool_lit() => true, - Interpolated(ref nt) => match &nt.0 { - NtLiteral(_) => true, - NtExpr(e) => match &e.kind { - ast::ExprKind::Lit(_) => true, - ast::ExprKind::Unary(ast::UnOp::Neg, e) => { - matches!(&e.kind, ast::ExprKind::Lit(_)) - } - _ => false, - }, - _ => false, - }, + // njn: fix up + // Interpolated(ref nt) => match &nt.0 { + // NtLiteral(_) => true, + // NtExpr(e) => match &e.kind { + // ast::ExprKind::Lit(_) => true, + // ast::ExprKind::Unary(ast::UnOp::Neg, e) => { + // matches!(&e.kind, ast::ExprKind::Lit(_)) + // } + // _ => false, + // }, + // _ => false, + // }, // njn: too simple compared to what's above? OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar( NonterminalKind::Literal | NonterminalKind::Expr, @@ -662,7 +672,6 @@ impl Token { Cow::Owned(Token::new(Ident(ident.name, *is_raw), ident.span)) } NtLifetime(ident) => Cow::Owned(Token::new(Lifetime(ident.name), ident.span)), - _ => Cow::Borrowed(self), }, _ => Cow::Borrowed(self), } @@ -712,22 +721,19 @@ impl Token { self.ident().is_some_and(|(ident, _)| ident.name == name) } - /// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`? + /// Would `maybe_reparse_metavar_expr` in `parser.rs` return `Ok(..)`? /// That is, is this a pre-parsed expression dropped into the token stream /// (which happens while parsing the result of macro expansion)? - pub fn is_whole_expr(&self) -> bool { - if let Interpolated(nt) = &self.kind - && let NtExpr(_) | NtLiteral(_) = &nt.0 - { - true - } else if matches!( + pub fn is_metavar_expr(&self) -> bool { + matches!( self.is_metavar_seq(), - Some(NonterminalKind::Block | NonterminalKind::Path) - ) { - true - } else { - false - } + Some( + NonterminalKind::Expr + | NonterminalKind::Literal + | NonterminalKind::Block + | NonterminalKind::Path + ) + ) } /// Are we at a block from a metavar (`$b:block`)? @@ -895,10 +901,8 @@ impl PartialEq for Token { #[derive(Clone, Encodable, Decodable)] /// For interpolation during macro expansion. pub enum Nonterminal { - NtExpr(P), NtIdent(Ident, IdentIsRaw), NtLifetime(Ident), - NtLiteral(P), } #[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)] @@ -982,15 +986,12 @@ impl fmt::Display for NonterminalKind { impl Nonterminal { pub fn use_span(&self) -> Span { match self { - NtExpr(expr) | NtLiteral(expr) => expr.span, NtIdent(ident, _) | NtLifetime(ident) => ident.span, } } pub fn descr(&self) -> &'static str { match self { - NtExpr(..) => "expression", - NtLiteral(..) => "literal", NtIdent(..) => "identifier", NtLifetime(..) => "lifetime", } @@ -1016,9 +1017,7 @@ impl PartialEq for Nonterminal { impl fmt::Debug for Nonterminal { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { - NtExpr(..) => f.pad("NtExpr(..)"), NtIdent(..) => f.pad("NtIdent(..)"), - NtLiteral(..) => f.pad("NtLiteral(..)"), NtLifetime(..) => f.pad("NtLifetime(..)"), } } diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 1105bf10228ec..4d6925ac615b5 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -483,7 +483,6 @@ impl TokenStream { Nonterminal::NtLifetime(ident) => { TokenStream::token_alone(token::Lifetime(ident.name), ident.span) } - Nonterminal::NtExpr(expr) | Nonterminal::NtLiteral(expr) => TokenStream::from_ast(expr), } } diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 21402d1b2d289..dce5ddf95a39c 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -844,10 +844,8 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere fn nonterminal_to_string(&self, nt: &Nonterminal) -> String { match nt { - token::NtExpr(e) => self.expr_to_string(e), &token::NtIdent(e, is_raw) => IdentPrinter::for_ast_ident(e, is_raw.into()).to_string(), token::NtLifetime(e) => e.to_string(), - token::NtLiteral(e) => self.expr_to_string(e), } } diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index bd3f652057575..8741d6f9b7a8e 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -254,6 +254,9 @@ pub(super) fn transcribe<'a>( // Emit as a token stream within `Delimiter::Invisible` to maintain parsing // priorities. marker.visit_span(&mut sp); + // njn: `sp` usage here means that both the open delim + // and close delim end up with the same span, which + // covers the `$foo` in the decl macro RHS TokenTree::Delimited( DelimSpan::from_single(sp), DelimSpacing::new(Spacing::Alone, Spacing::Alone), @@ -289,6 +292,12 @@ pub(super) fn transcribe<'a>( MatchedSingle(ParseNtResult::PatWithOr(ref pat)) => { mk_delimited(NonterminalKind::PatWithOr, TokenStream::from_ast(pat)) } + MatchedSingle(ParseNtResult::Expr(ref expr)) => { + mk_delimited(NonterminalKind::Expr, TokenStream::from_ast(expr)) + } + MatchedSingle(ParseNtResult::Literal(ref expr)) => { + mk_delimited(NonterminalKind::Literal, TokenStream::from_ast(expr)) + } MatchedSingle(ParseNtResult::Ty(ref ty)) => { mk_delimited(NonterminalKind::Ty, TokenStream::from_ast(ty)) } diff --git a/compiler/rustc_index/src/bit_set/tests.rs b/compiler/rustc_index/src/bit_set/tests.rs index 351d62feed949..2819f24372623 100644 --- a/compiler/rustc_index/src/bit_set/tests.rs +++ b/compiler/rustc_index/src/bit_set/tests.rs @@ -302,7 +302,7 @@ fn chunked_bitset() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x8000_0000_0000_0000 ])), - ], + ], // njn: trailing comma here causes a crash in reparse_metavar_seq? ); assert_eq!(b4096.count(), 2); b4096.assert_valid(); @@ -336,7 +336,7 @@ fn chunked_bitset() { ])), Zeros(2048), Zeros(1808), - ], + ], // njn: trailing comma here causes a crash in reparse_metavar_seq? ); let mut b10000b = ChunkedBitSet::::new_empty(10000); b10000b.clone_from(&b10000); diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index c65e0c43377c8..5e52f4e6d74e5 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -803,7 +803,7 @@ parse_unexpected_parentheses_in_match_arm_pattern = unexpected parentheses surro parse_unexpected_self_in_generic_parameters = unexpected keyword `Self` in generic parameters .note = you cannot use `Self` as a generic parameter because it is reserved for associated items -parse_unexpected_token_after_dot = unexpected token: `{$actual}` +parse_unexpected_token_after_dot = unexpected token: {$actual} parse_unexpected_token_after_label = expected `while`, `for`, `loop` or `{"{"}` after a label .suggestion_remove_label = consider removing the label diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index aeccab5d88f48..728750e1ee3d9 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -1600,10 +1600,10 @@ pub(crate) struct SelfArgumentPointer { #[derive(Diagnostic)] #[diag(parse_unexpected_token_after_dot)] -pub struct UnexpectedTokenAfterDot<'a> { +pub struct UnexpectedTokenAfterDot { #[primary_span] pub span: Span, - pub actual: Cow<'a, str>, + pub actual: String, } #[derive(Diagnostic)] diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 69790eb4871c9..9bbd705778d28 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -3,8 +3,9 @@ use super::diagnostics::SnapshotParser; use super::pat::{CommaRecoveryMode, Expected, RecoverColon, RecoverComma}; use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{ - AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Recovered, Restrictions, - SemiColonMode, SeqSep, TokenExpectType, TokenType, Trailing, TrailingToken, + AttrWrapper, BlockMode, ClosureSpans, ForceCollect, ParseNtResult, Parser, PathStyle, + Recovered, Restrictions, SemiColonMode, SeqSep, TokenExpectType, TokenType, Trailing, + TrailingToken, }; use crate::errors; @@ -15,7 +16,7 @@ use ast::{CoroutineKind, ForLoopKind, GenBlockKind, MatchKind, Pat, Path, PathSe use core::mem; use core::ops::ControlFlow; use rustc_ast::ptr::P; -use rustc_ast::token::{self, Delimiter, Token, TokenKind}; +use rustc_ast::token::{self, Delimiter, InvisibleOrigin, NonterminalKind, Token, TokenKind}; use rustc_ast::util::case::Case; use rustc_ast::util::classify; use rustc_ast::util::parser::{prec_let_scrutinee_needs_par, AssocOp, Fixity}; @@ -37,23 +38,27 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{BytePos, ErrorGuaranteed, Pos, Span}; use thin_vec::{thin_vec, ThinVec}; -/// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression -/// dropped into the token stream, which happens while parsing the result of -/// macro expansion). Placement of these is not as complex as I feared it would -/// be. The important thing is to make sure that lookahead doesn't balk at -/// `token::Interpolated` tokens. -macro_rules! maybe_whole_expr { +/// Possibly reparse an expression produced from a metavar during declarative +/// macro expansion. +macro_rules! maybe_reparse_metavar_expr { ($p:expr) => { let span = $p.token.span; - if let token::Interpolated(nt) = &$p.token.kind { - match &nt.0 { - token::NtExpr(e) | token::NtLiteral(e) => { - let e = e.clone(); - $p.bump(); - return Ok(e); - } - _ => {} - }; + if let Some(expr) = crate::maybe_reparse_metavar_seq!( + $p, + token::NonterminalKind::Expr, + token::NonterminalKind::Expr, + super::ParseNtResult::Expr(expr), + expr + ) { + return Ok(expr); + } else if let Some(lit) = crate::maybe_reparse_metavar_seq!( + $p, + token::NonterminalKind::Literal, + token::NonterminalKind::Literal, + super::ParseNtResult::Literal(lit), + lit + ) { + return Ok(lit); } else if let Some(block) = crate::maybe_reparse_metavar_seq!( $p, token::NonterminalKind::Block, @@ -684,7 +689,7 @@ impl<'a> Parser<'a> { // can't continue an expression after an ident token::Ident(name, is_raw) => token::ident_can_begin_expr(name, t.span, is_raw), token::Literal(..) | token::Pound => true, - _ => t.is_whole_expr(), + _ => t.is_metavar_expr(), }; self.token.is_ident_named(sym::not) && self.look_ahead(1, token_cannot_continue_expr) } @@ -721,6 +726,14 @@ impl<'a> Parser<'a> { TokenKind::OpenDelim(Delimiter::Invisible(_)) => { panic!("njn: invis-delim?"); } + TokenKind::CloseDelim(Delimiter::Invisible(_)) => { + // njn: needed? + // `expr.span` is the interpolated span, because invisible open + // and close delims both get marked with the same span, one + // that covers the entire thing between them. (See + // `rustc_expand::mbe::transcribe::transcribe`.) + self.prev_token.span + } _ => expr.span, } } @@ -1069,13 +1082,19 @@ impl<'a> Parser<'a> { } fn error_unexpected_after_dot(&self) { - let actual = pprust::token_to_string(&self.token); + let actual = super::token_descr(&self.token); let span = self.token.span; let sm = self.psess.source_map(); let (span, actual) = match (&self.token.kind, self.subparser_name) { (token::Eof, Some(_)) if let Ok(actual) = sm.span_to_snippet(sm.next_point(span)) => { - (span.shrink_to_hi(), actual.into()) + // njn: o.rs: used for the `)` + (span.shrink_to_hi(), format!("`{}`", actual)) + } + (token::CloseDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar(_))), _) => { + // njn: hack: do nothing, explain why + return; } + // njn: o.rs: used for the `` _ => (span, actual), }; self.dcx().emit_err(errors::UnexpectedTokenAfterDot { span, actual }); @@ -1436,7 +1455,7 @@ impl<'a> Parser<'a> { /// correctly if called from `parse_dot_or_call_expr()`. fn parse_expr_bottom(&mut self) -> PResult<'a, P> { maybe_recover_from_interpolated_ty_qpath!(self, true); - maybe_whole_expr!(self); + maybe_reparse_metavar_expr!(self); // Outer attributes are already parsed and will be // added to the return value after the fact. @@ -2140,49 +2159,134 @@ impl<'a> Parser<'a> { recovered } + /// njn: needed? correct? + /// Keep this in sync with `Token::can_begin_literal_maybe_minus` and + /// `Lit::from_token` (excluding unary negation). + pub fn maybe_parse_token_lit(&mut self) -> Option { + match self.token.uninterpolate().kind { + token::Ident(name, IdentIsRaw::No) if name.is_bool_lit() => { + self.bump(); + Some(token::Lit::new(token::Bool, name, None)) + } + token::Literal(token_lit) => { + self.bump(); + Some(token_lit) + } + token::OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar( + NonterminalKind::Literal, + ))) => { + let lit = crate::reparse_metavar_seq!( + self, + NonterminalKind::Literal, + ParseNtResult::Literal(lit), + lit + ); + let ast::ExprKind::Lit(token_lit) = lit.kind else { + panic!("didn't reparse a literal"); + }; + Some(token_lit) + } + token::OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar( + NonterminalKind::Expr, + ))) => { + let mut self2 = self.clone(); // njn: ugh + let expr = crate::reparse_metavar_seq!( + self2, + NonterminalKind::Expr, + ParseNtResult::Expr(expr), + expr + ); + if let ast::ExprKind::Lit(token_lit) = expr.kind { + *self = self2; + Some(token_lit) + } else { + None + } + } + _ => None, + } + } + /// Matches `lit = true | false | token_lit`. /// Returns `None` if the next token is not a literal. - pub(super) fn parse_opt_token_lit(&mut self) -> Option<(token::Lit, Span)> { - let recovered = self.recover_after_dot(); - let token = recovered.as_ref().unwrap_or(&self.token); - let span = token.span; - - token::Lit::from_token(token).map(|token_lit| { - self.bump(); - (token_lit, span) - }) + // njn: correct? + // fn parse_opt_token_lit(&mut self) -> Option<(token::Lit, Span)> { + // let recovered = self.recover_after_dot(); + // let token = recovered.as_ref().unwrap_or(&self.token); + // let span = token.span; + + // token::Lit::from_token(token).map(|token_lit| { + // self.bump(); + // (token_lit, span) + // }) + // } + fn parse_opt_token_lit(&mut self) -> Option<(token::Lit, Span)> { + match self.recover_after_dot() { + Some(recovered) => self.token = recovered, + None => {} + } + let span = self.token.span; + self.maybe_parse_token_lit().map(|token_lit| (token_lit, span)) } /// Matches `lit = true | false | token_lit`. /// Returns `None` if the next token is not a literal. - pub(super) fn parse_opt_meta_item_lit(&mut self) -> Option { - let recovered = self.recover_after_dot(); - let token = recovered.as_ref().unwrap_or(&self.token); - match token::Lit::from_token(token) { - Some(lit) => { - match MetaItemLit::from_token_lit(lit, token.span) { - Ok(lit) => { - self.bump(); - Some(lit) - } - Err(err) => { - let span = token.uninterpolated_span(); - self.bump(); - let guar = report_lit_error(self.psess, err, lit, 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(guar), symbol, lit.suffix); - Some( - MetaItemLit::from_token_lit(lit, span) - .unwrap_or_else(|_| unreachable!()), - ) - } + // njn: correct? + // pub(super) fn parse_opt_meta_item_lit(&mut self) -> Option { + // let recovered = self.recover_after_dot(); + // let token = recovered.as_ref().unwrap_or(&self.token); + // match token::Lit::from_token(token) { + // Some(lit) => { + // match MetaItemLit::from_token_lit(lit, token.span) { + // Ok(lit) => { + // self.bump(); + // Some(lit) + // } + // Err(err) => { + // let span = token.uninterpolated_span(); + // self.bump(); + // let guar = report_lit_error(self.psess, err, lit, 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(guar), symbol, lit.suffix); + // Some( + // MetaItemLit::from_token_lit(lit, span) + // .unwrap_or_else(|_| unreachable!()), + // ) + // } + // } + // } + // None => None, + // } + // } + fn parse_opt_meta_item_lit(&mut self) -> Option { + match self.recover_after_dot() { + Some(recovered) => self.token = recovered, + None => {} + } + // eprintln!("pre-pre-EMIT1 {:?}", self.token); + // self.look_ahead(1, |x| eprintln!("pre-pre-EMIT2 {x:?}")); + // self.look_ahead(2, |x| eprintln!("pre-pre-EMIT3 {x:?}")); + let span = self.token.span; + let span2 = self.uninterpolated_token_span(); // njn: not working + self.maybe_parse_token_lit().map(|token_lit| { + match MetaItemLit::from_token_lit(token_lit, span) { + Ok(lit) => lit, + Err(err) => { + // njn: clean up + // eprintln!("pre-EMIT {span:?}, {span2:?}"); + let guar = report_lit_error(&self.psess, err, token_lit, span2); + // 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(token_lit.kind, token_lit.symbol, None); + let symbol = Symbol::intern(&suffixless_lit.to_string()); + let token_lit = token::Lit::new(token::Err(guar), symbol, token_lit.suffix); + MetaItemLit::from_token_lit(token_lit, span2).unwrap_or_else(|_| unreachable!()) } } - None => None, - } + }) } pub(super) fn expect_no_tuple_index_suffix(&self, span: Span, suffix: Symbol) { @@ -2206,7 +2310,7 @@ impl<'a> Parser<'a> { /// Matches `'-' lit | lit` (cf. `ast_validation::AstValidator::check_expr_within_pat`). /// Keep this in sync with `Token::can_begin_literal_maybe_minus`. pub fn parse_literal_maybe_minus(&mut self) -> PResult<'a, P> { - maybe_whole_expr!(self); + maybe_reparse_metavar_expr!(self); let lo = self.token.span; let minus_present = self.eat(&token::BinOp(token::Minus)); diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 146b8d0430bb5..1aeb08c83be95 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1219,6 +1219,8 @@ impl<'a> Parser<'a> { self.token.is_keyword(kw::Unsafe) && self.is_keyword_ahead(1, &[kw::Extern]) && self.look_ahead( + // njn: won't work with interpolate? + // njn: need to check all look_ahead calls for problems? 2 + self.look_ahead(2, |t| t.can_begin_literal_maybe_minus() as usize), |t| t.kind == token::OpenDelim(Delimiter::Brace), ) @@ -2413,12 +2415,15 @@ impl<'a> Parser<'a> { }) // `extern ABI fn` || self.check_keyword_case(kw::Extern, case) + // njn: explain tree_look_ahead && self.look_ahead(1, |t| t.can_begin_literal_maybe_minus()) - && (self.look_ahead(2, |t| t.is_keyword_case(kw::Fn, case)) || + && (self.tree_look_ahead(2, |t| t.is_keyword_case(kw::Fn, case)) == Some(true) || // this branch is only for better diagnostic in later, `pub` is not allowed here (self.may_recover() - && self.look_ahead(2, |t| t.is_keyword(kw::Pub)) - && self.look_ahead(3, |t| t.is_keyword_case(kw::Fn, case)))) + && self.tree_look_ahead(2, |t| t.is_keyword(kw::Pub)) == Some(true) + && self.tree_look_ahead(3, |t| t.is_keyword_case(kw::Fn, case)) == Some(true) + ) + ) } /// Parses all the "front matter" (or "qualifiers") for a `fn` declaration, diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 9cc35ffcf1e3b..ef2b352654e92 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -101,7 +101,23 @@ macro_rules! reparse_metavar_seq { let Ok($nt_res) = $p.parse_nonterminal($nt_kind) else { panic!("failed to reparse"); }; - $p.expect(&token::CloseDelim(delim)).expect("no close delim when reparsing"); + // njn: sometimes with expressions we get a trailing comma, possibly + // related to the FIXME in `collect_tokens_for_expr`. + if $nt_kind == NonterminalKind::Expr && matches!($p.token.kind, token::TokenKind::Comma) { + $p.bump(); + } + //$p.expect(&token::CloseDelim(delim)).expect("no close delim when reparsing"); + let res = $p.expect(&token::CloseDelim(delim)); + match res { + Ok(_) => {} + // njn: no close delim when reparsing: Token { kind: Comma, span: + // compiler/rustc_index/src/bit_set/tests.rs:305:10: 305:11 (#0) } + Err(_) => { + eprintln!("no close delim when reparsing: {:?}", $p.token); + $p.bump(); + panic!("no close delim when reparsing2: {:?}", $p.token); + } + } $ret }}; } @@ -1229,6 +1245,32 @@ impl<'a> Parser<'a> { looker(&token) } + /// njn: comment, explain non-zero dist requirements + pub fn tree_look_ahead( + // njn: remove Debug + &self, + dist: usize, + looker: impl FnOnce(&Token) -> R, + ) -> Option { + assert_ne!(dist, 0); + + let tree_cursor = self.token_cursor.tree_cursor.clone(); + // njn: remove x and y + let x = tree_cursor.look_ahead(dist - 1); + //eprintln!("x = `{x:#?}`"); + match x { + Some(TokenTree::Token(token, _)) => { + let y = Some(looker(token)); + //eprintln!("=> {y:?}"); + y + } + _ => { + //eprintln!("=> None"); + None + } + } + } + /// Returns whether any of the given keywords are `dist` tokens ahead of the current one. pub(crate) fn is_keyword_ahead(&self, dist: usize, kws: &[Symbol]) -> bool { self.look_ahead(dist, |t| kws.iter().any(|&kw| t.is_keyword(kw))) @@ -1608,6 +1650,22 @@ impl<'a> Parser<'a> { pub fn approx_token_stream_pos(&self) -> usize { self.num_bump_calls } + + // njn: comment + // njn: rename? + pub fn uninterpolated_token_span(&self) -> Span { + match &self.token.kind { + token::Interpolated(nt) => nt.0.use_span(), // njn: or nt.1? + // njn: this pretty much assumes that it'll be a single token + // between the invisible delims. True for ident, lifetime, most + // literals, not true for `-1`. Could try to be more precise, match + // on the NonterminalKind as well + token::OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar(_))) => { + self.look_ahead(1, |t| t.span) + } + _ => self.token.span, + } + } } pub(crate) fn make_unclosed_delims_error( @@ -1662,6 +1720,8 @@ pub enum ParseNtResult { Stmt(P), PatParam(P, /* inferred */ bool), PatWithOr(P), + Expr(P), // njn: combine with Literal? + Literal(P), Ty(P), Meta(P), Path(P), @@ -1683,6 +1743,8 @@ impl ParseNtResult { ParseNtResult::Stmt(x) => ParseNtResult::Stmt(x), ParseNtResult::PatParam(x, inf) => ParseNtResult::PatParam(x, inf), ParseNtResult::PatWithOr(x) => ParseNtResult::PatWithOr(x), + ParseNtResult::Expr(x) => ParseNtResult::Expr(x), + ParseNtResult::Literal(x) => ParseNtResult::Literal(x), ParseNtResult::Ty(x) => ParseNtResult::Ty(x), ParseNtResult::Meta(x) => ParseNtResult::Meta(x), ParseNtResult::Path(x) => ParseNtResult::Path(x), diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index a6aef729275ef..8ae2e783bcfde 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -45,10 +45,7 @@ impl<'a> Parser<'a> { /// Old variant of `may_be_ident`. Being phased out. fn nt_may_be_ident(nt: &token::Nonterminal) -> bool { match nt { - NtExpr(_) - | NtIdent(..) - | NtLiteral(_) // `true`, `false` - => true, + NtIdent(..) => true, NtLifetime(_) => false, } @@ -76,7 +73,7 @@ impl<'a> Parser<'a> { NonterminalKind::Block => match &token.kind { token::OpenDelim(Delimiter::Brace) => true, token::Interpolated(nt) => match &nt.0 { - NtLifetime(_) | NtExpr(_) | NtLiteral(_) => true, + NtLifetime(_) => true, NtIdent(..) => false, }, token::OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar(k))) => match k { @@ -168,8 +165,8 @@ impl<'a> Parser<'a> { // While a block *expression* may have attributes (e.g. `#[my_attr] { ... }`), // the ':block' matcher does not support them return Ok(ParseNtResult::Block( - self.collect_tokens_no_attrs(|this| this.parse_block())?) - ) + self.collect_tokens_no_attrs(|this| this.parse_block())?, + )); } NonterminalKind::Stmt => match self.parse_stmt(ForceCollect::Yes)? { Some(stmt) => return Ok(ParseNtResult::Stmt(P(stmt))), @@ -195,10 +192,14 @@ impl<'a> Parser<'a> { ) })?)); } - NonterminalKind::Expr => NtExpr(self.parse_expr_force_collect()?), + NonterminalKind::Expr => { + return Ok(ParseNtResult::Expr(self.parse_expr_force_collect()?)); + } NonterminalKind::Literal => { // The `:literal` matcher does not support attributes - NtLiteral(self.collect_tokens_no_attrs(|this| this.parse_literal_maybe_minus())?) + return Ok(ParseNtResult::Literal( + self.collect_tokens_no_attrs(|this| this.parse_literal_maybe_minus())?, + )); } NonterminalKind::Ty => { diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 1dae53d2cf2ce..545f5d7cb8537 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -964,7 +964,7 @@ impl<'a> Parser<'a> { t.is_path_start() // e.g. `MY_CONST`; || t.kind == token::Dot // e.g. `.5` for recovery; || t.can_begin_literal_maybe_minus() // e.g. `42`. - || t.is_whole_expr() + || t.is_metavar_expr() || t.is_lifetime() // recover `'a` instead of `'a'` || (self.may_recover() // recover leading `(` && t.kind == token::OpenDelim(Delimiter::Parenthesis) diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index e312c8fc30070..fd39ba4290a1a 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -195,6 +195,7 @@ impl<'a> Parser<'a> { if let Some(NonterminalKind::Ty) = self.token.is_metavar_seq() { let mut self2 = self.clone(); let ty = + // njn: qual crate::reparse_metavar_seq!(self2, NonterminalKind::Ty, ParseNtResult::Ty(ty), ty); if let ast::TyKind::Path(None, path) = ty.into_inner().kind { *self = self2; diff --git a/tests/ui/attributes/nonterminal-expansion.rs b/tests/ui/attributes/nonterminal-expansion.rs index abc0c2d3fbbc4..ff1b279cd55e1 100644 --- a/tests/ui/attributes/nonterminal-expansion.rs +++ b/tests/ui/attributes/nonterminal-expansion.rs @@ -5,7 +5,7 @@ macro_rules! pass_nonterminal { ($n:expr) => { #[repr(align($n))] - //~^ ERROR expected unsuffixed literal or identifier, found expression `n!()` + //~^ ERROR expected unsuffixed literal or identifier, found `expr` metavariable struct S; }; } diff --git a/tests/ui/attributes/nonterminal-expansion.stderr b/tests/ui/attributes/nonterminal-expansion.stderr index 9d7be2c00eadc..ee19d78ce8fcb 100644 --- a/tests/ui/attributes/nonterminal-expansion.stderr +++ b/tests/ui/attributes/nonterminal-expansion.stderr @@ -1,4 +1,4 @@ -error: expected unsuffixed literal or identifier, found expression `n!()` +error: expected unsuffixed literal or identifier, found `expr` metavariable --> $DIR/nonterminal-expansion.rs:7:22 | LL | #[repr(align($n))] diff --git a/tests/ui/cfg/cfg-method-receiver.rs b/tests/ui/cfg/cfg-method-receiver.rs index 71134ff17b527..29b1ab432f836 100644 --- a/tests/ui/cfg/cfg-method-receiver.rs +++ b/tests/ui/cfg/cfg-method-receiver.rs @@ -8,4 +8,5 @@ macro_rules! cbor_map { fn main() { cbor_map! { #[cfg(test)] 4}; //~^ ERROR removing an expression is not supported in this position + //~| ERROR removing an expression is not supported in this position } diff --git a/tests/ui/cfg/cfg-method-receiver.stderr b/tests/ui/cfg/cfg-method-receiver.stderr index 5767a7c1b4b1c..90028c3bcce72 100644 --- a/tests/ui/cfg/cfg-method-receiver.stderr +++ b/tests/ui/cfg/cfg-method-receiver.stderr @@ -4,6 +4,14 @@ error: removing an expression is not supported in this position LL | cbor_map! { #[cfg(test)] 4}; | ^^^^^^^^^^^^ +error: removing an expression is not supported in this position + --> $DIR/cfg-method-receiver.rs:9:17 + | +LL | cbor_map! { #[cfg(test)] 4}; + | ^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0689]: can't call method `signum` on ambiguous numeric type `{integer}` --> $DIR/cfg-method-receiver.rs:3:14 | @@ -19,6 +27,6 @@ help: you must specify a concrete type for this numeric value, like `i32` LL | cbor_map! { #[cfg(test)] 4_i32}; | ~~~~~ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0689`. diff --git a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs index d3cf8a61b1d4e..ef3cebc7cc96e 100644 --- a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs +++ b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs @@ -28,8 +28,8 @@ struct S9; macro_rules! generate_s10 { ($expr: expr) => { #[cfg(feature = $expr)] - //~^ ERROR expected unsuffixed literal or identifier, found expression `concat!("nonexistent")` - //~| ERROR expected unsuffixed literal or identifier, found expression `concat!("nonexistent")` + //~^ ERROR expected unsuffixed literal or identifier, found `expr` metavariable + //~| ERROR expected unsuffixed literal or identifier, found `expr` metavariable struct S10; } } diff --git a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr index fd193836bc402..2184ac7267e25 100644 --- a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr +++ b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr @@ -54,7 +54,7 @@ LL | #[cfg(a = b"hi")] | | | help: consider removing the prefix -error: expected unsuffixed literal or identifier, found expression `concat!("nonexistent")` +error: expected unsuffixed literal or identifier, found `expr` metavariable --> $DIR/cfg-attr-syntax-validation.rs:30:25 | LL | #[cfg(feature = $expr)] @@ -65,7 +65,7 @@ LL | generate_s10!(concat!("nonexistent")); | = note: this error originates in the macro `generate_s10` (in Nightly builds, run with -Z macro-backtrace for more info) -error: expected unsuffixed literal or identifier, found expression `concat!("nonexistent")` +error: expected unsuffixed literal or identifier, found `expr` metavariable --> $DIR/cfg-attr-syntax-validation.rs:30:25 | LL | #[cfg(feature = $expr)] diff --git a/tests/ui/macros/issue-98790.rs b/tests/ui/macros/issue-98790.rs index de42335333241..0030ed607111b 100644 --- a/tests/ui/macros/issue-98790.rs +++ b/tests/ui/macros/issue-98790.rs @@ -21,6 +21,6 @@ fn main() { repro!(match () { () => true } | true), // njn: this is invalid syntax, bleh //"pub fn repro() -> bool { (match () { () => true, }) | true }" - "pub fn repro() -> bool { match () { () => true, } | true }" + "pub fn repro() -> bool { match () { () => true } | true }" ); } diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index d33ba16d5cea2..0f9c0a036ba72 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -37,25 +37,24 @@ macro_rules! vis { ($vis:vis) => { stringify!($vis) }; } // the same result (which is preferable.) macro_rules! c1 { ($frag:ident, [$($tt:tt)*], $s:literal) => { + // Prior to #124121: + // - the first of these two lines would create a + // `TokenKind::Interpolated` that would be printed with the AST + // pretty printer; + // - the second of these two lines would create a token stream that + // would be printed with the TokenStream pretty printer. + // + // Now `TokenKind::Interpolated` is gone and they are both printed with + // the TokenStream pretty printer. But it doesn't hurt to keep both + // assertions to check this is so. + // + // (This also explains the name `c1`. There used to be a `c2` macro for + // cases where the two pretty printers produced different output.) assert_eq!($frag!($($tt)*), $s); assert_eq!(stringify!($($tt)*), $s); }; } -// Use this when AST pretty-printing and TokenStream pretty-printing give -// different results. -// -// `c1` and `c2` could be in a single macro, but having them separate makes it -// easy to find the cases where the two pretty-printing approaches give -// different results. -macro_rules! c2 { - ($frag:ident, [$($tt:tt)*], $s1:literal, $s2:literal $(,)?) => { - assert_ne!($s1, $s2, "should use `c1!` instead"); - assert_eq!($frag!($($tt)*), $s1); - assert_eq!(stringify!($($tt)*), $s2); - }; -} - #[test] fn test_block() { c1!(block, [ {} ], "{}"); @@ -76,7 +75,7 @@ fn test_expr() { // ExprKind::Array c1!(expr, [ [] ], "[]"); c1!(expr, [ [true] ], "[true]"); - c2!(expr, [ [true,] ], "[true]", "[true,]"); + c1!(expr, [ [true,] ], "[true,]"); c1!(expr, [ [true, true] ], "[true, true]"); // ExprKind::ConstBlock @@ -85,11 +84,11 @@ fn test_expr() { // ExprKind::Call c1!(expr, [ f() ], "f()"); c1!(expr, [ f::() ], "f::()"); - c2!(expr, [ f :: < u8>( ) ], "f::()", "f :: < u8>()"); + c1!(expr, [ 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,)"); + c1!(expr, [ f(true,) ], "f(true,)"); c1!(expr, [ ()() ], "()()"); // ExprKind::MethodCall @@ -101,7 +100,7 @@ fn test_expr() { c1!(expr, [ () ], "()"); c1!(expr, [ (true,) ], "(true,)"); c1!(expr, [ (true, false) ], "(true, false)"); - c2!(expr, [ (true, false,) ], "(true, false)", "(true, false,)"); + c1!(expr, [ (true, false,) ], "(true, false,)"); // ExprKind::Binary c1!(expr, [ true || false ], "true || false"); @@ -131,16 +130,12 @@ fn test_expr() { c1!(expr, [ if let Some(a) = b { c } else { d } ], "if let Some(a) = b { c } else { d }"); c1!(expr, [ if let _ = true && false {} ], "if let _ = true && false {}"); c1!(expr, [ if let _ = (true && false) {} ], "if let _ = (true && false) {}"); - macro_rules! c2_if_let { - ($expr:expr, $expr_expected:expr, $tokens_expected:expr $(,)?) => { - c2!(expr, [ if let _ = $expr {} ], $expr_expected, $tokens_expected); + macro_rules! c1_if_let { + ($expr:expr, $s:literal) => { + c1!(expr, [ if let _ = $expr {} ], $s); }; } - c2_if_let!( - true && false, - "if let _ = (true && false) {}", - "if let _ = true && false {}", - ); + c1_if_let!(true && false, "if let _ = true && false {}"); c1!(expr, [ match () { _ if let _ = Struct {} => {} } ], "match () { _ if let _ = Struct {} => {} }" @@ -203,16 +198,12 @@ fn test_expr() { } ], "match self { Ok => 1, Err => 0, }" ); - macro_rules! c2_match_arm { - ([ $expr:expr ], $expr_expected:expr, $tokens_expected:expr $(,)?) => { - c2!(expr, [ match () { _ => $expr } ], $expr_expected, $tokens_expected); + macro_rules! c1_match_arm { + ([ $expr:expr ], $s:literal) => { + c1!(expr, [ match () { _ => $expr } ], $s); }; } - c2_match_arm!( - [ { 1 } - 1 ], - "match () { _ => ({ 1 }) - 1, }", - "match () { _ => { 1 } - 1 }", - ); + c1_match_arm!([ { 1 } - 1 ], "match () { _ => { 1 } - 1 }"); // ExprKind::Closure c1!(expr, [ || {} ], "|| {}"); @@ -227,22 +218,19 @@ fn test_expr() { c1!(expr, [ static async || self ], "static async || self"); c1!(expr, [ static async move || self ], "static async move || self"); c1!(expr, [ || -> u8 { self } ], "|| -> u8 { self }"); - c2!(expr, [ 1 + || {} ], "1 + (|| {})", "1 + || {}"); // AST?? + c1!(expr, [ 1 + || {} ], "1 + || {}"); // ExprKind::Block c1!(expr, [ {} ], "{}"); c1!(expr, [ unsafe {} ], "unsafe {}"); c1!(expr, [ 'a: {} ], "'a: {}"); c1!(expr, [ #[attr] {} ], "#[attr] {}"); - c2!(expr, + c1!(expr, [ { #![attr] } ], - "{\n\ - \x20 #![attr]\n\ - }", "{ #![attr] }" ); @@ -274,7 +262,7 @@ fn test_expr() { c1!(expr, [ ..hi ], "..hi"); c1!(expr, [ lo.. ], "lo.."); c1!(expr, [ lo..hi ], "lo..hi"); - c2!(expr, [ lo .. hi ], "lo..hi", "lo .. hi"); + c1!(expr, [ lo .. hi ], "lo .. hi"); c1!(expr, [ ..=hi ], "..=hi"); c1!(expr, [ lo..=hi ], "lo..=hi"); c1!(expr, [ -2..=-1 ], "-2..=-1"); @@ -650,7 +638,7 @@ fn test_stmt() { macro_rules! c1_expr_as_stmt { // Parse as expr, then reparse as stmt. // - // The c1_minus_one macro below can't directly call `c2!(stmt, ...)` + // The c1_minus_one macro below can't directly call `c1!(stmt, ...)` // because `$expr - 1` cannot be parsed directly as a stmt. A statement // boundary occurs after the `match void {}`, after which the `-` token // hits "no rules expected this token in macro call". diff --git a/tests/ui/macros/trace_faulty_macros.stderr b/tests/ui/macros/trace_faulty_macros.stderr index db96dead20629..6799966380bbc 100644 --- a/tests/ui/macros/trace_faulty_macros.stderr +++ b/tests/ui/macros/trace_faulty_macros.stderr @@ -98,9 +98,9 @@ LL | 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;` + = note: to `test! ((x, 1+1))` + = note: expanding `test! { (x, 1+1) }` + = note: to `let x = 1+1;` error: aborting due to 5 previous errors diff --git a/tests/ui/parser/float-field-interpolated.rs b/tests/ui/parser/float-field-interpolated.rs index 990f2926dc861..bf7163039c420 100644 --- a/tests/ui/parser/float-field-interpolated.rs +++ b/tests/ui/parser/float-field-interpolated.rs @@ -5,10 +5,10 @@ macro_rules! generate_field_accesses { let s = S(0, (0, 0)); s.$a; // OK - { s.$b; } //~ ERROR unexpected token: `1.1` - //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found literal `1.1` - { s.$c; } //~ ERROR unexpected token: `1.1` - //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found expression `1.1` + { s.$b; } //~ ERROR unexpected token: `literal` metavariable + //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `literal` metavariable + { s.$c; } //~ ERROR unexpected token: `expr` metavariable + //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `expr` metavariable }; } diff --git a/tests/ui/parser/float-field-interpolated.stderr b/tests/ui/parser/float-field-interpolated.stderr index 2a1a4926cb3c6..e2b7e3a7dbe75 100644 --- a/tests/ui/parser/float-field-interpolated.stderr +++ b/tests/ui/parser/float-field-interpolated.stderr @@ -1,4 +1,4 @@ -error: unexpected token: `1.1` +error: unexpected token: `literal` metavariable --> $DIR/float-field-interpolated.rs:8:13 | LL | { s.$b; } @@ -9,7 +9,7 @@ LL | generate_field_accesses!(1.1, 1.1, 1.1); | = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info) -error: expected one of `.`, `;`, `?`, `}`, or an operator, found literal `1.1` +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `literal` metavariable --> $DIR/float-field-interpolated.rs:8:13 | LL | { s.$b; } @@ -20,7 +20,7 @@ LL | generate_field_accesses!(1.1, 1.1, 1.1); | = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info) -error: unexpected token: `1.1` +error: unexpected token: `expr` metavariable --> $DIR/float-field-interpolated.rs:10:13 | LL | { s.$c; } @@ -31,7 +31,7 @@ LL | generate_field_accesses!(1.1, 1.1, 1.1); | = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info) -error: expected one of `.`, `;`, `?`, `}`, or an operator, found expression `1.1` +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `expr` metavariable --> $DIR/float-field-interpolated.rs:10:13 | LL | { s.$c; } diff --git a/tests/ui/parser/macro/trait-non-item-macros.rs b/tests/ui/parser/macro/trait-non-item-macros.rs index e93000193b6e3..b4140613cbae7 100644 --- a/tests/ui/parser/macro/trait-non-item-macros.rs +++ b/tests/ui/parser/macro/trait-non-item-macros.rs @@ -1,7 +1,7 @@ macro_rules! bah { ($a:expr) => { $a - }; //~^ ERROR macro expansion ignores expression `2` and any tokens following + }; //~^ ERROR macro expansion ignores `expr` metavariable and any tokens following } trait Bar { diff --git a/tests/ui/parser/macro/trait-non-item-macros.stderr b/tests/ui/parser/macro/trait-non-item-macros.stderr index 1a82848377895..62b42fa8b8dd7 100644 --- a/tests/ui/parser/macro/trait-non-item-macros.stderr +++ b/tests/ui/parser/macro/trait-non-item-macros.stderr @@ -1,4 +1,4 @@ -error: macro expansion ignores expression `2` and any tokens following +error: macro expansion ignores `expr` metavariable and any tokens following --> $DIR/trait-non-item-macros.rs:3:9 | LL | $a diff --git a/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout b/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout index 4df7812ad397b..6523f2485cd1f 100644 --- a/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout +++ b/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout @@ -1,5 +1,4 @@ -PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = #[allow(warnings)] 0; 0 }, } -PRINT-DERIVE DEEP-RE-COLLECTED (DISPLAY): enum E { V = { let _ = #[allow(warnings)] #[allow(warnings)] 0; 0 }, } +PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = #[allow(warnings)] #[allow(warnings)] 0; 0 }, } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "enum", diff --git a/tests/ui/proc-macro/macro-rules-derive-cfg.rs b/tests/ui/proc-macro/macro-rules-derive-cfg.rs index 68026a60be686..6b00963b668ff 100644 --- a/tests/ui/proc-macro/macro-rules-derive-cfg.rs +++ b/tests/ui/proc-macro/macro-rules-derive-cfg.rs @@ -2,6 +2,7 @@ //@ compile-flags: -Z span-debug --error-format human //@ aux-build:test-macros.rs +/* #![feature(rustc_attrs)] #![feature(stmt_expr_attributes)] @@ -27,5 +28,27 @@ produce_it!(#[cfg_attr(not(FALSE), rustc_dummy(second))] { #![cfg_attr(not(FALSE), allow(unused))] 30 }); +*/ fn main() {} + +/* njn: this test is failing. Getting this output with attributes repeated: + ++PRINT-DERIVE INPUT (DISPLAY): struct Foo ++{ ++ val : ++ [bool ; ++ { ++ let a = #[rustc_dummy(first)] #[rustc_dummy(second)] ++ #! [allow(unused)] #[rustc_dummy(second)] { #! [allow(unused)] 30 } ; ++ 0 ++ }] ++} ++ + +Plus the annoying: + + "error: test compilation failed although it shouldn't! + failed to decode compiler output as json: line: {" + +*/ diff --git a/tests/ui/proc-macro/macro-rules-derive-cfg.stdout b/tests/ui/proc-macro/macro-rules-derive-cfg.stdout deleted file mode 100644 index 257d59974b88d..0000000000000 --- a/tests/ui/proc-macro/macro-rules-derive-cfg.stdout +++ /dev/null @@ -1,180 +0,0 @@ -PRINT-DERIVE INPUT (DISPLAY): struct Foo -{ - val : - [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 - }] -} -PRINT-DERIVE INPUT (DEBUG): TokenStream [ - Ident { - ident: "struct", - span: $DIR/macro-rules-derive-cfg.rs:17:9: 17:15 (#3), - }, - Ident { - ident: "Foo", - span: $DIR/macro-rules-derive-cfg.rs:17:16: 17:19 (#3), - }, - Group { - delimiter: Brace, - stream: TokenStream [ - Ident { - ident: "val", - span: $DIR/macro-rules-derive-cfg.rs:18:13: 18:16 (#3), - }, - Punct { - ch: ':', - spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:18:16: 18:17 (#3), - }, - Group { - delimiter: Bracket, - stream: TokenStream [ - Ident { - ident: "bool", - span: $DIR/macro-rules-derive-cfg.rs:18:19: 18:23 (#3), - }, - Punct { - ch: ';', - spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:18:23: 18:24 (#3), - }, - Group { - delimiter: Brace, - stream: TokenStream [ - Ident { - ident: "let", - span: $DIR/macro-rules-derive-cfg.rs:19:17: 19:20 (#3), - }, - Ident { - ident: "a", - span: $DIR/macro-rules-derive-cfg.rs:19:21: 19:22 (#3), - }, - Punct { - ch: '=', - spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:19:23: 19:24 (#3), - }, - Punct { - ch: '#', - spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:19:25: 19:26 (#3), - }, - Group { - delimiter: Bracket, - stream: TokenStream [ - Ident { - ident: "rustc_dummy", - span: $DIR/macro-rules-derive-cfg.rs:19:48: 19:59 (#3), - }, - Group { - delimiter: Parenthesis, - stream: TokenStream [ - Ident { - ident: "first", - span: $DIR/macro-rules-derive-cfg.rs:19:60: 19:65 (#3), - }, - ], - span: $DIR/macro-rules-derive-cfg.rs:19:59: 19:66 (#3), - }, - ], - span: $DIR/macro-rules-derive-cfg.rs:19:25: 19:26 (#3), - }, - Punct { - ch: '#', - spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:26:13: 26:14 (#0), - }, - Group { - delimiter: Bracket, - stream: TokenStream [ - Ident { - ident: "rustc_dummy", - span: $DIR/macro-rules-derive-cfg.rs:26:36: 26:47 (#0), - }, - Group { - delimiter: Parenthesis, - stream: TokenStream [ - Ident { - ident: "second", - span: $DIR/macro-rules-derive-cfg.rs:26:48: 26:54 (#0), - }, - ], - span: $DIR/macro-rules-derive-cfg.rs:26:47: 26:55 (#0), - }, - ], - span: $DIR/macro-rules-derive-cfg.rs:26:13: 26:14 (#0), - }, - Group { - delimiter: Brace, - stream: TokenStream [ - Punct { - ch: '#', - spacing: Joint, - span: $DIR/macro-rules-derive-cfg.rs:27:5: 27:6 (#0), - }, - Punct { - ch: '!', - spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:27:6: 27:7 (#0), - }, - Group { - delimiter: Bracket, - stream: TokenStream [ - Ident { - ident: "allow", - span: $DIR/macro-rules-derive-cfg.rs:27:29: 27:34 (#0), - }, - Group { - delimiter: Parenthesis, - stream: TokenStream [ - Ident { - ident: "unused", - span: $DIR/macro-rules-derive-cfg.rs:27:35: 27:41 (#0), - }, - ], - span: $DIR/macro-rules-derive-cfg.rs:27:34: 27:42 (#0), - }, - ], - span: $DIR/macro-rules-derive-cfg.rs:27:5: 27:6 (#0), - }, - Literal { - kind: Integer, - symbol: "30", - suffix: None, - span: $DIR/macro-rules-derive-cfg.rs:28:5: 28:7 (#0), - }, - ], - span: $DIR/macro-rules-derive-cfg.rs:26:58: 29:2 (#0), - }, - Punct { - ch: ';', - spacing: Alone, - span: $DIR/macro-rules-derive-cfg.rs:19:74: 19:75 (#3), - }, - Literal { - kind: Integer, - symbol: "0", - suffix: None, - span: $DIR/macro-rules-derive-cfg.rs:20:17: 20:18 (#3), - }, - ], - span: $DIR/macro-rules-derive-cfg.rs:18:25: 21:14 (#3), - }, - ], - span: $DIR/macro-rules-derive-cfg.rs:18:18: 21:15 (#3), - }, - ], - span: $DIR/macro-rules-derive-cfg.rs:17:20: 22:10 (#3), - }, -] diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs index b8c0eb3e6d6d7..14eb690db3fa0 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs @@ -59,8 +59,10 @@ fn _macros() { } use_expr!((let 0 = 1 && 0 == 0)); //~^ ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement use_expr!((let 0 = 1)); //~^ ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement match () { #[cfg(FALSE)] () if let 0 = 1 => {} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.stderr index 2341dbbbdbd00..634b9a2ce0d6c 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.stderr @@ -124,15 +124,33 @@ LL | use_expr!((let 0 = 1 && 0 == 0)); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:62:16 + --> $DIR/feature-gate.rs:60:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:63:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:63:16 | LL | use_expr!((let 0 = 1)); | ^^^ | = note: only supported directly in conditions of `if` and `while` expressions + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: no rules expected the token `let` - --> $DIR/feature-gate.rs:70:15 + --> $DIR/feature-gate.rs:72:15 | LL | macro_rules! use_expr { | --------------------- when calling this macro @@ -202,7 +220,7 @@ LL | () if let Range { start: _, end: _ } = (true..true) && false => {} = help: you can write `if matches!(, )` instead of `if let = ` error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:66:12 + --> $DIR/feature-gate.rs:68:12 | LL | () if let 0 = 1 => {} | ^^^^^^^^^^^^ @@ -262,6 +280,6 @@ LL | () if let Range { start: _, end: _ } = (true..true) && false => {} = help: add `#![feature(let_chains)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 23 previous errors +error: aborting due to 25 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions-without-feature-gate.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions-without-feature-gate.rs index 096036bb1333a..c6aa5126c8285 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions-without-feature-gate.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions-without-feature-gate.rs @@ -62,8 +62,12 @@ fn _macros() { } use_expr!((let 0 = 1 && 0 == 0)); //~^ ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement use_expr!((let 0 = 1)); //~^ ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement } fn nested_within_if_expr() { diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions-without-feature-gate.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions-without-feature-gate.stderr index 31f389512edb4..9ba1e0162955f 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions-without-feature-gate.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions-without-feature-gate.stderr @@ -233,7 +233,7 @@ LL | while (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:70:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:74:9 | LL | if &let 0 = 0 {} | ^^^^^^^^^ @@ -241,7 +241,7 @@ LL | if &let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:73:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:77:9 | LL | if !let 0 = 0 {} | ^^^^^^^^^ @@ -249,7 +249,7 @@ LL | if !let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:75:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:79:9 | LL | if *let 0 = 0 {} | ^^^^^^^^^ @@ -257,7 +257,7 @@ LL | if *let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:77:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:81:9 | LL | if -let 0 = 0 {} | ^^^^^^^^^ @@ -265,7 +265,7 @@ LL | if -let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:85:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:89:9 | LL | if (let 0 = 0)? {} | ^^^^^^^^^ @@ -273,20 +273,20 @@ LL | if (let 0 = 0)? {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:88:16 + --> $DIR/disallowed-positions-without-feature-gate.rs:92:16 | LL | if true || let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions-without-feature-gate.rs:88:13 + --> $DIR/disallowed-positions-without-feature-gate.rs:92:13 | LL | if true || let 0 = 0 {} | ^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:90:17 + --> $DIR/disallowed-positions-without-feature-gate.rs:94:17 | LL | if (true || let 0 = 0) {} | ^^^^^^^^^ @@ -294,7 +294,7 @@ LL | if (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:92:25 + --> $DIR/disallowed-positions-without-feature-gate.rs:96:25 | LL | if true && (true || let 0 = 0) {} | ^^^^^^^^^ @@ -302,7 +302,7 @@ LL | if true && (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:94:25 + --> $DIR/disallowed-positions-without-feature-gate.rs:98:25 | LL | if true || (true && let 0 = 0) {} | ^^^^^^^^^ @@ -310,7 +310,7 @@ LL | if true || (true && let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:98:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:102:12 | LL | if x = let 0 = 0 {} | ^^^ @@ -318,7 +318,7 @@ LL | if x = let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:101:15 + --> $DIR/disallowed-positions-without-feature-gate.rs:105:15 | LL | if true..(let 0 = 0) {} | ^^^^^^^^^ @@ -326,7 +326,7 @@ LL | if true..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:104:11 + --> $DIR/disallowed-positions-without-feature-gate.rs:108:11 | LL | if ..(let 0 = 0) {} | ^^^^^^^^^ @@ -334,7 +334,7 @@ LL | if ..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:106:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:110:9 | LL | if (let 0 = 0).. {} | ^^^^^^^^^ @@ -342,7 +342,7 @@ LL | if (let 0 = 0).. {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:110:8 + --> $DIR/disallowed-positions-without-feature-gate.rs:114:8 | LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -350,7 +350,7 @@ LL | if let Range { start: _, end: _ } = true..true && false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:113:8 + --> $DIR/disallowed-positions-without-feature-gate.rs:117:8 | LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -358,7 +358,7 @@ LL | if let Range { start: _, end: _ } = true..true || false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:119:8 + --> $DIR/disallowed-positions-without-feature-gate.rs:123:8 | LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -366,7 +366,7 @@ LL | if let Range { start: F, end } = F..|| true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:125:8 + --> $DIR/disallowed-positions-without-feature-gate.rs:129:8 | LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -374,7 +374,7 @@ LL | if let Range { start: true, end } = t..&&false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:129:19 + --> $DIR/disallowed-positions-without-feature-gate.rs:133:19 | LL | if let true = let true = true {} | ^^^ @@ -382,7 +382,7 @@ LL | if let true = let true = true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:134:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:138:12 | LL | while &let 0 = 0 {} | ^^^^^^^^^ @@ -390,7 +390,7 @@ LL | while &let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:137:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:141:12 | LL | while !let 0 = 0 {} | ^^^^^^^^^ @@ -398,7 +398,7 @@ LL | while !let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:139:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:143:12 | LL | while *let 0 = 0 {} | ^^^^^^^^^ @@ -406,7 +406,7 @@ LL | while *let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:141:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:145:12 | LL | while -let 0 = 0 {} | ^^^^^^^^^ @@ -414,7 +414,7 @@ LL | while -let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:149:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:153:12 | LL | while (let 0 = 0)? {} | ^^^^^^^^^ @@ -422,20 +422,20 @@ LL | while (let 0 = 0)? {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:152:19 + --> $DIR/disallowed-positions-without-feature-gate.rs:156:19 | LL | while true || let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions-without-feature-gate.rs:152:16 + --> $DIR/disallowed-positions-without-feature-gate.rs:156:16 | LL | while true || let 0 = 0 {} | ^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:154:20 + --> $DIR/disallowed-positions-without-feature-gate.rs:158:20 | LL | while (true || let 0 = 0) {} | ^^^^^^^^^ @@ -443,7 +443,7 @@ LL | while (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:156:28 + --> $DIR/disallowed-positions-without-feature-gate.rs:160:28 | LL | while true && (true || let 0 = 0) {} | ^^^^^^^^^ @@ -451,7 +451,7 @@ LL | while true && (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:158:28 + --> $DIR/disallowed-positions-without-feature-gate.rs:162:28 | LL | while true || (true && let 0 = 0) {} | ^^^^^^^^^ @@ -459,7 +459,7 @@ LL | while true || (true && let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:162:15 + --> $DIR/disallowed-positions-without-feature-gate.rs:166:15 | LL | while x = let 0 = 0 {} | ^^^ @@ -467,7 +467,7 @@ LL | while x = let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:165:18 + --> $DIR/disallowed-positions-without-feature-gate.rs:169:18 | LL | while true..(let 0 = 0) {} | ^^^^^^^^^ @@ -475,7 +475,7 @@ LL | while true..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:168:14 + --> $DIR/disallowed-positions-without-feature-gate.rs:172:14 | LL | while ..(let 0 = 0) {} | ^^^^^^^^^ @@ -483,7 +483,7 @@ LL | while ..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:170:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:174:12 | LL | while (let 0 = 0).. {} | ^^^^^^^^^ @@ -491,7 +491,7 @@ LL | while (let 0 = 0).. {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:174:11 + --> $DIR/disallowed-positions-without-feature-gate.rs:178:11 | LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -499,7 +499,7 @@ LL | while let Range { start: _, end: _ } = true..true && false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:177:11 + --> $DIR/disallowed-positions-without-feature-gate.rs:181:11 | LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -507,7 +507,7 @@ LL | while let Range { start: _, end: _ } = true..true || false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:183:11 + --> $DIR/disallowed-positions-without-feature-gate.rs:187:11 | LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -515,7 +515,7 @@ LL | while let Range { start: F, end } = F..|| true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:189:11 + --> $DIR/disallowed-positions-without-feature-gate.rs:193:11 | LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -523,7 +523,7 @@ LL | while let Range { start: true, end } = t..&&false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:193:22 + --> $DIR/disallowed-positions-without-feature-gate.rs:197:22 | LL | while let true = let true = true {} | ^^^ @@ -531,7 +531,7 @@ LL | while let true = let true = true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:208:6 + --> $DIR/disallowed-positions-without-feature-gate.rs:212:6 | LL | &let 0 = 0; | ^^^ @@ -539,7 +539,7 @@ LL | &let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:211:6 + --> $DIR/disallowed-positions-without-feature-gate.rs:215:6 | LL | !let 0 = 0; | ^^^ @@ -547,7 +547,7 @@ LL | !let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:213:6 + --> $DIR/disallowed-positions-without-feature-gate.rs:217:6 | LL | *let 0 = 0; | ^^^ @@ -555,7 +555,7 @@ LL | *let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:215:6 + --> $DIR/disallowed-positions-without-feature-gate.rs:219:6 | LL | -let 0 = 0; | ^^^ @@ -563,7 +563,7 @@ LL | -let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:217:13 + --> $DIR/disallowed-positions-without-feature-gate.rs:221:13 | LL | let _ = let _ = 3; | ^^^ @@ -571,7 +571,7 @@ LL | let _ = let _ = 3; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:225:6 + --> $DIR/disallowed-positions-without-feature-gate.rs:229:6 | LL | (let 0 = 0)?; | ^^^ @@ -579,7 +579,7 @@ LL | (let 0 = 0)?; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:228:13 + --> $DIR/disallowed-positions-without-feature-gate.rs:232:13 | LL | true || let 0 = 0; | ^^^ @@ -587,7 +587,7 @@ LL | true || let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:230:14 + --> $DIR/disallowed-positions-without-feature-gate.rs:234:14 | LL | (true || let 0 = 0); | ^^^ @@ -595,7 +595,7 @@ LL | (true || let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:232:22 + --> $DIR/disallowed-positions-without-feature-gate.rs:236:22 | LL | true && (true || let 0 = 0); | ^^^ @@ -603,7 +603,7 @@ LL | true && (true || let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:236:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:240:9 | LL | x = let 0 = 0; | ^^^ @@ -611,7 +611,7 @@ LL | x = let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:239:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:243:12 | LL | true..(let 0 = 0); | ^^^ @@ -619,7 +619,7 @@ LL | true..(let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:241:8 + --> $DIR/disallowed-positions-without-feature-gate.rs:245:8 | LL | ..(let 0 = 0); | ^^^ @@ -627,7 +627,7 @@ LL | ..(let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:243:6 + --> $DIR/disallowed-positions-without-feature-gate.rs:247:6 | LL | (let 0 = 0)..; | ^^^ @@ -635,7 +635,7 @@ LL | (let 0 = 0)..; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:246:6 + --> $DIR/disallowed-positions-without-feature-gate.rs:250:6 | LL | (let Range { start: _, end: _ } = true..true || false); | ^^^ @@ -643,7 +643,7 @@ LL | (let Range { start: _, end: _ } = true..true || false); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:250:6 + --> $DIR/disallowed-positions-without-feature-gate.rs:254:6 | LL | (let true = let true = true); | ^^^ @@ -651,7 +651,7 @@ LL | (let true = let true = true); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:250:17 + --> $DIR/disallowed-positions-without-feature-gate.rs:254:17 | LL | (let true = let true = true); | ^^^ @@ -659,7 +659,7 @@ LL | (let true = let true = true); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:256:25 + --> $DIR/disallowed-positions-without-feature-gate.rs:260:25 | LL | let x = true && let y = 1; | ^^^ @@ -667,7 +667,7 @@ LL | let x = true && let y = 1; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:262:19 + --> $DIR/disallowed-positions-without-feature-gate.rs:266:19 | LL | [1, 2, 3][let _ = ()] | ^^^ @@ -675,7 +675,7 @@ LL | [1, 2, 3][let _ = ()] = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:267:6 + --> $DIR/disallowed-positions-without-feature-gate.rs:271:6 | LL | &let 0 = 0 | ^^^ @@ -683,7 +683,7 @@ LL | &let 0 = 0 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:277:17 + --> $DIR/disallowed-positions-without-feature-gate.rs:281:17 | LL | true && let 1 = 1 | ^^^ @@ -691,7 +691,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:282:17 + --> $DIR/disallowed-positions-without-feature-gate.rs:286:17 | LL | true && let 1 = 1 | ^^^ @@ -699,7 +699,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:287:17 + --> $DIR/disallowed-positions-without-feature-gate.rs:291:17 | LL | true && let 1 = 1 | ^^^ @@ -707,7 +707,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:298:17 + --> $DIR/disallowed-positions-without-feature-gate.rs:302:17 | LL | true && let 1 = 1 | ^^^ @@ -715,7 +715,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/disallowed-positions-without-feature-gate.rs:298:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:302:9 | LL | true && let 1 = 1 | ^^^^^^^^^^^^^^^^^ @@ -726,124 +726,124 @@ LL | { true && let 1 = 1 } | + + error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:307:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:311:9 | LL | if (let Some(a) = opt && true) { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions-without-feature-gate.rs:307:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:311:9 | LL | if (let Some(a) = opt && true) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:311:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:315:9 | LL | if (let Some(a) = opt) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions-without-feature-gate.rs:311:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:315:9 | LL | if (let Some(a) = opt) && true { | ^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:314:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:318:9 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions-without-feature-gate.rs:314:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:318:9 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:314:32 + --> $DIR/disallowed-positions-without-feature-gate.rs:318:32 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions-without-feature-gate.rs:314:32 + --> $DIR/disallowed-positions-without-feature-gate.rs:318:32 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:319:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:323:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions-without-feature-gate.rs:319:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:323:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:319:31 + --> $DIR/disallowed-positions-without-feature-gate.rs:323:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions-without-feature-gate.rs:319:31 + --> $DIR/disallowed-positions-without-feature-gate.rs:323:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:323:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:327:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions-without-feature-gate.rs:323:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:327:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:323:31 + --> $DIR/disallowed-positions-without-feature-gate.rs:327:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions-without-feature-gate.rs:323:31 + --> $DIR/disallowed-positions-without-feature-gate.rs:327:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:327:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:331:9 | LL | if (let Some(a) = opt && (true)) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions-without-feature-gate.rs:327:9 + --> $DIR/disallowed-positions-without-feature-gate.rs:331:9 | LL | if (let Some(a) = opt && (true)) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:332:22 + --> $DIR/disallowed-positions-without-feature-gate.rs:336:22 | LL | let x = (true && let y = 1); | ^^^ @@ -851,7 +851,7 @@ LL | let x = (true && let y = 1); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:337:20 + --> $DIR/disallowed-positions-without-feature-gate.rs:341:20 | LL | ([1, 2, 3][let _ = ()]) | ^^^ @@ -867,15 +867,51 @@ LL | use_expr!((let 0 = 1 && 0 == 0)); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions-without-feature-gate.rs:65:16 + --> $DIR/disallowed-positions-without-feature-gate.rs:63:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions-without-feature-gate.rs:63:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions-without-feature-gate.rs:67:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions-without-feature-gate.rs:67:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions-without-feature-gate.rs:67:16 | LL | use_expr!((let 0 = 1)); | ^^^ | = note: only supported directly in conditions of `if` and `while` expressions + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0308]: mismatched types - --> $DIR/disallowed-positions-without-feature-gate.rs:101:8 + --> $DIR/disallowed-positions-without-feature-gate.rs:105:8 | LL | if true..(let 0 = 0) {} | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` @@ -884,7 +920,7 @@ LL | if true..(let 0 = 0) {} found struct `std::ops::Range` error[E0308]: mismatched types - --> $DIR/disallowed-positions-without-feature-gate.rs:110:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:114:12 | LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -895,7 +931,7 @@ LL | if let Range { start: _, end: _ } = true..true && false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions-without-feature-gate.rs:113:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:117:12 | LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -906,7 +942,7 @@ LL | if let Range { start: _, end: _ } = true..true || false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions-without-feature-gate.rs:119:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:123:12 | LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` @@ -917,7 +953,7 @@ LL | if let Range { start: F, end } = F..|| true {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions-without-feature-gate.rs:125:12 + --> $DIR/disallowed-positions-without-feature-gate.rs:129:12 | LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` @@ -928,7 +964,7 @@ LL | if let Range { start: true, end } = t..&&false {} found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions-without-feature-gate.rs:81:20 + --> $DIR/disallowed-positions-without-feature-gate.rs:85:20 | LL | if let 0 = 0? {} | ^^ the `?` operator cannot be applied to type `{integer}` @@ -936,7 +972,7 @@ LL | if let 0 = 0? {} = help: the trait `Try` is not implemented for `{integer}` error[E0308]: mismatched types - --> $DIR/disallowed-positions-without-feature-gate.rs:165:11 + --> $DIR/disallowed-positions-without-feature-gate.rs:169:11 | LL | while true..(let 0 = 0) {} | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` @@ -945,7 +981,7 @@ LL | while true..(let 0 = 0) {} found struct `std::ops::Range` error[E0308]: mismatched types - --> $DIR/disallowed-positions-without-feature-gate.rs:174:15 + --> $DIR/disallowed-positions-without-feature-gate.rs:178:15 | LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -956,7 +992,7 @@ LL | while let Range { start: _, end: _ } = true..true && false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions-without-feature-gate.rs:177:15 + --> $DIR/disallowed-positions-without-feature-gate.rs:181:15 | LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -967,7 +1003,7 @@ LL | while let Range { start: _, end: _ } = true..true || false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions-without-feature-gate.rs:183:15 + --> $DIR/disallowed-positions-without-feature-gate.rs:187:15 | LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` @@ -978,7 +1014,7 @@ LL | while let Range { start: F, end } = F..|| true {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions-without-feature-gate.rs:189:15 + --> $DIR/disallowed-positions-without-feature-gate.rs:193:15 | LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` @@ -989,7 +1025,7 @@ LL | while let Range { start: true, end } = t..&&false {} found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions-without-feature-gate.rs:145:23 + --> $DIR/disallowed-positions-without-feature-gate.rs:149:23 | LL | while let 0 = 0? {} | ^^ the `?` operator cannot be applied to type `{integer}` @@ -997,7 +1033,7 @@ LL | while let 0 = 0? {} = help: the trait `Try` is not implemented for `{integer}` error[E0308]: mismatched types - --> $DIR/disallowed-positions-without-feature-gate.rs:246:10 + --> $DIR/disallowed-positions-without-feature-gate.rs:250:10 | LL | (let Range { start: _, end: _ } = true..true || false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1008,14 +1044,14 @@ LL | (let Range { start: _, end: _ } = true..true || false); found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions-without-feature-gate.rs:221:17 + --> $DIR/disallowed-positions-without-feature-gate.rs:225:17 | LL | let 0 = 0?; | ^^ the `?` operator cannot be applied to type `{integer}` | = help: the trait `Try` is not implemented for `{integer}` -error: aborting due to 105 previous errors +error: aborting due to 109 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs index 4ac3ea53a08ab..dd05d16e0fdc0 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs @@ -80,8 +80,12 @@ fn _macros() { } use_expr!((let 0 = 1 && 0 == 0)); //~^ ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement use_expr!((let 0 = 1)); //~^ ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement } fn nested_within_if_expr() { diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.stderr index ab58abf4d4605..c40269f270360 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.stderr @@ -233,7 +233,7 @@ LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:88:9 + --> $DIR/disallowed-positions.rs:92:9 | LL | if &let 0 = 0 {} | ^^^^^^^^^ @@ -241,7 +241,7 @@ LL | if &let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:91:9 + --> $DIR/disallowed-positions.rs:95:9 | LL | if !let 0 = 0 {} | ^^^^^^^^^ @@ -249,7 +249,7 @@ LL | if !let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:93:9 + --> $DIR/disallowed-positions.rs:97:9 | LL | if *let 0 = 0 {} | ^^^^^^^^^ @@ -257,7 +257,7 @@ LL | if *let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:95:9 + --> $DIR/disallowed-positions.rs:99:9 | LL | if -let 0 = 0 {} | ^^^^^^^^^ @@ -265,7 +265,7 @@ LL | if -let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:103:9 + --> $DIR/disallowed-positions.rs:107:9 | LL | if (let 0 = 0)? {} | ^^^^^^^^^ @@ -273,20 +273,20 @@ LL | if (let 0 = 0)? {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:106:16 + --> $DIR/disallowed-positions.rs:110:16 | LL | if true || let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions.rs:106:13 + --> $DIR/disallowed-positions.rs:110:13 | LL | if true || let 0 = 0 {} | ^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:108:17 + --> $DIR/disallowed-positions.rs:112:17 | LL | if (true || let 0 = 0) {} | ^^^^^^^^^ @@ -294,7 +294,7 @@ LL | if (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:110:25 + --> $DIR/disallowed-positions.rs:114:25 | LL | if true && (true || let 0 = 0) {} | ^^^^^^^^^ @@ -302,7 +302,7 @@ LL | if true && (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:112:25 + --> $DIR/disallowed-positions.rs:116:25 | LL | if true || (true && let 0 = 0) {} | ^^^^^^^^^ @@ -310,7 +310,7 @@ LL | if true || (true && let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:116:12 + --> $DIR/disallowed-positions.rs:120:12 | LL | if x = let 0 = 0 {} | ^^^ @@ -318,7 +318,7 @@ LL | if x = let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:119:15 + --> $DIR/disallowed-positions.rs:123:15 | LL | if true..(let 0 = 0) {} | ^^^^^^^^^ @@ -326,7 +326,7 @@ LL | if true..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:122:11 + --> $DIR/disallowed-positions.rs:126:11 | LL | if ..(let 0 = 0) {} | ^^^^^^^^^ @@ -334,7 +334,7 @@ LL | if ..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:124:9 + --> $DIR/disallowed-positions.rs:128:9 | LL | if (let 0 = 0).. {} | ^^^^^^^^^ @@ -342,7 +342,7 @@ LL | if (let 0 = 0).. {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:128:8 + --> $DIR/disallowed-positions.rs:132:8 | LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -350,7 +350,7 @@ LL | if let Range { start: _, end: _ } = true..true && false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:131:8 + --> $DIR/disallowed-positions.rs:135:8 | LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -358,7 +358,7 @@ LL | if let Range { start: _, end: _ } = true..true || false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:137:8 + --> $DIR/disallowed-positions.rs:141:8 | LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -366,7 +366,7 @@ LL | if let Range { start: F, end } = F..|| true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:143:8 + --> $DIR/disallowed-positions.rs:147:8 | LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -374,7 +374,7 @@ LL | if let Range { start: true, end } = t..&&false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:147:19 + --> $DIR/disallowed-positions.rs:151:19 | LL | if let true = let true = true {} | ^^^ @@ -382,7 +382,7 @@ LL | if let true = let true = true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:152:12 + --> $DIR/disallowed-positions.rs:156:12 | LL | while &let 0 = 0 {} | ^^^^^^^^^ @@ -390,7 +390,7 @@ LL | while &let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:155:12 + --> $DIR/disallowed-positions.rs:159:12 | LL | while !let 0 = 0 {} | ^^^^^^^^^ @@ -398,7 +398,7 @@ LL | while !let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:157:12 + --> $DIR/disallowed-positions.rs:161:12 | LL | while *let 0 = 0 {} | ^^^^^^^^^ @@ -406,7 +406,7 @@ LL | while *let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:159:12 + --> $DIR/disallowed-positions.rs:163:12 | LL | while -let 0 = 0 {} | ^^^^^^^^^ @@ -414,7 +414,7 @@ LL | while -let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:167:12 + --> $DIR/disallowed-positions.rs:171:12 | LL | while (let 0 = 0)? {} | ^^^^^^^^^ @@ -422,20 +422,20 @@ LL | while (let 0 = 0)? {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:170:19 + --> $DIR/disallowed-positions.rs:174:19 | LL | while true || let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions.rs:170:16 + --> $DIR/disallowed-positions.rs:174:16 | LL | while true || let 0 = 0 {} | ^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:172:20 + --> $DIR/disallowed-positions.rs:176:20 | LL | while (true || let 0 = 0) {} | ^^^^^^^^^ @@ -443,7 +443,7 @@ LL | while (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:174:28 + --> $DIR/disallowed-positions.rs:178:28 | LL | while true && (true || let 0 = 0) {} | ^^^^^^^^^ @@ -451,7 +451,7 @@ LL | while true && (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:176:28 + --> $DIR/disallowed-positions.rs:180:28 | LL | while true || (true && let 0 = 0) {} | ^^^^^^^^^ @@ -459,7 +459,7 @@ LL | while true || (true && let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:180:15 + --> $DIR/disallowed-positions.rs:184:15 | LL | while x = let 0 = 0 {} | ^^^ @@ -467,7 +467,7 @@ LL | while x = let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:183:18 + --> $DIR/disallowed-positions.rs:187:18 | LL | while true..(let 0 = 0) {} | ^^^^^^^^^ @@ -475,7 +475,7 @@ LL | while true..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:186:14 + --> $DIR/disallowed-positions.rs:190:14 | LL | while ..(let 0 = 0) {} | ^^^^^^^^^ @@ -483,7 +483,7 @@ LL | while ..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:188:12 + --> $DIR/disallowed-positions.rs:192:12 | LL | while (let 0 = 0).. {} | ^^^^^^^^^ @@ -491,7 +491,7 @@ LL | while (let 0 = 0).. {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:192:11 + --> $DIR/disallowed-positions.rs:196:11 | LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -499,7 +499,7 @@ LL | while let Range { start: _, end: _ } = true..true && false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:195:11 + --> $DIR/disallowed-positions.rs:199:11 | LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -507,7 +507,7 @@ LL | while let Range { start: _, end: _ } = true..true || false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:201:11 + --> $DIR/disallowed-positions.rs:205:11 | LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -515,7 +515,7 @@ LL | while let Range { start: F, end } = F..|| true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:207:11 + --> $DIR/disallowed-positions.rs:211:11 | LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -523,7 +523,7 @@ LL | while let Range { start: true, end } = t..&&false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:211:22 + --> $DIR/disallowed-positions.rs:215:22 | LL | while let true = let true = true {} | ^^^ @@ -531,7 +531,7 @@ LL | while let true = let true = true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:226:6 + --> $DIR/disallowed-positions.rs:230:6 | LL | &let 0 = 0; | ^^^ @@ -539,7 +539,7 @@ LL | &let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:229:6 + --> $DIR/disallowed-positions.rs:233:6 | LL | !let 0 = 0; | ^^^ @@ -547,7 +547,7 @@ LL | !let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:231:6 + --> $DIR/disallowed-positions.rs:235:6 | LL | *let 0 = 0; | ^^^ @@ -555,7 +555,7 @@ LL | *let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:233:6 + --> $DIR/disallowed-positions.rs:237:6 | LL | -let 0 = 0; | ^^^ @@ -563,7 +563,7 @@ LL | -let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:241:6 + --> $DIR/disallowed-positions.rs:245:6 | LL | (let 0 = 0)?; | ^^^ @@ -571,7 +571,7 @@ LL | (let 0 = 0)?; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:244:13 + --> $DIR/disallowed-positions.rs:248:13 | LL | true || let 0 = 0; | ^^^ @@ -579,7 +579,7 @@ LL | true || let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:246:14 + --> $DIR/disallowed-positions.rs:250:14 | LL | (true || let 0 = 0); | ^^^ @@ -587,7 +587,7 @@ LL | (true || let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:248:22 + --> $DIR/disallowed-positions.rs:252:22 | LL | true && (true || let 0 = 0); | ^^^ @@ -595,7 +595,7 @@ LL | true && (true || let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:252:9 + --> $DIR/disallowed-positions.rs:256:9 | LL | x = let 0 = 0; | ^^^ @@ -603,7 +603,7 @@ LL | x = let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:255:12 + --> $DIR/disallowed-positions.rs:259:12 | LL | true..(let 0 = 0); | ^^^ @@ -611,7 +611,7 @@ LL | true..(let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:257:8 + --> $DIR/disallowed-positions.rs:261:8 | LL | ..(let 0 = 0); | ^^^ @@ -619,7 +619,7 @@ LL | ..(let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:259:6 + --> $DIR/disallowed-positions.rs:263:6 | LL | (let 0 = 0)..; | ^^^ @@ -627,7 +627,7 @@ LL | (let 0 = 0)..; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:262:6 + --> $DIR/disallowed-positions.rs:266:6 | LL | (let Range { start: _, end: _ } = true..true || false); | ^^^ @@ -635,7 +635,7 @@ LL | (let Range { start: _, end: _ } = true..true || false); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:266:6 + --> $DIR/disallowed-positions.rs:270:6 | LL | (let true = let true = true); | ^^^ @@ -643,7 +643,7 @@ LL | (let true = let true = true); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:266:17 + --> $DIR/disallowed-positions.rs:270:17 | LL | (let true = let true = true); | ^^^ @@ -651,7 +651,7 @@ LL | (let true = let true = true); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:272:25 + --> $DIR/disallowed-positions.rs:276:25 | LL | let x = true && let y = 1; | ^^^ @@ -659,7 +659,7 @@ LL | let x = true && let y = 1; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:278:19 + --> $DIR/disallowed-positions.rs:282:19 | LL | [1, 2, 3][let _ = ()] | ^^^ @@ -667,7 +667,7 @@ LL | [1, 2, 3][let _ = ()] = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:283:6 + --> $DIR/disallowed-positions.rs:287:6 | LL | &let 0 = 0 | ^^^ @@ -675,7 +675,7 @@ LL | &let 0 = 0 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:293:17 + --> $DIR/disallowed-positions.rs:297:17 | LL | true && let 1 = 1 | ^^^ @@ -683,7 +683,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:298:17 + --> $DIR/disallowed-positions.rs:302:17 | LL | true && let 1 = 1 | ^^^ @@ -691,7 +691,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:303:17 + --> $DIR/disallowed-positions.rs:307:17 | LL | true && let 1 = 1 | ^^^ @@ -699,7 +699,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:314:17 + --> $DIR/disallowed-positions.rs:318:17 | LL | true && let 1 = 1 | ^^^ @@ -707,7 +707,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/disallowed-positions.rs:314:9 + --> $DIR/disallowed-positions.rs:318:9 | LL | true && let 1 = 1 | ^^^^^^^^^^^^^^^^^ @@ -718,124 +718,124 @@ LL | { true && let 1 = 1 } | + + error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:323:9 + --> $DIR/disallowed-positions.rs:327:9 | LL | if (let Some(a) = opt && true) { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:323:9 + --> $DIR/disallowed-positions.rs:327:9 | LL | if (let Some(a) = opt && true) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:327:9 + --> $DIR/disallowed-positions.rs:331:9 | LL | if (let Some(a) = opt) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:327:9 + --> $DIR/disallowed-positions.rs:331:9 | LL | if (let Some(a) = opt) && true { | ^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:330:9 + --> $DIR/disallowed-positions.rs:334:9 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:330:9 + --> $DIR/disallowed-positions.rs:334:9 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:330:32 + --> $DIR/disallowed-positions.rs:334:32 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:330:32 + --> $DIR/disallowed-positions.rs:334:32 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:337:9 + --> $DIR/disallowed-positions.rs:341:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:337:9 + --> $DIR/disallowed-positions.rs:341:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:337:31 + --> $DIR/disallowed-positions.rs:341:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:337:31 + --> $DIR/disallowed-positions.rs:341:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:341:9 + --> $DIR/disallowed-positions.rs:345:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:341:9 + --> $DIR/disallowed-positions.rs:345:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:341:31 + --> $DIR/disallowed-positions.rs:345:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:341:31 + --> $DIR/disallowed-positions.rs:345:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:345:9 + --> $DIR/disallowed-positions.rs:349:9 | LL | if (let Some(a) = opt && (true)) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:345:9 + --> $DIR/disallowed-positions.rs:349:9 | LL | if (let Some(a) = opt && (true)) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:361:22 + --> $DIR/disallowed-positions.rs:365:22 | LL | let x = (true && let y = 1); | ^^^ @@ -843,7 +843,7 @@ LL | let x = (true && let y = 1); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:366:20 + --> $DIR/disallowed-positions.rs:370:20 | LL | ([1, 2, 3][let _ = ()]) | ^^^ @@ -859,15 +859,51 @@ LL | use_expr!((let 0 = 1 && 0 == 0)); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:83:16 + --> $DIR/disallowed-positions.rs:81:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:81:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:85:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:85:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:85:16 | LL | use_expr!((let 0 = 1)); | ^^^ | = note: only supported directly in conditions of `if` and `while` expressions + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:119:8 + --> $DIR/disallowed-positions.rs:123:8 | LL | if true..(let 0 = 0) {} | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` @@ -876,7 +912,7 @@ LL | if true..(let 0 = 0) {} found struct `std::ops::Range` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:128:12 + --> $DIR/disallowed-positions.rs:132:12 | LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -887,7 +923,7 @@ LL | if let Range { start: _, end: _ } = true..true && false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:131:12 + --> $DIR/disallowed-positions.rs:135:12 | LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -898,7 +934,7 @@ LL | if let Range { start: _, end: _ } = true..true || false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:137:12 + --> $DIR/disallowed-positions.rs:141:12 | LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` @@ -909,7 +945,7 @@ LL | if let Range { start: F, end } = F..|| true {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:143:12 + --> $DIR/disallowed-positions.rs:147:12 | LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` @@ -920,7 +956,7 @@ LL | if let Range { start: true, end } = t..&&false {} found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:99:20 + --> $DIR/disallowed-positions.rs:103:20 | LL | if let 0 = 0? {} | ^^ the `?` operator cannot be applied to type `{integer}` @@ -928,7 +964,7 @@ LL | if let 0 = 0? {} = help: the trait `Try` is not implemented for `{integer}` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:183:11 + --> $DIR/disallowed-positions.rs:187:11 | LL | while true..(let 0 = 0) {} | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` @@ -937,7 +973,7 @@ LL | while true..(let 0 = 0) {} found struct `std::ops::Range` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:192:15 + --> $DIR/disallowed-positions.rs:196:15 | LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -948,7 +984,7 @@ LL | while let Range { start: _, end: _ } = true..true && false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:195:15 + --> $DIR/disallowed-positions.rs:199:15 | LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -959,7 +995,7 @@ LL | while let Range { start: _, end: _ } = true..true || false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:201:15 + --> $DIR/disallowed-positions.rs:205:15 | LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` @@ -970,7 +1006,7 @@ LL | while let Range { start: F, end } = F..|| true {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:207:15 + --> $DIR/disallowed-positions.rs:211:15 | LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` @@ -981,7 +1017,7 @@ LL | while let Range { start: true, end } = t..&&false {} found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:163:23 + --> $DIR/disallowed-positions.rs:167:23 | LL | while let 0 = 0? {} | ^^ the `?` operator cannot be applied to type `{integer}` @@ -989,7 +1025,7 @@ LL | while let 0 = 0? {} = help: the trait `Try` is not implemented for `{integer}` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:262:10 + --> $DIR/disallowed-positions.rs:266:10 | LL | (let Range { start: _, end: _ } = true..true || false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1000,14 +1036,14 @@ LL | (let Range { start: _, end: _ } = true..true || false); found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:237:17 + --> $DIR/disallowed-positions.rs:241:17 | LL | let 0 = 0?; | ^^ the `?` operator cannot be applied to type `{integer}` | = help: the trait `Try` is not implemented for `{integer}` -error: aborting due to 104 previous errors +error: aborting due to 108 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`.