Skip to content

Commit

Permalink
Auto merge of rust-lang#101928 - notriddle:rollup-pexhhxe, r=notriddle
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Sep 17, 2022
2 parents c524c7d + cafca7d commit 4a12d10
Show file tree
Hide file tree
Showing 34 changed files with 307 additions and 212 deletions.
16 changes: 8 additions & 8 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2088,15 +2088,15 @@ pub enum InlineAsmRegOrRegClass {
bitflags::bitflags! {
#[derive(Encodable, Decodable, HashStable_Generic)]
pub struct InlineAsmOptions: u16 {
const PURE = 1 << 0;
const NOMEM = 1 << 1;
const READONLY = 1 << 2;
const PURE = 1 << 0;
const NOMEM = 1 << 1;
const READONLY = 1 << 2;
const PRESERVES_FLAGS = 1 << 3;
const NORETURN = 1 << 4;
const NOSTACK = 1 << 5;
const ATT_SYNTAX = 1 << 6;
const RAW = 1 << 7;
const MAY_UNWIND = 1 << 8;
const NORETURN = 1 << 4;
const NOSTACK = 1 << 5;
const ATT_SYNTAX = 1 << 6;
const RAW = 1 << 7;
const MAY_UNWIND = 1 << 8;
}
}

Expand Down
68 changes: 34 additions & 34 deletions compiler/rustc_ast/src/util/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,11 @@ impl ExprPrecedence {
match self {
ExprPrecedence::Closure => PREC_CLOSURE,

ExprPrecedence::Break |
ExprPrecedence::Continue |
ExprPrecedence::Ret |
ExprPrecedence::Yield |
ExprPrecedence::Yeet => PREC_JUMP,
ExprPrecedence::Break
| ExprPrecedence::Continue
| ExprPrecedence::Ret
| ExprPrecedence::Yield
| ExprPrecedence::Yeet => PREC_JUMP,

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

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

// Unary, postfix
ExprPrecedence::Await |
ExprPrecedence::Call |
ExprPrecedence::MethodCall |
ExprPrecedence::Field |
ExprPrecedence::Index |
ExprPrecedence::Try |
ExprPrecedence::InlineAsm |
ExprPrecedence::Mac => PREC_POSTFIX,
ExprPrecedence::Await
| ExprPrecedence::Call
| ExprPrecedence::MethodCall
| ExprPrecedence::Field
| ExprPrecedence::Index
| ExprPrecedence::Try
| ExprPrecedence::InlineAsm
| ExprPrecedence::Mac => PREC_POSTFIX,

// Never need parens
ExprPrecedence::Array |
ExprPrecedence::Repeat |
ExprPrecedence::Tup |
ExprPrecedence::Lit |
ExprPrecedence::Path |
ExprPrecedence::Paren |
ExprPrecedence::If |
ExprPrecedence::While |
ExprPrecedence::ForLoop |
ExprPrecedence::Loop |
ExprPrecedence::Match |
ExprPrecedence::ConstBlock |
ExprPrecedence::Block |
ExprPrecedence::TryBlock |
ExprPrecedence::Async |
ExprPrecedence::Struct |
ExprPrecedence::Err => PREC_PAREN,
ExprPrecedence::Array
| ExprPrecedence::Repeat
| ExprPrecedence::Tup
| ExprPrecedence::Lit
| ExprPrecedence::Path
| ExprPrecedence::Paren
| ExprPrecedence::If
| ExprPrecedence::While
| ExprPrecedence::ForLoop
| ExprPrecedence::Loop
| ExprPrecedence::Match
| ExprPrecedence::ConstBlock
| ExprPrecedence::Block
| ExprPrecedence::TryBlock
| ExprPrecedence::Async
| ExprPrecedence::Struct
| ExprPrecedence::Err => PREC_PAREN,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
symbol_mangling_invalid_symbol_name = symbol-name({$mangled_formatted})
symbol_mangling_invalid_trait_item = demangling({$demangling_formatted})
symbol_mangling_alt_invalid_trait_item = demangling-alt({$alt_demangling_formatted})
symbol_mangling_invalid_def_path = def-path({$def_path})
symbol_mangling_test_output = {$kind}({$content})
9 changes: 4 additions & 5 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,10 @@ impl LifetimeName {
match self {
LifetimeName::ImplicitObjectLifetimeDefault | LifetimeName::Infer => true,

// It might seem surprising that `Fresh` counts as
// *not* elided -- but this is because, as far as the code
// in the compiler is concerned -- `Fresh` variants act
// equivalently to "some fresh name". They correspond to
// early-bound regions on an impl, in other words.
// It might seem surprising that `Fresh` counts as not *elided*
// -- but this is because, as far as the code in the compiler is
// concerned -- `Fresh` variants act equivalently to "some fresh name".
// They correspond to early-bound regions on an impl, in other words.
LifetimeName::Error | LifetimeName::Param(..) | LifetimeName::Static => false,
}
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,8 @@ impl CheckAttrVisitor<'_> {
E0552,
"unrecognized representation hint"
)
.help("valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`")
.help("valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, \
`i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`")
.emit();

continue;
Expand Down
44 changes: 21 additions & 23 deletions compiler/rustc_symbol_mangling/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
//! Errors emitted by symbol_mangling.

use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
use rustc_macros::SessionDiagnostic;
use rustc_span::Span;

#[derive(SessionDiagnostic)]
#[diag(symbol_mangling::invalid_symbol_name)]
pub struct InvalidSymbolName {
#[diag(symbol_mangling::test_output)]
pub struct TestOutput {
#[primary_span]
pub span: Span,
pub mangled_formatted: String,
pub kind: Kind,
pub content: String,
}

#[derive(SessionDiagnostic)]
#[diag(symbol_mangling::invalid_trait_item)]
pub struct InvalidTraitItem {
#[primary_span]
pub span: Span,
pub demangling_formatted: String,
pub enum Kind {
SymbolName,
Demangling,
DemanglingAlt,
DefPath,
}

#[derive(SessionDiagnostic)]
#[diag(symbol_mangling::alt_invalid_trait_item)]
pub struct AltInvalidTraitItem {
#[primary_span]
pub span: Span,
pub alt_demangling_formatted: String,
}

#[derive(SessionDiagnostic)]
#[diag(symbol_mangling::invalid_def_path)]
pub struct InvalidDefPath {
#[primary_span]
pub span: Span,
pub def_path: String,
impl IntoDiagnosticArg for Kind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
let kind = match self {
Kind::SymbolName => "symbol-name",
Kind::Demangling => "demangling",
Kind::DemanglingAlt => "demangling-alt",
Kind::DefPath => "def-path",
}
.into();
DiagnosticArgValue::Str(kind)
}
}
22 changes: 13 additions & 9 deletions compiler/rustc_symbol_mangling/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! def-path. This is used for unit testing the code that generates
//! paths etc in all kinds of annoying scenarios.

use crate::errors::{AltInvalidTraitItem, InvalidDefPath, InvalidSymbolName, InvalidTraitItem};
use crate::errors::{Kind, TestOutput};
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{subst::InternalSubsts, Instance, TyCtxt};
Expand Down Expand Up @@ -60,26 +60,30 @@ impl SymbolNamesTest<'_> {
tcx.erase_regions(InternalSubsts::identity_for_item(tcx, def_id)),
);
let mangled = tcx.symbol_name(instance);
tcx.sess.emit_err(InvalidSymbolName {
tcx.sess.emit_err(TestOutput {
span: attr.span,
mangled_formatted: format!("{mangled}"),
kind: Kind::SymbolName,
content: format!("{mangled}"),
});
if let Ok(demangling) = rustc_demangle::try_demangle(mangled.name) {
tcx.sess.emit_err(InvalidTraitItem {
tcx.sess.emit_err(TestOutput {
span: attr.span,
demangling_formatted: format!("{demangling}"),
kind: Kind::Demangling,
content: format!("{demangling}"),
});
tcx.sess.emit_err(AltInvalidTraitItem {
tcx.sess.emit_err(TestOutput {
span: attr.span,
alt_demangling_formatted: format!("{:#}", demangling),
kind: Kind::DemanglingAlt,
content: format!("{:#}", demangling),
});
}
}

for attr in tcx.get_attrs(def_id.to_def_id(), DEF_PATH) {
tcx.sess.emit_err(InvalidDefPath {
tcx.sess.emit_err(TestOutput {
span: attr.span,
def_path: with_no_trimmed_paths!(tcx.def_path_str(def_id.to_def_id())),
kind: Kind::DefPath,
content: with_no_trimmed_paths!(tcx.def_path_str(def_id.to_def_id())),
});
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ fn main() {
// Cargo doesn't pass RUSTFLAGS to proc_macros:
// https://github.com/rust-lang/cargo/issues/4423
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
// We also declare that the flag is expected, which is mainly needed for
// later stages so that they don't warn about #[cfg(bootstrap)],
// but enabling it for stage 0 too lets any warnings, if they occur,
// occur more early on, e.g. about #[cfg(bootstrap = "foo")].
// We also declare that the flag is expected, which we need to do to not
// get warnings about it being unexpected.
if stage == "0" {
cmd.arg("--cfg=bootstrap");
}
Expand Down
11 changes: 11 additions & 0 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include!("../dylib_util.rs");

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

if verbose > 1 {
eprintln!(
Expand Down
Loading

0 comments on commit 4a12d10

Please sign in to comment.