Skip to content

Commit 7cadf0b

Browse files
committed
Auto merge of rust-lang#3326 - rust-lang:rustup-2024-02-26, r=RalfJung
Automatic Rustup also fixes rust-lang/miri#3308
2 parents 8d74063 + db0b49b commit 7cadf0b

File tree

301 files changed

+4798
-1952
lines changed

Some content is hidden

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

301 files changed

+4798
-1952
lines changed

.github/workflows/ci.yml

+33
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,20 @@ jobs:
6565
- name: x86_64-gnu-tools
6666
os: ubuntu-20.04-16core-64gb
6767
env: {}
68+
defaults:
69+
run:
70+
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
6871
timeout-minutes: 600
6972
runs-on: "${{ matrix.os }}"
7073
steps:
74+
- if: "contains(matrix.os, 'windows')"
75+
uses: msys2/setup-msys2@v2.22.0
76+
with:
77+
msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}"
78+
update: false
79+
release: true
80+
path-type: inherit
81+
install: "make dos2unix diffutils\n"
7182
- name: disable git crlf conversion
7283
run: git config --global core.autocrlf false
7384
- name: checkout the source code
@@ -461,9 +472,20 @@ jobs:
461472
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-extended --enable-profiler"
462473
SCRIPT: python x.py dist bootstrap --include-default-paths
463474
os: windows-2019-8core-32gb
475+
defaults:
476+
run:
477+
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
464478
timeout-minutes: 600
465479
runs-on: "${{ matrix.os }}"
466480
steps:
481+
- if: "contains(matrix.os, 'windows')"
482+
uses: msys2/setup-msys2@v2.22.0
483+
with:
484+
msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}"
485+
update: false
486+
release: true
487+
path-type: inherit
488+
install: "make dos2unix diffutils\n"
467489
- name: disable git crlf conversion
468490
run: git config --global core.autocrlf false
469491
- name: checkout the source code
@@ -589,9 +611,20 @@ jobs:
589611
env:
590612
CODEGEN_BACKENDS: "llvm,cranelift"
591613
os: ubuntu-20.04-16core-64gb
614+
defaults:
615+
run:
616+
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
592617
timeout-minutes: 600
593618
runs-on: "${{ matrix.os }}"
594619
steps:
620+
- if: "contains(matrix.os, 'windows')"
621+
uses: msys2/setup-msys2@v2.22.0
622+
with:
623+
msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}"
624+
update: false
625+
release: true
626+
path-type: inherit
627+
install: "make dos2unix diffutils\n"
595628
- name: disable git crlf conversion
596629
run: git config --global core.autocrlf false
597630
- name: checkout the source code

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4101,6 +4101,7 @@ dependencies = [
41014101
"rustc_target",
41024102
"rustc_trait_selection",
41034103
"rustc_type_ir",
4104+
"smallvec",
41044105
"tracing",
41054106
"unicode-security",
41064107
]

INSTALL.md

+17-7
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,9 @@ toolchain.
145145

146146
1. Download the latest [MSYS2 installer][msys2] and go through the installer.
147147

148-
2. Run `mingw32_shell.bat` or `mingw64_shell.bat` from the MSYS2 installation
149-
directory (e.g. `C:\msys64`), depending on whether you want 32-bit or 64-bit
150-
Rust. (As of the latest version of MSYS2 you have to run `msys2_shell.cmd
151-
-mingw32` or `msys2_shell.cmd -mingw64` from the command line instead.)
148+
2. Start a MINGW64 or MINGW32 shell (depending on whether you want 32-bit
149+
or 64-bit Rust) either from your start menu, or by running `mingw64.exe`
150+
or `mingw32.exe` from your MSYS2 installation directory (e.g. `C:\msys64`).
152151

153152
3. From this terminal, install the required tools:
154153

@@ -157,8 +156,7 @@ toolchain.
157156
pacman -Sy pacman-mirrors
158157

159158
# Install build tools needed for Rust. If you're building a 32-bit compiler,
160-
# then replace "x86_64" below with "i686". If you've already got Git, Python,
161-
# or CMake installed and in PATH you can remove them from this list.
159+
# then replace "x86_64" below with "i686".
162160
# Note that it is important that you do **not** use the 'python2', 'cmake',
163161
# and 'ninja' packages from the 'msys2' subsystem.
164162
# The build has historically been known to fail with these packages.
@@ -175,9 +173,21 @@ toolchain.
175173
4. Navigate to Rust's source code (or clone it), then build it:
176174

177175
```sh
178-
python x.py setup user && python x.py build && python x.py install
176+
python x.py setup dist && python x.py build && python x.py install
179177
```
180178

179+
If you want to use the native versions of Git, Python, or CMake you can remove
180+
them from the above pacman command and install them from another source. Make
181+
sure that they're in your Windows PATH, and edit the relevant `mingw[32|64].ini`
182+
file in your MSYS2 installation directory by uncommenting the line
183+
`MSYS2_PATH_TYPE=inherit` to include them in your MSYS2 PATH.
184+
185+
Using Windows native Python can be helpful if you get errors when building LLVM.
186+
You may also want to use Git for Windows, as it is often *much* faster. Turning
187+
off real-time protection in the Windows Virus & Threat protections settings can
188+
also help with long run times (although note that it will automatically turn
189+
itself back on after some time).
190+
181191
### MSVC
182192

183193
MSVC builds of Rust additionally require an installation of Visual Studio 2017

compiler/rustc_ast/src/token.rs

+28-10
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl Lit {
107107
/// Keep this in sync with `Token::can_begin_literal_or_bool` excluding unary negation.
108108
pub fn from_token(token: &Token) -> Option<Lit> {
109109
match token.uninterpolate().kind {
110-
Ident(name, false) if name.is_bool_lit() => Some(Lit::new(Bool, name, None)),
110+
Ident(name, IdentIsRaw::No) if name.is_bool_lit() => Some(Lit::new(Bool, name, None)),
111111
Literal(token_lit) => Some(token_lit),
112112
Interpolated(ref nt)
113113
if let NtExpr(expr) | NtLiteral(expr) = &nt.0
@@ -183,7 +183,7 @@ impl LitKind {
183183
}
184184
}
185185

186-
pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool {
186+
pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
187187
let ident_token = Token::new(Ident(name, is_raw), span);
188188

189189
!ident_token.is_reserved_ident()
@@ -214,7 +214,7 @@ pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool {
214214
.contains(&name)
215215
}
216216

217-
fn ident_can_begin_type(name: Symbol, span: Span, is_raw: bool) -> bool {
217+
fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
218218
let ident_token = Token::new(Ident(name, is_raw), span);
219219

220220
!ident_token.is_reserved_ident()
@@ -223,6 +223,24 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: bool) -> bool {
223223
.contains(&name)
224224
}
225225

226+
#[derive(PartialEq, Encodable, Decodable, Debug, Copy, Clone, HashStable_Generic)]
227+
pub enum IdentIsRaw {
228+
No,
229+
Yes,
230+
}
231+
232+
impl From<bool> for IdentIsRaw {
233+
fn from(b: bool) -> Self {
234+
if b { Self::Yes } else { Self::No }
235+
}
236+
}
237+
238+
impl From<IdentIsRaw> for bool {
239+
fn from(is_raw: IdentIsRaw) -> bool {
240+
matches!(is_raw, IdentIsRaw::Yes)
241+
}
242+
}
243+
226244
// SAFETY: due to the `Clone` impl below, all fields of all variants other than
227245
// `Interpolated` must impl `Copy`.
228246
#[derive(PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
@@ -298,7 +316,7 @@ pub enum TokenKind {
298316
/// Do not forget about `NtIdent` when you want to match on identifiers.
299317
/// It's recommended to use `Token::(ident,uninterpolate,uninterpolated_span)` to
300318
/// treat regular and interpolated identifiers in the same way.
301-
Ident(Symbol, /* is_raw */ bool),
319+
Ident(Symbol, IdentIsRaw),
302320
/// Lifetime identifier token.
303321
/// Do not forget about `NtLifetime` when you want to match on lifetime identifiers.
304322
/// It's recommended to use `Token::(lifetime,uninterpolate,uninterpolated_span)` to
@@ -411,7 +429,7 @@ impl Token {
411429

412430
/// Recovers a `Token` from an `Ident`. This creates a raw identifier if necessary.
413431
pub fn from_ast_ident(ident: Ident) -> Self {
414-
Token::new(Ident(ident.name, ident.is_raw_guess()), ident.span)
432+
Token::new(Ident(ident.name, ident.is_raw_guess().into()), ident.span)
415433
}
416434

417435
/// For interpolated tokens, returns a span of the fragment to which the interpolated
@@ -567,7 +585,7 @@ impl Token {
567585
pub fn can_begin_literal_maybe_minus(&self) -> bool {
568586
match self.uninterpolate().kind {
569587
Literal(..) | BinOp(Minus) => true,
570-
Ident(name, false) if name.is_bool_lit() => true,
588+
Ident(name, IdentIsRaw::No) if name.is_bool_lit() => true,
571589
Interpolated(ref nt) => match &nt.0 {
572590
NtLiteral(_) => true,
573591
NtExpr(e) => match &e.kind {
@@ -602,7 +620,7 @@ impl Token {
602620

603621
/// Returns an identifier if this token is an identifier.
604622
#[inline]
605-
pub fn ident(&self) -> Option<(Ident, /* is_raw */ bool)> {
623+
pub fn ident(&self) -> Option<(Ident, IdentIsRaw)> {
606624
// We avoid using `Token::uninterpolate` here because it's slow.
607625
match &self.kind {
608626
&Ident(name, is_raw) => Some((Ident::new(name, self.span), is_raw)),
@@ -755,7 +773,7 @@ impl Token {
755773
/// Returns `true` if the token is a non-raw identifier for which `pred` holds.
756774
pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(Ident) -> bool) -> bool {
757775
match self.ident() {
758-
Some((id, false)) => pred(id),
776+
Some((id, IdentIsRaw::No)) => pred(id),
759777
_ => false,
760778
}
761779
}
@@ -806,7 +824,7 @@ impl Token {
806824
_ => return None,
807825
},
808826
SingleQuote => match joint.kind {
809-
Ident(name, false) => Lifetime(Symbol::intern(&format!("'{name}"))),
827+
Ident(name, IdentIsRaw::No) => Lifetime(Symbol::intern(&format!("'{name}"))),
810828
_ => return None,
811829
},
812830

@@ -836,7 +854,7 @@ pub enum Nonterminal {
836854
NtPat(P<ast::Pat>),
837855
NtExpr(P<ast::Expr>),
838856
NtTy(P<ast::Ty>),
839-
NtIdent(Ident, /* is_raw */ bool),
857+
NtIdent(Ident, IdentIsRaw),
840858
NtLifetime(Ident),
841859
NtLiteral(P<ast::Expr>),
842860
/// Stuff inside brackets for attributes

compiler/rustc_ast/src/tokenstream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ impl TokenStream {
656656
DelimSpacing::new(Spacing::JointHidden, Spacing::Alone),
657657
Delimiter::Bracket,
658658
[
659-
TokenTree::token_alone(token::Ident(sym::doc, false), span),
659+
TokenTree::token_alone(token::Ident(sym::doc, token::IdentIsRaw::No), span),
660660
TokenTree::token_alone(token::Eq, span),
661661
TokenTree::token_alone(
662662
TokenKind::lit(token::StrRaw(num_of_hashes), data, None),

compiler/rustc_ast_pretty/src/pprust/state.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {
185185

186186
// IDENT + `!`: `println!()`, but `if !x { ... }` needs a space after the `if`
187187
(Tok(Token { kind: Ident(sym, is_raw), span }, _), Tok(Token { kind: Not, .. }, _))
188-
if !Ident::new(*sym, *span).is_reserved() || *is_raw =>
188+
if !Ident::new(*sym, *span).is_reserved() || matches!(is_raw, IdentIsRaw::Yes) =>
189189
{
190190
false
191191
}
@@ -197,7 +197,7 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {
197197
|| *sym == kw::Fn
198198
|| *sym == kw::SelfUpper
199199
|| *sym == kw::Pub
200-
|| *is_raw =>
200+
|| matches!(is_raw, IdentIsRaw::Yes) =>
201201
{
202202
false
203203
}
@@ -731,7 +731,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
731731
token::NtBlock(e) => self.block_to_string(e),
732732
token::NtStmt(e) => self.stmt_to_string(e),
733733
token::NtPat(e) => self.pat_to_string(e),
734-
token::NtIdent(e, is_raw) => IdentPrinter::for_ast_ident(*e, *is_raw).to_string(),
734+
&token::NtIdent(e, is_raw) => IdentPrinter::for_ast_ident(e, is_raw.into()).to_string(),
735735
token::NtLifetime(e) => e.to_string(),
736736
token::NtLiteral(e) => self.expr_to_string(e),
737737
token::NtVis(e) => self.vis_to_string(e),
@@ -795,7 +795,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
795795

796796
/* Name components */
797797
token::Ident(s, is_raw) => {
798-
IdentPrinter::new(s, is_raw, convert_dollar_crate).to_string().into()
798+
IdentPrinter::new(s, is_raw.into(), convert_dollar_crate).to_string().into()
799799
}
800800
token::Lifetime(s) => s.to_string().into(),
801801

compiler/rustc_builtin_macros/src/asm.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use ast::token::IdentIsRaw;
12
use rustc_ast as ast;
23
use rustc_ast::ptr::P;
34
use rustc_ast::token::{self, Delimiter};
@@ -416,7 +417,7 @@ fn parse_reg<'a>(
416417
) -> PResult<'a, ast::InlineAsmRegOrRegClass> {
417418
p.expect(&token::OpenDelim(Delimiter::Parenthesis))?;
418419
let result = match p.token.uninterpolate().kind {
419-
token::Ident(name, false) => ast::InlineAsmRegOrRegClass::RegClass(name),
420+
token::Ident(name, IdentIsRaw::No) => ast::InlineAsmRegOrRegClass::RegClass(name),
420421
token::Literal(token::Lit { kind: token::LitKind::Str, symbol, suffix: _ }) => {
421422
*explicit_reg = true;
422423
ast::InlineAsmRegOrRegClass::Reg(symbol)

compiler/rustc_builtin_macros/src/assert/context.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use rustc_ast::{
22
ptr::P,
3-
token,
4-
token::Delimiter,
3+
token::{self, Delimiter, IdentIsRaw},
54
tokenstream::{DelimSpan, TokenStream, TokenTree},
65
BinOpKind, BorrowKind, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall, Mutability,
76
Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind, DUMMY_NODE_ID,
@@ -170,7 +169,10 @@ impl<'cx, 'a> Context<'cx, 'a> {
170169
];
171170
let captures = self.capture_decls.iter().flat_map(|cap| {
172171
[
173-
TokenTree::token_joint_hidden(token::Ident(cap.ident.name, false), cap.ident.span),
172+
TokenTree::token_joint_hidden(
173+
token::Ident(cap.ident.name, IdentIsRaw::No),
174+
cap.ident.span,
175+
),
174176
TokenTree::token_alone(token::Comma, self.span),
175177
]
176178
});

compiler/rustc_builtin_macros/src/deriving/decodable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ where
198198
match fields {
199199
Unnamed(fields, is_tuple) => {
200200
let path_expr = cx.expr_path(outer_pat_path);
201-
if !*is_tuple {
201+
if matches!(is_tuple, IsTuple::No) {
202202
path_expr
203203
} else {
204204
let fields = fields

compiler/rustc_builtin_macros/src/deriving/default.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ fn default_struct_substructure(
6262
let default_call = |span| cx.expr_call_global(span, default_ident.clone(), ThinVec::new());
6363

6464
let expr = match summary {
65-
Unnamed(_, false) => cx.expr_ident(trait_span, substr.type_ident),
66-
Unnamed(fields, true) => {
65+
Unnamed(_, IsTuple::No) => cx.expr_ident(trait_span, substr.type_ident),
66+
Unnamed(fields, IsTuple::Yes) => {
6767
let exprs = fields.iter().map(|sp| default_call(*sp)).collect();
6868
cx.expr_call_ident(trait_span, substr.type_ident, exprs)
6969
}

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,16 @@ pub struct FieldInfo {
286286
pub other_selflike_exprs: Vec<P<Expr>>,
287287
}
288288

289+
#[derive(Copy, Clone)]
290+
pub enum IsTuple {
291+
No,
292+
Yes,
293+
}
294+
289295
/// Fields for a static method
290296
pub enum StaticFields {
291297
/// Tuple and unit structs/enum variants like this.
292-
Unnamed(Vec<Span>, bool /*is tuple*/),
298+
Unnamed(Vec<Span>, IsTuple),
293299
/// Normal structs/struct variants.
294300
Named(Vec<(Ident, Span)>),
295301
}
@@ -1439,7 +1445,10 @@ impl<'a> TraitDef<'a> {
14391445
}
14401446
}
14411447

1442-
let is_tuple = matches!(struct_def, ast::VariantData::Tuple(..));
1448+
let is_tuple = match struct_def {
1449+
ast::VariantData::Tuple(..) => IsTuple::Yes,
1450+
_ => IsTuple::No,
1451+
};
14431452
match (just_spans.is_empty(), named_idents.is_empty()) {
14441453
(false, false) => cx
14451454
.dcx()

compiler/rustc_builtin_macros/src/format.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_ast::{
1010
use rustc_data_structures::fx::FxHashSet;
1111
use rustc_errors::{Applicability, DiagnosticBuilder, MultiSpan, PResult, SingleLabelManySpans};
1212
use rustc_expand::base::{self, *};
13+
use rustc_parse::parser::Recovered;
1314
use rustc_parse_format as parse;
1415
use rustc_span::symbol::{Ident, Symbol};
1516
use rustc_span::{BytePos, InnerSpan, Span};
@@ -111,9 +112,8 @@ fn parse_args<'a>(ecx: &mut ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<
111112
_ => return Err(err),
112113
}
113114
}
114-
Ok(recovered) => {
115-
assert!(recovered);
116-
}
115+
Ok(Recovered::Yes) => (),
116+
Ok(Recovered::No) => unreachable!(),
117117
}
118118
}
119119
first = false;

0 commit comments

Comments
 (0)