Skip to content

Rollup of 7 pull requests #96387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -743,9 +743,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.71"
version = "0.1.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "163437f05ca8f29d7e9128ea728dedf5eb620e445fbca273641d3a3050305f23"
checksum = "afdbb35d279238cf77f0c9e8d90ad50d6c7bff476ab342baafa29440f0f10bff"
dependencies = [
"cc",
"rustc-std-workspace-core",
43 changes: 34 additions & 9 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -431,10 +431,11 @@ impl<'a> Parser<'a> {
return Ok(true);
} else if self.look_ahead(0, |t| {
t == &token::CloseDelim(token::Brace)
|| (
t.can_begin_expr() && t != &token::Semi && t != &token::Pound
// Avoid triggering with too many trailing `#` in raw string.
)
|| (t.can_begin_expr() && t != &token::Semi && t != &token::Pound)
// Avoid triggering with too many trailing `#` in raw string.
|| (sm.is_multiline(
self.prev_token.span.shrink_to_hi().until(self.token.span.shrink_to_lo())
) && t == &token::Pound)
}) {
// Missing semicolon typo. This is triggered if the next token could either start a
// new statement or is a block close. For example:
@@ -508,7 +509,12 @@ impl<'a> Parser<'a> {
}

if self.check_too_many_raw_str_terminators(&mut err) {
return Err(err);
if expected.contains(&TokenType::Token(token::Semi)) && self.eat(&token::Semi) {
err.emit();
return Ok(true);
} else {
return Err(err);
}
}

if self.prev_token.span == DUMMY_SP {
@@ -538,22 +544,41 @@ impl<'a> Parser<'a> {
}

fn check_too_many_raw_str_terminators(&mut self, err: &mut Diagnostic) -> bool {
let sm = self.sess.source_map();
match (&self.prev_token.kind, &self.token.kind) {
(
TokenKind::Literal(Lit {
kind: LitKind::StrRaw(n_hashes) | LitKind::ByteStrRaw(n_hashes),
..
}),
TokenKind::Pound,
) => {
) if !sm.is_multiline(
self.prev_token.span.shrink_to_hi().until(self.token.span.shrink_to_lo()),
) =>
{
let n_hashes: u8 = *n_hashes;
err.set_primary_message("too many `#` when terminating raw string");
let str_span = self.prev_token.span;
let mut span = self.token.span;
let mut count = 0;
while self.token.kind == TokenKind::Pound
&& !sm.is_multiline(span.shrink_to_hi().until(self.token.span.shrink_to_lo()))
{
span = span.with_hi(self.token.span.hi());
self.bump();
count += 1;
}
err.set_span(span);
err.span_suggestion(
self.token.span,
"remove the extra `#`",
span,
&format!("remove the extra `#`{}", pluralize!(count)),
String::new(),
Applicability::MachineApplicable,
);
err.note(&format!("the raw string started with {n_hashes} `#`s"));
err.span_label(
str_span,
&format!("this raw string started with {n_hashes} `#`{}", pluralize!(n_hashes)),
);
true
}
_ => false,
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/android_base.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
base.os = "android".into();
base.dwarf_version = Some(2);
base.position_independent_executables = true;
base.has_thread_local = false;
base.has_thread_local = true;
// This is for backward compatibility, see https://github.com/rust-lang/rust/issues/49867
// for context. (At that time, there was no `-C force-unwind-tables`, so the only solution
// was to always emit `uwtable`).
Original file line number Diff line number Diff line change
@@ -1727,6 +1727,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
} else if cat_a == cat_b {
match (a.kind(), b.kind()) {
(ty::Adt(def_a, _), ty::Adt(def_b, _)) => def_a == def_b,
(ty::Foreign(def_a), ty::Foreign(def_b)) => def_a == def_b,
// Matching on references results in a lot of unhelpful
// suggestions, so let's just not do that for now.
//
16 changes: 12 additions & 4 deletions compiler/rustc_typeck/src/check/expr.rs
Original file line number Diff line number Diff line change
@@ -78,10 +78,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// While we don't allow *arbitrary* coercions here, we *do* allow
// coercions from ! to `expected`.
if ty.is_never() {
assert!(
!self.typeck_results.borrow().adjustments().contains_key(expr.hir_id),
"expression with never type wound up being adjusted"
);
if let Some(adjustments) = self.typeck_results.borrow().adjustments().get(expr.hir_id) {
self.tcx().sess.delay_span_bug(
expr.span,
"expression with never type wound up being adjusted",
);
return if let [Adjustment { kind: Adjust::NeverToAny, target }] = &adjustments[..] {
target.to_owned()
} else {
self.tcx().ty_error()
};
}

let adj_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::AdjustmentType,
span: expr.span,
2 changes: 2 additions & 0 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ mod nofloat;
mod num;

#[stable(feature = "fmt_flags_align", since = "1.28.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "Alignment")]
/// Possible alignments returned by `Formatter::align`
#[derive(Debug)]
pub enum Alignment {
@@ -462,6 +463,7 @@ impl<'a> Arguments<'a> {
///
/// [`format()`]: ../../std/fmt/fn.format.html
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "Arguments")]
#[derive(Copy, Clone)]
pub struct Arguments<'a> {
// Format string pieces to print.
15 changes: 15 additions & 0 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
@@ -162,6 +162,7 @@ unsafe impl Sync for AtomicBool {}
/// loads and stores of pointers. Its size depends on the target pointer's size.
#[cfg(target_has_atomic_load_store = "ptr")]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "AtomicPtr")]
#[cfg_attr(target_pointer_width = "16", repr(C, align(2)))]
#[cfg_attr(target_pointer_width = "32", repr(C, align(4)))]
#[cfg_attr(target_pointer_width = "64", repr(C, align(8)))]
@@ -1458,6 +1459,7 @@ macro_rules! atomic_int {
$stable_nand:meta,
$const_stable:meta,
$stable_init_const:meta,
$diagnostic_item:meta,
$s_int_type:literal,
$extra_feature:expr,
$min_fn:ident, $max_fn:ident,
@@ -1480,6 +1482,7 @@ macro_rules! atomic_int {
///
/// [module-level documentation]: crate::sync::atomic
#[$stable]
#[$diagnostic_item]
#[repr(C, align($align))]
pub struct $atomic_type {
v: UnsafeCell<$int_type>,
@@ -2306,6 +2309,7 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI8"),
"i8",
"",
atomic_min, atomic_max,
@@ -2325,6 +2329,7 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU8"),
"u8",
"",
atomic_umin, atomic_umax,
@@ -2344,6 +2349,7 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI16"),
"i16",
"",
atomic_min, atomic_max,
@@ -2363,6 +2369,7 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU16"),
"u16",
"",
atomic_umin, atomic_umax,
@@ -2382,6 +2389,7 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI32"),
"i32",
"",
atomic_min, atomic_max,
@@ -2401,6 +2409,7 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU32"),
"u32",
"",
atomic_umin, atomic_umax,
@@ -2420,6 +2429,7 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI64"),
"i64",
"",
atomic_min, atomic_max,
@@ -2439,6 +2449,7 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU64"),
"u64",
"",
atomic_umin, atomic_umax,
@@ -2458,6 +2469,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI128"),
"i128",
"#![feature(integer_atomics)]\n\n",
atomic_min, atomic_max,
@@ -2477,6 +2489,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU128"),
"u128",
"#![feature(integer_atomics)]\n\n",
atomic_umin, atomic_umax,
@@ -2500,6 +2513,7 @@ macro_rules! atomic_int_ptr_sized {
stable(feature = "atomic_nand", since = "1.27.0"),
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
stable(feature = "rust1", since = "1.0.0"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicIsize"),
"isize",
"",
atomic_min, atomic_max,
@@ -2520,6 +2534,7 @@ macro_rules! atomic_int_ptr_sized {
stable(feature = "atomic_nand", since = "1.27.0"),
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
stable(feature = "rust1", since = "1.0.0"),
cfg_attr(not(test), rustc_diagnostic_item = "AtomicUsize"),
"usize",
"",
atomic_umin, atomic_umax,
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core" }
libc = { version = "0.2.116", default-features = false, features = ['rustc-dep-of-std'] }
compiler_builtins = { version = "0.1.71" }
compiler_builtins = { version = "0.1.72" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" }
hashbrown = { version = "0.12", default-features = false, features = ['rustc-dep-of-std'] }
1 change: 1 addition & 0 deletions library/std/src/error.rs
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ use crate::time;
/// high-level module to provide its own errors while also revealing some of the
/// implementation for debugging via `source` chains.
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "Error")]
pub trait Error: Debug + Display {
/// The lower-level source of this error, if any.
///
1 change: 1 addition & 0 deletions library/std/src/sys/unix/thread_local_dtor.rs
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
// fallback implementation to use as well.
#[cfg(any(
target_os = "linux",
target_os = "android",
target_os = "fuchsia",
target_os = "redox",
target_os = "emscripten"
9 changes: 9 additions & 0 deletions src/bootstrap/builder/tests.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,16 @@ fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config {
// don't save toolstates
config.save_toolstates = None;
config.dry_run = true;

// Ignore most submodules, since we don't need them for a dry run.
// But make sure to check out the `doc` and `rust-analyzer` submodules, since some steps need them
// just to know which commands to run.
let submodule_build = Build::new(Config::parse(&["check".to_owned()]));
let submodule_builder = Builder::new(&submodule_build);
submodule_builder.update_submodule(Path::new("src/doc/book"));
submodule_builder.update_submodule(Path::new("src/tools/rust-analyzer"));
config.submodules = Some(false);

config.ninja_in_file = false;
// try to avoid spurious failures in dist where we create/delete each others file
// HACK: rather than pull in `tempdir`, use the one that cargo has conveniently created for us
425 changes: 207 additions & 218 deletions src/librustdoc/html/static/js/search.js

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions src/librustdoc/html/static/js/settings.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Local js definitions:
/* eslint-env es6 */
/* eslint no-var: "error" */
/* eslint prefer-const: "error" */
/* global getSettingValue, getVirtualKey, onEachLazy, updateLocalStorage, updateSystemTheme */
/* global addClass, removeClass */

@@ -55,9 +58,9 @@
function setEvents() {
updateLightAndDark();
onEachLazy(document.getElementsByClassName("slider"), function(elem) {
var toggle = elem.previousElementSibling;
var settingId = toggle.id;
var settingValue = getSettingValue(settingId);
const toggle = elem.previousElementSibling;
const settingId = toggle.id;
const settingValue = getSettingValue(settingId);
if (settingValue !== null) {
toggle.checked = settingValue === "true";
}
@@ -68,9 +71,9 @@
toggle.onkeyrelease = handleKey;
});
onEachLazy(document.getElementsByClassName("select-wrapper"), function(elem) {
var select = elem.getElementsByTagName("select")[0];
var settingId = select.id;
var settingValue = getSettingValue(settingId);
const select = elem.getElementsByTagName("select")[0];
const settingId = select.id;
const settingValue = getSettingValue(settingId);
if (settingValue !== null) {
select.value = settingValue;
}
22 changes: 22 additions & 0 deletions src/test/ui/extern/extern-type-diag-not-similar.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// We previously mentioned other extern types in the error message here.
//
// Two extern types shouldn't really be considered similar just
// because they are both extern types.

#![feature(extern_types)]
extern {
type ShouldNotBeMentioned;
}

extern {
type Foo;
}

unsafe impl Send for ShouldNotBeMentioned {}

fn assert_send<T: Send + ?Sized>() {}

fn main() {
assert_send::<Foo>()
//~^ ERROR `Foo` cannot be sent between threads safely
}
16 changes: 16 additions & 0 deletions src/test/ui/extern/extern-type-diag-not-similar.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error[E0277]: `Foo` cannot be sent between threads safely
--> $DIR/extern-type-diag-not-similar.rs:20:19
|
LL | assert_send::<Foo>()
| ^^^ `Foo` cannot be sent between threads safely
|
= help: the trait `Send` is not implemented for `Foo`
note: required by a bound in `assert_send`
--> $DIR/extern-type-diag-not-similar.rs:17:19
|
LL | fn assert_send<T: Send + ?Sized>() {}
| ^^^^ required by this bound in `assert_send`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
5 changes: 5 additions & 0 deletions src/test/ui/never_type/issue-96335.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
0.....{loop{}1};
//~^ ERROR unexpected token
//~| ERROR mismatched types
}
35 changes: 35 additions & 0 deletions src/test/ui/never_type/issue-96335.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
error: unexpected token: `...`
--> $DIR/issue-96335.rs:2:6
|
LL | 0.....{loop{}1};
| ^^^
|
help: use `..` for an exclusive range
|
LL | 0....{loop{}1};
| ~~
help: or `..=` for an inclusive range
|
LL | 0..=..{loop{}1};
| ~~~

error[E0308]: mismatched types
--> $DIR/issue-96335.rs:2:9
|
LL | 0.....{loop{}1};
| ----^^^^^^^^^^^
| | |
| | expected integer, found struct `RangeTo`
| arguments to this function are incorrect
|
= note: expected type `{integer}`
found struct `RangeTo<{integer}>`
note: associated function defined here
--> $SRC_DIR/core/src/ops/range.rs:LL:COL
|
LL | pub const fn new(start: Idx, end: Idx) -> Self {
| ^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
20 changes: 19 additions & 1 deletion src/test/ui/parser/raw/raw-str-unbalanced.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
static s: &'static str =
r#""## //~ ERROR too many `#` when terminating raw string
;

static s2: &'static str =
r#"
"## //~ too many `#` when terminating raw string
"#### //~ ERROR too many `#` when terminating raw string
;

const A: &'static str = r"" //~ ERROR expected `;`, found `#`

// Test
#[test]
fn test() {}

const B: &'static str = r""## //~ ERROR too many `#` when terminating raw string

// Test
#[test]
fn test2() {}

fn main() {}
36 changes: 31 additions & 5 deletions src/test/ui/parser/raw/raw-str-unbalanced.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
error: too many `#` when terminating raw string
--> $DIR/raw-str-unbalanced.rs:3:9
--> $DIR/raw-str-unbalanced.rs:2:10
|
LL | "##
| ^ help: remove the extra `#`
LL | r#""##
| -----^ help: remove the extra `#`
| |
| this raw string started with 1 `#`

error: too many `#` when terminating raw string
--> $DIR/raw-str-unbalanced.rs:7:9
|
LL | / r#"
LL | | "####
| | -^^^ help: remove the extra `#`s
| |________|
| this raw string started with 1 `#`

error: expected `;`, found `#`
--> $DIR/raw-str-unbalanced.rs:10:28
|
LL | const A: &'static str = r""
| ^ help: add `;` here
...
LL | #[test]
| - unexpected token

error: too many `#` when terminating raw string
--> $DIR/raw-str-unbalanced.rs:16:28
|
= note: the raw string started with 1 `#`s
LL | const B: &'static str = r""##
| ---^^ help: remove the extra `#`s
| |
| this raw string started with 0 `#`s

error: aborting due to previous error
error: aborting due to 4 previous errors

20 changes: 16 additions & 4 deletions src/tools/rustdoc-js/tester.js
Original file line number Diff line number Diff line change
@@ -85,8 +85,11 @@ function extractFunction(content, functionName) {
}

// Stupid function extractor for array.
function extractArrayVariable(content, arrayName) {
var splitter = "var " + arrayName;
function extractArrayVariable(content, arrayName, kind) {
if (typeof kind === "undefined") {
kind = "let ";
}
var splitter = kind + arrayName;
while (true) {
var start = content.indexOf(splitter);
if (start === -1) {
@@ -126,12 +129,18 @@ function extractArrayVariable(content, arrayName) {
}
content = content.slice(start + 1);
}
if (kind === "let ") {
return extractArrayVariable(content, arrayName, "const ");
}
return null;
}

// Stupid function extractor for variable.
function extractVariable(content, varName) {
var splitter = "var " + varName;
function extractVariable(content, varName, kind) {
if (typeof kind === "undefined") {
kind = "let ";
}
var splitter = kind + varName;
while (true) {
var start = content.indexOf(splitter);
if (start === -1) {
@@ -162,6 +171,9 @@ function extractVariable(content, varName) {
}
content = content.slice(start + 1);
}
if (kind === "let ") {
return extractVariable(content, varName, "const ");
}
return null;
}