Skip to content

Commit

Permalink
Auto merge of #130473 - matthiaskrgr:rollup-lf29374, r=matthiaskrgr
Browse files Browse the repository at this point in the history
Rollup of 9 pull requests

Successful merges:

 - #128535 (Format `std::env::consts` docstrings with markdown backticks)
 - #128961 (Fix #128930: Print documentation of CLI options missing their arg)
 - #129988 (Use `Vec` in `rustc_interface::Config::locale_resources`)
 - #130201 (Encode `coroutine_by_move_body_def_id` in crate metadata)
 - #130275 (Don't call `extern_crate` when local crate name is the same as a dependency and we have a trait error)
 - #130314 (Use the same precedence for all macro-like exprs)
 - #130440 (Don't ICE in `opaque_hidden_inferred_bound` lint for RPITIT in trait with no default method body)
 - #130458 (`rustc_codegen_ssa` cleanups)
 - #130469 (Mark `where_clauses_object_safety` as removed)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Sep 17, 2024
2 parents e9e13a6 + 065690e commit f609b7e
Show file tree
Hide file tree
Showing 58 changed files with 602 additions and 426 deletions.
11 changes: 6 additions & 5 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ impl Expr {
ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node),
ExprKind::Unary(..) => ExprPrecedence::Unary,
ExprKind::Lit(_) | ExprKind::IncludedBytes(..) => ExprPrecedence::Lit,
ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast,
ExprKind::Cast(..) => ExprPrecedence::Cast,
ExprKind::Let(..) => ExprPrecedence::Let,
ExprKind::If(..) => ExprPrecedence::If,
ExprKind::While(..) => ExprPrecedence::While,
Expand All @@ -1317,17 +1317,18 @@ impl Expr {
ExprKind::Break(..) => ExprPrecedence::Break,
ExprKind::Continue(..) => ExprPrecedence::Continue,
ExprKind::Ret(..) => ExprPrecedence::Ret,
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
ExprKind::OffsetOf(..) => ExprPrecedence::OffsetOf,
ExprKind::MacCall(..) => ExprPrecedence::Mac,
ExprKind::Struct(..) => ExprPrecedence::Struct,
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
ExprKind::Paren(..) => ExprPrecedence::Paren,
ExprKind::Try(..) => ExprPrecedence::Try,
ExprKind::Yield(..) => ExprPrecedence::Yield,
ExprKind::Yeet(..) => ExprPrecedence::Yeet,
ExprKind::FormatArgs(..) => ExprPrecedence::FormatArgs,
ExprKind::Become(..) => ExprPrecedence::Become,
ExprKind::InlineAsm(..)
| ExprKind::Type(..)
| ExprKind::OffsetOf(..)
| ExprKind::FormatArgs(..)
| ExprKind::MacCall(..) => ExprPrecedence::Mac,
ExprKind::Err(_) | ExprKind::Dummy => ExprPrecedence::Err,
}
}
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_ast/src/util/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,7 @@ pub enum ExprPrecedence {
Field,
Index,
Try,
InlineAsm,
OffsetOf,
Mac,
FormatArgs,

Array,
Repeat,
Expand Down Expand Up @@ -333,17 +330,14 @@ impl ExprPrecedence {
| ExprPrecedence::ConstBlock
| ExprPrecedence::Field
| ExprPrecedence::ForLoop
| ExprPrecedence::FormatArgs
| ExprPrecedence::Gen
| ExprPrecedence::If
| ExprPrecedence::Index
| ExprPrecedence::InlineAsm
| ExprPrecedence::Lit
| ExprPrecedence::Loop
| ExprPrecedence::Mac
| ExprPrecedence::Match
| ExprPrecedence::MethodCall
| ExprPrecedence::OffsetOf
| ExprPrecedence::Paren
| ExprPrecedence::Path
| ExprPrecedence::PostfixMatch
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub trait ArchiveBuilderBuilder {
}
}

pub fn create_mingw_dll_import_lib(
fn create_mingw_dll_import_lib(
sess: &Session,
lib_name: &str,
import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,
Expand Down
26 changes: 13 additions & 13 deletions compiler/rustc_codegen_ssa/src/back/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{fmt, io, mem};
use rustc_target::spec::LldFlavor;

#[derive(Clone)]
pub struct Command {
pub(crate) struct Command {
program: Program,
args: Vec<OsString>,
env: Vec<(OsString, OsString)>,
Expand All @@ -23,28 +23,28 @@ enum Program {
}

impl Command {
pub fn new<P: AsRef<OsStr>>(program: P) -> Command {
pub(crate) fn new<P: AsRef<OsStr>>(program: P) -> Command {
Command::_new(Program::Normal(program.as_ref().to_owned()))
}

pub fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
pub(crate) fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
Command::_new(Program::CmdBatScript(program.as_ref().to_owned()))
}

pub fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
pub(crate) fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
Command::_new(Program::Lld(program.as_ref().to_owned(), flavor))
}

fn _new(program: Program) -> Command {
Command { program, args: Vec::new(), env: Vec::new(), env_remove: Vec::new() }
}

pub fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
pub(crate) fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
self._arg(arg.as_ref());
self
}

pub fn args<I>(&mut self, args: I) -> &mut Command
pub(crate) fn args<I>(&mut self, args: I) -> &mut Command
where
I: IntoIterator<Item: AsRef<OsStr>>,
{
Expand All @@ -58,7 +58,7 @@ impl Command {
self.args.push(arg.to_owned());
}

pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
pub(crate) fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
where
K: AsRef<OsStr>,
V: AsRef<OsStr>,
Expand All @@ -71,7 +71,7 @@ impl Command {
self.env.push((key.to_owned(), value.to_owned()));
}

pub fn env_remove<K>(&mut self, key: K) -> &mut Command
pub(crate) fn env_remove<K>(&mut self, key: K) -> &mut Command
where
K: AsRef<OsStr>,
{
Expand All @@ -83,11 +83,11 @@ impl Command {
self.env_remove.push(key.to_owned());
}

pub fn output(&mut self) -> io::Result<Output> {
pub(crate) fn output(&mut self) -> io::Result<Output> {
self.command().output()
}

pub fn command(&self) -> process::Command {
pub(crate) fn command(&self) -> process::Command {
let mut ret = match self.program {
Program::Normal(ref p) => process::Command::new(p),
Program::CmdBatScript(ref p) => {
Expand All @@ -111,17 +111,17 @@ impl Command {

// extensions

pub fn get_args(&self) -> &[OsString] {
pub(crate) fn get_args(&self) -> &[OsString] {
&self.args
}

pub fn take_args(&mut self) -> Vec<OsString> {
pub(crate) fn take_args(&mut self) -> Vec<OsString> {
mem::take(&mut self.args)
}

/// Returns a `true` if we're pretty sure that this'll blow OS spawn limits,
/// or `false` if we should attempt to spawn and see what the OS says.
pub fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
pub(crate) fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
// We mostly only care about Windows in this method, on Unix the limits
// can be gargantuan anyway so we're pretty unlikely to hit them
if cfg!(unix) {
Expand Down
54 changes: 31 additions & 23 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::errors;
/// and prevent inspection of linker output in case of errors, which we occasionally do.
/// This should be acceptable because other messages from rustc are in English anyway,
/// and may also be desirable to improve searchability of the linker diagnostics.
pub fn disable_localization(linker: &mut Command) {
pub(crate) fn disable_localization(linker: &mut Command) {
// No harm in setting both env vars simultaneously.
// Unix-style linkers.
linker.env("LC_ALL", "C");
Expand All @@ -41,7 +41,7 @@ pub fn disable_localization(linker: &mut Command) {
/// The third parameter is for env vars, used on windows to set up the
/// path for MSVC to find its DLLs, and gcc to find its bundled
/// toolchain
pub fn get_linker<'a>(
pub(crate) fn get_linker<'a>(
sess: &'a Session,
linker: &Path,
flavor: LinkerFlavor,
Expand Down Expand Up @@ -215,28 +215,36 @@ fn link_or_cc_args<L: Linker + ?Sized>(
macro_rules! generate_arg_methods {
($($ty:ty)*) => { $(
impl $ty {
pub fn verbatim_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
#[allow(unused)]
pub(crate) fn verbatim_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
verbatim_args(self, args)
}
pub fn verbatim_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
#[allow(unused)]
pub(crate) fn verbatim_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
verbatim_args(self, iter::once(arg))
}
pub fn link_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>, IntoIter: ExactSizeIterator>) -> &mut Self {
#[allow(unused)]
pub(crate) fn link_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>, IntoIter: ExactSizeIterator>) -> &mut Self {
link_args(self, args)
}
pub fn link_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
#[allow(unused)]
pub(crate) fn link_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
link_args(self, iter::once(arg))
}
pub fn cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
#[allow(unused)]
pub(crate) fn cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
cc_args(self, args)
}
pub fn cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
#[allow(unused)]
pub(crate) fn cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
cc_args(self, iter::once(arg))
}
pub fn link_or_cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
#[allow(unused)]
pub(crate) fn link_or_cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
link_or_cc_args(self, args)
}
pub fn link_or_cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
#[allow(unused)]
pub(crate) fn link_or_cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
link_or_cc_args(self, iter::once(arg))
}
}
Expand All @@ -263,7 +271,7 @@ generate_arg_methods! {
/// represents the meaning of each option being passed down. This trait is then
/// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
/// MSVC linker (e.g., `link.exe`) is being used.
pub trait Linker {
pub(crate) trait Linker {
fn cmd(&mut self) -> &mut Command;
fn is_cc(&self) -> bool {
false
Expand Down Expand Up @@ -314,12 +322,12 @@ pub trait Linker {
}

impl dyn Linker + '_ {
pub fn take_cmd(&mut self) -> Command {
pub(crate) fn take_cmd(&mut self) -> Command {
mem::replace(self.cmd(), Command::new(""))
}
}

pub struct GccLinker<'a> {
struct GccLinker<'a> {
cmd: Command,
sess: &'a Session,
target_cpu: &'a str,
Expand Down Expand Up @@ -849,7 +857,7 @@ impl<'a> Linker for GccLinker<'a> {
}
}

pub struct MsvcLinker<'a> {
struct MsvcLinker<'a> {
cmd: Command,
sess: &'a Session,
}
Expand Down Expand Up @@ -1103,7 +1111,7 @@ impl<'a> Linker for MsvcLinker<'a> {
}
}

pub struct EmLinker<'a> {
struct EmLinker<'a> {
cmd: Command,
sess: &'a Session,
}
Expand Down Expand Up @@ -1220,7 +1228,7 @@ impl<'a> Linker for EmLinker<'a> {
}
}

pub struct WasmLd<'a> {
struct WasmLd<'a> {
cmd: Command,
sess: &'a Session,
}
Expand Down Expand Up @@ -1404,7 +1412,7 @@ impl<'a> WasmLd<'a> {
}

/// Linker shepherd script for L4Re (Fiasco)
pub struct L4Bender<'a> {
struct L4Bender<'a> {
cmd: Command,
sess: &'a Session,
hinted_static: bool,
Expand Down Expand Up @@ -1510,7 +1518,7 @@ impl<'a> Linker for L4Bender<'a> {
}

impl<'a> L4Bender<'a> {
pub fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
L4Bender { cmd, sess, hinted_static: false }
}

Expand All @@ -1523,14 +1531,14 @@ impl<'a> L4Bender<'a> {
}

/// Linker for AIX.
pub struct AixLinker<'a> {
struct AixLinker<'a> {
cmd: Command,
sess: &'a Session,
hinted_static: Option<bool>,
}

impl<'a> AixLinker<'a> {
pub fn new(cmd: Command, sess: &'a Session) -> AixLinker<'a> {
fn new(cmd: Command, sess: &'a Session) -> AixLinker<'a> {
AixLinker { cmd, sess, hinted_static: None }
}

Expand Down Expand Up @@ -1758,7 +1766,7 @@ pub(crate) fn linked_symbols(

/// Much simplified and explicit CLI for the NVPTX linker. The linker operates
/// with bitcode and uses LLVM backend to generate a PTX assembly.
pub struct PtxLinker<'a> {
struct PtxLinker<'a> {
cmd: Command,
sess: &'a Session,
}
Expand Down Expand Up @@ -1824,7 +1832,7 @@ impl<'a> Linker for PtxLinker<'a> {
}

/// The `self-contained` LLVM bitcode linker
pub struct LlbcLinker<'a> {
struct LlbcLinker<'a> {
cmd: Command,
sess: &'a Session,
}
Expand Down Expand Up @@ -1895,7 +1903,7 @@ impl<'a> Linker for LlbcLinker<'a> {
fn linker_plugin_lto(&mut self) {}
}

pub struct BpfLinker<'a> {
struct BpfLinker<'a> {
cmd: Command,
sess: &'a Session,
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use rustc_target::spec::{ef_avr_arch, RelocModel, Target};
/// <dd>The metadata can be found in the `.rustc` section of the shared library.</dd>
/// </dl>
#[derive(Debug)]
pub struct DefaultMetadataLoader;
pub(crate) struct DefaultMetadataLoader;

static AIX_METADATA_SYMBOL_NAME: &'static str = "__aix_rust_metadata";

Expand Down Expand Up @@ -416,7 +416,7 @@ fn macho_is_arm64e(target: &Target) -> bool {
target.llvm_target.starts_with("arm64e")
}

pub enum MetadataPosition {
pub(crate) enum MetadataPosition {
First,
Last,
}
Expand Down Expand Up @@ -452,7 +452,7 @@ pub enum MetadataPosition {
/// * ELF - All other targets are similar to Windows in that there's a
/// `SHF_EXCLUDE` flag we can set on sections in an object file to get
/// automatically removed from the final output.
pub fn create_wrapper_file(
pub(crate) fn create_wrapper_file(
sess: &Session,
section_name: String,
data: &[u8],
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub mod archive;
pub mod command;
pub(crate) mod command;
pub mod link;
pub mod linker;
pub(crate) mod linker;
pub mod lto;
pub mod metadata;
pub mod rpath;
pub(crate) mod rpath;
pub mod symbol_export;
pub mod write;
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_fs_util::try_canonicalize;
use tracing::debug;

pub struct RPathConfig<'a> {
pub(super) struct RPathConfig<'a> {
pub libs: &'a [&'a Path],
pub out_filename: PathBuf,
pub is_like_osx: bool,
pub linker_is_gnu: bool,
}

pub fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec<OsString> {
pub(super) fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec<OsString> {
debug!("preparing the RPATH!");

let rpaths = get_rpaths(config);
Expand Down
Loading

0 comments on commit f609b7e

Please sign in to comment.