From 014363e89e4347332c50daede2efa66af3c2c243 Mon Sep 17 00:00:00 2001 From: Orion Gonzalez Date: Wed, 11 Dec 2024 00:53:07 +0100 Subject: Don't emit "field expressions may not have generic arguments" if it's a method call without () --- compiler/rustc_parse/src/parser/expr.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_parse/src/parser/expr.rs') diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index eeb83a85e59..0904a42d8a4 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1369,11 +1369,14 @@ impl<'a> Parser<'a> { )) } else { // Field access `expr.f` + let span = lo.to(self.prev_token.span); if let Some(args) = seg.args { - self.dcx().emit_err(errors::FieldExpressionWithGeneric(args.span())); + // See `StashKey::GenericInFieldExpr` for more info on why we stash this. + self.dcx() + .create_err(errors::FieldExpressionWithGeneric(args.span())) + .stash(seg.ident.span, StashKey::GenericInFieldExpr); } - let span = lo.to(self.prev_token.span); Ok(self.mk_expr(span, ExprKind::Field(self_arg, seg.ident))) } } -- cgit 1.4.1-3-g733a5 From 3f97c6be8d4b78c9df55804171c588ebfadcb63e Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 13 Sep 2024 14:00:10 -0400 Subject: Add unwrap_unsafe_binder and wrap_unsafe_binder macro operators --- compiler/rustc_ast/src/ast.rs | 21 +++++++++++- compiler/rustc_ast/src/mut_visit.rs | 6 ++++ compiler/rustc_ast/src/util/classify.rs | 2 ++ compiler/rustc_ast/src/visit.rs | 4 +++ compiler/rustc_ast_lowering/src/expr.rs | 8 +++++ compiler/rustc_ast_passes/src/feature_gate.rs | 1 + compiler/rustc_ast_pretty/src/pprust/state/expr.rs | 19 +++++++++++ .../rustc_builtin_macros/src/assert/context.rs | 3 +- compiler/rustc_feature/src/unstable.rs | 2 ++ compiler/rustc_hir/src/hir.rs | 13 ++++++-- compiler/rustc_hir/src/intravisit.rs | 4 +++ compiler/rustc_hir_pretty/src/lib.rs | 13 ++++++++ compiler/rustc_hir_typeck/src/expr.rs | 25 ++++++++++++-- compiler/rustc_hir_typeck/src/expr_use_visitor.rs | 7 ++++ compiler/rustc_lint/src/dangling.rs | 2 ++ compiler/rustc_lint/src/if_let_rescope.rs | 1 + compiler/rustc_mir_build/src/thir/cx/expr.rs | 5 +++ compiler/rustc_parse/src/parser/expr.rs | 23 +++++++++++-- compiler/rustc_passes/src/input_stats.rs | 39 +++++++++++++++++++--- compiler/rustc_passes/src/liveness.rs | 3 ++ compiler/rustc_passes/src/naked_functions.rs | 1 + compiler/rustc_span/src/symbol.rs | 3 ++ library/core/src/lib.rs | 2 ++ library/core/src/unsafe_binder.rs | 25 ++++++++++++++ library/std/src/lib.rs | 2 ++ 25 files changed, 222 insertions(+), 12 deletions(-) create mode 100644 library/core/src/unsafe_binder.rs (limited to 'compiler/rustc_parse/src/parser/expr.rs') diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 5ffad332bcd..697ee275a9b 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1382,6 +1382,7 @@ impl Expr { | ExprKind::Tup(_) | ExprKind::Type(..) | ExprKind::Underscore + | ExprKind::UnsafeBinderCast(..) | ExprKind::While(..) | ExprKind::Err(_) | ExprKind::Dummy => ExprPrecedence::Unambiguous, @@ -1509,7 +1510,13 @@ pub enum ExprKind { /// `'label: for await? pat in iter { block }` /// /// This is desugared to a combination of `loop` and `match` expressions. - ForLoop { pat: P, iter: P, body: P, label: Option