Skip to content

Commit 2034b6d

Browse files
committed
Auto merge of #111040 - matthiaskrgr:rollup-g2sns0f, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #110823 (Tweak await span to not contain dot) - #111015 (Remove wrong assertion in match checking.) - #111023 (Test precise capture with a multi-variant enum and exhaustive patterns) - #111032 (Migrate `builtin_macros::asm` diagnostics to translatable diagnostics) - #111033 (Ping Nadrieril when changing exhaustiveness checking) - #111037 (Close parentheses for `offset_of` in AST pretty printing) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9ecda8d + 9de14d8 commit 2034b6d

File tree

121 files changed

+812
-882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+812
-882
lines changed

compiler/rustc_ast/src/ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1430,8 +1430,8 @@ pub enum ExprKind {
14301430
/// The async block used to have a `NodeId`, which was removed in favor of
14311431
/// using the parent `NodeId` of the parent `Expr`.
14321432
Async(CaptureBy, P<Block>),
1433-
/// An await expression (`my_future.await`).
1434-
Await(P<Expr>),
1433+
/// An await expression (`my_future.await`). Span is of await keyword.
1434+
Await(P<Expr>, Span),
14351435

14361436
/// A try block (`try { ... }`).
14371437
TryBlock(P<Block>),

compiler/rustc_ast/src/mut_visit.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,10 @@ pub fn noop_visit_expr<T: MutVisitor>(
14151415
ExprKind::Async(_capture_by, body) => {
14161416
vis.visit_block(body);
14171417
}
1418-
ExprKind::Await(expr) => vis.visit_expr(expr),
1418+
ExprKind::Await(expr, await_kw_span) => {
1419+
vis.visit_expr(expr);
1420+
vis.visit_span(await_kw_span);
1421+
}
14191422
ExprKind::Assign(el, er, _) => {
14201423
vis.visit_expr(el);
14211424
vis.visit_expr(er);

compiler/rustc_ast/src/util/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
388388
// X { y: 1 } + X { y: 2 }
389389
contains_exterior_struct_lit(lhs) || contains_exterior_struct_lit(rhs)
390390
}
391-
ast::ExprKind::Await(x)
391+
ast::ExprKind::Await(x, _)
392392
| ast::ExprKind::Unary(_, x)
393393
| ast::ExprKind::Cast(x, _)
394394
| ast::ExprKind::Type(x, _)

compiler/rustc_ast/src/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
864864
ExprKind::Async(_, body) => {
865865
visitor.visit_block(body);
866866
}
867-
ExprKind::Await(expr) => visitor.visit_expr(expr),
867+
ExprKind::Await(expr, _) => visitor.visit_expr(expr),
868868
ExprKind::Assign(lhs, rhs, _) => {
869869
visitor.visit_expr(lhs);
870870
visitor.visit_expr(rhs);

compiler/rustc_ast_lowering/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub struct BaseExpressionDoubleDot {
108108
pub struct AwaitOnlyInAsyncFnAndBlocks {
109109
#[primary_span]
110110
#[label]
111-
pub dot_await_span: Span,
111+
pub await_kw_span: Span,
112112
#[label(ast_lowering_this_not_async)]
113113
pub item_span: Option<Span>,
114114
}

compiler/rustc_ast_lowering/src/expr.rs

+5-19
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
185185
hir::AsyncGeneratorKind::Block,
186186
|this| this.with_new_scopes(|this| this.lower_block_expr(block)),
187187
),
188-
ExprKind::Await(expr) => {
189-
let dot_await_span = if expr.span.hi() < e.span.hi() {
190-
let span_with_whitespace = self
191-
.tcx
192-
.sess
193-
.source_map()
194-
.span_extend_while(expr.span, char::is_whitespace)
195-
.unwrap_or(expr.span);
196-
span_with_whitespace.shrink_to_hi().with_hi(e.span.hi())
197-
} else {
198-
// this is a recovered `await expr`
199-
e.span
200-
};
201-
self.lower_expr_await(dot_await_span, expr)
202-
}
188+
ExprKind::Await(expr, await_kw_span) => self.lower_expr_await(*await_kw_span, expr),
203189
ExprKind::Closure(box Closure {
204190
binder,
205191
capture_clause,
@@ -710,18 +696,18 @@ impl<'hir> LoweringContext<'_, 'hir> {
710696
/// }
711697
/// }
712698
/// ```
713-
fn lower_expr_await(&mut self, dot_await_span: Span, expr: &Expr) -> hir::ExprKind<'hir> {
714-
let full_span = expr.span.to(dot_await_span);
699+
fn lower_expr_await(&mut self, await_kw_span: Span, expr: &Expr) -> hir::ExprKind<'hir> {
700+
let full_span = expr.span.to(await_kw_span);
715701
match self.generator_kind {
716702
Some(hir::GeneratorKind::Async(_)) => {}
717703
Some(hir::GeneratorKind::Gen) | None => {
718704
self.tcx.sess.emit_err(AwaitOnlyInAsyncFnAndBlocks {
719-
dot_await_span,
705+
await_kw_span,
720706
item_span: self.current_item,
721707
});
722708
}
723709
}
724-
let span = self.mark_span_with_reason(DesugaringKind::Await, dot_await_span, None);
710+
let span = self.mark_span_with_reason(DesugaringKind::Await, await_kw_span, None);
725711
let gen_future_span = self.mark_span_with_reason(
726712
DesugaringKind::Await,
727713
full_span,

compiler/rustc_ast_lowering/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ fn may_contain_yield_point(e: &ast::Expr) -> bool {
583583

584584
impl Visitor<'_> for MayContainYieldPoint {
585585
fn visit_expr(&mut self, e: &ast::Expr) {
586-
if let ast::ExprKind::Await(_) | ast::ExprKind::Yield(_) = e.kind {
586+
if let ast::ExprKind::Await(_, _) | ast::ExprKind::Yield(_) = e.kind {
587587
self.0 = true;
588588
} else {
589589
visit::walk_expr(self, e);

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ impl<'a> State<'a> {
447447
self.ibox(0);
448448
self.print_block_with_attrs(blk, attrs);
449449
}
450-
ast::ExprKind::Await(expr) => {
450+
ast::ExprKind::Await(expr, _) => {
451451
self.print_expr_maybe_paren(expr, parser::PREC_POSTFIX);
452452
self.word(".await");
453453
}
@@ -566,7 +566,7 @@ impl<'a> State<'a> {
566566
self.print_ident(field);
567567
}
568568
}
569-
569+
self.pclose();
570570
self.end();
571571
}
572572
ast::ExprKind::MacCall(m) => self.print_mac(m),

compiler/rustc_borrowck/messages.ftl

+9
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,15 @@ borrowck_moved_due_to_method_call =
203203
*[false] call
204204
}
205205
206+
borrowck_moved_due_to_await =
207+
{$place_name} {$is_partial ->
208+
[true] partially moved
209+
*[false] moved
210+
} due to this {$is_loop_message ->
211+
[true] await, in previous iteration of loop
212+
*[false] await
213+
}
214+
206215
borrowck_value_moved_here =
207216
value {$is_partial ->
208217
[true] partially moved

compiler/rustc_borrowck/src/diagnostics/mod.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -1085,12 +1085,21 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10851085
}
10861086
}
10871087
} else {
1088-
err.subdiagnostic(CaptureReasonLabel::MethodCall {
1089-
fn_call_span,
1090-
place_name: &place_name,
1091-
is_partial,
1092-
is_loop_message,
1093-
});
1088+
if let Some((CallDesugaringKind::Await, _)) = desugaring {
1089+
err.subdiagnostic(CaptureReasonLabel::Await {
1090+
fn_call_span,
1091+
place_name: &place_name,
1092+
is_partial,
1093+
is_loop_message,
1094+
});
1095+
} else {
1096+
err.subdiagnostic(CaptureReasonLabel::MethodCall {
1097+
fn_call_span,
1098+
place_name: &place_name,
1099+
is_partial,
1100+
is_loop_message,
1101+
});
1102+
}
10941103
// Erase and shadow everything that could be passed to the new infcx.
10951104
let ty = moved_place.ty(self.body, tcx).ty;
10961105

compiler/rustc_borrowck/src/session_diagnostics.rs

+8
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,14 @@ pub(crate) enum CaptureReasonLabel<'a> {
338338
is_partial: bool,
339339
is_loop_message: bool,
340340
},
341+
#[label(borrowck_moved_due_to_await)]
342+
Await {
343+
#[primary_span]
344+
fn_call_span: Span,
345+
place_name: &'a str,
346+
is_partial: bool,
347+
is_loop_message: bool,
348+
},
341349
#[label(borrowck_value_moved_here)]
342350
MovedHere {
343351
#[primary_span]

compiler/rustc_builtin_macros/messages.ftl

+35
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,40 @@ builtin_macros_asm_pure_no_output = asm with the `pure` option must have at leas
169169
170170
builtin_macros_asm_modifier_invalid = asm template modifier must be a single character
171171
172+
builtin_macros_asm_requires_template = requires at least a template string argument
173+
174+
builtin_macros_asm_expected_comma = expected token: `,`
175+
.label = expected `,`
176+
177+
builtin_macros_asm_underscore_input = _ cannot be used for input operands
178+
179+
builtin_macros_asm_sym_no_path = expected a path for argument to `sym`
180+
181+
builtin_macros_asm_expected_other = expected operand, {$is_global_asm ->
182+
[true] options
183+
*[false] clobber_abi, options
184+
}, or additional template string
185+
186+
builtin_macros_asm_duplicate_arg = duplicate argument named `{$name}`
187+
.label = previously here
188+
.arg = duplicate argument
189+
190+
builtin_macros_asm_pos_after = positional arguments cannot follow named arguments or explicit register arguments
191+
.pos = positional argument
192+
.named = named argument
193+
.explicit = explicit register argument
194+
195+
builtin_macros_asm_noreturn = asm outputs are not allowed with the `noreturn` option
196+
197+
builtin_macros_global_asm_clobber_abi = `clobber_abi` cannot be used with `global_asm!`
198+
199+
builtin_macros_asm_clobber_no_reg = asm with `clobber_abi` must specify explicit registers for outputs
200+
builtin_macros_asm_clobber_abi = clobber_abi
201+
builtin_macros_asm_clobber_outputs = generic outputs
202+
203+
builtin_macros_asm_opt_already_provided = the `{$symbol}` option was already provided
204+
.label = this option was already provided
205+
.suggestion = remove this option
206+
172207
builtin_macros_test_runner_invalid = `test_runner` argument must be a path
173208
builtin_macros_test_runner_nargs = `#![test_runner(..)]` accepts exactly 1 argument

0 commit comments

Comments
 (0)