Skip to content

Commit 4a12d10

Browse files
committed
Auto merge of rust-lang#101928 - notriddle:rollup-pexhhxe, r=notriddle
Rollup of 8 pull requests Successful merges: - rust-lang#101340 (Adding Fuchsia zxdb debugging walkthrough to docs) - rust-lang#101741 (Adding needs-unwind arg to applicable compiler ui tests) - rust-lang#101782 (Update `symbol_mangling` diagnostics migration) - rust-lang#101878 (More simple formatting) - rust-lang#101898 (Remove some unused CSS rules) - rust-lang#101911 (rustdoc: remove no-op CSS on `.source .content`) - rust-lang#101914 (rustdoc-json-types: Document that ResolvedPath can also be a union) - rust-lang#101921 (Pass --cfg=bootstrap for rustdoc for proc_macro crates) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents c524c7d + cafca7d commit 4a12d10

34 files changed

+307
-212
lines changed

compiler/rustc_ast/src/ast.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -2088,15 +2088,15 @@ pub enum InlineAsmRegOrRegClass {
20882088
bitflags::bitflags! {
20892089
#[derive(Encodable, Decodable, HashStable_Generic)]
20902090
pub struct InlineAsmOptions: u16 {
2091-
const PURE = 1 << 0;
2092-
const NOMEM = 1 << 1;
2093-
const READONLY = 1 << 2;
2091+
const PURE = 1 << 0;
2092+
const NOMEM = 1 << 1;
2093+
const READONLY = 1 << 2;
20942094
const PRESERVES_FLAGS = 1 << 3;
2095-
const NORETURN = 1 << 4;
2096-
const NOSTACK = 1 << 5;
2097-
const ATT_SYNTAX = 1 << 6;
2098-
const RAW = 1 << 7;
2099-
const MAY_UNWIND = 1 << 8;
2095+
const NORETURN = 1 << 4;
2096+
const NOSTACK = 1 << 5;
2097+
const ATT_SYNTAX = 1 << 6;
2098+
const RAW = 1 << 7;
2099+
const MAY_UNWIND = 1 << 8;
21002100
}
21012101
}
21022102

compiler/rustc_ast/src/util/parser.rs

+34-34
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,11 @@ impl ExprPrecedence {
297297
match self {
298298
ExprPrecedence::Closure => PREC_CLOSURE,
299299

300-
ExprPrecedence::Break |
301-
ExprPrecedence::Continue |
302-
ExprPrecedence::Ret |
303-
ExprPrecedence::Yield |
304-
ExprPrecedence::Yeet => PREC_JUMP,
300+
ExprPrecedence::Break
301+
| ExprPrecedence::Continue
302+
| ExprPrecedence::Ret
303+
| ExprPrecedence::Yield
304+
| ExprPrecedence::Yeet => PREC_JUMP,
305305

306306
// `Range` claims to have higher precedence than `Assign`, but `x .. x = x` fails to
307307
// parse, instead of parsing as `(x .. x) = x`. Giving `Range` a lower precedence
@@ -318,43 +318,43 @@ impl ExprPrecedence {
318318
ExprPrecedence::AssignOp => AssocOp::Assign.precedence() as i8,
319319

320320
// Unary, prefix
321-
ExprPrecedence::Box |
322-
ExprPrecedence::AddrOf |
321+
ExprPrecedence::Box
322+
| ExprPrecedence::AddrOf
323323
// Here `let pats = expr` has `let pats =` as a "unary" prefix of `expr`.
324324
// However, this is not exactly right. When `let _ = a` is the LHS of a binop we
325325
// need parens sometimes. E.g. we can print `(let _ = a) && b` as `let _ = a && b`
326326
// but we need to print `(let _ = a) < b` as-is with parens.
327-
ExprPrecedence::Let |
328-
ExprPrecedence::Unary => PREC_PREFIX,
327+
| ExprPrecedence::Let
328+
| ExprPrecedence::Unary => PREC_PREFIX,
329329

330330
// Unary, postfix
331-
ExprPrecedence::Await |
332-
ExprPrecedence::Call |
333-
ExprPrecedence::MethodCall |
334-
ExprPrecedence::Field |
335-
ExprPrecedence::Index |
336-
ExprPrecedence::Try |
337-
ExprPrecedence::InlineAsm |
338-
ExprPrecedence::Mac => PREC_POSTFIX,
331+
ExprPrecedence::Await
332+
| ExprPrecedence::Call
333+
| ExprPrecedence::MethodCall
334+
| ExprPrecedence::Field
335+
| ExprPrecedence::Index
336+
| ExprPrecedence::Try
337+
| ExprPrecedence::InlineAsm
338+
| ExprPrecedence::Mac => PREC_POSTFIX,
339339

340340
// Never need parens
341-
ExprPrecedence::Array |
342-
ExprPrecedence::Repeat |
343-
ExprPrecedence::Tup |
344-
ExprPrecedence::Lit |
345-
ExprPrecedence::Path |
346-
ExprPrecedence::Paren |
347-
ExprPrecedence::If |
348-
ExprPrecedence::While |
349-
ExprPrecedence::ForLoop |
350-
ExprPrecedence::Loop |
351-
ExprPrecedence::Match |
352-
ExprPrecedence::ConstBlock |
353-
ExprPrecedence::Block |
354-
ExprPrecedence::TryBlock |
355-
ExprPrecedence::Async |
356-
ExprPrecedence::Struct |
357-
ExprPrecedence::Err => PREC_PAREN,
341+
ExprPrecedence::Array
342+
| ExprPrecedence::Repeat
343+
| ExprPrecedence::Tup
344+
| ExprPrecedence::Lit
345+
| ExprPrecedence::Path
346+
| ExprPrecedence::Paren
347+
| ExprPrecedence::If
348+
| ExprPrecedence::While
349+
| ExprPrecedence::ForLoop
350+
| ExprPrecedence::Loop
351+
| ExprPrecedence::Match
352+
| ExprPrecedence::ConstBlock
353+
| ExprPrecedence::Block
354+
| ExprPrecedence::TryBlock
355+
| ExprPrecedence::Async
356+
| ExprPrecedence::Struct
357+
| ExprPrecedence::Err => PREC_PAREN,
358358
}
359359
}
360360
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
symbol_mangling_invalid_symbol_name = symbol-name({$mangled_formatted})
2-
3-
symbol_mangling_invalid_trait_item = demangling({$demangling_formatted})
4-
5-
symbol_mangling_alt_invalid_trait_item = demangling-alt({$alt_demangling_formatted})
6-
7-
symbol_mangling_invalid_def_path = def-path({$def_path})
1+
symbol_mangling_test_output = {$kind}({$content})

compiler/rustc_hir/src/hir.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,10 @@ impl LifetimeName {
139139
match self {
140140
LifetimeName::ImplicitObjectLifetimeDefault | LifetimeName::Infer => true,
141141

142-
// It might seem surprising that `Fresh` counts as
143-
// *not* elided -- but this is because, as far as the code
144-
// in the compiler is concerned -- `Fresh` variants act
145-
// equivalently to "some fresh name". They correspond to
146-
// early-bound regions on an impl, in other words.
142+
// It might seem surprising that `Fresh` counts as not *elided*
143+
// -- but this is because, as far as the code in the compiler is
144+
// concerned -- `Fresh` variants act equivalently to "some fresh name".
145+
// They correspond to early-bound regions on an impl, in other words.
147146
LifetimeName::Error | LifetimeName::Param(..) | LifetimeName::Static => false,
148147
}
149148
}

compiler/rustc_passes/src/check_attr.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,8 @@ impl CheckAttrVisitor<'_> {
16661666
E0552,
16671667
"unrecognized representation hint"
16681668
)
1669-
.help("valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`")
1669+
.help("valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, \
1670+
`i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`")
16701671
.emit();
16711672

16721673
continue;
+21-23
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
11
//! Errors emitted by symbol_mangling.
22
3+
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
34
use rustc_macros::SessionDiagnostic;
45
use rustc_span::Span;
56

67
#[derive(SessionDiagnostic)]
7-
#[diag(symbol_mangling::invalid_symbol_name)]
8-
pub struct InvalidSymbolName {
8+
#[diag(symbol_mangling::test_output)]
9+
pub struct TestOutput {
910
#[primary_span]
1011
pub span: Span,
11-
pub mangled_formatted: String,
12+
pub kind: Kind,
13+
pub content: String,
1214
}
1315

14-
#[derive(SessionDiagnostic)]
15-
#[diag(symbol_mangling::invalid_trait_item)]
16-
pub struct InvalidTraitItem {
17-
#[primary_span]
18-
pub span: Span,
19-
pub demangling_formatted: String,
16+
pub enum Kind {
17+
SymbolName,
18+
Demangling,
19+
DemanglingAlt,
20+
DefPath,
2021
}
2122

22-
#[derive(SessionDiagnostic)]
23-
#[diag(symbol_mangling::alt_invalid_trait_item)]
24-
pub struct AltInvalidTraitItem {
25-
#[primary_span]
26-
pub span: Span,
27-
pub alt_demangling_formatted: String,
28-
}
29-
30-
#[derive(SessionDiagnostic)]
31-
#[diag(symbol_mangling::invalid_def_path)]
32-
pub struct InvalidDefPath {
33-
#[primary_span]
34-
pub span: Span,
35-
pub def_path: String,
23+
impl IntoDiagnosticArg for Kind {
24+
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
25+
let kind = match self {
26+
Kind::SymbolName => "symbol-name",
27+
Kind::Demangling => "demangling",
28+
Kind::DemanglingAlt => "demangling-alt",
29+
Kind::DefPath => "def-path",
30+
}
31+
.into();
32+
DiagnosticArgValue::Str(kind)
33+
}
3634
}

compiler/rustc_symbol_mangling/src/test.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! def-path. This is used for unit testing the code that generates
55
//! paths etc in all kinds of annoying scenarios.
66
7-
use crate::errors::{AltInvalidTraitItem, InvalidDefPath, InvalidSymbolName, InvalidTraitItem};
7+
use crate::errors::{Kind, TestOutput};
88
use rustc_hir::def_id::LocalDefId;
99
use rustc_middle::ty::print::with_no_trimmed_paths;
1010
use rustc_middle::ty::{subst::InternalSubsts, Instance, TyCtxt};
@@ -60,26 +60,30 @@ impl SymbolNamesTest<'_> {
6060
tcx.erase_regions(InternalSubsts::identity_for_item(tcx, def_id)),
6161
);
6262
let mangled = tcx.symbol_name(instance);
63-
tcx.sess.emit_err(InvalidSymbolName {
63+
tcx.sess.emit_err(TestOutput {
6464
span: attr.span,
65-
mangled_formatted: format!("{mangled}"),
65+
kind: Kind::SymbolName,
66+
content: format!("{mangled}"),
6667
});
6768
if let Ok(demangling) = rustc_demangle::try_demangle(mangled.name) {
68-
tcx.sess.emit_err(InvalidTraitItem {
69+
tcx.sess.emit_err(TestOutput {
6970
span: attr.span,
70-
demangling_formatted: format!("{demangling}"),
71+
kind: Kind::Demangling,
72+
content: format!("{demangling}"),
7173
});
72-
tcx.sess.emit_err(AltInvalidTraitItem {
74+
tcx.sess.emit_err(TestOutput {
7375
span: attr.span,
74-
alt_demangling_formatted: format!("{:#}", demangling),
76+
kind: Kind::DemanglingAlt,
77+
content: format!("{:#}", demangling),
7578
});
7679
}
7780
}
7881

7982
for attr in tcx.get_attrs(def_id.to_def_id(), DEF_PATH) {
80-
tcx.sess.emit_err(InvalidDefPath {
83+
tcx.sess.emit_err(TestOutput {
8184
span: attr.span,
82-
def_path: with_no_trimmed_paths!(tcx.def_path_str(def_id.to_def_id())),
85+
kind: Kind::DefPath,
86+
content: with_no_trimmed_paths!(tcx.def_path_str(def_id.to_def_id())),
8387
});
8488
}
8589
}

src/bootstrap/bin/rustc.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ fn main() {
139139
// Cargo doesn't pass RUSTFLAGS to proc_macros:
140140
// https://github.com/rust-lang/cargo/issues/4423
141141
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
142-
// We also declare that the flag is expected, which is mainly needed for
143-
// later stages so that they don't warn about #[cfg(bootstrap)],
144-
// but enabling it for stage 0 too lets any warnings, if they occur,
145-
// occur more early on, e.g. about #[cfg(bootstrap = "foo")].
142+
// We also declare that the flag is expected, which we need to do to not
143+
// get warnings about it being unexpected.
146144
if stage == "0" {
147145
cmd.arg("--cfg=bootstrap");
148146
}

src/bootstrap/bin/rustdoc.rs

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ include!("../dylib_util.rs");
1111

1212
fn main() {
1313
let args = env::args_os().skip(1).collect::<Vec<_>>();
14+
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
1415
let rustdoc = env::var_os("RUSTDOC_REAL").expect("RUSTDOC_REAL was not set");
1516
let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set");
1617
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
@@ -62,6 +63,16 @@ fn main() {
6263
cmd.arg("-Clink-arg=-Wl,--threads=1");
6364
}
6465
}
66+
// Cargo doesn't pass RUSTDOCFLAGS to proc_macros:
67+
// https://github.com/rust-lang/cargo/issues/4423
68+
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
69+
// We also declare that the flag is expected, which we need to do to not
70+
// get warnings about it being unexpected.
71+
if stage == "0" {
72+
cmd.arg("--cfg=bootstrap");
73+
}
74+
cmd.arg("-Zunstable-options");
75+
cmd.arg("--check-cfg=values(bootstrap)");
6576

6677
if verbose > 1 {
6778
eprintln!(

0 commit comments

Comments
 (0)