Skip to content

Commit f128057

Browse files
committed
Auto merge of rust-lang#3003 - rust-lang:rustup-2023-08-02, r=RalfJung
Automatic sync from rustc
2 parents 320cd7d + 2d01258 commit f128057

File tree

778 files changed

+13374
-6384
lines changed

Some content is hidden

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

778 files changed

+13374
-6384
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ jobs:
418418
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --host=aarch64-pc-windows-msvc --enable-full-tools --enable-profiler"
419419
SCRIPT: python x.py dist bootstrap --include-default-paths
420420
DIST_REQUIRE_ALL_TOOLS: 1
421-
WINDOWS_SDK_20348_HACK: 1
422421
os: windows-2019-8core-32gb
423422
- name: dist-i686-mingw
424423
env:

.gitmodules

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
11
[submodule "src/doc/nomicon"]
22
path = src/doc/nomicon
33
url = https://github.com/rust-lang/nomicon.git
4+
shallow = true
45
[submodule "src/tools/cargo"]
56
path = src/tools/cargo
67
url = https://github.com/rust-lang/cargo.git
8+
shallow = true
79
[submodule "src/doc/reference"]
810
path = src/doc/reference
911
url = https://github.com/rust-lang/reference.git
12+
shallow = true
1013
[submodule "src/doc/book"]
1114
path = src/doc/book
1215
url = https://github.com/rust-lang/book.git
16+
shallow = true
1317
[submodule "src/doc/rust-by-example"]
1418
path = src/doc/rust-by-example
1519
url = https://github.com/rust-lang/rust-by-example.git
20+
shallow = true
1621
[submodule "library/stdarch"]
1722
path = library/stdarch
1823
url = https://github.com/rust-lang/stdarch.git
24+
shallow = true
1925
[submodule "src/doc/rustc-dev-guide"]
2026
path = src/doc/rustc-dev-guide
2127
url = https://github.com/rust-lang/rustc-dev-guide.git
28+
shallow = true
2229
[submodule "src/doc/edition-guide"]
2330
path = src/doc/edition-guide
2431
url = https://github.com/rust-lang/edition-guide.git
32+
shallow = true
2533
[submodule "src/llvm-project"]
2634
path = src/llvm-project
2735
url = https://github.com/rust-lang/llvm-project.git
2836
branch = rustc/16.0-2023-06-05
37+
shallow = true
2938
[submodule "src/doc/embedded-book"]
3039
path = src/doc/embedded-book
3140
url = https://github.com/rust-embedded/book.git
41+
shallow = true
3242
[submodule "library/backtrace"]
3343
path = library/backtrace
3444
url = https://github.com/rust-lang/backtrace-rs.git
45+
shallow = true

Cargo.lock

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,6 +2495,7 @@ dependencies = [
24952495
"serde_json",
24962496
"sysinfo",
24972497
"tar",
2498+
"tempfile",
24982499
"xz",
24992500
"zip",
25002501
]
@@ -3785,7 +3786,7 @@ name = "rustc_lexer"
37853786
version = "0.1.0"
37863787
dependencies = [
37873788
"expect-test",
3788-
"unic-emoji-char",
3789+
"unicode-properties",
37893790
"unicode-xid",
37903791
]
37913792

@@ -5445,38 +5446,6 @@ dependencies = [
54455446
"tempfile",
54465447
]
54475448

5448-
[[package]]
5449-
name = "unic-char-property"
5450-
version = "0.9.0"
5451-
source = "registry+https://github.com/rust-lang/crates.io-index"
5452-
checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221"
5453-
dependencies = [
5454-
"unic-char-range",
5455-
]
5456-
5457-
[[package]]
5458-
name = "unic-char-range"
5459-
version = "0.9.0"
5460-
source = "registry+https://github.com/rust-lang/crates.io-index"
5461-
checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc"
5462-
5463-
[[package]]
5464-
name = "unic-common"
5465-
version = "0.9.0"
5466-
source = "registry+https://github.com/rust-lang/crates.io-index"
5467-
checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc"
5468-
5469-
[[package]]
5470-
name = "unic-emoji-char"
5471-
version = "0.9.0"
5472-
source = "registry+https://github.com/rust-lang/crates.io-index"
5473-
checksum = "0b07221e68897210270a38bde4babb655869637af0f69407f96053a34f76494d"
5474-
dependencies = [
5475-
"unic-char-property",
5476-
"unic-char-range",
5477-
"unic-ucd-version",
5478-
]
5479-
54805449
[[package]]
54815450
name = "unic-langid"
54825451
version = "0.9.1"
@@ -5520,15 +5489,6 @@ dependencies = [
55205489
"unic-langid-impl",
55215490
]
55225491

5523-
[[package]]
5524-
name = "unic-ucd-version"
5525-
version = "0.9.0"
5526-
source = "registry+https://github.com/rust-lang/crates.io-index"
5527-
checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4"
5528-
dependencies = [
5529-
"unic-common",
5530-
]
5531-
55325492
[[package]]
55335493
name = "unicase"
55345494
version = "2.6.0"
@@ -5566,6 +5526,12 @@ dependencies = [
55665526
"tinyvec",
55675527
]
55685528

5529+
[[package]]
5530+
name = "unicode-properties"
5531+
version = "0.1.0"
5532+
source = "registry+https://github.com/rust-lang/crates.io-index"
5533+
checksum = "c7f91c8b21fbbaa18853c3d0801c78f4fc94cdb976699bb03e832e75f7fd22f0"
5534+
55695535
[[package]]
55705536
name = "unicode-script"
55715537
version = "0.5.5"

compiler/rustc/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn set_windows_exe_options() {
1818
let mut manifest = env::current_dir().unwrap();
1919
manifest.push(WINDOWS_MANIFEST_FILE);
2020

21-
println!("cargo:rerun-if-changed={}", WINDOWS_MANIFEST_FILE);
21+
println!("cargo:rerun-if-changed={WINDOWS_MANIFEST_FILE}");
2222
// Embed the Windows application manifest file.
2323
println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFEST:EMBED");
2424
println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFESTINPUT:{}", manifest.to_str().unwrap());

compiler/rustc_abi/src/layout.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ pub trait LayoutCalculator {
260260
}
261261
_ => assert!(
262262
start == Bound::Unbounded && end == Bound::Unbounded,
263-
"nonscalar layout for layout_scalar_valid_range type: {:#?}",
264-
st,
263+
"nonscalar layout for layout_scalar_valid_range type: {st:#?}",
265264
),
266265
}
267266

@@ -463,7 +462,7 @@ pub trait LayoutCalculator {
463462
min = 0;
464463
max = 0;
465464
}
466-
assert!(min <= max, "discriminant range is {}...{}", min, max);
465+
assert!(min <= max, "discriminant range is {min}...{max}");
467466
let (min_ity, signed) = discr_range_of_repr(min, max); //Integer::repr_discr(tcx, ty, &repr, min, max);
468467

469468
let mut align = dl.aggregate_align;
@@ -537,8 +536,7 @@ pub trait LayoutCalculator {
537536
// space necessary to represent would have to be discarded (or layout is wrong
538537
// on thinking it needs 16 bits)
539538
panic!(
540-
"layout decided on a larger discriminant type ({:?}) than typeck ({:?})",
541-
min_ity, typeck_ity
539+
"layout decided on a larger discriminant type ({min_ity:?}) than typeck ({typeck_ity:?})"
542540
);
543541
// However, it is fine to make discr type however large (as an optimisation)
544542
// after this point – we’ll just truncate the value we load in codegen.

compiler/rustc_abi/src/lib.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl TargetDataLayout {
332332
16 => 1 << 15,
333333
32 => 1 << 31,
334334
64 => 1 << 47,
335-
bits => panic!("obj_size_bound: unknown pointer bit size {}", bits),
335+
bits => panic!("obj_size_bound: unknown pointer bit size {bits}"),
336336
}
337337
}
338338

@@ -342,7 +342,7 @@ impl TargetDataLayout {
342342
16 => I16,
343343
32 => I32,
344344
64 => I64,
345-
bits => panic!("ptr_sized_integer: unknown pointer bit size {}", bits),
345+
bits => panic!("ptr_sized_integer: unknown pointer bit size {bits}"),
346346
}
347347
}
348348

@@ -399,7 +399,7 @@ impl FromStr for Endian {
399399
match s {
400400
"little" => Ok(Self::Little),
401401
"big" => Ok(Self::Big),
402-
_ => Err(format!(r#"unknown endian: "{}""#, s)),
402+
_ => Err(format!(r#"unknown endian: "{s}""#)),
403403
}
404404
}
405405
}
@@ -456,7 +456,7 @@ impl Size {
456456
pub fn bits(self) -> u64 {
457457
#[cold]
458458
fn overflow(bytes: u64) -> ! {
459-
panic!("Size::bits: {} bytes in bits doesn't fit in u64", bytes)
459+
panic!("Size::bits: {bytes} bytes in bits doesn't fit in u64")
460460
}
461461

462462
self.bytes().checked_mul(8).unwrap_or_else(|| overflow(self.bytes()))
@@ -1179,17 +1179,12 @@ impl FieldsShape {
11791179
unreachable!("FieldsShape::offset: `Primitive`s have no fields")
11801180
}
11811181
FieldsShape::Union(count) => {
1182-
assert!(
1183-
i < count.get(),
1184-
"tried to access field {} of union with {} fields",
1185-
i,
1186-
count
1187-
);
1182+
assert!(i < count.get(), "tried to access field {i} of union with {count} fields");
11881183
Size::ZERO
11891184
}
11901185
FieldsShape::Array { stride, count } => {
11911186
let i = u64::try_from(i).unwrap();
1192-
assert!(i < count, "tried to access field {} of array with {} fields", i, count);
1187+
assert!(i < count, "tried to access field {i} of array with {count} fields");
11931188
stride * i
11941189
}
11951190
FieldsShape::Arbitrary { ref offsets, .. } => offsets[FieldIdx::from_usize(i)],
@@ -1294,7 +1289,7 @@ impl Abi {
12941289
Primitive::Int(_, signed) => signed,
12951290
_ => false,
12961291
},
1297-
_ => panic!("`is_signed` on non-scalar ABI {:?}", self),
1292+
_ => panic!("`is_signed` on non-scalar ABI {self:?}"),
12981293
}
12991294
}
13001295

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 89 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! and a borrowed `TokenStream` is sufficient to build an owned `TokenStream` without taking
1414
//! ownership of the original.
1515
16-
use crate::ast::StmtKind;
16+
use crate::ast::{AttrStyle, StmtKind};
1717
use crate::ast_traits::{HasAttrs, HasSpan, HasTokens};
1818
use crate::token::{self, Delimiter, Nonterminal, Token, TokenKind};
1919
use crate::AttrVec;
@@ -22,11 +22,11 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2222
use rustc_data_structures::sync::{self, Lrc};
2323
use rustc_macros::HashStable_Generic;
2424
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
25-
use rustc_span::{Span, DUMMY_SP};
25+
use rustc_span::{sym, Span, Symbol, DUMMY_SP};
2626
use smallvec::{smallvec, SmallVec};
2727

2828
use std::borrow::Cow;
29-
use std::{fmt, iter, mem};
29+
use std::{cmp, fmt, iter, mem};
3030

3131
/// When the main Rust parser encounters a syntax-extension invocation, it
3232
/// parses the arguments to the invocation as a token tree. This is a very
@@ -566,6 +566,92 @@ impl TokenStream {
566566
pub fn chunks(&self, chunk_size: usize) -> core::slice::Chunks<'_, TokenTree> {
567567
self.0.chunks(chunk_size)
568568
}
569+
570+
/// Desugar doc comments like `/// foo` in the stream into `#[doc =
571+
/// r"foo"]`. Modifies the `TokenStream` via `Lrc::make_mut`, but as little
572+
/// as possible.
573+
pub fn desugar_doc_comments(&mut self) {
574+
if let Some(desugared_stream) = desugar_inner(self.clone()) {
575+
*self = desugared_stream;
576+
}
577+
578+
// The return value is `None` if nothing in `stream` changed.
579+
fn desugar_inner(mut stream: TokenStream) -> Option<TokenStream> {
580+
let mut i = 0;
581+
let mut modified = false;
582+
while let Some(tt) = stream.0.get(i) {
583+
match tt {
584+
&TokenTree::Token(
585+
Token { kind: token::DocComment(_, attr_style, data), span },
586+
_spacing,
587+
) => {
588+
let desugared = desugared_tts(attr_style, data, span);
589+
let desugared_len = desugared.len();
590+
Lrc::make_mut(&mut stream.0).splice(i..i + 1, desugared);
591+
modified = true;
592+
i += desugared_len;
593+
}
594+
595+
&TokenTree::Token(..) => i += 1,
596+
597+
&TokenTree::Delimited(sp, delim, ref delim_stream) => {
598+
if let Some(desugared_delim_stream) = desugar_inner(delim_stream.clone()) {
599+
let new_tt = TokenTree::Delimited(sp, delim, desugared_delim_stream);
600+
Lrc::make_mut(&mut stream.0)[i] = new_tt;
601+
modified = true;
602+
}
603+
i += 1;
604+
}
605+
}
606+
}
607+
if modified { Some(stream) } else { None }
608+
}
609+
610+
fn desugared_tts(attr_style: AttrStyle, data: Symbol, span: Span) -> Vec<TokenTree> {
611+
// Searches for the occurrences of `"#*` and returns the minimum number of `#`s
612+
// required to wrap the text. E.g.
613+
// - `abc d` is wrapped as `r"abc d"` (num_of_hashes = 0)
614+
// - `abc "d"` is wrapped as `r#"abc "d""#` (num_of_hashes = 1)
615+
// - `abc "##d##"` is wrapped as `r###"abc ##"d"##"###` (num_of_hashes = 3)
616+
let mut num_of_hashes = 0;
617+
let mut count = 0;
618+
for ch in data.as_str().chars() {
619+
count = match ch {
620+
'"' => 1,
621+
'#' if count > 0 => count + 1,
622+
_ => 0,
623+
};
624+
num_of_hashes = cmp::max(num_of_hashes, count);
625+
}
626+
627+
// `/// foo` becomes `doc = r"foo"`.
628+
let delim_span = DelimSpan::from_single(span);
629+
let body = TokenTree::Delimited(
630+
delim_span,
631+
Delimiter::Bracket,
632+
[
633+
TokenTree::token_alone(token::Ident(sym::doc, false), span),
634+
TokenTree::token_alone(token::Eq, span),
635+
TokenTree::token_alone(
636+
TokenKind::lit(token::StrRaw(num_of_hashes), data, None),
637+
span,
638+
),
639+
]
640+
.into_iter()
641+
.collect::<TokenStream>(),
642+
);
643+
644+
if attr_style == AttrStyle::Inner {
645+
vec![
646+
TokenTree::token_alone(token::Pound, span),
647+
TokenTree::token_alone(token::Not, span),
648+
body,
649+
]
650+
} else {
651+
vec![TokenTree::token_alone(token::Pound, span), body]
652+
}
653+
}
654+
}
569655
}
570656

571657
/// By-reference iterator over a [`TokenStream`], that produces `&TokenTree`
@@ -628,15 +714,6 @@ impl TokenTreeCursor {
628714
pub fn look_ahead(&self, n: usize) -> Option<&TokenTree> {
629715
self.stream.0.get(self.index + n)
630716
}
631-
632-
// Replace the previously obtained token tree with `tts`, and rewind to
633-
// just before them.
634-
pub fn replace_prev_and_rewind(&mut self, tts: Vec<TokenTree>) {
635-
assert!(self.index > 0);
636-
self.index -= 1;
637-
let stream = Lrc::make_mut(&mut self.stream.0);
638-
stream.splice(self.index..self.index + 1, tts);
639-
}
640717
}
641718

642719
#[derive(Debug, Copy, Clone, PartialEq, Encodable, Decodable, HashStable_Generic)]

0 commit comments

Comments
 (0)