Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8424f8e

Browse files
committed
Auto merge of #120089 - matthiaskrgr:rollup-xyfqrb5, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #119172 (Detect `NulInCStr` error earlier.) - #119833 (Make tcx optional from StableMIR run macro and extend it to accept closures) - #119967 (Add `PatKind::Err` to AST/HIR) - #119978 (Move async closure parameters into the resultant closure's future eagerly) - #120021 (don't store const var origins for known vars) - #120038 (Don't create a separate "basename" when naming and opening a MIR dump file) - #120057 (Don't ICE when deducing future output if other errors already occurred) - #120073 (Remove spastorino from users_on_vacation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a34faab + 054a435 commit 8424f8e

File tree

75 files changed

+761
-644
lines changed

Some content is hidden

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

75 files changed

+761
-644
lines changed

‎compiler/rustc_ast/src/ast.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ impl Pat {
625625
| PatKind::Range(..)
626626
| PatKind::Ident(..)
627627
| PatKind::Path(..)
628-
| PatKind::MacCall(_) => {}
628+
| PatKind::MacCall(_)
629+
| PatKind::Err(_) => {}
629630
}
630631
}
631632

@@ -809,6 +810,9 @@ pub enum PatKind {
809810

810811
/// A macro pattern; pre-expansion.
811812
MacCall(P<MacCall>),
813+
814+
/// Placeholder for a pattern that wasn't syntactically well formed in some way.
815+
Err(ErrorGuaranteed),
812816
}
813817

814818
/// Whether the `..` is present in a struct fields pattern.

‎compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
12671267
let Pat { id, kind, span, tokens } = pat.deref_mut();
12681268
vis.visit_id(id);
12691269
match kind {
1270-
PatKind::Wild | PatKind::Rest | PatKind::Never => {}
1270+
PatKind::Wild | PatKind::Rest | PatKind::Never | PatKind::Err(_)=> {}
12711271
PatKind::Ident(_binding_mode, ident, sub) => {
12721272
vis.visit_ident(ident);
12731273
visit_opt(sub, |sub| vis.visit_pat(sub));

‎compiler/rustc_ast/src/util/literal.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_lexer::unescape::{
88
};
99
use rustc_span::symbol::{kw, sym, Symbol};
1010
use rustc_span::Span;
11-
use std::ops::Range;
1211
use std::{ascii, fmt, str};
1312

1413
// Escapes a string, represented as a symbol. Reuses the original symbol,
@@ -39,7 +38,6 @@ pub enum LitError {
3938
InvalidFloatSuffix,
4039
NonDecimalFloat(u32),
4140
IntTooLarge(u32),
42-
NulInCStr(Range<usize>),
4341
}
4442

4543
impl LitKind {
@@ -156,10 +154,7 @@ impl LitKind {
156154
let s = symbol.as_str();
157155
let mut buf = Vec::with_capacity(s.len());
158156
let mut error = Ok(());
159-
unescape_c_string(s, Mode::CStr, &mut |span, c| match c {
160-
Ok(CStrUnit::Byte(0) | CStrUnit::Char('0円')) => {
161-
error = Err(LitError::NulInCStr(span));
162-
}
157+
unescape_c_string(s, Mode::CStr, &mut |_span, c| match c {
163158
Ok(CStrUnit::Byte(b)) => buf.push(b),
164159
Ok(CStrUnit::Char(c)) => {
165160
buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes())
@@ -179,10 +174,7 @@ impl LitKind {
179174
// can convert the symbol directly to a `Lrc<u8>` on success.
180175
let s = symbol.as_str();
181176
let mut error = Ok(());
182-
unescape_c_string(s, Mode::RawCStr, &mut |span, c| match c {
183-
Ok(CStrUnit::Byte(0) | CStrUnit::Char('0円')) => {
184-
error = Err(LitError::NulInCStr(span));
185-
}
177+
unescape_c_string(s, Mode::RawCStr, &mut |_, c| match c {
186178
Ok(_) => {}
187179
Err(err) => {
188180
if err.is_fatal() {

‎compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) {
568568
walk_list!(visitor, visit_expr, lower_bound);
569569
walk_list!(visitor, visit_expr, upper_bound);
570570
}
571-
PatKind::Wild | PatKind::Rest | PatKind::Never => {}
571+
PatKind::Wild | PatKind::Rest | PatKind::Never | PatKind::Err(_)=> {}
572572
PatKind::Tuple(elems) | PatKind::Slice(elems) | PatKind::Or(elems) => {
573573
walk_list!(visitor, visit_pat, elems);
574574
}

‎compiler/rustc_ast_lowering/messages.ftl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ ast_lowering_assoc_ty_parentheses =
1414
ast_lowering_async_coroutines_not_supported =
1515
`async` coroutines are not yet supported
1616
17-
ast_lowering_async_non_move_closure_not_supported =
18-
`async` non-`move` closures with parameters are not currently supported
19-
.help = consider using `let` statements to manually capture variables by reference before entering an `async move` closure
20-
2117
ast_lowering_att_syntax_only_x86 =
2218
the `att_syntax` option is only supported on x86
2319

‎compiler/rustc_ast_lowering/src/errors.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,6 @@ pub struct ClosureCannotBeStatic {
145145
pub fn_decl_span: Span,
146146
}
147147

148-
#[derive(Diagnostic, Clone, Copy)]
149-
#[help]
150-
#[diag(ast_lowering_async_non_move_closure_not_supported, code = "E0708")]
151-
pub struct AsyncNonMoveClosureNotSupported {
152-
#[primary_span]
153-
pub fn_decl_span: Span,
154-
}
155-
156148
#[derive(Diagnostic, Clone, Copy)]
157149
#[diag(ast_lowering_functional_record_update_destructuring_assignment)]
158150
pub struct FunctionalRecordUpdateDestructuringAssignment {

‎compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::errors::{
2-
AsyncCoroutinesNotSupported, AsyncNonMoveClosureNotSupported,AwaitOnlyInAsyncFnAndBlocks,
3-
BaseExpressionDoubleDot,ClosureCannotBeStatic, CoroutineTooManyParameters,
2+
AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks,BaseExpressionDoubleDot,
3+
ClosureCannotBeStatic, CoroutineTooManyParameters,
44
FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd, MatchArmWithNoBody,
55
NeverPatternWithBody, NeverPatternWithGuard, NotSupportedForLifetimeBinderAsyncClosure,
66
UnderscoreExprLhsAssign,
@@ -13,7 +13,6 @@ use rustc_ast::*;
1313
use rustc_data_structures::stack::ensure_sufficient_stack;
1414
use rustc_hir as hir;
1515
use rustc_hir::def::{DefKind, Res};
16-
use rustc_middle::span_bug;
1716
use rustc_session::errors::report_lit_error;
1817
use rustc_span::source_map::{respan, Spanned};
1918
use rustc_span::symbol::{kw, sym, Ident, Symbol};
@@ -1028,51 +1027,43 @@ impl<'hir> LoweringContext<'_, 'hir> {
10281027
fn_decl_span: Span,
10291028
fn_arg_span: Span,
10301029
) -> hir::ExprKind<'hir> {
1031-
let CoroutineKind::Async { closure_id: inner_closure_id, .. } = coroutine_kind else {
1032-
span_bug!(fn_decl_span, "`async gen` and `gen` closures are not supported, yet");
1033-
};
1034-
10351030
if let &ClosureBinder::For { span, .. } = binder {
10361031
self.dcx().emit_err(NotSupportedForLifetimeBinderAsyncClosure { span });
10371032
}
10381033

10391034
let (binder_clause, generic_params) = self.lower_closure_binder(binder);
10401035

1041-
let outer_decl =
1042-
FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) };
1043-
10441036
let body = self.with_new_scopes(fn_decl_span, |this| {
1045-
// FIXME(cramertj): allow `async` non-`move` closures with arguments.
1046-
if capture_clause == CaptureBy::Ref && !decl.inputs.is_empty() {
1047-
this.dcx().emit_err(AsyncNonMoveClosureNotSupported { fn_decl_span });
1048-
}
1049-
10501037
// Transform `async |x: u8| -> X { ... }` into
10511038
// `|x: u8| || -> X { ... }`.
1052-
let body_id = this.lower_fn_body(&outer_decl,|this| {
1039+
let body_id = this.lower_body(|this| {
10531040
let async_ret_ty = if let FnRetTy::Ty(ty) = &decl.output {
10541041
let itctx = ImplTraitContext::Disallowed(ImplTraitPosition::AsyncBlock);
10551042
Some(hir::FnRetTy::Return(this.lower_ty(ty, &itctx)))
10561043
} else {
10571044
None
10581045
};
10591046

1060-
let async_body = this.make_desugared_coroutine_expr(
1061-
capture_clause,
1062-
inner_closure_id,
1063-
async_ret_ty,
1047+
let (parameters, expr) = this.lower_coroutine_body_with_moved_arguments(
1048+
decl,
1049+
|this| this.with_new_scopes(fn_decl_span, |this| this.lower_expr_mut(body)),
10641050
body.span,
1065-
hir::CoroutineDesugaring::Async,
1051+
coroutine_kind,
10661052
hir::CoroutineSource::Closure,
1067-
|this| this.with_new_scopes(fn_decl_span, |this| this.lower_expr_mut(body)),
1053+
async_ret_ty,
10681054
);
1069-
let hir_id = this.lower_node_id(inner_closure_id);
1055+
1056+
let hir_id = this.lower_node_id(coroutine_kind.closure_id());
10701057
this.maybe_forward_track_caller(body.span, closure_hir_id, hir_id);
1071-
hir::Expr { hir_id, kind: async_body, span: this.lower_span(body.span) }
1058+
1059+
(parameters, expr)
10721060
});
10731061
body_id
10741062
});
10751063

1064+
let outer_decl =
1065+
FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) };
1066+
10761067
let bound_generic_params = self.lower_lifetime_binder(closure_id, generic_params);
10771068
// We need to lower the declaration outside the new scope, because we
10781069
// have to conserve the state of being inside a loop condition for the

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /