Skip to content

Commit aed2187

Browse files
committed
Auto merge of rust-lang#124448 - matthiaskrgr:rollup-iloy9vz, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#124370 (Fix substitution parts having a shifted underline in some cases) - rust-lang#124394 (Fix ICE on invalid const param types) - rust-lang#124425 (Do not ICE on invalid consts when walking mono-reachable blocks) - rust-lang#124434 (Remove lazycell and once_cell from compiletest dependencies) - rust-lang#124437 (doc: Make the `mod.rs` in the comment point to the correct location) - rust-lang#124443 (Elaborate in comment about `statx` probe) - rust-lang#124445 (bootstrap: Change `global(true)` to `global = true` for flags for consistency) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 825e831 + 6f8811d commit aed2187

File tree

19 files changed

+232
-176
lines changed

19 files changed

+232
-176
lines changed

Cargo.lock

-8
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,9 @@ dependencies = [
760760
"glob",
761761
"home",
762762
"indexmap",
763-
"lazycell",
764763
"libc",
765764
"miow",
766765
"miropt-test-tools",
767-
"once_cell",
768766
"regex",
769767
"rustfix 0.8.1",
770768
"serde",
@@ -2151,12 +2149,6 @@ version = "1.4.0"
21512149
source = "registry+https://github.com/rust-lang/crates.io-index"
21522150
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
21532151

2154-
[[package]]
2155-
name = "lazycell"
2156-
version = "1.3.0"
2157-
source = "registry+https://github.com/rust-lang/crates.io-index"
2158-
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
2159-
21602152
[[package]]
21612153
name = "leb128"
21622154
version = "0.2.5"

compiler/rustc_errors/src/emitter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ impl HumanEmitter {
20192019
let offset: isize = offsets
20202020
.iter()
20212021
.filter_map(
2022-
|(start, v)| if span_start_pos <= *start { None } else { Some(v) },
2022+
|(start, v)| if span_start_pos < *start { None } else { Some(v) },
20232023
)
20242024
.sum();
20252025
let underline_start = (span_start_pos + start) as isize + offset;
@@ -2028,7 +2028,7 @@ impl HumanEmitter {
20282028
let padding: usize = max_line_num_len + 3;
20292029
for p in underline_start..underline_end {
20302030
if let DisplaySuggestion::Underline = show_code_change {
2031-
// If this is a replacement, underline with `^`, if this is an addition
2031+
// If this is a replacement, underline with `~`, if this is an addition
20322032
// underline with `+`.
20332033
buffer.putc(
20342034
row_num,

compiler/rustc_hir_analysis/src/collect.rs

+2
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
386386

387387
fn ct_infer(&self, ty: Ty<'tcx>, _: Option<&ty::GenericParamDef>, span: Span) -> Const<'tcx> {
388388
let ty = self.tcx.fold_regions(ty, |r, _| match *r {
389+
rustc_type_ir::RegionKind::ReStatic => r,
390+
389391
// This is never reached in practice. If it ever is reached,
390392
// `ReErased` should be changed to `ReStatic`, and any other region
391393
// left alone.

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Type checking expressions.
22
//!
3-
//! See `mod.rs` for more context on type checking in general.
3+
//! See [`rustc_hir_analysis::check`] for more context on type checking in general.
44
55
use crate::cast;
66
use crate::coercion::CoerceMany;

compiler/rustc_middle/src/mir/mod.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,7 @@ impl<'tcx> Body<'tcx> {
701701
env,
702702
crate::ty::EarlyBinder::bind(constant.const_),
703703
);
704-
let Some(bits) = mono_literal.try_eval_bits(tcx, env) else {
705-
bug!("Couldn't evaluate constant {:?} in mono {:?}", constant, instance);
706-
};
707-
bits
704+
mono_literal.try_eval_bits(tcx, env)
708705
};
709706

710707
let TerminatorKind::SwitchInt { discr, targets } = &block.terminator().kind else {
@@ -714,7 +711,7 @@ impl<'tcx> Body<'tcx> {
714711
// If this is a SwitchInt(const _), then we can just evaluate the constant and return.
715712
let discr = match discr {
716713
Operand::Constant(constant) => {
717-
let bits = eval_mono_const(constant);
714+
let bits = eval_mono_const(constant)?;
718715
return Some((bits, targets));
719716
}
720717
Operand::Move(place) | Operand::Copy(place) => place,
@@ -748,7 +745,7 @@ impl<'tcx> Body<'tcx> {
748745
match rvalue {
749746
Rvalue::NullaryOp(NullOp::UbChecks, _) => Some((tcx.sess.ub_checks() as u128, targets)),
750747
Rvalue::Use(Operand::Constant(constant)) => {
751-
let bits = eval_mono_const(constant);
748+
let bits = eval_mono_const(constant)?;
752749
Some((bits, targets))
753750
}
754751
_ => None,

library/std/src/sys/pal/unix/fs.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,16 @@ cfg_has_statx! {{
198198
return Some(Err(err));
199199
}
200200

201-
// `ENOSYS` might come from a faulty FUSE driver.
202-
//
203-
// Other errors are not a good enough indicator either -- it is
204-
// known that `EPERM` can be returned as a result of using seccomp to
205-
// block the syscall.
201+
// We're not yet entirely sure whether `statx` is usable on this kernel
202+
// or not. Syscalls can return errors from things other than the kernel
203+
// per se, e.g. `EPERM` can be returned if seccomp is used to block the
204+
// syscall, or `ENOSYS` might be returned from a faulty FUSE driver.
206205
//
207206
// Availability is checked by performing a call which expects `EFAULT`
208207
// if the syscall is usable.
209208
//
210209
// See: https://github.com/rust-lang/rust/issues/65662
211210
//
212-
// FIXME this can probably just do the call if `EPERM` was received, but
213-
// previous iteration of the code checked it for all errors and for now
214-
// this is retained.
215211
// FIXME what about transient conditions like `ENOMEM`?
216212
let err2 = cvt(statx(0, ptr::null(), 0, libc::STATX_ALL, ptr::null_mut()))
217213
.err()

src/bootstrap/src/core/config/flags.rs

+40-40
Original file line numberDiff line numberDiff line change
@@ -41,72 +41,72 @@ pub struct Flags {
4141
#[command(subcommand)]
4242
pub cmd: Subcommand,
4343

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

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

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

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

69-
#[arg(global(true), long, value_name = "PATH")]
69+
#[arg(global = true, long, value_name = "PATH")]
7070
/// build paths to exclude
7171
pub exclude: Vec<PathBuf>, // keeping for client backward compatibility
72-
#[arg(global(true), long, value_name = "PATH")]
72+
#[arg(global = true, long, value_name = "PATH")]
7373
/// build paths to skip
7474
pub skip: Vec<PathBuf>,
75-
#[arg(global(true), long)]
75+
#[arg(global = true, long)]
7676
/// include default paths in addition to the provided ones
7777
pub include_default_paths: bool,
7878

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

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

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

108108
#[arg(
109-
global(true),
109+
global = true,
110110
short,
111111
long,
112112
value_hint = clap::ValueHint::Other,
@@ -117,68 +117,68 @@ pub struct Flags {
117117
pub jobs: usize,
118118
// This overrides the deny-warnings configuration option,
119119
// which passes -Dwarnings to the compiler invocations.
120-
#[arg(global(true), long)]
120+
#[arg(global = true, long)]
121121
#[arg(value_enum, default_value_t=Warnings::Default, value_name = "deny|warn")]
122122
/// if value is deny, will deny warnings
123123
/// if value is warn, will emit warnings
124124
/// otherwise, use the default configured behaviour
125125
pub warnings: Warnings,
126126

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

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

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

146146
/// whether rebuilding llvm should be skipped, overriding `skip-rebuld` in config.toml
147-
#[arg(global(true), long, value_name = "VALUE")]
147+
#[arg(global = true, long, value_name = "VALUE")]
148148
pub llvm_skip_rebuild: Option<bool>,
149149
/// generate PGO profile with rustc build
150-
#[arg(global(true), value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
150+
#[arg(global = true, value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
151151
pub rust_profile_generate: Option<String>,
152152
/// use PGO profile for rustc build
153-
#[arg(global(true), value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
153+
#[arg(global = true, value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
154154
pub rust_profile_use: Option<String>,
155155
/// use PGO profile for LLVM build
156-
#[arg(global(true), value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
156+
#[arg(global = true, value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
157157
pub llvm_profile_use: Option<String>,
158158
// LLVM doesn't support a custom location for generating profile
159159
// information.
160160
//
161161
// llvm_out/build/profiles/ is the location this writes to.
162162
/// generate PGO profile with llvm built for rustc
163-
#[arg(global(true), long)]
163+
#[arg(global = true, long)]
164164
pub llvm_profile_generate: bool,
165165
/// Enable BOLT link flags
166-
#[arg(global(true), long)]
166+
#[arg(global = true, long)]
167167
pub enable_bolt_settings: bool,
168168
/// Skip stage0 compiler validation
169-
#[arg(global(true), long)]
169+
#[arg(global = true, long)]
170170
pub skip_stage0_validation: bool,
171171
/// Additional reproducible artifacts that should be added to the reproducible artifacts archive.
172-
#[arg(global(true), long)]
172+
#[arg(global = true, long)]
173173
pub reproducible_artifact: Vec<String>,
174-
#[arg(global(true))]
174+
#[arg(global = true)]
175175
/// paths for the subcommand
176176
pub paths: Vec<PathBuf>,
177177
/// override options in config.toml
178-
#[arg(global(true), value_hint = clap::ValueHint::Other, long, value_name = "section.option=value")]
178+
#[arg(global = true, value_hint = clap::ValueHint::Other, long, value_name = "section.option=value")]
179179
pub set: Vec<String>,
180180
/// arguments passed to subcommands
181-
#[arg(global(true), last(true), value_name = "ARGS")]
181+
#[arg(global = true, last(true), value_name = "ARGS")]
182182
pub free_args: Vec<String>,
183183
}
184184

@@ -192,7 +192,7 @@ impl Flags {
192192
struct HelpVerboseOnly {
193193
#[arg(short, long)]
194194
help: bool,
195-
#[arg(global(true), short, long, action = clap::ArgAction::Count)]
195+
#[arg(global = true, short, long, action = clap::ArgAction::Count)]
196196
pub verbose: u8,
197197
#[arg(value_enum)]
198198
cmd: Kind,
@@ -260,16 +260,16 @@ pub enum Subcommand {
260260
#[arg(long, requires = "fix")]
261261
allow_staged: bool,
262262
/// clippy lints to allow
263-
#[arg(global(true), short = 'A', action = clap::ArgAction::Append, value_name = "LINT")]
263+
#[arg(global = true, short = 'A', action = clap::ArgAction::Append, value_name = "LINT")]
264264
allow: Vec<String>,
265265
/// clippy lints to deny
266-
#[arg(global(true), short = 'D', action = clap::ArgAction::Append, value_name = "LINT")]
266+
#[arg(global = true, short = 'D', action = clap::ArgAction::Append, value_name = "LINT")]
267267
deny: Vec<String>,
268268
/// clippy lints to warn on
269-
#[arg(global(true), short = 'W', action = clap::ArgAction::Append, value_name = "LINT")]
269+
#[arg(global = true, short = 'W', action = clap::ArgAction::Append, value_name = "LINT")]
270270
warn: Vec<String>,
271271
/// clippy lints to forbid
272-
#[arg(global(true), short = 'F', action = clap::ArgAction::Append, value_name = "LINT")]
272+
#[arg(global = true, short = 'F', action = clap::ArgAction::Append, value_name = "LINT")]
273273
forbid: Vec<String>,
274274
},
275275
/// Run cargo fix

src/tools/compiletest/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ regex = "1.0"
2121
serde = { version = "1.0", features = ["derive"] }
2222
serde_json = "1.0"
2323
rustfix = "0.8.1"
24-
once_cell = "1.16.0"
2524
walkdir = "2"
2625
glob = "0.3.0"
27-
lazycell = "1.3.0"
2826
anyhow = "1"
2927
home = "0.5.5"
3028

src/tools/compiletest/src/common.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::iter;
66
use std::path::{Path, PathBuf};
77
use std::process::Command;
88
use std::str::FromStr;
9+
use std::sync::OnceLock;
910

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

387-
pub target_cfgs: AtomicLazyCell<TargetCfgs>,
387+
pub target_cfgs: OnceLock<TargetCfgs>,
388388

389389
pub nocapture: bool,
390390

@@ -406,13 +406,7 @@ impl Config {
406406
}
407407

408408
pub fn target_cfgs(&self) -> &TargetCfgs {
409-
match self.target_cfgs.borrow() {
410-
Some(cfgs) => cfgs,
411-
None => {
412-
let _ = self.target_cfgs.fill(TargetCfgs::new(self));
413-
self.target_cfgs.borrow().unwrap()
414-
}
415-
}
409+
self.target_cfgs.get_or_init(|| TargetCfgs::new(self))
416410
}
417411

418412
pub fn target_cfg(&self) -> &TargetCfg {

src/tools/compiletest/src/errors.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::io::prelude::*;
66
use std::io::BufReader;
77
use std::path::Path;
88
use std::str::FromStr;
9+
use std::sync::OnceLock;
910

10-
use once_cell::sync::Lazy;
1111
use regex::Regex;
1212
use tracing::*;
1313

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

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

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

0 commit comments

Comments
 (0)