Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into use-high-bit-of-mas…
Browse files Browse the repository at this point in the history
…k-for-select
  • Loading branch information
jhorstmann committed Aug 2, 2023
2 parents 67a608b + 7a5d2d0 commit d17819e
Show file tree
Hide file tree
Showing 739 changed files with 12,929 additions and 6,041 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ jobs:
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --host=aarch64-pc-windows-msvc --enable-full-tools --enable-profiler"
SCRIPT: python x.py dist bootstrap --include-default-paths
DIST_REQUIRE_ALL_TOOLS: 1
WINDOWS_SDK_20348_HACK: 1
os: windows-2019-8core-32gb
- name: dist-i686-mingw
env:
Expand Down
11 changes: 11 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
[submodule "src/doc/nomicon"]
path = src/doc/nomicon
url = https://github.com/rust-lang/nomicon.git
shallow = true
[submodule "src/tools/cargo"]
path = src/tools/cargo
url = https://github.com/rust-lang/cargo.git
shallow = true
[submodule "src/doc/reference"]
path = src/doc/reference
url = https://github.com/rust-lang/reference.git
shallow = true
[submodule "src/doc/book"]
path = src/doc/book
url = https://github.com/rust-lang/book.git
shallow = true
[submodule "src/doc/rust-by-example"]
path = src/doc/rust-by-example
url = https://github.com/rust-lang/rust-by-example.git
shallow = true
[submodule "library/stdarch"]
path = library/stdarch
url = https://github.com/rust-lang/stdarch.git
shallow = true
[submodule "src/doc/rustc-dev-guide"]
path = src/doc/rustc-dev-guide
url = https://github.com/rust-lang/rustc-dev-guide.git
shallow = true
[submodule "src/doc/edition-guide"]
path = src/doc/edition-guide
url = https://github.com/rust-lang/edition-guide.git
shallow = true
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
branch = rustc/16.0-2023-06-05
shallow = true
[submodule "src/doc/embedded-book"]
path = src/doc/embedded-book
url = https://github.com/rust-embedded/book.git
shallow = true
[submodule "library/backtrace"]
path = library/backtrace
url = https://github.com/rust-lang/backtrace-rs.git
shallow = true
50 changes: 8 additions & 42 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2495,6 +2495,7 @@ dependencies = [
"serde_json",
"sysinfo",
"tar",
"tempfile",
"xz",
"zip",
]
Expand Down Expand Up @@ -3785,7 +3786,7 @@ name = "rustc_lexer"
version = "0.1.0"
dependencies = [
"expect-test",
"unic-emoji-char",
"unicode-properties",
"unicode-xid",
]

Expand Down Expand Up @@ -5445,38 +5446,6 @@ dependencies = [
"tempfile",
]

[[package]]
name = "unic-char-property"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221"
dependencies = [
"unic-char-range",
]

[[package]]
name = "unic-char-range"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc"

[[package]]
name = "unic-common"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc"

[[package]]
name = "unic-emoji-char"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b07221e68897210270a38bde4babb655869637af0f69407f96053a34f76494d"
dependencies = [
"unic-char-property",
"unic-char-range",
"unic-ucd-version",
]

[[package]]
name = "unic-langid"
version = "0.9.1"
Expand Down Expand Up @@ -5520,15 +5489,6 @@ dependencies = [
"unic-langid-impl",
]

[[package]]
name = "unic-ucd-version"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4"
dependencies = [
"unic-common",
]

[[package]]
name = "unicase"
version = "2.6.0"
Expand Down Expand Up @@ -5566,6 +5526,12 @@ dependencies = [
"tinyvec",
]

[[package]]
name = "unicode-properties"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7f91c8b21fbbaa18853c3d0801c78f4fc94cdb976699bb03e832e75f7fd22f0"

[[package]]
name = "unicode-script"
version = "0.5.5"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn set_windows_exe_options() {
let mut manifest = env::current_dir().unwrap();
manifest.push(WINDOWS_MANIFEST_FILE);

println!("cargo:rerun-if-changed={}", WINDOWS_MANIFEST_FILE);
println!("cargo:rerun-if-changed={WINDOWS_MANIFEST_FILE}");
// Embed the Windows application manifest file.
println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFEST:EMBED");
println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFESTINPUT:{}", manifest.to_str().unwrap());
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ pub trait LayoutCalculator {
}
_ => assert!(
start == Bound::Unbounded && end == Bound::Unbounded,
"nonscalar layout for layout_scalar_valid_range type: {:#?}",
st,
"nonscalar layout for layout_scalar_valid_range type: {st:#?}",
),
}

Expand Down Expand Up @@ -463,7 +462,7 @@ pub trait LayoutCalculator {
min = 0;
max = 0;
}
assert!(min <= max, "discriminant range is {}...{}", min, max);
assert!(min <= max, "discriminant range is {min}...{max}");
let (min_ity, signed) = discr_range_of_repr(min, max); //Integer::repr_discr(tcx, ty, &repr, min, max);

let mut align = dl.aggregate_align;
Expand Down Expand Up @@ -537,8 +536,7 @@ pub trait LayoutCalculator {
// space necessary to represent would have to be discarded (or layout is wrong
// on thinking it needs 16 bits)
panic!(
"layout decided on a larger discriminant type ({:?}) than typeck ({:?})",
min_ity, typeck_ity
"layout decided on a larger discriminant type ({min_ity:?}) than typeck ({typeck_ity:?})"
);
// However, it is fine to make discr type however large (as an optimisation)
// after this point – we’ll just truncate the value we load in codegen.
Expand Down
19 changes: 7 additions & 12 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl TargetDataLayout {
16 => 1 << 15,
32 => 1 << 31,
64 => 1 << 47,
bits => panic!("obj_size_bound: unknown pointer bit size {}", bits),
bits => panic!("obj_size_bound: unknown pointer bit size {bits}"),
}
}

Expand All @@ -342,7 +342,7 @@ impl TargetDataLayout {
16 => I16,
32 => I32,
64 => I64,
bits => panic!("ptr_sized_integer: unknown pointer bit size {}", bits),
bits => panic!("ptr_sized_integer: unknown pointer bit size {bits}"),
}
}

Expand Down Expand Up @@ -399,7 +399,7 @@ impl FromStr for Endian {
match s {
"little" => Ok(Self::Little),
"big" => Ok(Self::Big),
_ => Err(format!(r#"unknown endian: "{}""#, s)),
_ => Err(format!(r#"unknown endian: "{s}""#)),
}
}
}
Expand Down Expand Up @@ -456,7 +456,7 @@ impl Size {
pub fn bits(self) -> u64 {
#[cold]
fn overflow(bytes: u64) -> ! {
panic!("Size::bits: {} bytes in bits doesn't fit in u64", bytes)
panic!("Size::bits: {bytes} bytes in bits doesn't fit in u64")
}

self.bytes().checked_mul(8).unwrap_or_else(|| overflow(self.bytes()))
Expand Down Expand Up @@ -1179,17 +1179,12 @@ impl FieldsShape {
unreachable!("FieldsShape::offset: `Primitive`s have no fields")
}
FieldsShape::Union(count) => {
assert!(
i < count.get(),
"tried to access field {} of union with {} fields",
i,
count
);
assert!(i < count.get(), "tried to access field {i} of union with {count} fields");
Size::ZERO
}
FieldsShape::Array { stride, count } => {
let i = u64::try_from(i).unwrap();
assert!(i < count, "tried to access field {} of array with {} fields", i, count);
assert!(i < count, "tried to access field {i} of array with {count} fields");
stride * i
}
FieldsShape::Arbitrary { ref offsets, .. } => offsets[FieldIdx::from_usize(i)],
Expand Down Expand Up @@ -1294,7 +1289,7 @@ impl Abi {
Primitive::Int(_, signed) => signed,
_ => false,
},
_ => panic!("`is_signed` on non-scalar ABI {:?}", self),
_ => panic!("`is_signed` on non-scalar ABI {self:?}"),
}
}

Expand Down
101 changes: 89 additions & 12 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! and a borrowed `TokenStream` is sufficient to build an owned `TokenStream` without taking
//! ownership of the original.
use crate::ast::StmtKind;
use crate::ast::{AttrStyle, StmtKind};
use crate::ast_traits::{HasAttrs, HasSpan, HasTokens};
use crate::token::{self, Delimiter, Nonterminal, Token, TokenKind};
use crate::AttrVec;
Expand All @@ -22,11 +22,11 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{self, Lrc};
use rustc_macros::HashStable_Generic;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_span::{Span, DUMMY_SP};
use rustc_span::{sym, Span, Symbol, DUMMY_SP};
use smallvec::{smallvec, SmallVec};

use std::borrow::Cow;
use std::{fmt, iter, mem};
use std::{cmp, fmt, iter, mem};

/// When the main Rust parser encounters a syntax-extension invocation, it
/// parses the arguments to the invocation as a token tree. This is a very
Expand Down Expand Up @@ -566,6 +566,92 @@ impl TokenStream {
pub fn chunks(&self, chunk_size: usize) -> core::slice::Chunks<'_, TokenTree> {
self.0.chunks(chunk_size)
}

/// Desugar doc comments like `/// foo` in the stream into `#[doc =
/// r"foo"]`. Modifies the `TokenStream` via `Lrc::make_mut`, but as little
/// as possible.
pub fn desugar_doc_comments(&mut self) {
if let Some(desugared_stream) = desugar_inner(self.clone()) {
*self = desugared_stream;
}

// The return value is `None` if nothing in `stream` changed.
fn desugar_inner(mut stream: TokenStream) -> Option<TokenStream> {
let mut i = 0;
let mut modified = false;
while let Some(tt) = stream.0.get(i) {
match tt {
&TokenTree::Token(
Token { kind: token::DocComment(_, attr_style, data), span },
_spacing,
) => {
let desugared = desugared_tts(attr_style, data, span);
let desugared_len = desugared.len();
Lrc::make_mut(&mut stream.0).splice(i..i + 1, desugared);
modified = true;
i += desugared_len;
}

&TokenTree::Token(..) => i += 1,

&TokenTree::Delimited(sp, delim, ref delim_stream) => {
if let Some(desugared_delim_stream) = desugar_inner(delim_stream.clone()) {
let new_tt = TokenTree::Delimited(sp, delim, desugared_delim_stream);
Lrc::make_mut(&mut stream.0)[i] = new_tt;
modified = true;
}
i += 1;
}
}
}
if modified { Some(stream) } else { None }
}

fn desugared_tts(attr_style: AttrStyle, data: Symbol, span: Span) -> Vec<TokenTree> {
// Searches for the occurrences of `"#*` and returns the minimum number of `#`s
// required to wrap the text. E.g.
// - `abc d` is wrapped as `r"abc d"` (num_of_hashes = 0)
// - `abc "d"` is wrapped as `r#"abc "d""#` (num_of_hashes = 1)
// - `abc "##d##"` is wrapped as `r###"abc ##"d"##"###` (num_of_hashes = 3)
let mut num_of_hashes = 0;
let mut count = 0;
for ch in data.as_str().chars() {
count = match ch {
'"' => 1,
'#' if count > 0 => count + 1,
_ => 0,
};
num_of_hashes = cmp::max(num_of_hashes, count);
}

// `/// foo` becomes `doc = r"foo"`.
let delim_span = DelimSpan::from_single(span);
let body = TokenTree::Delimited(
delim_span,
Delimiter::Bracket,
[
TokenTree::token_alone(token::Ident(sym::doc, false), span),
TokenTree::token_alone(token::Eq, span),
TokenTree::token_alone(
TokenKind::lit(token::StrRaw(num_of_hashes), data, None),
span,
),
]
.into_iter()
.collect::<TokenStream>(),
);

if attr_style == AttrStyle::Inner {
vec![
TokenTree::token_alone(token::Pound, span),
TokenTree::token_alone(token::Not, span),
body,
]
} else {
vec![TokenTree::token_alone(token::Pound, span), body]
}
}
}
}

/// By-reference iterator over a [`TokenStream`], that produces `&TokenTree`
Expand Down Expand Up @@ -628,15 +714,6 @@ impl TokenTreeCursor {
pub fn look_ahead(&self, n: usize) -> Option<&TokenTree> {
self.stream.0.get(self.index + n)
}

// Replace the previously obtained token tree with `tts`, and rewind to
// just before them.
pub fn replace_prev_and_rewind(&mut self, tts: Vec<TokenTree>) {
assert!(self.index > 0);
self.index -= 1;
let stream = Lrc::make_mut(&mut self.stream.0);
stream.splice(self.index..self.index + 1, tts);
}
}

#[derive(Debug, Copy, Clone, PartialEq, Encodable, Decodable, HashStable_Generic)]
Expand Down
Loading

0 comments on commit d17819e

Please sign in to comment.