Skip to content

Commit

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

Successful merges:

 - #124370 (Fix substitution parts having a shifted underline in some cases)
 - #124394 (Fix ICE on invalid const param types)
 - #124425 (Do not ICE on invalid consts when walking mono-reachable blocks)
 - #124434 (Remove lazycell and once_cell from compiletest dependencies)
 - #124437 (doc: Make the `mod.rs` in the comment point to the correct location)
 - #124443 (Elaborate in comment about `statx` probe)
 - #124445 (bootstrap: Change `global(true)` to `global = true` for flags for consistency)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Apr 27, 2024
2 parents 825e831 + 6f8811d commit aed2187
Show file tree
Hide file tree
Showing 19 changed files with 232 additions and 176 deletions.
8 changes: 0 additions & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,9 @@ dependencies = [
"glob",
"home",
"indexmap",
"lazycell",
"libc",
"miow",
"miropt-test-tools",
"once_cell",
"regex",
"rustfix 0.8.1",
"serde",
Expand Down Expand Up @@ -2151,12 +2149,6 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"

[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"

[[package]]
name = "leb128"
version = "0.2.5"
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,7 @@ impl HumanEmitter {
let offset: isize = offsets
.iter()
.filter_map(
|(start, v)| if span_start_pos <= *start { None } else { Some(v) },
|(start, v)| if span_start_pos < *start { None } else { Some(v) },
)
.sum();
let underline_start = (span_start_pos + start) as isize + offset;
Expand All @@ -2028,7 +2028,7 @@ impl HumanEmitter {
let padding: usize = max_line_num_len + 3;
for p in underline_start..underline_end {
if let DisplaySuggestion::Underline = show_code_change {
// If this is a replacement, underline with `^`, if this is an addition
// If this is a replacement, underline with `~`, if this is an addition
// underline with `+`.
buffer.putc(
row_num,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {

fn ct_infer(&self, ty: Ty<'tcx>, _: Option<&ty::GenericParamDef>, span: Span) -> Const<'tcx> {
let ty = self.tcx.fold_regions(ty, |r, _| match *r {
rustc_type_ir::RegionKind::ReStatic => r,

// This is never reached in practice. If it ever is reached,
// `ReErased` should be changed to `ReStatic`, and any other region
// left alone.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Type checking expressions.
//!
//! See `mod.rs` for more context on type checking in general.
//! See [`rustc_hir_analysis::check`] for more context on type checking in general.
use crate::cast;
use crate::coercion::CoerceMany;
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,7 @@ impl<'tcx> Body<'tcx> {
env,
crate::ty::EarlyBinder::bind(constant.const_),
);
let Some(bits) = mono_literal.try_eval_bits(tcx, env) else {
bug!("Couldn't evaluate constant {:?} in mono {:?}", constant, instance);
};
bits
mono_literal.try_eval_bits(tcx, env)
};

let TerminatorKind::SwitchInt { discr, targets } = &block.terminator().kind else {
Expand All @@ -714,7 +711,7 @@ impl<'tcx> Body<'tcx> {
// If this is a SwitchInt(const _), then we can just evaluate the constant and return.
let discr = match discr {
Operand::Constant(constant) => {
let bits = eval_mono_const(constant);
let bits = eval_mono_const(constant)?;
return Some((bits, targets));
}
Operand::Move(place) | Operand::Copy(place) => place,
Expand Down Expand Up @@ -748,7 +745,7 @@ impl<'tcx> Body<'tcx> {
match rvalue {
Rvalue::NullaryOp(NullOp::UbChecks, _) => Some((tcx.sess.ub_checks() as u128, targets)),
Rvalue::Use(Operand::Constant(constant)) => {
let bits = eval_mono_const(constant);
let bits = eval_mono_const(constant)?;
Some((bits, targets))
}
_ => None,
Expand Down
12 changes: 4 additions & 8 deletions library/std/src/sys/pal/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,16 @@ cfg_has_statx! {{
return Some(Err(err));
}

// `ENOSYS` might come from a faulty FUSE driver.
//
// Other errors are not a good enough indicator either -- it is
// known that `EPERM` can be returned as a result of using seccomp to
// block the syscall.
// We're not yet entirely sure whether `statx` is usable on this kernel
// or not. Syscalls can return errors from things other than the kernel
// per se, e.g. `EPERM` can be returned if seccomp is used to block the
// syscall, or `ENOSYS` might be returned from a faulty FUSE driver.
//
// Availability is checked by performing a call which expects `EFAULT`
// if the syscall is usable.
//
// See: https://github.com/rust-lang/rust/issues/65662
//
// FIXME this can probably just do the call if `EPERM` was received, but
// previous iteration of the code checked it for all errors and for now
// this is retained.
// FIXME what about transient conditions like `ENOMEM`?
let err2 = cvt(statx(0, ptr::null(), 0, libc::STATX_ALL, ptr::null_mut()))
.err()
Expand Down
80 changes: 40 additions & 40 deletions src/bootstrap/src/core/config/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,72 +41,72 @@ pub struct Flags {
#[command(subcommand)]
pub cmd: Subcommand,

#[arg(global(true), short, long, action = clap::ArgAction::Count)]
#[arg(global = true, short, long, action = clap::ArgAction::Count)]
/// use verbose output (-vv for very verbose)
pub verbose: u8, // each extra -v after the first is passed to Cargo
#[arg(global(true), short, long)]
#[arg(global = true, short, long)]
/// use incremental compilation
pub incremental: bool,
#[arg(global(true), long, value_hint = clap::ValueHint::FilePath, value_name = "FILE")]
#[arg(global = true, long, value_hint = clap::ValueHint::FilePath, value_name = "FILE")]
/// TOML configuration file for build
pub config: Option<PathBuf>,
#[arg(global(true), long, value_hint = clap::ValueHint::DirPath, value_name = "DIR")]
#[arg(global = true, long, value_hint = clap::ValueHint::DirPath, value_name = "DIR")]
/// Build directory, overrides `build.build-dir` in `config.toml`
pub build_dir: Option<PathBuf>,

#[arg(global(true), long, value_hint = clap::ValueHint::Other, value_name = "BUILD")]
#[arg(global = true, long, value_hint = clap::ValueHint::Other, value_name = "BUILD")]
/// build target of the stage0 compiler
pub build: Option<String>,

#[arg(global(true), long, value_hint = clap::ValueHint::Other, value_name = "HOST", value_parser = target_selection_list)]
#[arg(global = true, long, value_hint = clap::ValueHint::Other, value_name = "HOST", value_parser = target_selection_list)]
/// host targets to build
pub host: Option<TargetSelectionList>,

#[arg(global(true), long, value_hint = clap::ValueHint::Other, value_name = "TARGET", value_parser = target_selection_list)]
#[arg(global = true, long, value_hint = clap::ValueHint::Other, value_name = "TARGET", value_parser = target_selection_list)]
/// target targets to build
pub target: Option<TargetSelectionList>,

#[arg(global(true), long, value_name = "PATH")]
#[arg(global = true, long, value_name = "PATH")]
/// build paths to exclude
pub exclude: Vec<PathBuf>, // keeping for client backward compatibility
#[arg(global(true), long, value_name = "PATH")]
#[arg(global = true, long, value_name = "PATH")]
/// build paths to skip
pub skip: Vec<PathBuf>,
#[arg(global(true), long)]
#[arg(global = true, long)]
/// include default paths in addition to the provided ones
pub include_default_paths: bool,

#[arg(global(true), value_hint = clap::ValueHint::Other, long)]
#[arg(global = true, value_hint = clap::ValueHint::Other, long)]
pub rustc_error_format: Option<String>,

#[arg(global(true), long, value_hint = clap::ValueHint::CommandString, value_name = "CMD")]
#[arg(global = true, long, value_hint = clap::ValueHint::CommandString, value_name = "CMD")]
/// command to run on failure
pub on_fail: Option<String>,
#[arg(global(true), long)]
#[arg(global = true, long)]
/// dry run; don't build anything
pub dry_run: bool,
/// Indicates whether to dump the work done from bootstrap shims
#[arg(global(true), long)]
#[arg(global = true, long)]
pub dump_bootstrap_shims: bool,
#[arg(global(true), value_hint = clap::ValueHint::Other, long, value_name = "N")]
#[arg(global = true, value_hint = clap::ValueHint::Other, long, value_name = "N")]
/// stage to build (indicates compiler to use/test, e.g., stage 0 uses the
/// bootstrap compiler, stage 1 the stage 0 rustc artifacts, etc.)
pub stage: Option<u32>,

#[arg(global(true), value_hint = clap::ValueHint::Other, long, value_name = "N")]
#[arg(global = true, value_hint = clap::ValueHint::Other, long, value_name = "N")]
/// stage(s) to keep without recompiling
/// (pass multiple times to keep e.g., both stages 0 and 1)
pub keep_stage: Vec<u32>,
#[arg(global(true), value_hint = clap::ValueHint::Other, long, value_name = "N")]
#[arg(global = true, value_hint = clap::ValueHint::Other, long, value_name = "N")]
/// stage(s) of the standard library to keep without recompiling
/// (pass multiple times to keep e.g., both stages 0 and 1)
pub keep_stage_std: Vec<u32>,
#[arg(global(true), long, value_hint = clap::ValueHint::DirPath, value_name = "DIR")]
#[arg(global = true, long, value_hint = clap::ValueHint::DirPath, value_name = "DIR")]
/// path to the root of the rust checkout
pub src: Option<PathBuf>,

#[arg(
global(true),
global = true,
short,
long,
value_hint = clap::ValueHint::Other,
Expand All @@ -117,68 +117,68 @@ pub struct Flags {
pub jobs: usize,
// This overrides the deny-warnings configuration option,
// which passes -Dwarnings to the compiler invocations.
#[arg(global(true), long)]
#[arg(global = true, long)]
#[arg(value_enum, default_value_t=Warnings::Default, value_name = "deny|warn")]
/// if value is deny, will deny warnings
/// if value is warn, will emit warnings
/// otherwise, use the default configured behaviour
pub warnings: Warnings,

#[arg(global(true), value_hint = clap::ValueHint::Other, long, value_name = "FORMAT")]
#[arg(global = true, value_hint = clap::ValueHint::Other, long, value_name = "FORMAT")]
/// rustc error format
pub error_format: Option<String>,
#[arg(global(true), long)]
#[arg(global = true, long)]
/// use message-format=json
pub json_output: bool,

#[arg(global(true), long, value_name = "STYLE")]
#[arg(global = true, long, value_name = "STYLE")]
#[arg(value_enum, default_value_t = Color::Auto)]
/// whether to use color in cargo and rustc output
pub color: Color,

#[arg(global(true), long)]
#[arg(global = true, long)]
/// Bootstrap uses this value to decide whether it should bypass locking the build process.
/// This is rarely needed (e.g., compiling the std library for different targets in parallel).
///
/// Unless you know exactly what you are doing, you probably don't need this.
pub bypass_bootstrap_lock: bool,

/// whether rebuilding llvm should be skipped, overriding `skip-rebuld` in config.toml
#[arg(global(true), long, value_name = "VALUE")]
#[arg(global = true, long, value_name = "VALUE")]
pub llvm_skip_rebuild: Option<bool>,
/// generate PGO profile with rustc build
#[arg(global(true), value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
#[arg(global = true, value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
pub rust_profile_generate: Option<String>,
/// use PGO profile for rustc build
#[arg(global(true), value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
#[arg(global = true, value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
pub rust_profile_use: Option<String>,
/// use PGO profile for LLVM build
#[arg(global(true), value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
#[arg(global = true, value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
pub llvm_profile_use: Option<String>,
// LLVM doesn't support a custom location for generating profile
// information.
//
// llvm_out/build/profiles/ is the location this writes to.
/// generate PGO profile with llvm built for rustc
#[arg(global(true), long)]
#[arg(global = true, long)]
pub llvm_profile_generate: bool,
/// Enable BOLT link flags
#[arg(global(true), long)]
#[arg(global = true, long)]
pub enable_bolt_settings: bool,
/// Skip stage0 compiler validation
#[arg(global(true), long)]
#[arg(global = true, long)]
pub skip_stage0_validation: bool,
/// Additional reproducible artifacts that should be added to the reproducible artifacts archive.
#[arg(global(true), long)]
#[arg(global = true, long)]
pub reproducible_artifact: Vec<String>,
#[arg(global(true))]
#[arg(global = true)]
/// paths for the subcommand
pub paths: Vec<PathBuf>,
/// override options in config.toml
#[arg(global(true), value_hint = clap::ValueHint::Other, long, value_name = "section.option=value")]
#[arg(global = true, value_hint = clap::ValueHint::Other, long, value_name = "section.option=value")]
pub set: Vec<String>,
/// arguments passed to subcommands
#[arg(global(true), last(true), value_name = "ARGS")]
#[arg(global = true, last(true), value_name = "ARGS")]
pub free_args: Vec<String>,
}

Expand All @@ -192,7 +192,7 @@ impl Flags {
struct HelpVerboseOnly {
#[arg(short, long)]
help: bool,
#[arg(global(true), short, long, action = clap::ArgAction::Count)]
#[arg(global = true, short, long, action = clap::ArgAction::Count)]
pub verbose: u8,
#[arg(value_enum)]
cmd: Kind,
Expand Down Expand Up @@ -260,16 +260,16 @@ pub enum Subcommand {
#[arg(long, requires = "fix")]
allow_staged: bool,
/// clippy lints to allow
#[arg(global(true), short = 'A', action = clap::ArgAction::Append, value_name = "LINT")]
#[arg(global = true, short = 'A', action = clap::ArgAction::Append, value_name = "LINT")]
allow: Vec<String>,
/// clippy lints to deny
#[arg(global(true), short = 'D', action = clap::ArgAction::Append, value_name = "LINT")]
#[arg(global = true, short = 'D', action = clap::ArgAction::Append, value_name = "LINT")]
deny: Vec<String>,
/// clippy lints to warn on
#[arg(global(true), short = 'W', action = clap::ArgAction::Append, value_name = "LINT")]
#[arg(global = true, short = 'W', action = clap::ArgAction::Append, value_name = "LINT")]
warn: Vec<String>,
/// clippy lints to forbid
#[arg(global(true), short = 'F', action = clap::ArgAction::Append, value_name = "LINT")]
#[arg(global = true, short = 'F', action = clap::ArgAction::Append, value_name = "LINT")]
forbid: Vec<String>,
},
/// Run cargo fix
Expand Down
2 changes: 0 additions & 2 deletions src/tools/compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ regex = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rustfix = "0.8.1"
once_cell = "1.16.0"
walkdir = "2"
glob = "0.3.0"
lazycell = "1.3.0"
anyhow = "1"
home = "0.5.5"

Expand Down
12 changes: 3 additions & 9 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use std::iter;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::str::FromStr;
use std::sync::OnceLock;

use crate::util::{add_dylib_path, PathBufExt};
use build_helper::git::GitConfig;
use lazycell::AtomicLazyCell;
use serde::de::{Deserialize, Deserializer, Error as _};
use std::collections::{HashMap, HashSet};
use test::{ColorConfig, OutputFormat};
Expand Down Expand Up @@ -384,7 +384,7 @@ pub struct Config {
/// Only rerun the tests that result has been modified accoring to Git status
pub only_modified: bool,

pub target_cfgs: AtomicLazyCell<TargetCfgs>,
pub target_cfgs: OnceLock<TargetCfgs>,

pub nocapture: bool,

Expand All @@ -406,13 +406,7 @@ impl Config {
}

pub fn target_cfgs(&self) -> &TargetCfgs {
match self.target_cfgs.borrow() {
Some(cfgs) => cfgs,
None => {
let _ = self.target_cfgs.fill(TargetCfgs::new(self));
self.target_cfgs.borrow().unwrap()
}
}
self.target_cfgs.get_or_init(|| TargetCfgs::new(self))
}

pub fn target_cfg(&self) -> &TargetCfg {
Expand Down
9 changes: 5 additions & 4 deletions src/tools/compiletest/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
use std::str::FromStr;
use std::sync::OnceLock;

use once_cell::sync::Lazy;
use regex::Regex;
use tracing::*;

Expand Down Expand Up @@ -117,10 +117,11 @@ fn parse_expected(
// //~^^^^^
// //[rev1]~
// //[rev1,rev2]~^^
static RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"//(?:\[(?P<revs>[\w\-,]+)])?~(?P<adjust>\||\^*)").unwrap());
static RE: OnceLock<Regex> = OnceLock::new();

let captures = RE.captures(line)?;
let captures = RE
.get_or_init(|| Regex::new(r"//(?:\[(?P<revs>[\w\-,]+)])?~(?P<adjust>\||\^*)").unwrap())
.captures(line)?;

match (test_revision, captures.name("revs")) {
// Only error messages that contain our revision between the square brackets apply to us.
Expand Down
Loading

0 comments on commit aed2187

Please sign in to comment.