Skip to content

Commit 7cd6f55

Browse files
committed
Auto merge of #110101 - JohnTitor:rollup-ol20aw7, r=JohnTitor
Rollup of 6 pull requests Successful merges: - #110058 (Remove `box_syntax` usage) - #110059 (ignore_git → omit_git_hash) - #110060 (Document that `&T` and `&mut T` are `Sync` if `T` is) - #110074 (Make the "codegen" profile of `config.toml` download and build llvm from source.) - #110086 (Add `max_line_length` to `.editorconfig`, matching rustfmt) - #110096 (Tweak tuple indexing suggestion) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0030465 + eed27ac commit 7cd6f55

File tree

17 files changed

+74
-43
lines changed

17 files changed

+74
-43
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ trim_trailing_whitespace = true
1111
insert_final_newline = true
1212
indent_style = space
1313
indent_size = 4
14+
max_line_length = 100
1415

1516
[*.md]
1617
# double whitespace at end of line

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,23 +2810,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
28102810
"cannot index into a value of type `{base_t}`",
28112811
);
28122812
// Try to give some advice about indexing tuples.
2813-
if let ty::Tuple(..) = base_t.kind() {
2813+
if let ty::Tuple(types) = base_t.kind() {
28142814
let mut needs_note = true;
28152815
// If the index is an integer, we can show the actual
28162816
// fixed expression:
2817-
if let ExprKind::Lit(ref lit) = idx.kind {
2818-
if let ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) = lit.node {
2819-
let snip = self.tcx.sess.source_map().span_to_snippet(base.span);
2820-
if let Ok(snip) = snip {
2821-
err.span_suggestion(
2822-
expr.span,
2823-
"to access tuple elements, use",
2824-
format!("{snip}.{i}"),
2825-
Applicability::MachineApplicable,
2826-
);
2827-
needs_note = false;
2828-
}
2817+
if let ExprKind::Lit(ref lit) = idx.kind
2818+
&& let ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) = lit.node
2819+
&& i < types.len().try_into().expect("expected tuple index to be < usize length")
2820+
{
2821+
let snip = self.tcx.sess.source_map().span_to_snippet(base.span);
2822+
if let Ok(snip) = snip {
2823+
err.span_suggestion(
2824+
expr.span,
2825+
"to access tuple elements, use",
2826+
format!("{snip}.{i}"),
2827+
Applicability::MachineApplicable,
2828+
);
2829+
needs_note = false;
28292830
}
2831+
} else if let ExprKind::Path(..) = idx.peel_borrows().kind {
2832+
err.span_label(idx.span, "cannot access tuple elements at a variable index");
28302833
}
28312834
if needs_note {
28322835
err.help(

config.example.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ changelog-seen = 2
585585
# Having the git information can cause a lot of rebuilds during development.
586586
#
587587
# FIXME(#76720): this can causes bugs if different compilers reuse the same metadata cache.
588-
#ignore-git = if rust.channel == "dev" { true } else { false }
588+
#omit-git-hash = if rust.channel == "dev" { true } else { false }
589589

590590
# Whether to create a source tarball by default when running `x dist`.
591591
#

library/core/src/primitive_docs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ mod prim_usize {}
13621362
/// * [`Hash`]
13631363
/// * [`ToSocketAddrs`]
13641364
/// * [`Send`] \(`&T` references also require <code>T: [Sync]</code>)
1365+
/// * [`Sync`]
13651366
///
13661367
/// [`std::fmt`]: fmt
13671368
/// [`Hash`]: hash::Hash

library/std/src/primitive_docs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ mod prim_usize {}
13621362
/// * [`Hash`]
13631363
/// * [`ToSocketAddrs`]
13641364
/// * [`Send`] \(`&T` references also require <code>T: [Sync]</code>)
1365+
/// * [`Sync`]
13651366
///
13661367
/// [`std::fmt`]: fmt
13671368
/// [`Hash`]: hash::Hash

src/bootstrap/channel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub enum GitInfo {
1919
#[default]
2020
Absent,
2121
/// This is a git repository.
22-
/// If the info should be used (`ignore_git` is false), this will be
22+
/// If the info should be used (`omit_git_hash` is false), this will be
2323
/// `Some`, otherwise it will be `None`.
2424
Present(Option<Info>),
2525
/// This is not a git repostory, but the info can be fetched from the
@@ -35,7 +35,7 @@ pub struct Info {
3535
}
3636

3737
impl GitInfo {
38-
pub fn new(ignore_git: bool, dir: &Path) -> GitInfo {
38+
pub fn new(omit_git_hash: bool, dir: &Path) -> GitInfo {
3939
// See if this even begins to look like a git dir
4040
if !dir.join(".git").exists() {
4141
match read_commit_info_file(dir) {
@@ -52,7 +52,7 @@ impl GitInfo {
5252

5353
// If we're ignoring the git info, we don't actually need to collect it, just make sure this
5454
// was a git repo in the first place.
55-
if ignore_git {
55+
if omit_git_hash {
5656
return GitInfo::Present(None);
5757
}
5858

src/bootstrap/config.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub struct Config {
7777
pub tools: Option<HashSet<String>>,
7878
pub sanitizers: bool,
7979
pub profiler: bool,
80-
pub ignore_git: bool,
80+
pub omit_git_hash: bool,
8181
pub exclude: Vec<TaskPath>,
8282
pub include_default_paths: bool,
8383
pub rustc_error_format: Option<String>,
@@ -764,7 +764,7 @@ define_config! {
764764
verbose_tests: Option<bool> = "verbose-tests",
765765
optimize_tests: Option<bool> = "optimize-tests",
766766
codegen_tests: Option<bool> = "codegen-tests",
767-
ignore_git: Option<bool> = "ignore-git",
767+
omit_git_hash: Option<bool> = "omit-git-hash",
768768
dist_src: Option<bool> = "dist-src",
769769
save_toolstates: Option<String> = "save-toolstates",
770770
codegen_backends: Option<Vec<String>> = "codegen-backends",
@@ -1097,7 +1097,7 @@ impl Config {
10971097
let mut debuginfo_level_tools = None;
10981098
let mut debuginfo_level_tests = None;
10991099
let mut optimize = None;
1100-
let mut ignore_git = None;
1100+
let mut omit_git_hash = None;
11011101

11021102
if let Some(rust) = toml.rust {
11031103
debug = rust.debug;
@@ -1118,7 +1118,7 @@ impl Config {
11181118
.map(|v| v.expect("invalid value for rust.split_debuginfo"))
11191119
.unwrap_or(SplitDebuginfo::default_for_platform(&config.build.triple));
11201120
optimize = rust.optimize;
1121-
ignore_git = rust.ignore_git;
1121+
omit_git_hash = rust.omit_git_hash;
11221122
config.rust_new_symbol_mangling = rust.new_symbol_mangling;
11231123
set(&mut config.rust_optimize_tests, rust.optimize_tests);
11241124
set(&mut config.codegen_tests, rust.codegen_tests);
@@ -1175,8 +1175,8 @@ impl Config {
11751175

11761176
// rust_info must be set before is_ci_llvm_available() is called.
11771177
let default = config.channel == "dev";
1178-
config.ignore_git = ignore_git.unwrap_or(default);
1179-
config.rust_info = GitInfo::new(config.ignore_git, &config.src);
1178+
config.omit_git_hash = omit_git_hash.unwrap_or(default);
1179+
config.rust_info = GitInfo::new(config.omit_git_hash, &config.src);
11801180

11811181
if let Some(llvm) = toml.llvm {
11821182
match llvm.ccache {

src/bootstrap/defaults/config.codegen.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ compiler-docs = true
99
assertions = true
1010
# enable warnings during the llvm compilation
1111
enable-warnings = true
12+
# build llvm from source
13+
download-ci-llvm = false
1214

1315
[rust]
1416
# This enables `RUSTC_LOG=debug`, avoiding confusing situations

src/bootstrap/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,14 @@ impl Build {
358358
#[cfg(not(unix))]
359359
let is_sudo = false;
360360

361-
let ignore_git = config.ignore_git;
362-
let rust_info = channel::GitInfo::new(ignore_git, &src);
363-
let cargo_info = channel::GitInfo::new(ignore_git, &src.join("src/tools/cargo"));
361+
let omit_git_hash = config.omit_git_hash;
362+
let rust_info = channel::GitInfo::new(omit_git_hash, &src);
363+
let cargo_info = channel::GitInfo::new(omit_git_hash, &src.join("src/tools/cargo"));
364364
let rust_analyzer_info =
365-
channel::GitInfo::new(ignore_git, &src.join("src/tools/rust-analyzer"));
366-
let clippy_info = channel::GitInfo::new(ignore_git, &src.join("src/tools/clippy"));
367-
let miri_info = channel::GitInfo::new(ignore_git, &src.join("src/tools/miri"));
368-
let rustfmt_info = channel::GitInfo::new(ignore_git, &src.join("src/tools/rustfmt"));
365+
channel::GitInfo::new(omit_git_hash, &src.join("src/tools/rust-analyzer"));
366+
let clippy_info = channel::GitInfo::new(omit_git_hash, &src.join("src/tools/clippy"));
367+
let miri_info = channel::GitInfo::new(omit_git_hash, &src.join("src/tools/miri"));
368+
let rustfmt_info = channel::GitInfo::new(omit_git_hash, &src.join("src/tools/rustfmt"));
369369

370370
// we always try to use git for LLVM builds
371371
let in_tree_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-project"));
@@ -1233,7 +1233,7 @@ impl Build {
12331233
match &self.config.channel[..] {
12341234
"stable" => num.to_string(),
12351235
"beta" => {
1236-
if self.rust_info().is_managed_git_subrepository() && !self.config.ignore_git {
1236+
if self.rust_info().is_managed_git_subrepository() && !self.config.omit_git_hash {
12371237
format!("{}-beta.{}", num, self.beta_prerelease_version())
12381238
} else {
12391239
format!("{}-beta", num)

src/bootstrap/tool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ pub fn prepare_tool_cargo(
320320
cargo.env("CFG_RELEASE_NUM", &builder.version);
321321
cargo.env("DOC_RUST_LANG_ORG_CHANNEL", builder.doc_rust_lang_org_channel());
322322

323-
let info = GitInfo::new(builder.config.ignore_git, &dir);
323+
let info = GitInfo::new(builder.config.omit_git_hash, &dir);
324324
if let Some(sha) = info.sha() {
325325
cargo.env("CFG_COMMIT_HASH", sha);
326326
}

0 commit comments

Comments
 (0)