Skip to content

Commit 70e720b

Browse files
committed
Auto merge of rust-lang#3270 - rust-lang:rustup-2024-01-21, r=RalfJung
Automatic Rustup
2 parents 0c8e1e6 + 7092c66 commit 70e720b

File tree

1,103 files changed

+17008
-8535
lines changed

Some content is hidden

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

1,103 files changed

+17008
-8535
lines changed

Cargo.lock

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,9 @@ checksum = "55b672471b4e9f9e95499ea597ff64941a309b2cdbffcc46f2cc5e2d971fd335"
714714

715715
[[package]]
716716
name = "compiler_builtins"
717-
version = "0.1.104"
717+
version = "0.1.105"
718718
source = "registry+https://github.com/rust-lang/crates.io-index"
719-
checksum = "99c3f9035afc33f4358773239573f7d121099856753e1bbd2a6a5207098fc741"
719+
checksum = "3686cc48897ce1950aa70fd595bd2dc9f767a3c4cca4cd17b2cb52a2d37e6eb4"
720720
dependencies = [
721721
"cc",
722722
"rustc-std-workspace-core",
@@ -2187,16 +2187,6 @@ dependencies = [
21872187
"cc",
21882188
]
21892189

2190-
[[package]]
2191-
name = "libloading"
2192-
version = "0.7.4"
2193-
source = "registry+https://github.com/rust-lang/crates.io-index"
2194-
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
2195-
dependencies = [
2196-
"cfg-if",
2197-
"winapi",
2198-
]
2199-
22002190
[[package]]
22012191
name = "libloading"
22022192
version = "0.8.1"
@@ -2366,9 +2356,9 @@ dependencies = [
23662356

23672357
[[package]]
23682358
name = "measureme"
2369-
version = "10.1.2"
2359+
version = "11.0.1"
23702360
source = "registry+https://github.com/rust-lang/crates.io-index"
2371-
checksum = "45e381dcdad44c3c435f8052b08c5c4a1449c48ab56f312345eae12d7a693dbe"
2361+
checksum = "dfa4a40f09af7aa6faef38285402a78847d0d72bf8827006cd2a332e1e6e4a8d"
23722362
dependencies = [
23732363
"log",
23742364
"memmap2",
@@ -2479,7 +2469,7 @@ dependencies = [
24792469
"lazy_static",
24802470
"libc",
24812471
"libffi",
2482-
"libloading 0.8.1",
2472+
"libloading",
24832473
"log",
24842474
"measureme",
24852475
"rand",
@@ -3879,6 +3869,7 @@ dependencies = [
38793869
name = "rustc_hir_analysis"
38803870
version = "0.0.0"
38813871
dependencies = [
3872+
"itertools",
38823873
"rustc_arena",
38833874
"rustc_ast",
38843875
"rustc_attr",
@@ -3917,6 +3908,7 @@ dependencies = [
39173908
name = "rustc_hir_typeck"
39183909
version = "0.0.0"
39193910
dependencies = [
3911+
"itertools",
39203912
"rustc_ast",
39213913
"rustc_attr",
39223914
"rustc_data_structures",
@@ -4003,7 +3995,7 @@ dependencies = [
40033995
name = "rustc_interface"
40043996
version = "0.0.0"
40053997
dependencies = [
4006-
"libloading 0.7.4",
3998+
"libloading",
40073999
"rustc-rayon",
40084000
"rustc-rayon-core",
40094001
"rustc_ast",
@@ -4133,7 +4125,7 @@ name = "rustc_metadata"
41334125
version = "0.0.0"
41344126
dependencies = [
41354127
"bitflags 2.4.1",
4136-
"libloading 0.7.4",
4128+
"libloading",
41374129
"odht",
41384130
"rustc_ast",
41394131
"rustc_attr",
@@ -4200,6 +4192,7 @@ name = "rustc_mir_build"
42004192
version = "0.0.0"
42014193
dependencies = [
42024194
"either",
4195+
"itertools",
42034196
"rustc_apfloat",
42044197
"rustc_arena",
42054198
"rustc_ast",
@@ -4352,6 +4345,7 @@ name = "rustc_pattern_analysis"
43524345
version = "0.0.0"
43534346
dependencies = [
43544347
"derivative",
4348+
"rustc-hash",
43554349
"rustc_apfloat",
43564350
"rustc_arena",
43574351
"rustc_data_structures",
@@ -4366,7 +4360,6 @@ dependencies = [
43664360
"rustc_target",
43674361
"smallvec",
43684362
"tracing",
4369-
"typed-arena",
43704363
]
43714364

43724365
[[package]]
@@ -5351,9 +5344,9 @@ dependencies = [
53515344

53525345
[[package]]
53535346
name = "thin-vec"
5354-
version = "0.2.12"
5347+
version = "0.2.13"
53555348
source = "registry+https://github.com/rust-lang/crates.io-index"
5356-
checksum = "aac81b6fd6beb5884b0cf3321b8117e6e5d47ecb6fc89f414cfdcca8b2fe2dd8"
5349+
checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b"
53575350

53585351
[[package]]
53595352
name = "thiserror"
@@ -5705,12 +5698,6 @@ dependencies = [
57055698
"rustc-hash",
57065699
]
57075700

5708-
[[package]]
5709-
name = "typed-arena"
5710-
version = "2.0.2"
5711-
source = "registry+https://github.com/rust-lang/crates.io-index"
5712-
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
5713-
57145701
[[package]]
57155702
name = "typenum"
57165703
version = "1.16.0"

compiler/rustc_abi/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ bitflags! {
4949
| ReprFlags::IS_LINEAR.bits();
5050
}
5151
}
52-
rustc_data_structures::external_bitflags_debug! { ReprFlags }
52+
53+
// This is the same as `rustc_data_structures::external_bitflags_debug` but without the
54+
// `rustc_data_structures` to make it build on stable.
55+
impl std::fmt::Debug for ReprFlags {
56+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
57+
bitflags::parser::to_writer(self, f)
58+
}
59+
}
5360

5461
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
5562
#[cfg_attr(feature = "nightly", derive(Encodable_Generic, Decodable_Generic, HashStable_Generic))]

compiler/rustc_ast/src/ast.rs

Lines changed: 11 additions & 3 deletions
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.
@@ -3300,9 +3304,13 @@ mod size_asserts {
33003304
static_assert_size!(Impl, 136);
33013305
static_assert_size!(Item, 136);
33023306
static_assert_size!(ItemKind, 64);
3303-
static_assert_size!(LitKind, 24);
3307+
// This can be removed after i128:128 is in the bootstrap compiler's target.
3308+
#[cfg(not(bootstrap))]
3309+
static_assert_size!(LitKind, 32);
33043310
static_assert_size!(Local, 72);
3305-
static_assert_size!(MetaItemLit, 40);
3311+
// This can be removed after i128:128 is in the bootstrap compiler's target.
3312+
#[cfg(not(bootstrap))]
3313+
static_assert_size!(MetaItemLit, 48);
33063314
static_assert_size!(Param, 40);
33073315
static_assert_size!(Pat, 72);
33083316
static_assert_size!(Path, 24);

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/classify.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
// Predicates on exprs and stmts that the pretty-printer and parser use
44

5-
use crate::ast;
5+
use crate::{ast, token::Delimiter};
66

77
/// Does this expression require a semicolon to be treated
88
/// as a statement? The negation of this: 'can this expression
@@ -59,8 +59,12 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> {
5959
| While(..)
6060
| ConstBlock(_) => break Some(expr),
6161

62-
// FIXME: These can end in `}`, but changing these would break stable code.
63-
InlineAsm(_) | OffsetOf(_, _) | MacCall(_) | IncludedBytes(_) | FormatArgs(_) => {
62+
MacCall(mac) => {
63+
break (mac.args.delim == Delimiter::Brace).then_some(expr);
64+
}
65+
66+
InlineAsm(_) | OffsetOf(_, _) | IncludedBytes(_) | FormatArgs(_) => {
67+
// These should have been denied pre-expansion.
6468
break None;
6569
}
6670

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)