Skip to content

Commit 2b3f260

Browse files
committed
Auto merge of rust-lang#107928 - matthiaskrgr:rollup-qnn380r, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#107657 (Add only modified subcommand for compiletest) - rust-lang#107864 (rustdoc: clean up `write!` calls with less stuttering) - rust-lang#107873 (Emit JSON output for the building of bootstrap itself) - rust-lang#107895 (remove redundant clones) - rust-lang#107897 (Reexported macros docs) - rust-lang#107909 (rustdoc: remove redundant `if s.is_empty()` from `find_testable_code`) - rust-lang#107912 (rustdoc: Don't resolve link to field on different variant) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8dabf5d + c8614a7 commit 2b3f260

File tree

21 files changed

+242
-62
lines changed

21 files changed

+242
-62
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ dependencies = [
895895
name = "compiletest"
896896
version = "0.0.0"
897897
dependencies = [
898+
"build_helper",
898899
"colored",
899900
"diff",
900901
"getopts",

compiler/rustc_codegen_ssa/src/back/archive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
203203
}
204204
}
205205

206-
self.src_archives.push((archive_path.to_owned(), archive_map));
206+
self.src_archives.push((archive_path, archive_map));
207207
Ok(())
208208
}
209209

compiler/rustc_log/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> {
9292
let fmt_layer = tracing_subscriber::fmt::layer()
9393
.with_writer(io::stderr)
9494
.without_time()
95-
.event_format(BacktraceFormatter { backtrace_target: str.to_string() });
95+
.event_format(BacktraceFormatter { backtrace_target: str });
9696
let subscriber = subscriber.with(fmt_layer);
9797
tracing::subscriber::set_global_default(subscriber).unwrap();
9898
}

compiler/rustc_parse_format/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,7 @@ impl<'a> Parser<'a> {
847847
0,
848848
ParseError {
849849
description: "expected format parameter to occur after `:`".to_owned(),
850-
note: Some(
851-
format!("`?` comes after `:`, try `{}:{}` instead", word, "?").to_owned(),
852-
),
850+
note: Some(format!("`?` comes after `:`, try `{}:{}` instead", word, "?")),
853851
label: "expected `?` to occur after `:`".to_owned(),
854852
span: pos.to(pos),
855853
secondary_label: None,

src/bootstrap/bootstrap.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,8 @@ def build_bootstrap(self, color, verbose_count):
784784
if self.get_toml("metrics", "build"):
785785
args.append("--features")
786786
args.append("build-metrics")
787+
if self.json_output:
788+
args.append("--message-format=json")
787789
if color == "always":
788790
args.append("--color=always")
789791
elif color == "never":
@@ -841,6 +843,7 @@ def parse_args():
841843
parser.add_argument('--build')
842844
parser.add_argument('--color', choices=['always', 'never', 'auto'])
843845
parser.add_argument('--clean', action='store_true')
846+
parser.add_argument('--json-output', action='store_true')
844847
parser.add_argument('-v', '--verbose', action='count', default=0)
845848

846849
return parser.parse_known_args(sys.argv)[0]
@@ -852,6 +855,7 @@ def bootstrap(args):
852855
build.rust_root = os.path.abspath(os.path.join(__file__, '../../..'))
853856
build.verbose = args.verbose != 0
854857
build.clean = args.clean
858+
build.json_output = args.json_output
855859

856860
# Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then `./config.toml`,
857861
# then `config.toml` in the root directory.

src/bootstrap/builder/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ mod dist {
557557
rustfix_coverage: false,
558558
pass: None,
559559
run: None,
560+
only_modified: false,
560561
};
561562

562563
let build = Build::new(config);
@@ -627,6 +628,7 @@ mod dist {
627628
rustfix_coverage: false,
628629
pass: None,
629630
run: None,
631+
only_modified: false,
630632
};
631633
// Make sure rustfmt binary not being found isn't an error.
632634
config.channel = "beta".to_string();

src/bootstrap/flags.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ pub enum Subcommand {
124124
fail_fast: bool,
125125
doc_tests: DocTests,
126126
rustfix_coverage: bool,
127+
only_modified: bool,
127128
},
128129
Bench {
129130
paths: Vec<PathBuf>,
@@ -301,6 +302,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
301302
opts.optflag("", "doc", "only run doc tests");
302303
opts.optflag("", "bless", "update all stderr/stdout files of failing ui tests");
303304
opts.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged");
305+
opts.optflag("", "only-modified", "only run tests that result has been changed");
304306
opts.optopt(
305307
"",
306308
"compare-mode",
@@ -598,6 +600,7 @@ Arguments:
598600
rustc_args: matches.opt_strs("rustc-args"),
599601
fail_fast: !matches.opt_present("no-fail-fast"),
600602
rustfix_coverage: matches.opt_present("rustfix-coverage"),
603+
only_modified: matches.opt_present("only-modified"),
601604
doc_tests: if matches.opt_present("doc") {
602605
DocTests::Only
603606
} else if matches.opt_present("no-doc") {
@@ -777,6 +780,13 @@ impl Subcommand {
777780
}
778781
}
779782

783+
pub fn only_modified(&self) -> bool {
784+
match *self {
785+
Subcommand::Test { only_modified, .. } => only_modified,
786+
_ => false,
787+
}
788+
}
789+
780790
pub fn force_rerun(&self) -> bool {
781791
match *self {
782792
Subcommand::Test { force_rerun, .. } => force_rerun,

src/bootstrap/format.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Runs rustfmt on the repository.
22
33
use crate::builder::Builder;
4-
use crate::util::{output, output_result, program_out_of_date, t};
5-
use build_helper::git::updated_master_branch;
4+
use crate::util::{output, program_out_of_date, t};
5+
use build_helper::git::get_git_modified_files;
66
use ignore::WalkBuilder;
77
use std::collections::VecDeque;
88
use std::path::{Path, PathBuf};
@@ -80,23 +80,11 @@ fn update_rustfmt_version(build: &Builder<'_>) {
8080
///
8181
/// Returns `None` if all files should be formatted.
8282
fn get_modified_rs_files(build: &Builder<'_>) -> Result<Option<Vec<String>>, String> {
83-
let Ok(updated_master) = updated_master_branch(Some(&build.config.src)) else { return Ok(None); };
84-
8583
if !verify_rustfmt_version(build) {
8684
return Ok(None);
8785
}
8886

89-
let merge_base =
90-
output_result(build.config.git().arg("merge-base").arg(&updated_master).arg("HEAD"))?;
91-
Ok(Some(
92-
output_result(
93-
build.config.git().arg("diff-index").arg("--name-only").arg(merge_base.trim()),
94-
)?
95-
.lines()
96-
.map(|s| s.trim().to_owned())
97-
.filter(|f| Path::new(f).extension().map_or(false, |ext| ext == "rs"))
98-
.collect(),
99-
))
87+
get_git_modified_files(Some(&build.config.src), &vec!["rs"])
10088
}
10189

10290
#[derive(serde::Deserialize)]

src/bootstrap/test.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,10 @@ note: if you're sure you want to do this, please open an issue as to why. In the
15101510
if builder.config.rust_optimize_tests {
15111511
cmd.arg("--optimize-tests");
15121512
}
1513+
if builder.config.cmd.only_modified() {
1514+
cmd.arg("--only-modified");
1515+
}
1516+
15131517
let mut flags = if is_rustdoc { Vec::new() } else { vec!["-Crpath".to_string()] };
15141518
flags.push(format!("-Cdebuginfo={}", builder.config.rust_debuginfo_level_tests));
15151519
flags.extend(builder.config.cmd.rustc_args().iter().map(|s| s.to_string()));

src/librustdoc/clean/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,10 +2209,12 @@ fn clean_maybe_renamed_item<'tcx>(
22092209
};
22102210

22112211
let mut extra_attrs = Vec::new();
2212-
if let Some(hir::Node::Item(use_node)) =
2213-
import_id.and_then(|def_id| cx.tcx.hir().find_by_def_id(def_id))
2212+
if let Some(import_id) = import_id &&
2213+
let Some(hir::Node::Item(use_node)) = cx.tcx.hir().find_by_def_id(import_id)
22142214
{
2215-
// We get all the various imports' attributes.
2215+
// First, we add the attributes from the current import.
2216+
extra_attrs.extend_from_slice(inline::load_attrs(cx, import_id.to_def_id()));
2217+
// Then we get all the various imports' attributes.
22162218
get_all_import_attributes(use_node, cx.tcx, item.owner_id.def_id, &mut extra_attrs);
22172219
}
22182220

0 commit comments

Comments
 (0)