Skip to content

Commit d963910

Browse files
author
Alexander Regueiro
committed
rustc: comments
1 parent eac0908 commit d963910

File tree

364 files changed

+4321
-4193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

364 files changed

+4321
-4193
lines changed

src/bootstrap/bin/rustc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fn main() {
149149
//
150150
// `compiler_builtins` are unconditionally compiled with panic=abort to
151151
// workaround undefined references to `rust_eh_unwind_resume` generated
152-
// otherwise, see issue https://github.com/rust-lang/rust/issues/43095.
152+
// otherwise, see issue #43095.
153153
if crate_name == "panic_abort" ||
154154
crate_name == "compiler_builtins" && stage != "0" {
155155
cmd.arg("-C").arg("panic=abort");

src/bootstrap/builder.rs

+20-19
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
8080
// It is reasonable to not have an implementation of make_run for rules
8181
// who do not want to get called from the root context. This means that
8282
// they are likely dependencies (e.g., sysroot creation) or similar, and
83-
// as such calling them from ./x.py isn't logical.
83+
// as such calling them from `./x.py` isn't logical.
8484
unimplemented!()
8585
}
8686
}
@@ -236,11 +236,11 @@ impl StepDescription {
236236
#[derive(Clone)]
237237
pub struct ShouldRun<'a> {
238238
pub builder: &'a Builder<'a>,
239-
// use a BTreeSet to maintain sort order
239+
// Use a `BTreeSet` to maintain sort order.
240240
paths: BTreeSet<PathSet>,
241241

242242
// If this is a default rule, this is an additional constraint placed on
243-
// its run. Generally something like compiler docs being enabled.
243+
// its run (generally something like compiler docs being enabled).
244244
is_really_default: bool,
245245
}
246246

@@ -249,7 +249,8 @@ impl<'a> ShouldRun<'a> {
249249
ShouldRun {
250250
builder,
251251
paths: BTreeSet::new(),
252-
is_really_default: true, // by default no additional conditions
252+
// By default no additional conditions.
253+
is_really_default: true,
253254
}
254255
}
255256

@@ -277,12 +278,12 @@ impl<'a> ShouldRun<'a> {
277278
self
278279
}
279280

280-
// single, non-aliased path
281+
// Single, non-aliased path.
281282
pub fn path(self, path: &str) -> Self {
282283
self.paths(&[path])
283284
}
284285

285-
// multiple aliases for the same job
286+
// Multiple aliases for the same job.
286287
pub fn paths(mut self, paths: &[&str]) -> Self {
287288
self.paths
288289
.insert(PathSet::Set(paths.iter().map(PathBuf::from).collect()));
@@ -301,7 +302,7 @@ impl<'a> ShouldRun<'a> {
301302
self
302303
}
303304

304-
// allows being more explicit about why should_run in Step returns the value passed to it
305+
// Allows being more explicit about why `Step::should_run` returns the value passed to it.
305306
pub fn never(mut self) -> ShouldRun<'a> {
306307
self.paths.insert(PathSet::empty());
307308
self
@@ -677,7 +678,7 @@ impl<'a> Builder<'a> {
677678
let compiler = self.compiler(self.top_stage, host);
678679
cmd.env("RUSTC_STAGE", compiler.stage.to_string())
679680
.env("RUSTC_SYSROOT", self.sysroot(compiler))
680-
// Note that this is *not* the sysroot_libdir because rustdoc must be linked
681+
// Note that this is *not* the `sysroot_libdir` because rustdoc must be linked
681682
// equivalently to rustc.
682683
.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler))
683684
.env("CFG_RELEASE_CHANNEL", &self.config.channel)
@@ -813,12 +814,12 @@ impl<'a> Builder<'a> {
813814
}
814815

815816
cargo.arg("-j").arg(self.jobs().to_string());
816-
// Remove make-related flags to ensure Cargo can correctly set things up
817+
// Remove make-related flags to ensure Cargo can correctly set things up.
817818
cargo.env_remove("MAKEFLAGS");
818819
cargo.env_remove("MFLAGS");
819820

820-
// FIXME: Temporary fix for https://github.com/rust-lang/cargo/issues/3005
821-
// Force cargo to output binaries with disambiguating hashes in the name
821+
// FIXME: temporary fix for rust-lang/cargo#3005.
822+
// Force cargo to output binaries with disambiguating hashes in the name.
822823
let metadata = if compiler.stage == 0 {
823824
// Treat stage0 like special channel, whether it's a normal prior-
824825
// release rustc or a local rebuild with the same version, so we
@@ -863,7 +864,7 @@ impl<'a> Builder<'a> {
863864
// "raw" compiler in that it's the exact snapshot we download. Normally
864865
// the stage0 build means it uses libraries build by the stage0
865866
// compiler, but for tools we just use the precompiled libraries that
866-
// we've downloaded
867+
// we've downloaded.
867868
let use_snapshot = mode == Mode::ToolBootstrap;
868869
assert!(!use_snapshot || stage == 0 || self.local_rebuild);
869870

@@ -920,7 +921,7 @@ impl<'a> Builder<'a> {
920921

921922
if mode.is_tool() {
922923
// Tools like cargo and rls don't get debuginfo by default right now, but this can be
923-
// enabled in the config. Adding debuginfo makes them several times larger.
924+
// enabled in the config. Adding debuginfo makes them several times larger.
924925
if self.config.rust_debuginfo_tools {
925926
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
926927
cargo.env(
@@ -1028,7 +1029,7 @@ impl<'a> Builder<'a> {
10281029
// Build scripts use either the `cc` crate or `configure/make` so we pass
10291030
// the options through environment variables that are fetched and understood by both.
10301031
//
1031-
// FIXME: the guard against msvc shouldn't need to be here
1032+
// FIXME: the guard against MSVC shouldn't need to be here.
10321033
if target.contains("msvc") {
10331034
if let Some(ref cl) = self.config.llvm_clang_cl {
10341035
cargo.env("CC", cl).env("CXX", cl);
@@ -1040,7 +1041,7 @@ impl<'a> Builder<'a> {
10401041
Some(ref s) => s,
10411042
None => return s.display().to_string(),
10421043
};
1043-
// FIXME: the cc-rs crate only recognizes the literal strings
1044+
// FIXME: the cc-rs crate only recognizes the literal strings.
10441045
// `ccache` and `sccache` when doing caching compilations, so we
10451046
// mirror that here. It should probably be fixed upstream to
10461047
// accept a new env var or otherwise work with custom ccache
@@ -1080,12 +1081,12 @@ impl<'a> Builder<'a> {
10801081
cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
10811082
}
10821083

1083-
// For `cargo doc` invocations, make rustdoc print the Rust version into the docs
1084+
// For `cargo doc` invocations, make rustdoc print the Rust version into the docs.
10841085
cargo.env("RUSTDOC_CRATE_VERSION", self.rust_version());
10851086

1086-
// Environment variables *required* throughout the build
1087+
// Environment variables *required* throughout the build.
10871088
//
1088-
// FIXME: should update code to not require this env var
1089+
// FIXME: should update code to not require this env var.
10891090
cargo.env("CFG_COMPILER_HOST_TRIPLE", target);
10901091

10911092
// Set this for all builds to make sure doc builds also get it.
@@ -1476,7 +1477,7 @@ mod __test {
14761477
#[test]
14771478
fn dist_with_target_flag() {
14781479
let mut config = configure(&["B"], &["C"]);
1479-
config.run_host_only = false; // as-if --target=C was passed
1480+
config.run_host_only = false; // as if `--target=C` were passed
14801481
let build = Build::new(config);
14811482
let mut builder = Builder::new(&build);
14821483
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);

src/bootstrap/cache.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ lazy_static! {
235235
pub struct Cache(
236236
RefCell<HashMap<
237237
TypeId,
238-
Box<dyn Any>, // actually a HashMap<Step, Interned<Step::Output>>
238+
// Actually a `HashMap<Step, Interned<Step::Output>>`.
239+
Box<dyn Any>,
239240
>>
240241
);
241242

src/bootstrap/compile.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ pub fn std_cargo(builder: &Builder,
165165
let features = builder.std_features();
166166

167167
if compiler.stage != 0 && builder.config.sanitizers {
168-
// This variable is used by the sanitizer runtime crates, e.g.
169-
// rustc_lsan, to build the sanitizer runtime from C code
168+
// This variable is used by the sanitizer runtime crates, e.g.,
169+
// `rustc_lsan`, to build the sanitizer runtime from C code
170170
// When this variable is missing, those crates won't compile the C code,
171171
// so we don't set this variable during stage0 where llvm-config is
172172
// missing
173-
// We also only build the runtimes when --enable-sanitizers (or its
173+
// We also only build the runtimes when `--enable-sanitizers` (or its
174174
// config.toml equivalent) is used
175175
let llvm_config = builder.ensure(native::Llvm {
176176
target: builder.config.build,
@@ -895,7 +895,7 @@ impl Step for Assemble {
895895
run.never()
896896
}
897897

898-
/// Prepare a new compiler from the artifacts in `stage`
898+
/// Prepares a new compiler from the artifacts in `stage`
899899
///
900900
/// This will assemble a compiler in `build/$host/stage$stage`. The compiler
901901
/// must have been previously produced by the `stage - 1` builder.build
@@ -921,17 +921,17 @@ impl Step for Assemble {
921921
// produce some other architecture compiler we need to start from
922922
// `build` to get there.
923923
//
924-
// FIXME: Perhaps we should download those libraries?
925-
// It would make builds faster...
924+
// FIXME: perhaps we should download those libraries?
925+
// It would certainly make builds faster.
926926
//
927-
// FIXME: It may be faster if we build just a stage 1 compiler and then
928-
// use that to bootstrap this compiler forward.
927+
// FIXME: it may be faster if we build just a stage 1 compiler and then
928+
// use that to bootstrap this compiler forward.
929929
let build_compiler =
930930
builder.compiler(target_compiler.stage - 1, builder.config.build);
931931

932932
// Build the libraries for this compiler to link to (i.e., the libraries
933933
// it uses at runtime). NOTE: Crates the target compiler compiles don't
934-
// link to these. (FIXME: Is that correct? It seems to be correct most
934+
// link to these. (FIXME: is that correct? It seems to be correct most
935935
// of the time but I think we do link to these for stage2/bin compilers
936936
// when not performing a full bootstrap).
937937
builder.ensure(Rustc {
@@ -958,7 +958,7 @@ impl Step for Assemble {
958958
let host = target_compiler.host;
959959
builder.info(&format!("Assembling stage{} compiler ({})", stage, host));
960960

961-
// Link in all dylibs to the libdir
961+
// Link in all dylibs to the libdir.
962962
let sysroot = builder.sysroot(target_compiler);
963963
let sysroot_libdir = sysroot.join(libdir(&*host));
964964
t!(fs::create_dir_all(&sysroot_libdir));
@@ -979,7 +979,7 @@ impl Step for Assemble {
979979

980980
dist::maybe_install_llvm_dylib(builder, target_compiler.host, &sysroot);
981981

982-
// Link the compiler binary itself into place
982+
// Link the compiler binary itself into place.
983983
let out_dir = builder.cargo_out(build_compiler, Mode::Rustc, host);
984984
let rustc = out_dir.join(exe("rustc_binary", &*host));
985985
let bindir = sysroot.join("bin");
@@ -992,7 +992,7 @@ impl Step for Assemble {
992992
}
993993
}
994994

995-
/// Link some files into a rustc sysroot.
995+
/// Links some files into a rustc sysroot.
996996
///
997997
/// For a particular stage this will link the file listed in `stamp` into the
998998
/// `sysroot_dst` provided.
@@ -1013,16 +1013,16 @@ pub fn run_cargo(builder: &Builder,
10131013
return Vec::new();
10141014
}
10151015

1016-
// `target_root_dir` looks like $dir/$target/release
1016+
// `target_root_dir` looks like `$dir/$target/release`.
10171017
let target_root_dir = stamp.parent().unwrap();
1018-
// `target_deps_dir` looks like $dir/$target/release/deps
1018+
// `target_deps_dir` looks like `$dir/$target/release/deps`.
10191019
let target_deps_dir = target_root_dir.join("deps");
1020-
// `host_root_dir` looks like $dir/release
1020+
// `host_root_dir` looks like `$dir/release`.
10211021
let host_root_dir = target_root_dir.parent().unwrap() // chop off `release`
10221022
.parent().unwrap() // chop off `$target`
10231023
.join(target_root_dir.file_name().unwrap());
10241024

1025-
// Spawn Cargo slurping up its JSON output. We'll start building up the
1025+
// Spawn Cargo, collecting its JSON output. We'll start building up the
10261026
// `deps` array of all files it generated along with a `toplevel` array of
10271027
// files we need to probe for later.
10281028
let mut deps = Vec::new();
@@ -1033,7 +1033,7 @@ pub fn run_cargo(builder: &Builder,
10331033
_ => return,
10341034
};
10351035
for filename in filenames {
1036-
// Skip files like executables
1036+
// Skip files like executables.
10371037
if !filename.ends_with(".rlib") &&
10381038
!filename.ends_with(".lib") &&
10391039
!is_dylib(&filename) &&
@@ -1056,7 +1056,7 @@ pub fn run_cargo(builder: &Builder,
10561056
continue;
10571057
}
10581058

1059-
// Otherwise this was a "top level artifact" which right now doesn't
1059+
// Otherwise, this was a "top level artifact" which right now doesn't
10601060
// have a hash in the name, but there's a version of this file in
10611061
// the `deps` folder which *does* have a hash in the name. That's
10621062
// the one we'll want to we'll probe for it later.
@@ -1080,7 +1080,7 @@ pub fn run_cargo(builder: &Builder,
10801080
exit(1);
10811081
}
10821082

1083-
// Ok now we need to actually find all the files listed in `toplevel`. We've
1083+
// Now we need to actually find all the files listed in `toplevel`. We've
10841084
// got a list of prefix/extensions and we basically just need to find the
10851085
// most recent file in the `deps` folder corresponding to each one.
10861086
let contents = t!(target_deps_dir.read_dir())
@@ -1168,15 +1168,15 @@ pub fn stream_cargo(
11681168
Err(e) => panic!("failed to execute command: {:?}\nerror: {}", cargo, e),
11691169
};
11701170

1171-
// Spawn Cargo slurping up its JSON output. We'll start building up the
1171+
// Spawn Cargo, collecting its JSON output. We'll start building up the
11721172
// `deps` array of all files it generated along with a `toplevel` array of
11731173
// files we need to probe for later.
11741174
let stdout = BufReader::new(child.stdout.take().unwrap());
11751175
for line in stdout.lines() {
11761176
let line = t!(line);
11771177
match serde_json::from_str::<CargoMessage>(&line) {
11781178
Ok(msg) => cb(msg),
1179-
// If this was informational, just print it out and continue
1179+
// If this was informational, just print it out and continue.
11801180
Err(_) => println!("{}", line)
11811181
}
11821182
}

src/bootstrap/dist.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2222,8 +2222,8 @@ impl Step for Lldb {
22222222
}
22232223
}
22242224

2225-
// The lldb scripts might be installed in lib/python$version
2226-
// or in lib64/python$version. If lib64 exists, use it;
2225+
// The lldb scripts might be installed in `lib/python$version`
2226+
// or in `lib64/python$version`. If lib64 exists, use it;
22272227
// otherwise lib.
22282228
let libdir = builder.llvm_out(target).join("lib64");
22292229
let (libdir, libdir_name) = if libdir.exists() {

src/bootstrap/doc.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,14 @@ impl Step for Test {
567567
compiler
568568
};
569569

570-
// Build libstd docs so that we generate relative links
570+
// Build libstd docs so that we generate relative links.
571571
builder.ensure(Std { stage, target });
572572

573573
builder.ensure(compile::Test { compiler, target });
574574
let out_dir = builder.stage_out(compiler, Mode::Test)
575575
.join(target).join("doc");
576576

577-
// See docs in std above for why we symlink
577+
// See docs in std above for why we symlink.
578578
let my_out = builder.crate_doc_out(target);
579579
t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
580580

@@ -633,14 +633,14 @@ impl Step for WhitelistedRustc {
633633
compiler
634634
};
635635

636-
// Build libstd docs so that we generate relative links
636+
// Build libstd docs so that we generate relative links.
637637
builder.ensure(Std { stage, target });
638638

639639
builder.ensure(compile::Rustc { compiler, target });
640640
let out_dir = builder.stage_out(compiler, Mode::Rustc)
641641
.join(target).join("doc");
642642

643-
// See docs in std above for why we symlink
643+
// See docs in std above for why we symlink.
644644
let my_out = builder.crate_doc_out(target);
645645
t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
646646

@@ -737,7 +737,7 @@ impl Step for Rustc {
737737
for krate in &compiler_crates {
738738
// Create all crate output directories first to make sure rustdoc uses
739739
// relative links.
740-
// FIXME: Cargo should probably do this itself.
740+
// FIXME: cargo should probably do this itself.
741741
t!(fs::create_dir_all(out_dir.join(krate)));
742742
cargo.arg("-p").arg(krate);
743743
}
@@ -879,7 +879,7 @@ impl Step for ErrorIndex {
879879
index.arg("html");
880880
index.arg(out.join("error-index.html"));
881881

882-
// FIXME: shouldn't have to pass this env var
882+
// FIXME: shouldn't have to pass this env var.
883883
index.env("CFG_BUILD", &builder.config.build)
884884
.env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
885885

@@ -936,7 +936,7 @@ fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()>
936936
if m.file_type().is_dir() {
937937
fs::remove_dir_all(dst)?;
938938
} else {
939-
// handle directory junctions on windows by falling back to
939+
// Handle directory junctions on Windows by falling back to
940940
// `remove_dir`.
941941
fs::remove_file(dst).or_else(|_| {
942942
fs::remove_dir(dst)

src/bootstrap/flags.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub struct Flags {
3333
pub rustc_error_format: Option<String>,
3434
pub dry_run: bool,
3535

36-
// true => deny
36+
// `true` => deny
3737
pub warnings: Option<bool>,
3838
}
3939

@@ -139,8 +139,8 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"
139139

140140
// We can't use getopt to parse the options until we have completed specifying which
141141
// options are valid, but under the current implementation, some options are conditional on
142-
// the subcommand. Therefore we must manually identify the subcommand first, so that we can
143-
// complete the definition of the options. Then we can use the getopt::Matches object from
142+
// the subcommand. Therefore, we must manually identify the subcommand first, so that we can
143+
// complete the definition of the options. Then we can use the `getopt::Matches` object from
144144
// there on out.
145145
let subcommand = args.iter().find(|&s| {
146146
(s == "build")

0 commit comments

Comments
 (0)