Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run rustfmt on files that need it. #125477

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly, this exact line was changed very recently in #124516 - shouldn't tidy have fired on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One would think so. I've been looking a bit at the code that x fmt uses to decide which files to format. It's surprisingly complex, and I wouldn't be surprised if it has bugs. I have also seen multiple cases where x fmt doesn't format a file that it should, and then I run it again and it does format it, though I can't determine any pattern to this. So in general I have suspicions that x fmt isn't entirely reliable in that way, and it's possible that tidy has similar issues.

// 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;
Loading