From 32e7b3ebb0a4aa88caf5567c26bd71884481c3b8 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Wed, 16 Nov 2022 21:46:06 +0100 Subject: [PATCH 1/2] Rip it out My type ascription Oh rip it out Ah If you think we live too much then You can sacrifice diagnostics Don't mix your garbage Into my syntax So many weird hacks keep diagnostics alive Yet I don't even step outside So many bad diagnostics keep tyasc alive Yet tyasc doesn't even bother to survive! --- compiler/rustc_ast/src/ast.rs | 1 - compiler/rustc_ast/src/mut_visit.rs | 2 +- compiler/rustc_ast/src/util/parser.rs | 21 ++--- .../rustc_ast_pretty/src/pprust/state/expr.rs | 12 ++- compiler/rustc_builtin_macros/src/asm.rs | 1 - compiler/rustc_builtin_macros/src/assert.rs | 1 - .../src/assert/context.rs | 1 - .../rustc_builtin_macros/src/edition_panic.rs | 1 - compiler/rustc_expand/src/base.rs | 2 - compiler/rustc_expand/src/expand.rs | 3 - compiler/rustc_expand/src/mbe/macro_rules.rs | 3 +- compiler/rustc_expand/src/placeholders.rs | 1 - compiler/rustc_hir_pretty/src/lib.rs | 12 ++- .../rustc_parse/src/parser/diagnostics.rs | 72 ----------------- compiler/rustc_parse/src/parser/expr.rs | 80 ++++--------------- compiler/rustc_parse/src/parser/item.rs | 2 +- compiler/rustc_parse/src/parser/mod.rs | 6 +- compiler/rustc_parse/src/parser/pat.rs | 2 +- compiler/rustc_parse/src/parser/stmt.rs | 3 +- compiler/rustc_parse/src/parser/ty.rs | 7 +- 20 files changed, 49 insertions(+), 184 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 7de594719ddc4..d007244bb8565 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1579,7 +1579,6 @@ pub enum ClosureBinder { pub struct MacCall { pub path: Path, pub args: P, - pub prior_type_ascription: Option<(Span, bool)>, } impl MacCall { diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 77f342d1eb322..9563c441b1d5b 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -611,7 +611,7 @@ pub fn noop_visit_attribute(attr: &mut Attribute, vis: &mut T) { } pub fn noop_visit_mac(mac: &mut MacCall, vis: &mut T) { - let MacCall { path, args, prior_type_ascription: _ } = mac; + let MacCall { path, args } = mac; vis.visit_path(path); visit_delim_args(args, vis); } diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs index 819f1884a0692..7b3d9a7fbcd63 100644 --- a/compiler/rustc_ast/src/util/parser.rs +++ b/compiler/rustc_ast/src/util/parser.rs @@ -53,8 +53,6 @@ pub enum AssocOp { DotDot, /// `..=` range DotDotEq, - /// `:` - Colon, } #[derive(PartialEq, Debug)] @@ -96,7 +94,6 @@ impl AssocOp { token::DotDotEq => Some(DotDotEq), // DotDotDot is no longer supported, but we need some way to display the error token::DotDotDot => Some(DotDotEq), - token::Colon => Some(Colon), // `<-` should probably be `< -` token::LArrow => Some(Less), _ if t.is_keyword(kw::As) => Some(As), @@ -133,7 +130,7 @@ impl AssocOp { pub fn precedence(&self) -> usize { use AssocOp::*; match *self { - As | Colon => 14, + As => 14, Multiply | Divide | Modulus => 13, Add | Subtract => 12, ShiftLeft | ShiftRight => 11, @@ -156,7 +153,7 @@ impl AssocOp { Assign | AssignOp(_) => Fixity::Right, As | Multiply | Divide | Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual - | LAnd | LOr | Colon => Fixity::Left, + | LAnd | LOr => Fixity::Left, DotDot | DotDotEq => Fixity::None, } } @@ -166,8 +163,9 @@ impl AssocOp { match *self { Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual => true, Assign | AssignOp(_) | As | Multiply | Divide | Modulus | Add | Subtract - | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd | LOr | DotDot | DotDotEq - | Colon => false, + | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd | LOr | DotDot | DotDotEq => { + false + } } } @@ -177,7 +175,7 @@ impl AssocOp { Assign | AssignOp(_) => true, Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual | As | Multiply | Divide | Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd | BitXor - | BitOr | LAnd | LOr | DotDot | DotDotEq | Colon => false, + | BitOr | LAnd | LOr | DotDot | DotDotEq => false, } } @@ -202,7 +200,7 @@ impl AssocOp { BitOr => Some(BinOpKind::BitOr), LAnd => Some(BinOpKind::And), LOr => Some(BinOpKind::Or), - Assign | AssignOp(_) | As | DotDot | DotDotEq | Colon => None, + Assign | AssignOp(_) | As | DotDot | DotDotEq => None, } } @@ -223,10 +221,9 @@ impl AssocOp { Greater | // `{ 42 } > 3` GreaterEqual | // `{ 42 } >= 3` AssignOp(_) | // `{ 42 } +=` - As | // `{ 42 } as usize` // Equal | // `{ 42 } == { 42 }` Accepting these here would regress incorrect // NotEqual | // `{ 42 } != { 42 } struct literals parser recovery. - Colon, // `{ 42 }: usize` + As // `{ 42 } as usize` ) } } @@ -254,7 +251,6 @@ pub enum ExprPrecedence { Binary(BinOpKind), Cast, - Type, Assign, AssignOp, @@ -312,7 +308,6 @@ impl ExprPrecedence { // Binop-like expr kinds, handled by `AssocOp`. ExprPrecedence::Binary(op) => AssocOp::from_ast_binop(op).precedence() as i8, ExprPrecedence::Cast => AssocOp::As.precedence() as i8, - ExprPrecedence::Type => AssocOp::Colon.precedence() as i8, ExprPrecedence::Assign | ExprPrecedence::AssignOp => AssocOp::Assign.precedence() as i8, diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index b125c6407d050..c28389eea2345 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -336,10 +336,16 @@ impl<'a> State<'a> { self.print_type(ty); } ast::ExprKind::Type(expr, ty) => { - let prec = AssocOp::Colon.precedence() as i8; - self.print_expr_maybe_paren(expr, prec); - self.word_space(":"); + self.word("type_ascribe!("); + self.ibox(0); + self.print_expr(expr); + + self.word(","); + self.space_if_not_bol(); self.print_type(ty); + + self.end(); + self.word(")"); } ast::ExprKind::Let(pat, scrutinee, _) => { self.print_let(pat, scrutinee); diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index 925392b500ad2..6658e972cc1d6 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -68,7 +68,6 @@ pub fn parse_asm_args<'a>( // After a template string, we always expect *only* a comma... let mut err = diag.struct_span_err(p.token.span, "expected token: `,`"); err.span_label(p.token.span, "expected `,`"); - p.maybe_annotate_with_ascription(&mut err, false); return Err(err); } else { // ...after that delegate to `expect` to also include the other expected tokens. diff --git a/compiler/rustc_builtin_macros/src/assert.rs b/compiler/rustc_builtin_macros/src/assert.rs index 8555c3593b333..3b78acb4558d2 100644 --- a/compiler/rustc_builtin_macros/src/assert.rs +++ b/compiler/rustc_builtin_macros/src/assert.rs @@ -59,7 +59,6 @@ pub fn expand_assert<'cx>( delim: MacDelimiter::Parenthesis, tokens, }), - prior_type_ascription: None, })), ); expr_if_not(cx, call_site_span, cond_expr, then, None) diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs index 93b07801e035d..2fe0c0da12f30 100644 --- a/compiler/rustc_builtin_macros/src/assert/context.rs +++ b/compiler/rustc_builtin_macros/src/assert/context.rs @@ -182,7 +182,6 @@ impl<'cx, 'a> Context<'cx, 'a> { delim: MacDelimiter::Parenthesis, tokens: initial.into_iter().chain(captures).collect::(), }), - prior_type_ascription: None, })), ) } diff --git a/compiler/rustc_builtin_macros/src/edition_panic.rs b/compiler/rustc_builtin_macros/src/edition_panic.rs index b2a21611db7f9..ef0db23ff2f2d 100644 --- a/compiler/rustc_builtin_macros/src/edition_panic.rs +++ b/compiler/rustc_builtin_macros/src/edition_panic.rs @@ -63,7 +63,6 @@ fn expand<'cx>( delim: MacDelimiter::Parenthesis, tokens: tts, }), - prior_type_ascription: None, })), ), ) diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 00453f78287ef..77ca21f863df9 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -991,7 +991,6 @@ pub struct ExpansionData { pub depth: usize, pub module: Rc, pub dir_ownership: DirOwnership, - pub prior_type_ascription: Option<(Span, bool)>, /// Some parent node that is close to this macro call pub lint_node_id: NodeId, pub is_trailing_mac: bool, @@ -1040,7 +1039,6 @@ impl<'a> ExtCtxt<'a> { depth: 0, module: Default::default(), dir_ownership: DirOwnership::Owned { relative: None }, - prior_type_ascription: None, lint_node_id: ast::CRATE_NODE_ID, is_trailing_mac: false, }, diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 5d47c1ed363fb..c03ae3e9aaedf 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -657,8 +657,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> { self.parse_ast_fragment(tok_result, fragment_kind, &mac.path, span) } SyntaxExtensionKind::LegacyBang(expander) => { - let prev = self.cx.current_expansion.prior_type_ascription; - self.cx.current_expansion.prior_type_ascription = mac.prior_type_ascription; let tok_result = expander.expand(self.cx, span, mac.args.tokens.clone()); let result = if let Some(result) = fragment_kind.make_from(tok_result) { result @@ -666,7 +664,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> { self.error_wrong_fragment_kind(fragment_kind, &mac, span); fragment_kind.dummy(span) }; - self.cx.current_expansion.prior_type_ascription = prev; result } _ => unreachable!(), diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index c0489f686336b..0b5e1c358aa39 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -239,8 +239,7 @@ fn expand_macro<'cx>( trace_macros_note(&mut cx.expansions, sp, msg); } - let mut p = Parser::new(sess, tts, false, None); - p.last_type_ascription = cx.current_expansion.prior_type_ascription; + let p = Parser::new(sess, tts, false, None); if is_local { cx.resolver.record_macro_rule_usage(node_id, i); diff --git a/compiler/rustc_expand/src/placeholders.rs b/compiler/rustc_expand/src/placeholders.rs index 03bb5c1dfe45f..e9af688ee2b61 100644 --- a/compiler/rustc_expand/src/placeholders.rs +++ b/compiler/rustc_expand/src/placeholders.rs @@ -21,7 +21,6 @@ pub fn placeholder( delim: ast::MacDelimiter::Parenthesis, tokens: ast::tokenstream::TokenStream::new(Vec::new()), }), - prior_type_ascription: None, }) } diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index f74c551a45b66..704a49d23d623 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1413,10 +1413,16 @@ impl<'a> State<'a> { self.print_type(ty); } hir::ExprKind::Type(expr, ty) => { - let prec = AssocOp::Colon.precedence() as i8; - self.print_expr_maybe_paren(expr, prec); - self.word_space(":"); + self.word("type_ascribe!("); + self.ibox(0); + self.print_expr(expr); + + self.word(","); + self.space_if_not_bol(); self.print_type(ty); + + self.end(); + self.word(")"); } hir::ExprKind::DropTemps(init) => { // Print `{`: diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 4c918c6702ed9..3dc87354f08df 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -574,7 +574,6 @@ impl<'a> Parser<'a> { err.span_label(sp, label_exp); err.span_label(self.token.span, "unexpected token"); } - self.maybe_annotate_with_ascription(&mut err, false); Err(err) } @@ -699,59 +698,6 @@ impl<'a> Parser<'a> { None } - pub fn maybe_annotate_with_ascription( - &mut self, - err: &mut Diagnostic, - maybe_expected_semicolon: bool, - ) { - if let Some((sp, likely_path)) = self.last_type_ascription.take() { - let sm = self.sess.source_map(); - let next_pos = sm.lookup_char_pos(self.token.span.lo()); - let op_pos = sm.lookup_char_pos(sp.hi()); - - let allow_unstable = self.sess.unstable_features.is_nightly_build(); - - if likely_path { - err.span_suggestion( - sp, - "maybe write a path separator here", - "::", - if allow_unstable { - Applicability::MaybeIncorrect - } else { - Applicability::MachineApplicable - }, - ); - self.sess.type_ascription_path_suggestions.borrow_mut().insert(sp); - } else if op_pos.line != next_pos.line && maybe_expected_semicolon { - err.span_suggestion( - sp, - "try using a semicolon", - ";", - Applicability::MaybeIncorrect, - ); - } else if allow_unstable { - err.span_label(sp, "tried to parse a type due to this type ascription"); - } else { - err.span_label(sp, "tried to parse a type due to this"); - } - if allow_unstable { - // Give extra information about type ascription only if it's a nightly compiler. - err.note( - "`#![feature(type_ascription)]` lets you annotate an expression with a type: \ - `: `", - ); - if !likely_path { - // Avoid giving too much info when it was likely an unrelated typo. - err.note( - "see issue #23416 \ - for more information", - ); - } - } - } - } - /// Eats and discards tokens until one of `kets` is encountered. Respects token trees, /// passes through any errors encountered. Used for error recovery. pub(super) fn eat_to_tokens(&mut self, kets: &[&TokenKind]) { @@ -1694,24 +1640,6 @@ impl<'a> Parser<'a> { } } - pub(super) fn could_ascription_be_path(&self, node: &ast::ExprKind) -> bool { - (self.token == token::Lt && // `foo:` - } - pub(super) fn recover_seq_parse_error( &mut self, delim: Delimiter, diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index dd2b03988c3e8..bb534a5c93bab 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -188,10 +188,8 @@ impl<'a> Parser<'a> { self.parse_prefix_expr(attrs)? } }; - let last_type_ascription_set = self.last_type_ascription.is_some(); if !self.should_continue_as_assoc_expr(&lhs) { - self.last_type_ascription = None; return Ok(lhs); } @@ -298,21 +296,19 @@ impl<'a> Parser<'a> { continue; } - let op = op.node; // Special cases: - if op == AssocOp::As { + if op.node == AssocOp::As { lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Cast)?; continue; - } else if op == AssocOp::Colon { - lhs = self.parse_assoc_op_ascribe(lhs, lhs_span)?; - continue; - } else if op == AssocOp::DotDot || op == AssocOp::DotDotEq { + } else if op.node == AssocOp::DotDot || op.node == AssocOp::DotDotEq { // If we didn't have to handle `x..`/`x..=`, it would be pretty easy to // generalise it to the Fixity::None code. - lhs = self.parse_range_expr(prec, lhs, op, cur_op_span)?; + lhs = self.parse_range_expr(prec, lhs, op.node, cur_op_span)?; break; } + let op = op.node; + let fixity = op.fixity(); let prec_adjustment = match fixity { Fixity::Right => 0, @@ -366,7 +362,7 @@ impl<'a> Parser<'a> { let aopexpr = self.mk_assign_op(source_map::respan(cur_op_span, aop), lhs, rhs); self.mk_expr(span, aopexpr) } - AssocOp::As | AssocOp::Colon | AssocOp::DotDot | AssocOp::DotDotEq => { + AssocOp::As | AssocOp::DotDot | AssocOp::DotDotEq => { self.span_bug(span, "AssocOp should have been handled by special case") } }; @@ -375,9 +371,7 @@ impl<'a> Parser<'a> { break; } } - if last_type_ascription_set { - self.last_type_ascription = None; - } + Ok(lhs) } @@ -815,21 +809,19 @@ impl<'a> Parser<'a> { &mut self, cast_expr: P, ) -> PResult<'a, P> { + if let ExprKind::Type(_, _) = cast_expr.kind { + panic!("ExprKind::Type must not be parsed"); + } + let span = cast_expr.span; - let (cast_kind, maybe_ascription_span) = - if let ExprKind::Type(ascripted_expr, _) = &cast_expr.kind { - ("type ascription", Some(ascripted_expr.span.shrink_to_hi().with_hi(span.hi()))) - } else { - ("cast", None) - }; let with_postfix = self.parse_dot_or_call_expr_with_(cast_expr, span)?; // Check if an illegal postfix operator has been added after the cast. // If the resulting expression is not a cast, it is an illegal postfix operator. - if !matches!(with_postfix.kind, ExprKind::Cast(_, _) | ExprKind::Type(_, _)) { + if !matches!(with_postfix.kind, ExprKind::Cast(_, _)) { let msg = format!( - "{cast_kind} cannot be followed by {}", + "cast cannot be followed by {}", match with_postfix.kind { ExprKind::Index(_, _) => "indexing", ExprKind::Try(_) => "`?`", @@ -855,44 +847,13 @@ impl<'a> Parser<'a> { ); }; - // If type ascription is "likely an error", the user will already be getting a useful - // help message, and doesn't need a second. - if self.last_type_ascription.map_or(false, |last_ascription| last_ascription.1) { - self.maybe_annotate_with_ascription(&mut err, false); - } else if let Some(ascription_span) = maybe_ascription_span { - let is_nightly = self.sess.unstable_features.is_nightly_build(); - if is_nightly { - suggest_parens(&mut err); - } - err.span_suggestion( - ascription_span, - &format!( - "{}remove the type ascription", - if is_nightly { "alternatively, " } else { "" } - ), - "", - if is_nightly { - Applicability::MaybeIncorrect - } else { - Applicability::MachineApplicable - }, - ); - } else { - suggest_parens(&mut err); - } + suggest_parens(&mut err); + err.emit(); }; Ok(with_postfix) } - fn parse_assoc_op_ascribe(&mut self, lhs: P, lhs_span: Span) -> PResult<'a, P> { - let maybe_path = self.could_ascription_be_path(&lhs.kind); - self.last_type_ascription = Some((self.prev_token.span, maybe_path)); - let lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Type)?; - self.sess.gated_spans.gate(sym::type_ascription, lhs.span); - Ok(lhs) - } - /// Parse `& mut? ` or `& raw [ const | mut ] `. fn parse_borrow_expr(&mut self, lo: Span) -> PResult<'a, (Span, ExprKind)> { self.expect_and()?; @@ -1001,12 +962,6 @@ impl<'a> Parser<'a> { } } - fn look_ahead_type_ascription_as_field(&mut self) -> bool { - self.look_ahead(1, |t| t.is_ident()) - && self.look_ahead(2, |t| t == &token::Colon) - && self.look_ahead(3, |t| t.can_begin_expr()) - } - fn parse_dot_suffix_expr(&mut self, lo: Span, base: P) -> PResult<'a, P> { match self.token.uninterpolate().kind { token::Ident(..) => self.parse_dot_suffix(base, lo), @@ -1160,9 +1115,7 @@ impl<'a> Parser<'a> { /// Parse a function call expression, `expr(...)`. fn parse_fn_call_expr(&mut self, lo: Span, fun: P) -> P { - let snapshot = if self.token.kind == token::OpenDelim(Delimiter::Parenthesis) - && self.look_ahead_type_ascription_as_field() - { + let snapshot = if self.token.kind == token::OpenDelim(Delimiter::Parenthesis) { Some((self.create_snapshot_for_diagnostic(), fun.kind.clone())) } else { None @@ -1503,7 +1456,6 @@ impl<'a> Parser<'a> { let mac = P(MacCall { path, args: self.parse_delim_args()?, - prior_type_ascription: self.last_type_ascription, }); (lo.to(self.prev_token.span), ExprKind::MacCall(mac)) } else if self.check(&token::OpenDelim(Delimiter::Brace)) diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 53680a82bdc2e..226460b9bb3d5 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -478,7 +478,7 @@ impl<'a> Parser<'a> { Ok(args) => { self.eat_semi_for_macro_if_needed(&args); self.complain_if_pub_macro(vis, false); - Ok(MacCall { path, args, prior_type_ascription: self.last_type_ascription }) + Ok(MacCall { path, args }) } Err(mut err) => { diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 2fd2a4e5154f3..906d24c198b7e 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -151,9 +151,6 @@ pub struct Parser<'a> { /// error. pub(super) unclosed_delims: Vec, last_unexpected_token_span: Option, - /// Span pointing at the `:` for the last type ascription the parser has seen, and whether it - /// looked like it could have been a mistyped path or literal `Option:Some(42)`). - pub last_type_ascription: Option<(Span, bool /* likely path typo */)>, /// If present, this `Parser` is not parsing Rust code but rather a macro call. subparser_name: Option<&'static str>, capture_state: CaptureState, @@ -168,7 +165,7 @@ pub struct Parser<'a> { // This type is used a lot, e.g. it's cloned when matching many declarative macro rules with nonterminals. Make sure // it doesn't unintentionally get bigger. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -rustc_data_structures::static_assert_size!(Parser<'_>, 336); +rustc_data_structures::static_assert_size!(Parser<'_>, 320); /// Stores span information about a closure. #[derive(Clone)] @@ -486,7 +483,6 @@ impl<'a> Parser<'a> { max_angle_bracket_count: 0, unclosed_delims: Vec::new(), last_unexpected_token_span: None, - last_type_ascription: None, subparser_name, capture_state: CaptureState { capturing: Capturing::No, diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 0b057f2f577fe..25d80c7c9c10a 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -692,7 +692,7 @@ impl<'a> Parser<'a> { fn parse_pat_mac_invoc(&mut self, path: Path) -> PResult<'a, PatKind> { self.bump(); let args = self.parse_delim_args()?; - let mac = P(MacCall { path, args, prior_type_ascription: self.last_type_ascription }); + let mac = P(MacCall { path, args }); Ok(PatKind::MacCall(mac)) } diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 1e5c283496035..159455c671a1d 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -184,7 +184,7 @@ impl<'a> Parser<'a> { _ => MacStmtStyle::NoBraces, }; - let mac = P(MacCall { path, args, prior_type_ascription: self.last_type_ascription }); + let mac = P(MacCall { path, args }); let kind = if (style == MacStmtStyle::Braces && self.token != token::Dot @@ -551,7 +551,6 @@ impl<'a> Parser<'a> { } let stmt = match self.parse_full_stmt(recover) { Err(mut err) if recover.yes() => { - self.maybe_annotate_with_ascription(&mut err, false); if let Some(ref mut snapshot) = snapshot { snapshot.recover_diff_marker(); } diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index a6f702e542869..8479a7bcff35e 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -317,7 +317,6 @@ impl<'a> Parser<'a> { let msg = format!("expected type, found {}", super::token_descr(&self.token)); let mut err = self.struct_span_err(self.token.span, &msg); err.span_label(self.token.span, "expected type"); - self.maybe_annotate_with_ascription(&mut err, true); return Err(err); }; @@ -685,11 +684,7 @@ impl<'a> Parser<'a> { let path = self.parse_path_inner(PathStyle::Type, ty_generics)?; if self.eat(&token::Not) { // Macro invocation in type position - Ok(TyKind::MacCall(P(MacCall { - path, - args: self.parse_delim_args()?, - prior_type_ascription: self.last_type_ascription, - }))) + Ok(TyKind::MacCall(P(MacCall { path, args: self.parse_delim_args()? }))) } else if allow_plus == AllowPlus::Yes && self.check_plus() { // `Trait1 + Trait2 + 'a` self.parse_remaining_bounds_path(Vec::new(), path, lo, true) From 9a59e5adf3aba32e7c14120bffa6d5a932cc64b3 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Thu, 29 Dec 2022 17:33:20 +0100 Subject: [PATCH 2/2] wip --- .../locales/en-US/parse.ftl | 8 + compiler/rustc_parse/src/errors.rs | 22 + .../rustc_parse/src/parser/diagnostics.rs | 44 +- compiler/rustc_parse/src/parser/expr.rs | 14 +- compiler/rustc_parse/src/parser/pat.rs | 8 +- compiler/rustc_parse/src/parser/path.rs | 67 ++- compiler/rustc_parse/src/parser/stmt.rs | 103 ++++- compiler/rustc_resolve/src/late.rs | 11 +- .../rustc_resolve/src/late/diagnostics.rs | 6 +- tests/ui/consts/auxiliary/external_macro.rs | 2 +- ...92-tuple-destructure-missing-parens.stderr | 1 + .../feature-gate-type_ascription.rs | 2 +- .../feature-gate-type_ascription.stderr | 6 +- .../equality-bound.stderr | 5 +- .../parse/trait-path-missing-gen_arg.rs | 3 - .../parse/trait-path-missing-gen_arg.stderr | 31 +- .../single-colon-path-not-const-generics.rs | 4 +- ...ingle-colon-path-not-const-generics.stderr | 11 +- tests/ui/impl-trait/issue-72911.stderr | 11 +- tests/ui/issues/issue-22644.rs | 12 +- tests/ui/issues/issue-22644.stderr | 51 +-- .../builtin-prelude-no-accidents.stderr | 15 +- tests/ui/macros/stringify.rs | 3 +- .../or-patterns/or-patterns-syntactic-fail.rs | 3 +- .../or-patterns-syntactic-fail.stderr | 41 +- tests/ui/parser/attr-stmt-expr-attr-bad.rs | 1 + .../ui/parser/attr-stmt-expr-attr-bad.stderr | 107 ++--- .../ui/parser/dyn-trait-compatibility.stderr | 24 +- .../issue-35813-postfix-after-cast.stderr | 389 ++---------------- tests/ui/parser/issues/issue-44406.stderr | 38 +- .../issues/issue-87086-colon-path-sep.stderr | 5 + tests/ui/parser/issues/issue-91461.stderr | 31 +- .../ui/parser/recover-from-bad-variant.stderr | 37 +- .../ui/pattern/pattern-error-continue.stderr | 15 +- .../ui/resolve/resolve-variant-assoc-item.rs | 2 +- .../resolve/resolve-variant-assoc-item.stderr | 16 +- .../suggestions/many-type-ascription.stderr | 10 +- .../type-ascription-instead-of-let.stderr | 27 +- .../type-ascription-instead-of-method.stderr | 10 +- .../type-ascription-instead-of-path-2.fixed | 2 +- .../type-ascription-instead-of-path-2.stderr | 10 +- .../type-ascription-instead-of-path.stderr | 18 +- .../type-ascription-instead-of-variant.stderr | 10 +- tests/ui/track-diagnostics/track4.stderr | 2 +- .../assoc_type_bound_with_struct.stderr | 12 +- tests/ui/type/ascription/issue-34255-1.stderr | 39 +- tests/ui/type/ascription/issue-47666.stderr | 14 +- tests/ui/type/ascription/issue-54516.stderr | 10 +- tests/ui/type/ascription/issue-60933.stderr | 10 +- tests/ui/type/issue-91268.stderr | 46 +-- tests/ui/type/missing-let-in-binding.fixed | 2 +- tests/ui/type/missing-let-in-binding.stderr | 18 +- ...ascription-instead-of-statement-end.stderr | 22 +- .../ui/type/type-ascription-precedence.stderr | 65 +-- .../type/type-ascription-with-fn-call.stderr | 11 +- tests/ui/type/type-path-err-node-types.stderr | 12 +- tests/ui/ufcs/ufcs-partially-resolved.stderr | 10 + 57 files changed, 611 insertions(+), 898 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/parse.ftl b/compiler/rustc_error_messages/locales/en-US/parse.ftl index 8f063f5082c95..356c644a1f836 100644 --- a/compiler/rustc_error_messages/locales/en-US/parse.ftl +++ b/compiler/rustc_error_messages/locales/en-US/parse.ftl @@ -373,6 +373,14 @@ parse_maybe_fn_typo_with_impl = you might have meant to write `impl` instead of parse_expected_fn_path_found_fn_keyword = expected identifier, found keyword `fn` .suggestion = use `Fn` to refer to the trait +parse_path_single_colon = path separator must be a double colon + .suggestion = use a double colon instead + +parse_colon_as_semi = statements are terminated with a semicolon + .suggestion = use a semicolon instead + +parse_type_ascription_removed = type ascription syntax has been removed, see issue #101728 + parse_where_clause_before_tuple_struct_body = where clauses are not allowed before tuple struct bodies .label = unexpected where clause .name_label = while parsing this tuple struct diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 06b970ad97977..1a3bee6c1726e 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -1256,6 +1256,28 @@ pub(crate) struct ExpectedFnPathFoundFnKeyword { pub fn_token_span: Span, } +#[derive(Diagnostic)] +#[diag(parse_path_single_colon)] +pub(crate) struct PathSingleColon { + #[primary_span] + #[suggestion(applicability = "machine-applicable", code = "::")] + pub span: Span, + + #[note(parse_type_ascription_removed)] + pub type_ascription: Option<()>, +} + +#[derive(Diagnostic)] +#[diag(parse_colon_as_semi)] +pub(crate) struct ColonAsSemi { + #[primary_span] + #[suggestion(applicability = "machine-applicable", code = ";")] + pub span: Span, + + #[note(parse_type_ascription_removed)] + pub type_ascription: Option<()>, +} + #[derive(Diagnostic)] #[diag(parse_where_clause_before_tuple_struct_body)] pub(crate) struct WhereClauseBeforeTupleStructBody { diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 3dc87354f08df..c0d9bd39b5ff0 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -4,7 +4,7 @@ use super::{ TokenExpectType, TokenType, }; use crate::errors::{ - AmbiguousPlus, AttributeOnParamType, BadQPathStage2, BadTypePlus, BadTypePlusSub, + AmbiguousPlus, AttributeOnParamType, BadQPathStage2, BadTypePlus, BadTypePlusSub, ColonAsSemi, ComparisonOperatorsCannotBeChained, ComparisonOperatorsCannotBeChainedSugg, ConstGenericWithoutBraces, ConstGenericWithoutBracesSugg, DocCommentOnParamType, DoubleColonInBound, ExpectedIdentifier, ExpectedSemi, ExpectedSemiSugg, @@ -85,6 +85,7 @@ impl RecoverQPath for Ty { } impl RecoverQPath for Pat { + const PATH_STYLE: PathStyle = PathStyle::Pat; fn to_ty(&self) -> Option> { self.to_ty() } @@ -241,6 +242,7 @@ impl<'a> DerefMut for SnapshotParser<'a> { impl<'a> Parser<'a> { #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_err>( &self, sp: S, @@ -1475,9 +1477,40 @@ impl<'a> Parser<'a> { if self.eat(&token::Semi) { return Ok(()); } + + if self.recover_colon_as_semi() { + return Ok(()); + } + self.expect(&token::Semi).map(drop) // Error unconditionally } + pub(super) fn recover_colon_as_semi(&mut self) -> bool { + let line_idx = |span: Span| { + self.sess + .source_map() + .span_to_lines(span) + .ok() + .and_then(|lines| Some(lines.lines.get(0)?.line_index)) + }; + + if self.may_recover() + && self.token == token::Colon + && self.look_ahead(1, |next| line_idx(self.token.span) < line_idx(next.span)) + { + self.sess.emit_err(ColonAsSemi { + span: self.token.span, + type_ascription: self.sess.unstable_features.is_nightly_build().then_some(()), + }); + + self.bump(); + + return true; + } + + false + } + /// Consumes alternative await syntaxes like `await!()`, `await `, /// `await? `, `await()`, and `await { }`. pub(super) fn recover_incorrect_await_syntax( @@ -1809,7 +1842,7 @@ impl<'a> Parser<'a> { && brace_depth == 0 && bracket_depth == 0 => { - debug!("recover_stmt_ return - Semi"); + debug!("recover_stmt_ return - Comma"); break; } _ => self.bump(), @@ -2236,6 +2269,7 @@ impl<'a> Parser<'a> { if is_op_or_dot { self.bump(); } + debug!("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); match self.parse_expr_res(Restrictions::CONST_EXPR, None) { Ok(expr) => { // Find a mistake like `MyTrait`. @@ -2249,7 +2283,8 @@ impl<'a> Parser<'a> { let value = self.mk_expr_err(start.to(expr.span)); err.emit(); return Ok(GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value })); - } else if token::Colon == snapshot.token.kind + } + /*else if token::Colon == snapshot.token.kind && expr.span.lo() == snapshot.token.span.hi() && matches!(expr.kind, ExprKind::Path(..)) { @@ -2262,7 +2297,8 @@ impl<'a> Parser<'a> { ); err.emit(); return Ok(GenericArg::Type(self.mk_ty(start.to(expr.span), TyKind::Err))); - } else if token::Comma == self.token.kind || self.token.kind.should_end_const_arg() + } */ + else if token::Comma == self.token.kind || self.token.kind.should_end_const_arg() { // Avoid the following output by checking that we consumed a full const arg: // help: expressions must be enclosed in braces to be used as const generic diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index bb534a5c93bab..53a0c7955ca3e 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -716,7 +716,7 @@ impl<'a> Parser<'a> { ( // `foo: ` ExprKind::Path(None, ast::Path { segments, .. }), - TokenKind::Ident(kw::For | kw::Loop | kw::While, false), + token::Ident(kw::For | kw::Loop | kw::While, false), ) if segments.len() == 1 => { let snapshot = self.create_snapshot_for_diagnostic(); let label = Label { @@ -1185,8 +1185,8 @@ impl<'a> Parser<'a> { return Some(self.mk_expr_err(span)); } Ok(_) => {} - Err(mut err) => { - err.emit(); + Err(err) => { + err.cancel(); } } } @@ -1474,7 +1474,7 @@ impl<'a> Parser<'a> { } /// Parse `'label: $expr`. The label is already parsed. - fn parse_labeled_expr( + pub(super) fn parse_labeled_expr( &mut self, label_: Label, mut consume_colon: bool, @@ -2864,6 +2864,11 @@ impl<'a> Parser<'a> { } else { e.span_label(pth.span, "while parsing this struct"); } + + if !recover { + return Err(e); + } + e.emit(); // If the next token is a comma, then try to parse @@ -2875,6 +2880,7 @@ impl<'a> Parser<'a> { break; } } + None } }; diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 25d80c7c9c10a..eb2fdb5f56c24 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -382,11 +382,11 @@ impl<'a> Parser<'a> { // Parse pattern starting with a path let (qself, path) = if self.eat_lt() { // Parse a qualified path - let (qself, path) = self.parse_qpath(PathStyle::Expr)?; + let (qself, path) = self.parse_qpath(PathStyle::Pat)?; (Some(qself), path) } else { // Parse an unqualified path - (None, self.parse_path(PathStyle::Expr)?) + (None, self.parse_path(PathStyle::Pat)?) }; let span = lo.to(self.prev_token.span); @@ -827,11 +827,11 @@ impl<'a> Parser<'a> { let lo = self.token.span; let (qself, path) = if self.eat_lt() { // Parse a qualified path - let (qself, path) = self.parse_qpath(PathStyle::Expr)?; + let (qself, path) = self.parse_qpath(PathStyle::Pat)?; (Some(qself), path) } else { // Parse an unqualified path - (None, self.parse_path(PathStyle::Expr)?) + (None, self.parse_path(PathStyle::Pat)?) }; let hi = self.prev_token.span; Ok(self.mk_expr(lo.to(hi), ExprKind::Path(qself, path))) diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 5333d3b8587dd..373f723f08965 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -1,5 +1,6 @@ use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{Parser, Restrictions, TokenType}; +use crate::errors::PathSingleColon; use crate::maybe_whole; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Token, TokenKind}; @@ -8,7 +9,7 @@ use rustc_ast::{ AssocConstraintKind, BlockCheckMode, GenericArg, GenericArgs, Generics, ParenthesizedArgs, Path, PathSegment, QSelf, }; -use rustc_errors::{pluralize, Applicability, PResult}; +use rustc_errors::{pluralize, Applicability, IntoDiagnostic, PResult}; use rustc_span::source_map::{BytePos, Span}; use rustc_span::symbol::{kw, sym, Ident}; use std::mem; @@ -24,7 +25,19 @@ pub enum PathStyle { /// In all such contexts the non-path interpretation is preferred by default for practical /// reasons, but the path interpretation can be forced by the disambiguator `::`, e.g. /// `x` - comparisons, `x::` - unambiguously a path. + /// + /// Also, a path may never be followed by a `:`. This means that we can eagerly recover if + /// we encounter it. Expr, + /// The same as `Expr`, but may be followed by a `:`. + /// For example, this code: + /// ```rust + /// struct S; + /// + /// let S: S; + /// // ^ Followed by a `:` + /// ``` + Pat, /// In other contexts, notably in types, no ambiguity exists and paths can be written /// without the disambiguator, e.g., `x` - unambiguously a path. /// Paths with disambiguators are still accepted, `x::` - unambiguously a path too. @@ -38,6 +51,12 @@ pub enum PathStyle { Mod, } +impl PathStyle { + fn has_generic_ambiguity(&self) -> bool { + matches!(self, Self::Expr | Self::Pat) + } +} + impl<'a> Parser<'a> { /// Parses a qualified path. /// Assumes that the leading `<` has been parsed already. @@ -198,7 +217,7 @@ impl<'a> Parser<'a> { ) -> PResult<'a, ()> { loop { let segment = self.parse_path_segment(style, ty_generics)?; - if style == PathStyle::Expr { + if style.has_generic_ambiguity() { // In order to check for trailing angle brackets, we must have finished // recursing (`parse_path_segment` can indirectly call this function), // that is, the next token must be the highlighted part of the below example: @@ -220,6 +239,23 @@ impl<'a> Parser<'a> { segments.push(segment); if self.is_import_coupler() || !self.eat(&token::ModSep) { + if style == PathStyle::Expr + && self.may_recover() + && self.token == token::Colon + && self.look_ahead(1, |token| token.is_ident() && !token.is_reserved_ident()) + { + self.bump(); // bump past the colon + self.sess.emit_err(PathSingleColon { + span: self.prev_token.span, + type_ascription: self + .sess + .unstable_features + .is_nightly_build() + .then_some(()), + }); + continue; + } + return Ok(()); } } @@ -273,8 +309,25 @@ impl<'a> Parser<'a> { ty_generics, )?; self.expect_gt().map_err(|mut err| { + // Try to recover a `:` into a `::` + if self.token == token::Colon + && self.look_ahead(1, |token| { + token.is_ident() && !token.is_reserved_ident() + }) + { + err.cancel(); + err = PathSingleColon { + span: self.token.span, + type_ascription: self + .sess + .unstable_features + .is_nightly_build() + .then_some(()), + } + .into_diagnostic(self.diagnostic()); + } // Attempt to find places where a missing `>` might belong. - if let Some(arg) = args + else if let Some(arg) = args .iter() .rev() .find(|arg| !matches!(arg, AngleBracketedArg::Constraint(_))) @@ -666,6 +719,7 @@ impl<'a> Parser<'a> { &mut self, ty_generics: Option<&Generics>, ) -> PResult<'a, Option> { + debug!("pain"); let start = self.token.span; let arg = if self.check_lifetime() && self.look_ahead(1, |t| !t.is_like_plus()) { // Parse lifetime argument. @@ -674,13 +728,18 @@ impl<'a> Parser<'a> { // Parse const argument. GenericArg::Const(self.parse_const_arg()?) } else if self.check_type() { + debug!("type"); // Parse type argument. let is_const_fn = self.look_ahead(1, |t| t.kind == token::OpenDelim(Delimiter::Parenthesis)); let mut snapshot = self.create_snapshot_for_diagnostic(); match self.parse_ty() { - Ok(ty) => GenericArg::Type(ty), + Ok(ty) => { + debug!(?ty, "success ty"); + GenericArg::Type(ty) + } Err(err) => { + debug!("should recover"); if is_const_fn { match (*snapshot).parse_expr_res(Restrictions::CONST_EXPR, None) { Ok(expr) => { diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 159455c671a1d..9c686c6cac5d4 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -11,10 +11,11 @@ use crate::errors::{ AssignmentElseNotAllowed, CompoundAssignmentExpressionInLet, ConstLetMutuallyExclusive, DocCommentDoesNotDocumentAnything, ExpectedStatementAfterOuterAttr, InvalidCurlyInLetElse, InvalidExpressionInLetElse, InvalidIdentiferStartsWithNumber, InvalidVariableDeclaration, - InvalidVariableDeclarationSub, WrapExpressionInParentheses, + InvalidVariableDeclarationSub, MalformedLoopLabel, WrapExpressionInParentheses, }; use crate::maybe_whole; +use ast::Label; use rustc_ast as ast; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, TokenKind}; @@ -24,7 +25,7 @@ use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, HasAttrs, Local, Stmt}; use rustc_ast::{StmtKind, DUMMY_NODE_ID}; use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult}; use rustc_span::source_map::{BytePos, Span}; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::{kw, sym, Ident}; use std::mem; @@ -554,6 +555,12 @@ impl<'a> Parser<'a> { if let Some(ref mut snapshot) = snapshot { snapshot.recover_diff_marker(); } + if self.token == token::Colon && self.sess.unstable_features.is_nightly_build() + { + // FIXME(Nilstrieb): Remove this again after a few months. + err.note("type ascription syntax has been removed, see issue #101728 "); + } + err.emit(); self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore); Some(self.mk_stmt_err(self.token.span)) @@ -584,19 +591,25 @@ impl<'a> Parser<'a> { }; let mut eat_semi = true; + let mut add_semi_to_stmt = false; + match &mut stmt.kind { // Expression without semicolon. StmtKind::Expr(expr) if self.token != token::Eof && classify::expr_requires_semi_to_be_stmt(expr) => { // Just check for errors and recover; do not eat semicolon yet. // `expect_one_of` returns PResult<'a, bool /* recovered */> - let replace_with_err = - match self.expect_one_of(&[], &[token::Semi, token::CloseDelim(Delimiter::Brace)]) { + + let expect_result = self.expect_one_of(&[], &[token::Semi, token::CloseDelim(Delimiter::Brace)]); + + let replace_with_err = 'break_recover: { + match expect_result { // Recover from parser, skip type error to avoid extra errors. - Ok(true) => true, - Err(mut e) => { - if let TokenKind::DocComment(..) = self.token.kind && - let Ok(snippet) = self.span_to_snippet(self.token.span) { + Ok(true) => true, + Err(mut e) => { + if let TokenKind::DocComment(..) = self.token.kind + && let Ok(snippet) = self.span_to_snippet(self.token.span) + { let sp = self.token.span; let marker = &snippet[..3]; let (comment_marker, doc_comment_marker) = marker.split_at(2); @@ -610,21 +623,72 @@ impl<'a> Parser<'a> { format!("{} {}", comment_marker, doc_comment_marker), Applicability::MaybeIncorrect, ); - } + } + + if self.recover_colon_as_semi() { + // recover_colon_as_semi has already emitted a nicer error. + e.cancel(); + add_semi_to_stmt = true; + eat_semi = false; - if let Err(mut e) = - self.check_mistyped_turbofish_with_multiple_type_params(e, expr) - { - if recover.no() { - return Err(e); + break 'break_recover false; } - e.emit(); - self.recover_stmt(); + + match &expr.kind { + ExprKind::Path(None, ast::Path { segments, .. }) if segments.len() == 1 => { + if self.token == token::Colon + && self.look_ahead(1, |token| { + token.is_whole_block() || matches!( + token.kind, + token::Ident(kw::For | kw::Loop | kw::While, false) + | token::OpenDelim(Delimiter::Brace) + ) + }) + { + let snapshot = self.create_snapshot_for_diagnostic(); + let label = Label { + ident: Ident::from_str_and_span( + &format!("'{}", segments[0].ident), + segments[0].ident.span, + ), + }; + match self.parse_labeled_expr(label, false) { + Ok(labeled_expr) => { + e.cancel(); + self.sess.emit_err(MalformedLoopLabel { + span: label.ident.span, + correct_label: label.ident, + }); + *expr = labeled_expr; + break 'break_recover false; + } + Err(err) => { + err.cancel(); + self.restore_snapshot(snapshot); + } + } + } + } + _ => {} + } + + if let Err(mut e) = + self.check_mistyped_turbofish_with_multiple_type_params(e, expr) + { + if recover.no() { + return Err(e); + } + e.emit(); + self.recover_stmt(); + } + + true + } - true + Ok(false) => false } - _ => false }; + if replace_with_err { // We already emitted an error, so don't emit another type error let sp = expr.span.to(self.prev_token.span); @@ -647,9 +711,10 @@ impl<'a> Parser<'a> { StmtKind::Empty | StmtKind::Item(_) | StmtKind::Local(_) | StmtKind::Semi(_) => eat_semi = false, } - if eat_semi && self.eat(&token::Semi) { + if add_semi_to_stmt || (eat_semi && self.eat(&token::Semi)) { stmt = stmt.add_trailing_semicolon(); } + stmt.span = stmt.span.to(self.prev_token.span); Ok(Some(stmt)) } diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index ca43762aa214e..4027953169711 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -3399,10 +3399,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { // // Similar thing, for types, happens in `report_errors` above. let report_errors_for_call = |this: &mut Self, parent_err: Spanned>| { - if !source.is_call() { - return Some(parent_err); - } - // Before we start looking for candidates, we have to get our hands // on the type user is trying to perform invocation on; basically: // we're transforming `HashMap::new` into just `HashMap`. @@ -3541,6 +3537,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { } Err(err) => { + debug!("a call??"); if let Some(err) = report_errors_for_call(self, err) { self.report_error(err.span, err.node); } @@ -3632,6 +3629,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { } /// Handles paths that may refer to associated items. + #[instrument(level = "debug", skip(self))] fn resolve_qpath( &mut self, qself: &Option>, @@ -3639,11 +3637,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { ns: Namespace, finalize: Finalize, ) -> Result, Spanned>> { - debug!( - "resolve_qpath(qself={:?}, path={:?}, ns={:?}, finalize={:?})", - qself, path, ns, finalize, - ); - if let Some(qself) = qself { if qself.position == 0 { // This is a case like `::B`, where there is no diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index d92b046d0b9f2..ebd83f3483da7 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -305,6 +305,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { /// Handles error reporting for `smart_resolve_path_fragment` function. /// Creates base error and amends it with one short label and possibly some longer helps/notes. + #[instrument(level = "debug", skip(self))] pub(crate) fn smart_resolve_report_errors( &mut self, path: &[Segment], @@ -350,7 +351,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { return (err, candidates); } - if !self.type_ascription_suggestion(&mut err, base_error.span) { + if !self.suggest_missing_let(&mut err, base_error.span) { let mut fallback = self.suggest_trait_and_bounds(&mut err, source, res, span, &base_error); @@ -1773,7 +1774,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { start.to(sm.next_point(start)) } - fn type_ascription_suggestion(&self, err: &mut Diagnostic, base_span: Span) -> bool { + #[instrument(level = "debug", skip(self, err))] + fn suggest_missing_let(&self, err: &mut Diagnostic, base_span: Span) -> bool { let sm = self.r.session.source_map(); let base_snippet = sm.span_to_snippet(base_span); if let Some(&sp) = self.diagnostic_metadata.current_type_ascription.last() { diff --git a/tests/ui/consts/auxiliary/external_macro.rs b/tests/ui/consts/auxiliary/external_macro.rs index d260634c9963b..fea24703ddadf 100644 --- a/tests/ui/consts/auxiliary/external_macro.rs +++ b/tests/ui/consts/auxiliary/external_macro.rs @@ -9,6 +9,6 @@ macro_rules! static_assert { ($test:expr) => { #[allow(dead_code)] - const _: () = [()][!($test: bool) as usize]; + const _: () = [()][!($test) as usize]; } } diff --git a/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr b/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr index a3c607b59037f..6d92fa5e14e98 100644 --- a/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr +++ b/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr @@ -65,6 +65,7 @@ error: unexpected `,` in pattern LL | let women, men: (Vec, Vec) = genomes.iter().cloned() | ^ | + = note: type ascription syntax has been removed, see issue #101728 help: try adding parentheses to match on a tuple | LL | let (women, men): (Vec, Vec) = genomes.iter().cloned() diff --git a/tests/ui/feature-gates/feature-gate-type_ascription.rs b/tests/ui/feature-gates/feature-gate-type_ascription.rs index 7a597157300ed..5c3f0e37df63d 100644 --- a/tests/ui/feature-gates/feature-gate-type_ascription.rs +++ b/tests/ui/feature-gates/feature-gate-type_ascription.rs @@ -1,5 +1,5 @@ // Type ascription is unstable fn main() { - let a = 10: u8; //~ ERROR type ascription is experimental + let a = type_ascribe!(10, u8); //~ ERROR use of unstable library feature 'type_ascription': placeholder syntax for type ascription } diff --git a/tests/ui/feature-gates/feature-gate-type_ascription.stderr b/tests/ui/feature-gates/feature-gate-type_ascription.stderr index 615d5b9a1e089..d747aea6d177f 100644 --- a/tests/ui/feature-gates/feature-gate-type_ascription.stderr +++ b/tests/ui/feature-gates/feature-gate-type_ascription.stderr @@ -1,8 +1,8 @@ -error[E0658]: type ascription is experimental +error[E0658]: use of unstable library feature 'type_ascription': placeholder syntax for type ascription --> $DIR/feature-gate-type_ascription.rs:4:13 | -LL | let a = 10: u8; - | ^^^^^^ +LL | let a = type_ascribe!(10, u8); + | ^^^^^^^^^^^^ | = note: see issue #23416 for more information = help: add `#![feature(type_ascription)]` to the crate attributes to enable diff --git a/tests/ui/generic-associated-types/equality-bound.stderr b/tests/ui/generic-associated-types/equality-bound.stderr index d78f7a7fbcee1..b21ff30a27da9 100644 --- a/tests/ui/generic-associated-types/equality-bound.stderr +++ b/tests/ui/generic-associated-types/equality-bound.stderr @@ -36,7 +36,10 @@ error[E0433]: failed to resolve: use of undeclared type `I` --> $DIR/equality-bound.rs:9:41 | LL | fn sum3(i: J) -> i32 where I::Item = i32 { - | ^ use of undeclared type `I` + | ^ + | | + | use of undeclared type `I` + | help: a type parameter with a similar name exists: `J` error: aborting due to 4 previous errors diff --git a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs index ecabf8943ea3c..b7b93ef1c443b 100644 --- a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs +++ b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs @@ -5,9 +5,6 @@ trait X { const _: () = { fn f1<'a>(arg : Box>) {} //~^ ERROR: expected one of `>`, a const expression, lifetime, or type, found `:` - //~| ERROR: expected parameter name, found `>` - //~| ERROR: expected one of `!`, `)`, `+`, `,`, or `::`, found `>` - //~| ERROR: constant provided when a type was expected }; const _: () = { diff --git a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr index 10ceccedcac1b..bfddb6dc693ca 100644 --- a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr +++ b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr @@ -3,41 +3,14 @@ error: expected one of `>`, a const expression, lifetime, or type, found `:` | LL | fn f1<'a>(arg : Box>) {} | ^ expected one of `>`, a const expression, lifetime, or type - | -help: expressions must be enclosed in braces to be used as const generic arguments - | -LL | fn f1<'a>(arg : Box<{ dyn X< : 32 } >>) {} - | + + - -error: expected parameter name, found `>` - --> $DIR/trait-path-missing-gen_arg.rs:6:36 - | -LL | fn f1<'a>(arg : Box>) {} - | ^ expected parameter name - -error: expected one of `!`, `)`, `+`, `,`, or `::`, found `>` - --> $DIR/trait-path-missing-gen_arg.rs:6:36 - | -LL | fn f1<'a>(arg : Box>) {} - | ^ - | | - | expected one of `!`, `)`, `+`, `,`, or `::` - | help: missing `,` error: expected one of `>`, a const expression, lifetime, or type, found `=` - --> $DIR/trait-path-missing-gen_arg.rs:14:30 + --> $DIR/trait-path-missing-gen_arg.rs:11:30 | LL | fn f1<'a>(arg : Box>) {} | - ^ expected one of `>`, a const expression, lifetime, or type | | | maybe try to close unmatched angle bracket -error[E0747]: constant provided when a type was expected - --> $DIR/trait-path-missing-gen_arg.rs:6:23 - | -LL | fn f1<'a>(arg : Box>) {} - | ^^^^^^^^^^^ - -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/generics/single-colon-path-not-const-generics.rs b/tests/ui/generics/single-colon-path-not-const-generics.rs index 55a7ae0bb6d91..dff00b0b72007 100644 --- a/tests/ui/generics/single-colon-path-not-const-generics.rs +++ b/tests/ui/generics/single-colon-path-not-const-generics.rs @@ -6,8 +6,8 @@ pub mod foo { pub struct Foo { a: Vec, - //~^ ERROR expected - //~| HELP path separator + //~^ ERROR path separator must be a double colon + //~| HELP use a double colon instead } fn main() {} diff --git a/tests/ui/generics/single-colon-path-not-const-generics.stderr b/tests/ui/generics/single-colon-path-not-const-generics.stderr index 3eafa9fa5a9dd..bb34c0ba546b6 100644 --- a/tests/ui/generics/single-colon-path-not-const-generics.stderr +++ b/tests/ui/generics/single-colon-path-not-const-generics.stderr @@ -1,11 +1,12 @@ -error: expected one of `,` or `>`, found `:` +error: path separator must be a double colon --> $DIR/single-colon-path-not-const-generics.rs:8:18 | +LL | pub struct Foo { + | --- while parsing this struct LL | a: Vec, - | ^ - | | - | expected one of `,` or `>` - | help: write a path separator here: `::` + | ^ help: use a double colon instead: `::` + | + = note: type ascription syntax has been removed, see issue #101728 error: aborting due to previous error diff --git a/tests/ui/impl-trait/issue-72911.stderr b/tests/ui/impl-trait/issue-72911.stderr index 0e86561aa2779..c10e69ce1dbd6 100644 --- a/tests/ui/impl-trait/issue-72911.stderr +++ b/tests/ui/impl-trait/issue-72911.stderr @@ -1,3 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/issue-72911.rs:7:24 + | +LL | pub fn gather_all() -> impl Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type + error[E0433]: failed to resolve: use of undeclared crate or module `foo` --> $DIR/issue-72911.rs:11:33 | @@ -10,6 +16,7 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo` LL | fn lint_files() -> impl Iterator { | ^^^ use of undeclared crate or module `foo` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0433`. +Some errors have detailed explanations: E0282, E0433. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/issues/issue-22644.rs b/tests/ui/issues/issue-22644.rs index b1d69dcd86260..e3ada65049d56 100644 --- a/tests/ui/issues/issue-22644.rs +++ b/tests/ui/issues/issue-22644.rs @@ -1,18 +1,12 @@ -#![feature(type_ascription)] - fn main() { - let a : usize = 0; - let long_name : usize = 0; + let a: usize = 0; + let long_name: usize = 0; println!("{}", a as usize > long_name); println!("{}", a as usize < long_name); //~ ERROR `<` is interpreted as a start of generic println!("{}{}", a as usize < long_name, long_name); //~^ ERROR `<` is interpreted as a start of generic println!("{}", a as usize < 4); //~ ERROR `<` is interpreted as a start of generic - println!("{}", a: usize > long_name); - println!("{}{}", a: usize < long_name, long_name); - //~^ ERROR `<` is interpreted as a start of generic - println!("{}", a: usize < 4); //~ ERROR `<` is interpreted as a start of generic println!("{}", a as @@ -30,6 +24,4 @@ fn main() { 5); println!("{}", a as usize << long_name); //~ ERROR `<<` is interpreted as a start of generic - - println!("{}", a: &mut 4); //~ ERROR expected type, found `4` } diff --git a/tests/ui/issues/issue-22644.stderr b/tests/ui/issues/issue-22644.stderr index 45027afa7b62b..0799e9ef11b14 100644 --- a/tests/ui/issues/issue-22644.stderr +++ b/tests/ui/issues/issue-22644.stderr @@ -1,5 +1,5 @@ error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:8:31 + --> $DIR/issue-22644.rs:6:31 | LL | println!("{}", a as usize < long_name); | ^ --------- interpreted as generic arguments @@ -12,7 +12,7 @@ LL | println!("{}", (a as usize) < long_name); | + + error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:9:33 + --> $DIR/issue-22644.rs:7:33 | LL | println!("{}{}", a as usize < long_name, long_name); | ^ -------------------- interpreted as generic arguments @@ -25,7 +25,7 @@ LL | println!("{}{}", (a as usize) < long_name, long_name); | + + error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:11:31 + --> $DIR/issue-22644.rs:9:31 | LL | println!("{}", a as usize < 4); | ^ - interpreted as generic arguments @@ -38,33 +38,7 @@ LL | println!("{}", (a as usize) < 4); | + + error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:13:31 - | -LL | println!("{}{}", a: usize < long_name, long_name); - | ^ -------------------- interpreted as generic arguments - | | - | not interpreted as comparison - | -help: try comparing the cast value - | -LL | println!("{}{}", (a: usize) < long_name, long_name); - | + + - -error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:15:29 - | -LL | println!("{}", a: usize < 4); - | ^ - interpreted as generic arguments - | | - | not interpreted as comparison - | -help: try comparing the cast value - | -LL | println!("{}", (a: usize) < 4); - | + + - -error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:20:20 + --> $DIR/issue-22644.rs:14:20 | LL | < | ^ not interpreted as comparison @@ -79,7 +53,7 @@ LL ~ usize) | error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:29:20 + --> $DIR/issue-22644.rs:23:20 | LL | < | ^ not interpreted as comparison @@ -96,7 +70,7 @@ LL ~ usize) | error: `<<` is interpreted as a start of generic arguments for `usize`, not a shift - --> $DIR/issue-22644.rs:32:31 + --> $DIR/issue-22644.rs:26:31 | LL | println!("{}", a as usize << long_name); | ^^ --------- interpreted as generic arguments @@ -108,16 +82,5 @@ help: try shifting the cast value LL | println!("{}", (a as usize) << long_name); | + + -error: expected type, found `4` - --> $DIR/issue-22644.rs:34:28 - | -LL | println!("{}", a: &mut 4); - | - ^ expected type - | | - | tried to parse a type due to this type ascription - | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information - -error: aborting due to 9 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/macros/builtin-prelude-no-accidents.stderr b/tests/ui/macros/builtin-prelude-no-accidents.stderr index 56af618d484b5..8cd9a63b80893 100644 --- a/tests/ui/macros/builtin-prelude-no-accidents.stderr +++ b/tests/ui/macros/builtin-prelude-no-accidents.stderr @@ -4,18 +4,21 @@ error[E0433]: failed to resolve: use of undeclared crate or module `env` LL | env::current_dir; | ^^^ use of undeclared crate or module `env` +error[E0433]: failed to resolve: use of undeclared crate or module `vec` + --> $DIR/builtin-prelude-no-accidents.rs:7:14 + | +LL | type B = vec::Vec; + | ^^^ + | | + | use of undeclared crate or module `vec` + | help: a struct with a similar name exists (notice the capitalization): `Vec` + error[E0433]: failed to resolve: use of undeclared crate or module `panic` --> $DIR/builtin-prelude-no-accidents.rs:6:14 | LL | type A = panic::PanicInfo; | ^^^^^ use of undeclared crate or module `panic` -error[E0433]: failed to resolve: use of undeclared crate or module `vec` - --> $DIR/builtin-prelude-no-accidents.rs:7:14 - | -LL | type B = vec::Vec; - | ^^^ use of undeclared crate or module `vec` - error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 5cd217df6fc2f..0ac26348ede9f 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -138,8 +138,7 @@ fn test_expr() { assert_eq!(stringify_expr!(expr as T), "expr as T"); // ExprKind::Type - assert_eq!(stringify_expr!(expr: T), "expr: T"); - assert_eq!(stringify_expr!(expr: T), "expr: T"); + // There is no syntax for type ascription. // ExprKind::If assert_eq!(stringify_expr!(if true {}), "if true {}"); diff --git a/tests/ui/or-patterns/or-patterns-syntactic-fail.rs b/tests/ui/or-patterns/or-patterns-syntactic-fail.rs index 358e9d034c474..ebf563c5d47fe 100644 --- a/tests/ui/or-patterns/or-patterns-syntactic-fail.rs +++ b/tests/ui/or-patterns/or-patterns-syntactic-fail.rs @@ -8,7 +8,8 @@ use E::*; fn no_top_level_or_patterns() { // We do *not* allow or-patterns at the top level of lambdas... - let _ = |A | B: E| (); //~ ERROR no implementation for `E | ()` + let _ = |A | B: E| (); //~ ERROR path separator must be a double colon + //~^ ERROR failed to resolve: `B` is a variant, not a module // -------- This looks like an or-pattern but is in fact `|A| (B: E | ())`. // ...and for now neither do we allow or-patterns at the top level of functions. diff --git a/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr b/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr index 10d42b7e3c0b8..93ad4778a19ac 100644 --- a/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr +++ b/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr @@ -1,43 +1,50 @@ +error: path separator must be a double colon + --> $DIR/or-patterns-syntactic-fail.rs:11:19 + | +LL | let _ = |A | B: E| (); + | ^ help: use a double colon instead: `::` + | + = note: type ascription syntax has been removed, see issue #101728 + error: top-level or-patterns are not allowed in function parameters - --> $DIR/or-patterns-syntactic-fail.rs:15:13 + --> $DIR/or-patterns-syntactic-fail.rs:16:13 | LL | fn fun1(A | B: E) {} | ^^^^^ help: wrap the pattern in parentheses: `(A | B)` error: top-level or-patterns are not allowed in function parameters - --> $DIR/or-patterns-syntactic-fail.rs:18:13 + --> $DIR/or-patterns-syntactic-fail.rs:19:13 | LL | fn fun2(| A | B: E) {} | ^^^^^^^ help: wrap the pattern in parentheses: `(A | B)` error: top-level or-patterns are not allowed in `let` bindings - --> $DIR/or-patterns-syntactic-fail.rs:23:9 + --> $DIR/or-patterns-syntactic-fail.rs:24:9 | LL | let A | B: E = A; | ^^^^^ help: wrap the pattern in parentheses: `(A | B)` error: top-level or-patterns are not allowed in `let` bindings - --> $DIR/or-patterns-syntactic-fail.rs:26:9 + --> $DIR/or-patterns-syntactic-fail.rs:27:9 | LL | let | A | B: E = A; | ^^^^^^^ help: wrap the pattern in parentheses: `(A | B)` -error[E0369]: no implementation for `E | ()` - --> $DIR/or-patterns-syntactic-fail.rs:11:22 +error[E0433]: failed to resolve: `B` is a variant, not a module + --> $DIR/or-patterns-syntactic-fail.rs:11:18 | LL | let _ = |A | B: E| (); - | ----^ -- () - | | - | E + | ^ `B` is a variant, not a module + | +help: there is an enum variant `E::B`; try using the variant's enum | -note: an implementation of `BitOr<_>` might be missing for `E` - --> $DIR/or-patterns-syntactic-fail.rs:6:1 +LL | let _ = |A | E| (); + | ~ +help: an enum with a similar name exists | -LL | enum E { A, B } - | ^^^^^^ must implement `BitOr<_>` -note: the trait `BitOr` must be implemented - --> $SRC_DIR/core/src/ops/bit.rs:LL:COL +LL | let _ = |A | E: E| (); + | ~ -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0369`. +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/parser/attr-stmt-expr-attr-bad.rs b/tests/ui/parser/attr-stmt-expr-attr-bad.rs index 469c3855c32ad..b6db3ea147444 100644 --- a/tests/ui/parser/attr-stmt-expr-attr-bad.rs +++ b/tests/ui/parser/attr-stmt-expr-attr-bad.rs @@ -8,6 +8,7 @@ fn main() {} //~^ ERROR expected one of #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); } //~^ ERROR an inner attribute is not permitted in this context +//~| ERROR an inner attribute is not permitted in this context //~| ERROR expected expression, found `)` #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); } //~^ ERROR an inner attribute is not permitted in this context diff --git a/tests/ui/parser/attr-stmt-expr-attr-bad.stderr b/tests/ui/parser/attr-stmt-expr-attr-bad.stderr index 872c560cb510c..0542665f000a2 100644 --- a/tests/ui/parser/attr-stmt-expr-attr-bad.stderr +++ b/tests/ui/parser/attr-stmt-expr-attr-bad.stderr @@ -28,6 +28,15 @@ LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); } = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files = note: outer attributes, like `#[test]`, annotate the item following them +error: an inner attribute is not permitted in this context + --> $DIR/attr-stmt-expr-attr-bad.rs:9:36 + | +LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); } + | ^^^^^^^^ + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files + = note: outer attributes, like `#[test]`, annotate the item following them + error: expected expression, found `)` --> $DIR/attr-stmt-expr-attr-bad.rs:9:44 | @@ -35,7 +44,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); } | ^ expected expression error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:12:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:13:38 | LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); } | ^^^^^^^^ @@ -44,13 +53,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); } = note: outer attributes, like `#[test]`, annotate the item following them error: expected expression, found `)` - --> $DIR/attr-stmt-expr-attr-bad.rs:12:46 + --> $DIR/attr-stmt-expr-attr-bad.rs:13:46 | LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); } | ^ expected expression error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:15:36 + --> $DIR/attr-stmt-expr-attr-bad.rs:16:36 | LL | #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; } | ^^^^^^^^ @@ -59,7 +68,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:17:33 + --> $DIR/attr-stmt-expr-attr-bad.rs:18:33 | LL | #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; } | ^^^^^^^^ @@ -68,7 +77,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:19:33 + --> $DIR/attr-stmt-expr-attr-bad.rs:20:33 | LL | #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; } | ^^^^^^^^ @@ -77,13 +86,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:21:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:22:34 | LL | #[cfg(FALSE)] fn e() { let _ = x #![attr] as Y; } | ^ expected one of 8 possible tokens error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:23:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:24:35 | LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; } | ^^^^^^^^ @@ -92,7 +101,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:25:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:26:40 | LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; } | ^^^^^^^^ @@ -101,7 +110,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:27:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:28:35 | LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; } | ^^^^^^^^ @@ -110,7 +119,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:29:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:30:40 | LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; } | ^^^^^^^^ @@ -119,19 +128,19 @@ LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected expression, found `..` - --> $DIR/attr-stmt-expr-attr-bad.rs:31:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:32:40 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] ..#[attr] 0; } | ^^ expected expression error: expected expression, found `..` - --> $DIR/attr-stmt-expr-attr-bad.rs:33:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:34:40 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] ..; } | ^^ expected expression error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:35:41 + --> $DIR/attr-stmt-expr-attr-bad.rs:36:41 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; } | ^^^^^^^^ @@ -140,7 +149,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:37:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:38:45 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; } | ^^^^^^^^ @@ -149,7 +158,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:39:37 + --> $DIR/attr-stmt-expr-attr-bad.rs:40:37 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -158,7 +167,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; } | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:41:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:42:38 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; } | ^^^^^^^^ @@ -167,13 +176,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:43:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:44:40 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} #[attr] else {}; } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:45:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:46:45 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; } | ---- ^^^^^^^ -- the attributes are attached to this branch @@ -182,7 +191,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; } | the branch belongs to this `else` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:47:46 + --> $DIR/attr-stmt-expr-attr-bad.rs:48:46 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; } | ^^^^^^^^ @@ -191,7 +200,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:49:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:50:45 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; } | ---- ^^^^^^^ ------- the attributes are attached to this branch @@ -200,7 +209,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; } | the branch belongs to this `else` error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:51:50 + --> $DIR/attr-stmt-expr-attr-bad.rs:52:50 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -209,7 +218,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; } | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:53:51 + --> $DIR/attr-stmt-expr-attr-bad.rs:54:51 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; } | ^^^^^^^^ @@ -218,7 +227,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:55:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:56:45 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -227,7 +236,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; } | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:57:46 + --> $DIR/attr-stmt-expr-attr-bad.rs:58:46 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; } | ^^^^^^^^ @@ -236,13 +245,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:59:48 + --> $DIR/attr-stmt-expr-attr-bad.rs:60:48 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} #[attr] else {}; } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:61:53 + --> $DIR/attr-stmt-expr-attr-bad.rs:62:53 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; } | ---- ^^^^^^^ -- the attributes are attached to this branch @@ -251,7 +260,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; } | the branch belongs to this `else` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:63:54 + --> $DIR/attr-stmt-expr-attr-bad.rs:64:54 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; } | ^^^^^^^^ @@ -260,7 +269,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:65:53 + --> $DIR/attr-stmt-expr-attr-bad.rs:66:53 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {}; } | ---- ^^^^^^^ --------------- the attributes are attached to this branch @@ -269,7 +278,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {} | the branch belongs to this `else` error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:67:66 + --> $DIR/attr-stmt-expr-attr-bad.rs:68:66 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -278,7 +287,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {} | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:69:67 + --> $DIR/attr-stmt-expr-attr-bad.rs:70:67 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]}; } | ^^^^^^^^ @@ -287,7 +296,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]} = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:72:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:73:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; } | ------- ^^^^^^^^ not permitted following an outer attribute @@ -298,7 +307,7 @@ LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:74:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:75:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; } | ------- ^^^^^^^^ not permitted following an outer attribute @@ -309,7 +318,7 @@ LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:76:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:77:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!(); } | ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation @@ -325,7 +334,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo!(); } | error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:78:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:79:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo![]; } | ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation @@ -341,7 +350,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo![]; } | error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:80:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:81:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!{}; } | ------- ^^^^^^^^ ------ the inner attribute doesn't annotate this item macro invocation @@ -357,7 +366,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo!{}; } | error[E0586]: inclusive range with no end - --> $DIR/attr-stmt-expr-attr-bad.rs:86:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:87:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } | ^^^ help: use `..` instead @@ -365,13 +374,13 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:86:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:87:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } | ^ expected one of `=>`, `if`, or `|` error[E0586]: inclusive range with no end - --> $DIR/attr-stmt-expr-attr-bad.rs:89:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:90:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } | ^^^ help: use `..` instead @@ -379,19 +388,19 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:89:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:90:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } | ^ expected one of `=>`, `if`, or `|` error: unexpected token: `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:92:39 + --> $DIR/attr-stmt-expr-attr-bad.rs:93:39 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=-#[attr] 10 => () } } | ^ error[E0586]: inclusive range with no end - --> $DIR/attr-stmt-expr-attr-bad.rs:94:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:95:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } | ^^^ help: use `..` instead @@ -399,47 +408,47 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:94:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:95:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } | ^ expected one of `=>`, `if`, or `|` error: unexpected token: `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:98:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:99:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); } | ^ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:98:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:99:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: unexpected token: `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:101:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:102:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); } | ^ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:101:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:102:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: expected statement after outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:106:37 + --> $DIR/attr-stmt-expr-attr-bad.rs:107:37 | LL | #[cfg(FALSE)] fn e() { { fn foo() { #[attr]; } } } | ^^^^^^^ error: expected statement after outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:108:37 + --> $DIR/attr-stmt-expr-attr-bad.rs:109:37 | LL | #[cfg(FALSE)] fn e() { { fn foo() { #[attr] } } } | ^^^^^^^ -error: aborting due to 53 previous errors +error: aborting due to 54 previous errors For more information about this error, try `rustc --explain E0586`. diff --git a/tests/ui/parser/dyn-trait-compatibility.stderr b/tests/ui/parser/dyn-trait-compatibility.stderr index 0cae01bd1e329..55b7a3c81fcda 100644 --- a/tests/ui/parser/dyn-trait-compatibility.stderr +++ b/tests/ui/parser/dyn-trait-compatibility.stderr @@ -1,15 +1,3 @@ -error[E0433]: failed to resolve: use of undeclared crate or module `dyn` - --> $DIR/dyn-trait-compatibility.rs:3:11 - | -LL | type A1 = dyn::dyn; - | ^^^ use of undeclared crate or module `dyn` - -error[E0433]: failed to resolve: use of undeclared crate or module `dyn` - --> $DIR/dyn-trait-compatibility.rs:9:23 - | -LL | type A3 = dyn<::dyn>; - | ^^^ use of undeclared crate or module `dyn` - error[E0412]: cannot find type `dyn` in this scope --> $DIR/dyn-trait-compatibility.rs:1:11 | @@ -46,6 +34,18 @@ error[E0412]: cannot find type `dyn` in this scope LL | type A3 = dyn<::dyn>; | ^^^ not found in this scope +error[E0433]: failed to resolve: use of undeclared crate or module `dyn` + --> $DIR/dyn-trait-compatibility.rs:3:11 + | +LL | type A1 = dyn::dyn; + | ^^^ use of undeclared crate or module `dyn` + +error[E0433]: failed to resolve: use of undeclared crate or module `dyn` + --> $DIR/dyn-trait-compatibility.rs:9:23 + | +LL | type A3 = dyn<::dyn>; + | ^^^ use of undeclared crate or module `dyn` + error: aborting due to 8 previous errors Some errors have detailed explanations: E0412, E0433. diff --git a/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr b/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr index 0c328bde285aa..736c40bb961bb 100644 --- a/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr +++ b/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr @@ -9,21 +9,11 @@ help: try surrounding the expression in parentheses LL | (vec![1, 2, 3] as Vec)[0]; | + + -error: type ascription cannot be followed by indexing - --> $DIR/issue-35813-postfix-after-cast.rs:12:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:12:18 | LL | vec![1, 2, 3]: Vec[0]; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (vec![1, 2, 3]: Vec)[0]; - | + + -help: alternatively, remove the type ascription - | -LL - vec![1, 2, 3]: Vec[0]; -LL + vec![1, 2, 3][0]; - | + | ^ expected one of `.`, `;`, `?`, `}`, or an operator error: cast cannot be followed by indexing --> $DIR/issue-35813-postfix-after-cast.rs:17:5 @@ -36,156 +26,31 @@ help: try surrounding the expression in parentheses LL | ((&[0]) as &[i32])[0]; | + + -error: type ascription cannot be followed by indexing - --> $DIR/issue-35813-postfix-after-cast.rs:19:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:19:14 | LL | (&[0i32]): &[i32; 1][0]; - | ^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | ((&[0i32]): &[i32; 1])[0]; - | + + -help: alternatively, remove the type ascription - | -LL - (&[0i32]): &[i32; 1][0]; -LL + (&[0i32])[0]; - | - -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:39:13 - | -LL | let _ = 0i32: i32: i32.count_ones(); - | ^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0i32: i32: i32).count_ones(); - | + + -help: alternatively, remove the type ascription - | -LL - let _ = 0i32: i32: i32.count_ones(); -LL + let _ = 0i32: i32.count_ones(); - | - -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:41:13 - | -LL | let _ = 0 as i32: i32.count_ones(); - | ^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0 as i32: i32).count_ones(); - | + + -help: alternatively, remove the type ascription - | -LL - let _ = 0 as i32: i32.count_ones(); -LL + let _ = 0 as i32.count_ones(); - | - -error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:43:13 - | -LL | let _ = 0i32: i32 as i32.count_ones(); - | ^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0i32: i32 as i32).count_ones(); - | + + - -error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:45:13 - | -LL | let _ = 0 as i32 as i32.count_ones(); - | ^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0 as i32 as i32).count_ones(); - | + + + | ^ expected one of `.`, `;`, `?`, `}`, or an operator -error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:47:13 +error: expected `{`, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:27:12 | -LL | let _ = 0i32: i32: i32 as u32 as i32.count_ones(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | if 5u64: u64: u64 == 0u64 { + | ^ expected `{` | -help: try surrounding the expression in parentheses +note: the `if` expression is missing a block after this condition + --> $DIR/issue-35813-postfix-after-cast.rs:27:8 | -LL | let _ = (0i32: i32: i32 as u32 as i32).count_ones(); - | + + +LL | if 5u64: u64: u64 == 0u64 { + | ^^^^ -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:49:13 - | -LL | let _ = 0i32: i32.count_ones(): u32; - | ^^^^^^^^^ +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:39:17 | -help: try surrounding the expression in parentheses - | -LL | let _ = (0i32: i32).count_ones(): u32; - | + + -help: alternatively, remove the type ascription - | -LL - let _ = 0i32: i32.count_ones(): u32; -LL + let _ = 0i32.count_ones(): u32; - | - -error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:51:13 - | -LL | let _ = 0 as i32.count_ones(): u32; - | ^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0 as i32).count_ones(): u32; - | + + - -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:53:13 - | -LL | let _ = 0i32: i32.count_ones() as u32; - | ^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0i32: i32).count_ones() as u32; - | + + -help: alternatively, remove the type ascription - | -LL - let _ = 0i32: i32.count_ones() as u32; -LL + let _ = 0i32.count_ones() as u32; - | - -error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:55:13 - | -LL | let _ = 0 as i32.count_ones() as u32; - | ^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0 as i32).count_ones() as u32; - | + + - -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:57:13 - | -LL | let _ = 0i32: i32: i32.count_ones() as u32 as i32; - | ^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0i32: i32: i32).count_ones() as u32 as i32; - | + + -help: alternatively, remove the type ascription - | -LL - let _ = 0i32: i32: i32.count_ones() as u32 as i32; -LL + let _ = 0i32: i32.count_ones() as u32 as i32; +LL | let _ = 0i32: i32: i32.count_ones(); + | ^ expected one of `.`, `;`, `?`, `else`, or an operator | + = note: type ascription syntax has been removed, see issue #101728 error: cast cannot be followed by a method call --> $DIR/issue-35813-postfix-after-cast.rs:62:13 @@ -223,21 +88,11 @@ help: try surrounding the expression in parentheses LL | (0 as i32).max(0); | + + -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:77:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:77:6 | LL | 0: i32.max(0); - | ^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (0: i32).max(0); - | + + -help: alternatively, remove the type ascription - | -LL - 0: i32.max(0); -LL + 0.max(0); - | + | ^ expected one of `.`, `;`, `?`, `}`, or an operator error: cast cannot be followed by a method call --> $DIR/issue-35813-postfix-after-cast.rs:92:8 @@ -250,21 +105,17 @@ help: try surrounding the expression in parentheses LL | if (5u64 as i32).max(0) == 0 { | + + -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:95:8 +error: expected `{`, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:95:12 | LL | if 5u64: u64.max(0) == 0 { - | ^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | if (5u64: u64).max(0) == 0 { - | + + -help: alternatively, remove the type ascription + | ^ expected `{` | -LL - if 5u64: u64.max(0) == 0 { -LL + if 5u64.max(0) == 0 { +note: the `if` expression is missing a block after this condition + --> $DIR/issue-35813-postfix-after-cast.rs:95:8 | +LL | if 5u64: u64.max(0) == 0 { + | ^^^^ error: cast cannot be followed by a method call --> $DIR/issue-35813-postfix-after-cast.rs:102:9 @@ -277,21 +128,11 @@ help: try surrounding the expression in parentheses LL | (5u64 as u32).max(0) == 0 | + + -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:106:9 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:106:13 | LL | 5u64: u64.max(0) == 0 - | ^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (5u64: u64).max(0) == 0 - | + + -help: alternatively, remove the type ascription - | -LL - 5u64: u64.max(0) == 0 -LL + 5u64.max(0) == 0 - | + | ^ expected one of `.`, `;`, `?`, `}`, or an operator error: cast cannot be followed by indexing --> $DIR/issue-35813-postfix-after-cast.rs:111:24 @@ -304,169 +145,11 @@ help: try surrounding the expression in parentheses LL | static bar: &[i32] = &((&[1,2,3] as &[i32])[0..1]); | + + -error: type ascription cannot be followed by indexing - --> $DIR/issue-35813-postfix-after-cast.rs:114:25 +error: expected one of `)`, `,`, `.`, `?`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:114:36 | LL | static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]); - | ^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | static bar2: &[i32] = &((&[1i32,2,3]: &[i32; 3])[0..1]); - | + + -help: alternatively, remove the type ascription - | -LL - static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]); -LL + static bar2: &[i32] = &(&[1i32,2,3][0..1]); - | - -error: cast cannot be followed by `?` - --> $DIR/issue-35813-postfix-after-cast.rs:119:5 - | -LL | Err(0u64) as Result?; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (Err(0u64) as Result)?; - | + + - -error: type ascription cannot be followed by `?` - --> $DIR/issue-35813-postfix-after-cast.rs:121:5 - | -LL | Err(0u64): Result?; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (Err(0u64): Result)?; - | + + -help: alternatively, remove the type ascription - | -LL - Err(0u64): Result?; -LL + Err(0u64)?; - | - -error: cast cannot be followed by a function call - --> $DIR/issue-35813-postfix-after-cast.rs:145:5 - | -LL | drop as fn(u8)(0); - | ^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (drop as fn(u8))(0); - | + + - -error: type ascription cannot be followed by a function call - --> $DIR/issue-35813-postfix-after-cast.rs:147:5 - | -LL | drop_ptr: fn(u8)(0); - | ^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (drop_ptr: fn(u8))(0); - | + + -help: alternatively, remove the type ascription - | -LL - drop_ptr: fn(u8)(0); -LL + drop_ptr(0); - | - -error: cast cannot be followed by `.await` - --> $DIR/issue-35813-postfix-after-cast.rs:152:5 - | -LL | Box::pin(noop()) as Pin>>.await; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (Box::pin(noop()) as Pin>>).await; - | + + - -error: type ascription cannot be followed by `.await` - --> $DIR/issue-35813-postfix-after-cast.rs:155:5 - | -LL | Box::pin(noop()): Pin>.await; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (Box::pin(noop()): Pin>).await; - | + + -help: alternatively, remove the type ascription - | -LL - Box::pin(noop()): Pin>.await; -LL + Box::pin(noop()).await; - | - -error: cast cannot be followed by a field access - --> $DIR/issue-35813-postfix-after-cast.rs:167:5 - | -LL | Foo::default() as Foo.bar; - | ^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (Foo::default() as Foo).bar; - | + + - -error: type ascription cannot be followed by a field access - --> $DIR/issue-35813-postfix-after-cast.rs:169:5 - | -LL | Foo::default(): Foo.bar; - | ^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (Foo::default(): Foo).bar; - | + + -help: alternatively, remove the type ascription - | -LL - Foo::default(): Foo.bar; -LL + Foo::default().bar; - | - -error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:84:9 - | -LL | if true { 33 } else { 44 } as i32.max(0), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (if true { 33 } else { 44 } as i32).max(0), - | + + - -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:86:9 - | -LL | if true { 33 } else { 44 }: i32.max(0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (if true { 33 } else { 44 }: i32).max(0) - | + + -help: alternatively, remove the type ascription - | -LL - if true { 33 } else { 44 }: i32.max(0) -LL + if true { 33 } else { 44 }.max(0) - | - -error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-35813-postfix-after-cast.rs:131:13 - | -LL | drop as F(); - | ^^^ only `Fn` traits may use parentheses - -error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-35813-postfix-after-cast.rs:133:15 - | -LL | drop_ptr: F(); - | ^^^ only `Fn` traits may use parentheses + | ^ expected one of `)`, `,`, `.`, `?`, or an operator -error: aborting due to 36 previous errors +error: aborting due to 16 previous errors -For more information about this error, try `rustc --explain E0214`. diff --git a/tests/ui/parser/issues/issue-44406.stderr b/tests/ui/parser/issues/issue-44406.stderr index 1f0c1ea4c2f13..0e30b09c6c3bc 100644 --- a/tests/ui/parser/issues/issue-44406.stderr +++ b/tests/ui/parser/issues/issue-44406.stderr @@ -1,3 +1,15 @@ +error: path separator must be a double colon + --> $DIR/issue-44406.rs:3:16 + | +LL | bar(baz: $rest) + | ^ help: use a double colon instead: `::` +... +LL | foo!(true); + | ---------- in this macro invocation + | + = note: type ascription syntax has been removed, see issue #101728 + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + error: expected identifier, found keyword `true` --> $DIR/issue-44406.rs:8:10 | @@ -9,25 +21,29 @@ help: escape `true` to use it as an identifier LL | foo!(r#true); | ++ -error: invalid `struct` delimiters or `fn` call arguments - --> $DIR/issue-44406.rs:3:9 +error[E0433]: failed to resolve: use of undeclared crate or module `baz` + --> $DIR/issue-44406.rs:3:13 | LL | bar(baz: $rest) - | ^^^^^^^^^^^^^^^ + | ^^^ use of undeclared crate or module `baz` ... LL | foo!(true); | ---------- in this macro invocation | = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) -help: if `bar` is a struct, use braces as delimiters - | -LL | bar { } - | ~ -help: if `bar` is a function, use the arguments directly + +error[E0425]: cannot find function `bar` in this scope + --> $DIR/issue-44406.rs:3:9 | -LL - bar(baz: $rest) -LL + bar(: $rest) +LL | bar(baz: $rest) + | ^^^ not found in this scope +... +LL | foo!(true); + | ---------- in this macro invocation | + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors +Some errors have detailed explanations: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/parser/issues/issue-87086-colon-path-sep.stderr b/tests/ui/parser/issues/issue-87086-colon-path-sep.stderr index 2050a16beb349..a3030db043f84 100644 --- a/tests/ui/parser/issues/issue-87086-colon-path-sep.stderr +++ b/tests/ui/parser/issues/issue-87086-colon-path-sep.stderr @@ -84,6 +84,11 @@ error[E0433]: failed to resolve: `Bar` is a variant, not a module | LL | Foo:Bar::Baz => {} | ^^^ `Bar` is a variant, not a module + | +help: there is an enum variant `Foo::Bar`; try using the variant's enum + | +LL | Foo => {} + | ~~~ error: aborting due to 10 previous errors diff --git a/tests/ui/parser/issues/issue-91461.stderr b/tests/ui/parser/issues/issue-91461.stderr index 94fcf1721d8c1..2416ca0952a0d 100644 --- a/tests/ui/parser/issues/issue-91461.stderr +++ b/tests/ui/parser/issues/issue-91461.stderr @@ -1,31 +1,8 @@ -error: expected identifier, found reserved identifier `_` - --> $DIR/issue-91461.rs:2:7 +error: expected one of `)`, `,`, `.`, `?`, or an operator, found `:` + --> $DIR/issue-91461.rs:2:8 | LL | a(_:b:,) - | ^ expected identifier, found reserved identifier + | ^ expected one of `)`, `,`, `.`, `?`, or an operator -error: expected type, found `,` - --> $DIR/issue-91461.rs:2:11 - | -LL | a(_:b:,) - | - -^ expected type - | | | - | | tried to parse a type due to this type ascription - | while parsing this struct - | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information - -error: expected type, found `,` - --> $DIR/issue-91461.rs:2:11 - | -LL | a(_:b:,) - | -^ expected type - | | - | tried to parse a type due to this type ascription - | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information - -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/recover-from-bad-variant.stderr b/tests/ui/parser/recover-from-bad-variant.stderr index 04968bbdf999d..731eb92a9e490 100644 --- a/tests/ui/parser/recover-from-bad-variant.stderr +++ b/tests/ui/parser/recover-from-bad-variant.stderr @@ -1,37 +1,8 @@ -error: invalid `struct` delimiters or `fn` call arguments - --> $DIR/recover-from-bad-variant.rs:7:13 +error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `:` + --> $DIR/recover-from-bad-variant.rs:7:24 | LL | let x = Enum::Foo(a: 3, b: 4); - | ^^^^^^^^^^^^^^^^^^^^^ - | -help: if `Enum::Foo` is a struct, use braces as delimiters - | -LL | let x = Enum::Foo { a: 3, b: 4 }; - | ~ ~ -help: if `Enum::Foo` is a function, use the arguments directly - | -LL - let x = Enum::Foo(a: 3, b: 4); -LL + let x = Enum::Foo(3, 4); - | - -error[E0164]: expected tuple struct or tuple variant, found struct variant `Enum::Foo` - --> $DIR/recover-from-bad-variant.rs:10:9 - | -LL | Enum::Foo(a, b) => {} - | ^^^^^^^^^^^^^^^ not a tuple struct or tuple variant - -error[E0769]: tuple variant `Enum::Bar` written as struct variant - --> $DIR/recover-from-bad-variant.rs:12:9 - | -LL | Enum::Bar { a, b } => {} - | ^^^^^^^^^^^^^^^^^^ - | -help: use the tuple variant pattern syntax instead - | -LL | Enum::Bar(a, b) => {} - | ~~~~~~ + | ^ expected one of 8 possible tokens -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0164, E0769. -For more information about an error, try `rustc --explain E0164`. diff --git a/tests/ui/pattern/pattern-error-continue.stderr b/tests/ui/pattern/pattern-error-continue.stderr index 4c2eff63ab5e8..adf95e8476786 100644 --- a/tests/ui/pattern/pattern-error-continue.stderr +++ b/tests/ui/pattern/pattern-error-continue.stderr @@ -1,9 +1,3 @@ -error[E0433]: failed to resolve: use of undeclared type `E` - --> $DIR/pattern-error-continue.rs:33:9 - | -LL | E::V => {} - | ^ use of undeclared type `E` - error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D` --> $DIR/pattern-error-continue.rs:18:9 | @@ -56,6 +50,15 @@ note: function defined here LL | fn f(_c: char) {} | ^ -------- +error[E0433]: failed to resolve: use of undeclared type `E` + --> $DIR/pattern-error-continue.rs:33:9 + | +LL | E::V => {} + | ^ + | | + | use of undeclared type `E` + | help: an enum with a similar name exists: `A` + error: aborting due to 5 previous errors Some errors have detailed explanations: E0023, E0308, E0433, E0532. diff --git a/tests/ui/resolve/resolve-variant-assoc-item.rs b/tests/ui/resolve/resolve-variant-assoc-item.rs index db4fedfb0bdf8..2b557d9f36931 100644 --- a/tests/ui/resolve/resolve-variant-assoc-item.rs +++ b/tests/ui/resolve/resolve-variant-assoc-item.rs @@ -3,5 +3,5 @@ use E::V; fn main() { E::V::associated_item; //~ ERROR failed to resolve: `V` is a variant, not a module - V::associated_item; //~ ERROR failed to resolve: `V` is a variant, not a module + V::associated_item(); //~ ERROR failed to resolve: `V` is a variant, not a module } diff --git a/tests/ui/resolve/resolve-variant-assoc-item.stderr b/tests/ui/resolve/resolve-variant-assoc-item.stderr index 4be1019968bcc..2a46ae9ccc6a2 100644 --- a/tests/ui/resolve/resolve-variant-assoc-item.stderr +++ b/tests/ui/resolve/resolve-variant-assoc-item.stderr @@ -3,12 +3,26 @@ error[E0433]: failed to resolve: `V` is a variant, not a module | LL | E::V::associated_item; | ^ `V` is a variant, not a module + | +help: there is an enum variant `E::V`; try using the variant's enum + | +LL | E; + | ~ error[E0433]: failed to resolve: `V` is a variant, not a module --> $DIR/resolve-variant-assoc-item.rs:6:5 | -LL | V::associated_item; +LL | V::associated_item(); | ^ `V` is a variant, not a module + | +help: there is an enum variant `E::V`; try using the variant's enum + | +LL | E(); + | ~ +help: an enum with a similar name exists + | +LL | E::associated_item(); + | ~ error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/many-type-ascription.stderr b/tests/ui/suggestions/many-type-ascription.stderr index 3706bbae9df9f..e36919c82f832 100644 --- a/tests/ui/suggestions/many-type-ascription.stderr +++ b/tests/ui/suggestions/many-type-ascription.stderr @@ -1,12 +1,10 @@ -error[E0658]: type ascription is experimental - --> $DIR/many-type-ascription.rs:2:13 +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/many-type-ascription.rs:2:14 | LL | let _ = 0: i32; - | ^^^^^^ + | ^ expected one of `.`, `;`, `?`, `else`, or an operator | - = note: see issue #23416 for more information - = help: add `#![feature(type_ascription)]` to the crate attributes to enable + = note: type ascription syntax has been removed, see issue #101728 error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/suggestions/type-ascription-instead-of-let.stderr b/tests/ui/suggestions/type-ascription-instead-of-let.stderr index 92e4b5798c889..32920006c4e90 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-let.stderr +++ b/tests/ui/suggestions/type-ascription-instead-of-let.stderr @@ -1,11 +1,10 @@ -error[E0425]: cannot find value `temp` in this scope - --> $DIR/type-ascription-instead-of-let.rs:5:9 +error: path separator must be a double colon + --> $DIR/type-ascription-instead-of-let.rs:5:13 | LL | temp: i32 = fun(5i32); - | ^^^^ - | | - | not found in this scope - | help: maybe you meant to write an assignment here: `let temp` + | ^ help: use a double colon instead: `::` + | + = note: type ascription syntax has been removed, see issue #101728 error[E0425]: cannot find value `temp` in this scope --> $DIR/type-ascription-instead-of-let.rs:7:9 @@ -13,6 +12,18 @@ error[E0425]: cannot find value `temp` in this scope LL | temp + value + 1 | ^^^^ not found in this scope -error: aborting due to 2 previous errors +error[E0433]: failed to resolve: use of undeclared crate or module `temp` + --> $DIR/type-ascription-instead-of-let.rs:5:9 + | +LL | temp: i32 = fun(5i32); + | ^^^^ use of undeclared crate or module `temp` + | +help: you might have meant to introduce a new binding + | +LL | let temp: i32 = fun(5i32); + | +++ + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0425`. +Some errors have detailed explanations: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/suggestions/type-ascription-instead-of-method.stderr b/tests/ui/suggestions/type-ascription-instead-of-method.stderr index 83bc33f410ad0..9be8c5ce3c188 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-method.stderr +++ b/tests/ui/suggestions/type-ascription-instead-of-method.stderr @@ -1,12 +1,10 @@ -error: expected type, found `"foo"` - --> $DIR/type-ascription-instead-of-method.rs:3:21 +error: path separator must be a double colon + --> $DIR/type-ascription-instead-of-method.rs:3:16 | LL | let _ = Box:new("foo".to_string()); - | - ^^^^^ expected type - | | - | help: maybe write a path separator here: `::` + | ^ help: use a double colon instead: `::` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` + = note: type ascription syntax has been removed, see issue #101728 error: aborting due to previous error diff --git a/tests/ui/suggestions/type-ascription-instead-of-path-2.fixed b/tests/ui/suggestions/type-ascription-instead-of-path-2.fixed index 787fcc1208e1b..934016b3b811f 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-path-2.fixed +++ b/tests/ui/suggestions/type-ascription-instead-of-path-2.fixed @@ -1,6 +1,6 @@ // run-rustfix fn main() -> Result<(), ()> { - let _ = vec![Ok(2)].into_iter().collect::,_>>()?; + let _ = vec![Ok(2)].into_iter().collect:,_>>()?; //~^ ERROR expected `::`, found `(` Ok(()) } diff --git a/tests/ui/suggestions/type-ascription-instead-of-path-2.stderr b/tests/ui/suggestions/type-ascription-instead-of-path-2.stderr index 970b220b73712..fdc9bbc5455bb 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-path-2.stderr +++ b/tests/ui/suggestions/type-ascription-instead-of-path-2.stderr @@ -1,12 +1,10 @@ -error: expected `::`, found `(` - --> $DIR/type-ascription-instead-of-path-2.rs:3:63 +error: expected one of `(`, `.`, `::`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/type-ascription-instead-of-path-2.rs:3:44 | LL | let _ = vec![Ok(2)].into_iter().collect:,_>>()?; - | - ^ expected `::` - | | - | help: maybe write a path separator here: `::` + | ^ expected one of 7 possible tokens | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` + = note: type ascription syntax has been removed, see issue #101728 error: aborting due to previous error diff --git a/tests/ui/suggestions/type-ascription-instead-of-path.stderr b/tests/ui/suggestions/type-ascription-instead-of-path.stderr index 518660cfa1686..d178621b8c613 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-path.stderr +++ b/tests/ui/suggestions/type-ascription-instead-of-path.stderr @@ -1,18 +1,10 @@ -error[E0433]: failed to resolve: use of undeclared crate or module `io` - --> $DIR/type-ascription-instead-of-path.rs:2:9 +error: path separator must be a double colon + --> $DIR/type-ascription-instead-of-path.rs:2:8 | LL | std:io::stdin(); - | ^^ use of undeclared crate or module `io` - -error[E0423]: expected value, found crate `std` - --> $DIR/type-ascription-instead-of-path.rs:2:5 + | ^ help: use a double colon instead: `::` | -LL | std:io::stdin(); - | ^^^- help: maybe you meant to write a path separator here: `::` - | | - | not a value + = note: type ascription syntax has been removed, see issue #101728 -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0423, E0433. -For more information about an error, try `rustc --explain E0423`. diff --git a/tests/ui/suggestions/type-ascription-instead-of-variant.stderr b/tests/ui/suggestions/type-ascription-instead-of-variant.stderr index f59ba78d4d38a..dfb7d8003faf9 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-variant.stderr +++ b/tests/ui/suggestions/type-ascription-instead-of-variant.stderr @@ -1,12 +1,10 @@ -error: expected type, found `""` - --> $DIR/type-ascription-instead-of-variant.rs:3:25 +error: path separator must be a double colon + --> $DIR/type-ascription-instead-of-variant.rs:3:19 | LL | let _ = Option:Some(""); - | - ^^ expected type - | | - | help: maybe write a path separator here: `::` + | ^ help: use a double colon instead: `::` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` + = note: type ascription syntax has been removed, see issue #101728 error: aborting due to previous error diff --git a/tests/ui/track-diagnostics/track4.stderr b/tests/ui/track-diagnostics/track4.stderr index c4668444c4bbb..9ebf222ee342f 100644 --- a/tests/ui/track-diagnostics/track4.stderr +++ b/tests/ui/track-diagnostics/track4.stderr @@ -3,7 +3,7 @@ error: missing `struct` for struct definition | LL | pub onion { | ^ --Ztrack-diagnostics: created at compiler/rustc_parse/src/parser/diagnostics.rs:LL:CC +-Ztrack-diagnostics: created at compiler/rustc_parse/src/parser/item.rs:LL:CC | help: add `struct` here to parse `onion` as a public struct | diff --git a/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr b/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr index 5be3349864182..21e5b9828f8b8 100644 --- a/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr +++ b/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr @@ -1,9 +1,3 @@ -error[E0433]: failed to resolve: use of undeclared type `Unresolved` - --> $DIR/assoc_type_bound_with_struct.rs:19:31 - | -LL | fn issue_95327() where ::Assoc: String {} - | ^^^^^^^^^^ use of undeclared type `Unresolved` - error[E0404]: expected trait, found struct `String` --> $DIR/assoc_type_bound_with_struct.rs:5:46 | @@ -85,6 +79,12 @@ LL | fn issue_95327() where ::Assoc: String {} | = note: similarly named trait `ToString` defined here +error[E0433]: failed to resolve: use of undeclared type `Unresolved` + --> $DIR/assoc_type_bound_with_struct.rs:19:31 + | +LL | fn issue_95327() where ::Assoc: String {} + | ^^^^^^^^^^ use of undeclared type `Unresolved` + error: aborting due to 6 previous errors Some errors have detailed explanations: E0404, E0433. diff --git a/tests/ui/type/ascription/issue-34255-1.stderr b/tests/ui/type/ascription/issue-34255-1.stderr index fafff19f8f6ec..d53f0c0f6abf2 100644 --- a/tests/ui/type/ascription/issue-34255-1.stderr +++ b/tests/ui/type/ascription/issue-34255-1.stderr @@ -1,36 +1,25 @@ -error[E0425]: cannot find value `input_cells` in this scope - --> $DIR/issue-34255-1.rs:7:9 +error: path separator must be a double colon + --> $DIR/issue-34255-1.rs:7:20 | LL | input_cells: Vec::new() - | ^^^^^^^^^^^ a field by this name exists in `Self` + | ^ help: use a double colon instead: `::` | -help: you might have meant to write a `struct` literal + = note: type ascription syntax has been removed, see issue #101728 + +error[E0433]: failed to resolve: use of undeclared crate or module `input_cells` + --> $DIR/issue-34255-1.rs:7:9 | -LL ~ pub fn new() -> Self { SomeStruct { LL | input_cells: Vec::new() - ... -LL | -LL ~ }} + | ^^^^^^^^^^^ use of undeclared crate or module `input_cells` | - -error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-34255-1.rs:7:27 +help: consider importing this struct | -LL | input_cells: Vec::new() - | ^^^^^ only `Fn` traits may use parentheses - -error[E0107]: missing generics for struct `Vec` - --> $DIR/issue-34255-1.rs:7:22 +LL | use std::vec::Vec; | -LL | input_cells: Vec::new() - | ^^^ expected at least 1 generic argument +help: if you import `Vec`, refer to it directly | -help: add missing generic argument +LL - input_cells: Vec::new() +LL + Vec::new() | -LL | input_cells: Vec::new() - | +++ - -error: aborting due to 3 previous errors -Some errors have detailed explanations: E0107, E0214, E0425. -For more information about an error, try `rustc --explain E0107`. +error: aborting due to 2 previous errors diff --git a/tests/ui/type/ascription/issue-47666.stderr b/tests/ui/type/ascription/issue-47666.stderr index 0f90fce3a42b9..2f815041ce13d 100644 --- a/tests/ui/type/ascription/issue-47666.stderr +++ b/tests/ui/type/ascription/issue-47666.stderr @@ -1,16 +1,10 @@ -error: expected type, found `<[_]>::into_vec(#[rustc_box] ::alloc::boxed::Box::new([0, 1]))` - --> $DIR/issue-47666.rs:3:25 +error: path separator must be a double colon + --> $DIR/issue-47666.rs:3:19 | LL | let _ = Option:Some(vec![0, 1]); - | - ^^^^^^^^^^ - | | | - | | expected type - | | in this macro invocation - | | this macro call doesn't expand to a type - | help: maybe write a path separator here: `::` + | ^ help: use a double colon instead: `::` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: this error originates in the macro `$crate::__rust_force_expr` which comes from the expansion of the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: type ascription syntax has been removed, see issue #101728 error: aborting due to previous error diff --git a/tests/ui/type/ascription/issue-54516.stderr b/tests/ui/type/ascription/issue-54516.stderr index 1ab9093e58445..7666864a9bcbb 100644 --- a/tests/ui/type/ascription/issue-54516.stderr +++ b/tests/ui/type/ascription/issue-54516.stderr @@ -1,12 +1,10 @@ -error: type ascription cannot be followed by a function call - --> $DIR/issue-54516.rs:5:20 +error: path separator must be a double colon + --> $DIR/issue-54516.rs:5:28 | LL | println!("{}", std::mem:size_of::>()); - | ^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | help: maybe write a path separator here: `::` + | ^ help: use a double colon instead: `::` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` + = note: type ascription syntax has been removed, see issue #101728 error: aborting due to previous error diff --git a/tests/ui/type/ascription/issue-60933.stderr b/tests/ui/type/ascription/issue-60933.stderr index 0b7f8edf62402..776cc412c326a 100644 --- a/tests/ui/type/ascription/issue-60933.stderr +++ b/tests/ui/type/ascription/issue-60933.stderr @@ -1,12 +1,10 @@ -error: type ascription cannot be followed by a function call - --> $DIR/issue-60933.rs:3:20 +error: path separator must be a double colon + --> $DIR/issue-60933.rs:3:28 | LL | let _: usize = std::mem:size_of::(); - | ^^^^^^^^-^^^^^^^^^^^^^^ - | | - | help: maybe write a path separator here: `::` + | ^ help: use a double colon instead: `::` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` + = note: type ascription syntax has been removed, see issue #101728 error: aborting due to previous error diff --git a/tests/ui/type/issue-91268.stderr b/tests/ui/type/issue-91268.stderr index 6c9ee9945844d..6c54c2df482bf 100644 --- a/tests/ui/type/issue-91268.stderr +++ b/tests/ui/type/issue-91268.stderr @@ -18,46 +18,16 @@ LL | 0: u8(ţ | | | unclosed delimiter -error[E0412]: cannot find type `ţ` in this scope - --> $DIR/issue-91268.rs:9:11 - | -LL | 0: u8(ţ - | ^ expecting a type here because of type ascription - -error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-91268.rs:9:8 - | -LL | 0: u8(ţ - | ^^^^ only `Fn` traits may use parentheses - | -help: use angle brackets instead - | -LL | 0: u8<ţ> - | ~ + - -error[E0109]: type arguments are not allowed on builtin type `u8` - --> $DIR/issue-91268.rs:9:11 - | -LL | 0: u8(ţ - | -- ^ type argument not allowed - | | - | not allowed on builtin type `u8` - | -help: primitive type `u8` doesn't have generic parameters - | -LL - 0: u8(ţ -LL + 0: u8 - | - -error[E0308]: mismatched types - --> $DIR/issue-91268.rs:9:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-91268.rs:8:11 | LL | fn main() { - | - expected `()` because of default return type + | ^ unclosed delimiter LL | 0: u8(ţ - | ^^^^^^^ expected `()`, found `u8` + | ^ + | | + | expected one of `.`, `;`, `?`, `}`, or an operator + | help: `}` may belong here -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0109, E0214, E0308, E0412. -For more information about an error, try `rustc --explain E0109`. diff --git a/tests/ui/type/missing-let-in-binding.fixed b/tests/ui/type/missing-let-in-binding.fixed index d1787688950ac..9def195ea390f 100644 --- a/tests/ui/type/missing-let-in-binding.fixed +++ b/tests/ui/type/missing-let-in-binding.fixed @@ -1,5 +1,5 @@ // run-rustfix fn main() { let mut _foo: i32 = 1; - let _foo: i32 = 4; //~ ERROR type ascription is experimental + let _foo:: i32 = 4; //~ ERROR type ascription is experimental } diff --git a/tests/ui/type/missing-let-in-binding.stderr b/tests/ui/type/missing-let-in-binding.stderr index 12759c5096e23..798373071434a 100644 --- a/tests/ui/type/missing-let-in-binding.stderr +++ b/tests/ui/type/missing-let-in-binding.stderr @@ -1,16 +1,22 @@ -error[E0658]: type ascription is experimental +error: path separator must be a double colon + --> $DIR/missing-let-in-binding.rs:4:9 + | +LL | _foo: i32 = 4; + | ^ help: use a double colon instead: `::` + | + = note: type ascription syntax has been removed, see issue #101728 + +error[E0433]: failed to resolve: use of undeclared crate or module `_foo` --> $DIR/missing-let-in-binding.rs:4:5 | LL | _foo: i32 = 4; - | ^^^^^^^^^ + | ^^^^ use of undeclared crate or module `_foo` | - = note: see issue #23416 for more information - = help: add `#![feature(type_ascription)]` to the crate attributes to enable help: you might have meant to introduce a new binding | LL | let _foo: i32 = 4; | +++ -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/type/type-ascription-instead-of-statement-end.stderr b/tests/ui/type/type-ascription-instead-of-statement-end.stderr index 521ebcdf1929c..600946d84df75 100644 --- a/tests/ui/type/type-ascription-instead-of-statement-end.stderr +++ b/tests/ui/type/type-ascription-instead-of-statement-end.stderr @@ -1,24 +1,16 @@ -error: expected type, found `0` - --> $DIR/type-ascription-instead-of-statement-end.rs:5:5 +error: statements are terminated with a semicolon + --> $DIR/type-ascription-instead-of-statement-end.rs:4:21 | LL | println!("test"): - | - help: try using a semicolon: `;` -LL | 0; - | ^ expected type + | ^ help: use a semicolon instead: `;` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information + = note: type ascription syntax has been removed, see issue #101728 -error: expected type, found `0` - --> $DIR/type-ascription-instead-of-statement-end.rs:9:23 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/type-ascription-instead-of-statement-end.rs:9:21 | LL | println!("test"): 0; - | - ^ expected type - | | - | tried to parse a type due to this type ascription - | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information + | ^ expected one of `.`, `;`, `?`, `}`, or an operator error: aborting due to 2 previous errors diff --git a/tests/ui/type/type-ascription-precedence.stderr b/tests/ui/type/type-ascription-precedence.stderr index edc5aeffdcd65..abe215ef85016 100644 --- a/tests/ui/type/type-ascription-precedence.stderr +++ b/tests/ui/type/type-ascription-precedence.stderr @@ -1,63 +1,8 @@ -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:31:7 +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `:` + --> $DIR/type-ascription-precedence.rs:29:7 | -LL | &(S: &S); - | ^ expected `&S`, found struct `S` +LL | &S: &S; // OK + | ^ expected one of 8 possible tokens -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:35:7 - | -LL | *(S: Z); - | ^ expected struct `Z`, found struct `S` - -error[E0614]: type `Z` cannot be dereferenced - --> $DIR/type-ascription-precedence.rs:35:5 - | -LL | *(S: Z); - | ^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:40:7 - | -LL | -(S: Z); - | ^ expected struct `Z`, found struct `S` - -error[E0600]: cannot apply unary operator `-` to type `Z` - --> $DIR/type-ascription-precedence.rs:40:5 - | -LL | -(S: Z); - | ^^^^^^^ cannot apply unary operator `-` - | -note: an implementation of `std::ops::Neg` might be missing for `Z` - --> $DIR/type-ascription-precedence.rs:9:1 - | -LL | struct Z; - | ^^^^^^^^ must implement `std::ops::Neg` -note: the trait `std::ops::Neg` must be implemented - --> $SRC_DIR/core/src/ops/arith.rs:LL:COL - -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:45:5 - | -LL | (S + Z): Z; - | ^^^^^^^ expected struct `Z`, found struct `S` - -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:49:5 - | -LL | (S * Z): Z; - | ^^^^^^^ expected struct `Z`, found struct `S` - -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:53:5 - | -LL | (S .. S): S; - | ^^^^^^^^ expected struct `S`, found struct `Range` - | - = note: expected struct `S` - found struct `std::ops::Range` - -error: aborting due to 8 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0308, E0600, E0614. -For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/type/type-ascription-with-fn-call.stderr b/tests/ui/type/type-ascription-with-fn-call.stderr index d78fd08fd6065..0e2d2928b2863 100644 --- a/tests/ui/type/type-ascription-with-fn-call.stderr +++ b/tests/ui/type/type-ascription-with-fn-call.stderr @@ -1,11 +1,10 @@ -error[E0573]: expected type, found function `f` - --> $DIR/type-ascription-with-fn-call.rs:6:5 +error: statements are terminated with a semicolon + --> $DIR/type-ascription-with-fn-call.rs:5:10 | LL | f() : - | - help: maybe you meant to write `;` here -LL | f(); - | ^^^ expecting a type here because of type ascription + | ^ help: use a semicolon instead: `;` + | + = note: type ascription syntax has been removed, see issue #101728 error: aborting due to previous error -For more information about this error, try `rustc --explain E0573`. diff --git a/tests/ui/type/type-path-err-node-types.stderr b/tests/ui/type/type-path-err-node-types.stderr index 1aed1dbe4babd..8b12aa1a393b2 100644 --- a/tests/ui/type/type-path-err-node-types.stderr +++ b/tests/ui/type/type-path-err-node-types.stderr @@ -1,9 +1,3 @@ -error[E0433]: failed to resolve: use of undeclared type `NonExistent` - --> $DIR/type-path-err-node-types.rs:15:5 - | -LL | NonExistent::Assoc::; - | ^^^^^^^^^^^ use of undeclared type `NonExistent` - error[E0412]: cannot find type `Nonexistent` in this scope --> $DIR/type-path-err-node-types.rs:7:12 | @@ -22,6 +16,12 @@ error[E0425]: cannot find value `nonexistent` in this scope LL | nonexistent.nonexistent::(); | ^^^^^^^^^^^ not found in this scope +error[E0433]: failed to resolve: use of undeclared type `NonExistent` + --> $DIR/type-path-err-node-types.rs:15:5 + | +LL | NonExistent::Assoc::; + | ^^^^^^^^^^^ use of undeclared type `NonExistent` + error[E0282]: type annotations needed --> $DIR/type-path-err-node-types.rs:23:14 | diff --git a/tests/ui/ufcs/ufcs-partially-resolved.stderr b/tests/ui/ufcs/ufcs-partially-resolved.stderr index 5f7f6aa9f6ec6..2f3f95e6aea85 100644 --- a/tests/ui/ufcs/ufcs-partially-resolved.stderr +++ b/tests/ui/ufcs/ufcs-partially-resolved.stderr @@ -3,12 +3,22 @@ error[E0433]: failed to resolve: `Y` is a variant, not a module | LL | let _: ::NN; | ^ `Y` is a variant, not a module + | +help: there is an enum variant `E::Y`; try using the variant's enum + | +LL | let _: E; + | ~ error[E0433]: failed to resolve: `Y` is a variant, not a module --> $DIR/ufcs-partially-resolved.rs:50:15 | LL | ::NN; | ^ `Y` is a variant, not a module + | +help: there is an enum variant `E::Y`; try using the variant's enum + | +LL | E; + | ~ error[E0576]: cannot find associated type `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:19:24