Skip to content

Commit 506052d

Browse files
committed
Auto merge of rust-lang#129162 - matthiaskrgr:rollup-r0oxdev, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#128990 (Re-enable more debuginfo tests on freebsd) - rust-lang#129042 (Special-case alias ty during the delayed bug emission in `try_from_lit`) - rust-lang#129086 (Stabilize `is_none_or`) - rust-lang#129149 (Migrate `validate_json.py` script to rust in `run-make/rustdoc-map-file` test) - rust-lang#129154 (Fix wrong source location for some incorrect macro definitions) - rust-lang#129161 (Stabilize std::thread::Builder::spawn_unchecked) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 569d7e3 + a9bf86a commit 506052d

File tree

20 files changed

+76
-71
lines changed

20 files changed

+76
-71
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3149,6 +3149,7 @@ dependencies = [
31493149
"gimli 0.31.0",
31503150
"object 0.36.2",
31513151
"regex",
3152+
"serde_json",
31523153
"similar",
31533154
"wasmparser 0.214.0",
31543155
]

compiler/rustc_const_eval/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#![feature(box_patterns)]
77
#![feature(decl_macro)]
88
#![feature(if_let_guard)]
9-
#![feature(is_none_or)]
109
#![feature(let_chains)]
1110
#![feature(never_type)]
1211
#![feature(rustdoc_internals)]

compiler/rustc_expand/src/mbe/quoted.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,24 @@ pub(super) fn parse(
5454

5555
// For each token tree in `input`, parse the token into a `self::TokenTree`, consuming
5656
// additional trees if need be.
57-
let mut trees = input.trees();
57+
let mut trees = input.trees().peekable();
5858
while let Some(tree) = trees.next() {
5959
// Given the parsed tree, if there is a metavar and we are expecting matchers, actually
6060
// parse out the matcher (i.e., in `$id:ident` this would parse the `:` and `ident`).
6161
let tree = parse_tree(tree, &mut trees, parsing_patterns, sess, node_id, features, edition);
6262
match tree {
6363
TokenTree::MetaVar(start_sp, ident) if parsing_patterns => {
64-
let span = match trees.next() {
64+
// Not consuming the next token immediately, as it may not be a colon
65+
let span = match trees.peek() {
6566
Some(&tokenstream::TokenTree::Token(
6667
Token { kind: token::Colon, span: colon_span },
6768
_,
6869
)) => {
70+
// Consume the colon first
71+
trees.next();
72+
73+
// It's ok to consume the next tree no matter how,
74+
// since if it's not a token then it will be an invalid declaration.
6975
match trees.next() {
7076
Some(tokenstream::TokenTree::Token(token, _)) => match token.ident() {
7177
Some((fragment, _)) => {
@@ -125,12 +131,13 @@ pub(super) fn parse(
125131
}
126132
_ => token.span,
127133
},
128-
Some(tree) => tree.span(),
129-
None => colon_span,
134+
// Invalid, return a nice source location
135+
_ => colon_span.with_lo(start_sp.lo()),
130136
}
131137
}
132-
Some(tree) => tree.span(),
133-
None => start_sp,
138+
// Whether it's none or some other tree, it doesn't belong to
139+
// the current meta variable, returning the original span.
140+
_ => start_sp,
134141
};
135142

136143
result.push(TokenTree::MetaVarDecl(span, ident, None));

compiler/rustc_hir_typeck/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(box_patterns)]
66
#![feature(control_flow_enum)]
77
#![feature(if_let_guard)]
8-
#![feature(is_none_or)]
98
#![feature(let_chains)]
109
#![feature(never_type)]
1110
#![feature(try_blocks)]

compiler/rustc_interface/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// tidy-alphabetical-start
22
#![feature(decl_macro)]
33
#![feature(let_chains)]
4-
#![feature(thread_spawn_unchecked)]
54
#![feature(try_blocks)]
65
// tidy-alphabetical-end
76

compiler/rustc_middle/src/ty/consts.rs

+4
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ impl<'tcx> Const<'tcx> {
305305
// mir.
306306
match tcx.at(expr.span).lit_to_const(lit_input) {
307307
Ok(c) => return Some(c),
308+
Err(_) if lit_input.ty.has_aliases() => {
309+
// allow the `ty` to be an alias type, though we cannot handle it here
310+
return None;
311+
}
308312
Err(e) => {
309313
tcx.dcx().span_delayed_bug(
310314
expr.span,

library/core/src/option.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,6 @@ impl<T> Option<T> {
656656
/// # Examples
657657
///
658658
/// ```
659-
/// #![feature(is_none_or)]
660-
///
661659
/// let x: Option<u32> = Some(2);
662660
/// assert_eq!(x.is_none_or(|x| x > 1), true);
663661
///
@@ -669,7 +667,7 @@ impl<T> Option<T> {
669667
/// ```
670668
#[must_use]
671669
#[inline]
672-
#[unstable(feature = "is_none_or", issue = "126383")]
670+
#[stable(feature = "is_none_or", since = "CURRENT_RUSTC_VERSION")]
673671
pub fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool {
674672
match self {
675673
None => true,

library/std/src/thread/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ impl Builder {
412412
/// # Examples
413413
///
414414
/// ```
415-
/// #![feature(thread_spawn_unchecked)]
416415
/// use std::thread;
417416
///
418417
/// let builder = thread::Builder::new();
@@ -433,7 +432,7 @@ impl Builder {
433432
/// ```
434433
///
435434
/// [`io::Result`]: crate::io::Result
436-
#[unstable(feature = "thread_spawn_unchecked", issue = "55132")]
435+
#[stable(feature = "thread_spawn_unchecked", since = "CURRENT_RUSTC_VERSION")]
437436
pub unsafe fn spawn_unchecked<F, T>(self, f: F) -> io::Result<JoinHandle<T>>
438437
where
439438
F: FnOnce() -> T,

src/tools/miri/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![feature(let_chains)]
1313
#![feature(trait_upcasting)]
1414
#![feature(strict_overflow_ops)]
15-
#![feature(is_none_or)]
1615
// Configure clippy and other lints
1716
#![allow(
1817
clippy::collapsible_else_if,

src/tools/run-make-support/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ wasmparser = { version = "0.214", default-features = false, features = ["std"] }
1111
regex = "1.8" # 1.8 to avoid memchr 2.6.0, as 2.5.0 is pinned in the workspace
1212
gimli = "0.31.0"
1313
build_helper = { path = "../build_helper" }
14+
serde_json = "1.0"

src/tools/run-make-support/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub use bstr;
3838
pub use gimli;
3939
pub use object;
4040
pub use regex;
41+
pub use serde_json;
4142
pub use wasmparser;
4243

4344
// Re-exports of external dependencies.

src/tools/rust-analyzer/crates/hir-ty/src/display.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ fn generic_args_sans_defaults<'ga>(
14621462
// otherwise, if the arg is equal to the param default, hide it (unless the
14631463
// default is an error which can happen for the trait Self type)
14641464
#[allow(unstable_name_collisions)]
1465-
default_parameters.get(i).is_none_or(|default_parameter| {
1465+
IsNoneOr::is_none_or(default_parameters.get(i), |default_parameter| {
14661466
// !is_err(default_parameter.skip_binders())
14671467
// &&
14681468
arg != &default_parameter.clone().substitute(Interner, &parameters)

tests/debuginfo/pretty-huge-vec.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ ignore-windows failing on win32 bot
2-
//@ ignore-freebsd: gdb package too new
32
//@ ignore-android: FIXME(#10381)
43
//@ compile-flags:-g
54
//@ min-gdb-version: 8.1

tests/debuginfo/pretty-std-collections.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ ignore-windows failing on win32 bot
2-
//@ ignore-freebsd: gdb package too new
32
//@ ignore-android: FIXME(#10381)
43
//@ ignore-windows-gnu: #128981
54
//@ compile-flags:-g

tests/debuginfo/pretty-std.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// ignore-tidy-linelength
2-
//@ ignore-freebsd: gdb package too new
32
//@ ignore-windows-gnu: #128981
43
//@ ignore-android: FIXME(#10381)
54
//@ compile-flags:-g

tests/debuginfo/pretty-uninitialized-vec.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ ignore-windows failing on win32 bot
2-
//@ ignore-freebsd: gdb package too new
32
//@ ignore-android: FIXME(#10381)
43
//@ compile-flags:-g
54
//@ min-gdb-version: 8.1
+44-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,54 @@
1-
use run_make_support::{python_command, rustdoc};
1+
// This test ensures that all items from `foo` are correctly generated into the `redirect-map.json`
2+
// file with `--generate-redirect-map` rustdoc option.
3+
4+
use std::path::Path;
5+
6+
use run_make_support::rfs::read_to_string;
7+
use run_make_support::{path, rustdoc, serde_json};
28

39
fn main() {
410
let out_dir = "out";
11+
let crate_name = "foo";
512
rustdoc()
613
.input("foo.rs")
14+
.crate_name(crate_name)
715
.arg("-Zunstable-options")
816
.arg("--generate-redirect-map")
917
.out_dir(&out_dir)
1018
.run();
11-
// FIXME (GuillaumeGomez): Port the python script to Rust as well.
12-
python_command().arg("validate_json.py").arg(&out_dir).run();
19+
20+
let generated = read_to_string(path(out_dir).join(crate_name).join("redirect-map.json"));
21+
let expected = read_to_string("expected.json");
22+
let generated: serde_json::Value =
23+
serde_json::from_str(&generated).expect("failed to parse JSON");
24+
let expected: serde_json::Value =
25+
serde_json::from_str(&expected).expect("failed to parse JSON");
26+
let expected = expected.as_object().unwrap();
27+
28+
let mut differences = Vec::new();
29+
for (key, expected_value) in expected.iter() {
30+
match generated.get(key) {
31+
Some(value) => {
32+
if expected_value != value {
33+
differences.push(format!(
34+
"values for key `{key}` don't match: `{expected_value:?}` != `{value:?}`"
35+
));
36+
}
37+
}
38+
None => differences.push(format!("missing key `{key}`")),
39+
}
40+
}
41+
for (key, data) in generated.as_object().unwrap().iter() {
42+
if !expected.contains_key(key) {
43+
differences.push(format!("Extra data not expected: key: `{key}`, data: `{data}`"));
44+
}
45+
}
46+
47+
if !differences.is_empty() {
48+
eprintln!("Found differences in JSON files:");
49+
for diff in differences {
50+
eprintln!("=> {diff}");
51+
}
52+
panic!("Found differences in JSON files");
53+
}
1354
}

tests/run-make/rustdoc-map-file/validate_json.py

-41
This file was deleted.

tests/crashes/116308.rs renamed to tests/ui/const-generics/adt_const_params/116308.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
//@ known-bug: #116308
1+
//@ check-pass
22
#![feature(adt_const_params)]
33

4+
// Regression test for #116308
5+
46
pub trait Identity {
57
type Identity;
68
}

tests/ui/macros/macro-match-nonterminal.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error: missing fragment specifier
2-
--> $DIR/macro-match-nonterminal.rs:2:8
2+
--> $DIR/macro-match-nonterminal.rs:2:6
33
|
44
LL | ($a, $b) => {
5-
| ^
5+
| ^^
66

77
error: missing fragment specifier
8-
--> $DIR/macro-match-nonterminal.rs:2:8
8+
--> $DIR/macro-match-nonterminal.rs:2:6
99
|
1010
LL | ($a, $b) => {
11-
| ^
11+
| ^^
1212
|
1313
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1414
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
@@ -27,10 +27,10 @@ error: aborting due to 3 previous errors
2727

2828
Future incompatibility report: Future breakage diagnostic:
2929
error: missing fragment specifier
30-
--> $DIR/macro-match-nonterminal.rs:2:8
30+
--> $DIR/macro-match-nonterminal.rs:2:6
3131
|
3232
LL | ($a, $b) => {
33-
| ^
33+
| ^^
3434
|
3535
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
3636
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>

0 commit comments

Comments
 (0)