Skip to content

Commit

Permalink
Auto merge of rust-lang#125477 - nnethercote:missed-rustfmt, r=compil…
Browse files Browse the repository at this point in the history
…er-errors

Run rustfmt on files that need it.

Somehow these files aren't properly formatted. By default `x fmt` and `x tidy` only check files that have changed against master, so if an ill-formatted file somehow slips in it can stay that way as long as it doesn't get modified(?)

I found these when I ran `x fmt` explicitly on every `.rs` file in the repo, while working on
rust-lang/compiler-team#750.
  • Loading branch information
bors committed May 24, 2024
2 parents 213ad10 + c1ac4a2 commit cb3791e
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 18 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use rustc_middle::middle::debugger_visualizer::{DebuggerVisualizerFile, Debugger
use rustc_middle::middle::exported_symbols;
use rustc_middle::middle::exported_symbols::SymbolExportKind;
use rustc_middle::middle::lang_items;
use rustc_middle::mir::BinOp;
use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem};
use rustc_middle::mir::BinOp;
use rustc_middle::query::Providers;
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_const_eval/src/const_eval/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ where
ErrorHandled::TooGeneric(span)
}
err_inval!(AlreadyReported(guar)) => ErrorHandled::Reported(guar, span),
err_inval!(Layout(LayoutError::ReferencesError(guar))) => ErrorHandled::Reported(
ReportedErrorInfo::tainted_by_errors(guar),
span,
),
err_inval!(Layout(LayoutError::ReferencesError(guar))) => {
ErrorHandled::Reported(ReportedErrorInfo::tainted_by_errors(guar), span)
}
// Report remaining errors.
_ => {
let (our_span, frames) = get_span_and_frames();
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_incremental/src/persist/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ fn load_dep_graph(sess: &Session) -> LoadResult<(Arc<SerializedDepGraph>, WorkPr

if let LoadResult::Ok { data: (work_products_data, start_pos) } = load_result {
// Decode the list of work_products
let Ok(mut work_product_decoder) =
MemDecoder::new(&work_products_data[..], start_pos)
let Ok(mut work_product_decoder) = MemDecoder::new(&work_products_data[..], start_pos)
else {
sess.dcx().emit_warn(errors::CorruptFile { path: &work_products_path });
return LoadResult::DataOutOfDate;
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_lint/src/for_loops_over_fallibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
};

let (article, ty, var) = match adt.did() {
did if cx.tcx.is_diagnostic_item(sym::Option, did) && ref_mutability.is_some() => ("a", "Option", "Some"),
did if cx.tcx.is_diagnostic_item(sym::Option, did) && ref_mutability.is_some() => {
("a", "Option", "Some")
}
did if cx.tcx.is_diagnostic_item(sym::Option, did) => ("an", "Option", "Some"),
did if cx.tcx.is_diagnostic_item(sym::Result, did) => ("a", "Result", "Ok"),
_ => return,
Expand Down
2 changes: 1 addition & 1 deletion library/test/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn fmt_thousands_sep(mut n: f64, sep: char) -> String {
(0, true) => write!(output, "{:06.2}", n / base as f64).unwrap(),
(0, false) => write!(output, "{:.2}", n / base as f64).unwrap(),
(_, true) => write!(output, "{:03}", n as usize / base).unwrap(),
_ => write!(output, "{}", n as usize / base).unwrap()
_ => write!(output, "{}", n as usize / base).unwrap(),
}
if pow != 0 {
output.push(sep);
Expand Down
29 changes: 24 additions & 5 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ fn check_cli<const N: usize>(paths: [&str; N]) {
macro_rules! std {
($host:ident => $target:ident, stage = $stage:literal) => {
compile::Std::new(
Compiler { host: TargetSelection::from_user(concat!(stringify!($host), "-", stringify!($host))), stage: $stage },
Compiler {
host: TargetSelection::from_user(concat!(
stringify!($host),
"-",
stringify!($host)
)),
stage: $stage,
},
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
)
};
Expand All @@ -83,7 +90,14 @@ macro_rules! doc_std {
macro_rules! rustc {
($host:ident => $target:ident, stage = $stage:literal) => {
compile::Rustc::new(
Compiler { host: TargetSelection::from_user(concat!(stringify!($host), "-", stringify!($host))), stage: $stage },
Compiler {
host: TargetSelection::from_user(concat!(
stringify!($host),
"-",
stringify!($host)
)),
stage: $stage,
},
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
)
};
Expand Down Expand Up @@ -141,10 +155,14 @@ fn check_missing_paths_for_x_test_tests() {

// Skip if not a test directory.
if path.ends_with("tests/auxiliary") || !path.is_dir() {
continue
continue;
}

assert!(tests_remap_paths.iter().any(|item| path.ends_with(*item)), "{} is missing in PATH_REMAP tests list.", path.display());
assert!(
tests_remap_paths.iter().any(|item| path.ends_with(*item)),
"{} is missing in PATH_REMAP tests list.",
path.display()
);
}
}

Expand Down Expand Up @@ -185,7 +203,8 @@ fn alias_and_path_for_library() {
&[std!(A => A, stage = 0), std!(A => A, stage = 1)]
);

let mut cache = run_build(&["library".into(), "core".into()], configure("doc", &["A-A"], &["A-A"]));
let mut cache =
run_build(&["library".into(), "core".into()], configure("doc", &["A-A"], &["A-A"]));
assert_eq!(first(cache.all::<doc::Std>()), &[doc_std!(A => A, stage = 0)]);
}

Expand Down
10 changes: 7 additions & 3 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,15 @@ than building it.
if !["A-A", "B-B", "C-C"].contains(&target_str.as_str()) {
let mut has_target = false;

let missing_targets_hashset: HashSet<_> = STAGE0_MISSING_TARGETS.iter().map(|t| t.to_string()).collect();
let duplicated_targets: Vec<_> = stage0_supported_target_list.intersection(&missing_targets_hashset).collect();
let missing_targets_hashset: HashSet<_> =
STAGE0_MISSING_TARGETS.iter().map(|t| t.to_string()).collect();
let duplicated_targets: Vec<_> =
stage0_supported_target_list.intersection(&missing_targets_hashset).collect();

if !duplicated_targets.is_empty() {
println!("Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list.");
println!(
"Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list."
);
for duplicated_target in duplicated_targets {
println!(" {duplicated_target}");
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/build_helper/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod ci;
pub mod git;
pub mod metrics;
pub mod util;
pub mod stage0_parser;
pub mod util;

0 comments on commit cb3791e

Please sign in to comment.