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

+1
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

+16-13
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

+1-1
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

+1
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

+1
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

+3-3
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

+6-6
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

+2
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

+8-8
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

+1-1
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
}

src/ci/docker/host-x86_64/x86_64-gnu-distcheck/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ RUN sh /scripts/sccache.sh
2424
# We are disabling CI LLVM since distcheck is an offline build.
2525
ENV NO_DOWNLOAD_CI_LLVM 1
2626

27-
ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu --set rust.ignore-git=false
27+
ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu --set rust.omit-git-hash=false
2828
ENV SCRIPT python3 ../x.py --stage 2 test distcheck
2929
ENV DIST_SRC 1

src/doc/unstable-book/src/language-features/lang-items.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,26 @@ and one for deallocation. A freestanding program that uses the `Box`
1616
sugar for dynamic allocations via `malloc` and `free`:
1717

1818
```rust,ignore (libc-is-finicky)
19-
#![feature(lang_items, box_syntax, start, libc, core_intrinsics, rustc_private)]
19+
#![feature(lang_items, start, libc, core_intrinsics, rustc_private, rustc_attrs)]
2020
#![no_std]
2121
use core::intrinsics;
2222
use core::panic::PanicInfo;
23+
use core::ptr::NonNull;
2324
2425
extern crate libc;
2526
26-
struct Unique<T>(*mut T);
27+
struct Unique<T>(NonNull<T>);
2728
2829
#[lang = "owned_box"]
2930
pub struct Box<T>(Unique<T>);
3031
32+
impl<T> Box<T> {
33+
pub fn new(x: T) -> Self {
34+
#[rustc_box]
35+
Box::new(x)
36+
}
37+
}
38+
3139
#[lang = "exchange_malloc"]
3240
unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
3341
let p = libc::malloc(size as libc::size_t) as *mut u8;
@@ -47,13 +55,13 @@ unsafe fn box_free<T: ?Sized>(ptr: *mut T) {
4755
4856
#[start]
4957
fn main(_argc: isize, _argv: *const *const u8) -> isize {
50-
let _x = box 1;
58+
let _x = Box::new(1);
5159
5260
0
5361
}
5462
5563
#[lang = "eh_personality"] extern fn rust_eh_personality() {}
56-
#[lang = "panic_impl"] extern fn rust_begin_panic(info: &PanicInfo) -> ! { unsafe { intrinsics::abort() } }
64+
#[lang = "panic_impl"] extern fn rust_begin_panic(_info: &PanicInfo) -> ! { intrinsics::abort() }
5765
#[no_mangle] pub extern fn rust_eh_register_frames () {}
5866
#[no_mangle] pub extern fn rust_eh_unregister_frames () {}
5967
```

src/doc/unstable-book/src/language-features/plugin.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ additional checks for code style, safety, etc. Now let's write a plugin
3737
that warns about any item named `lintme`.
3838

3939
```rust,ignore (requires-stage-2)
40-
#![feature(box_syntax, rustc_private)]
40+
#![feature(rustc_private)]
4141
4242
extern crate rustc_ast;
4343
@@ -68,7 +68,7 @@ impl EarlyLintPass for Pass {
6868
#[no_mangle]
6969
fn __rustc_plugin_registrar(reg: &mut Registry) {
7070
reg.lint_store.register_lints(&[&TEST_LINT]);
71-
reg.lint_store.register_early_pass(|| box Pass);
71+
reg.lint_store.register_early_pass(|| Box::new(Pass));
7272
}
7373
```
7474

tests/ui/index_message.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
fn main() {
2-
let z = ();
3-
let _ = z[0]; //~ ERROR cannot index into a value of type `()`
2+
let z = (10,);
3+
let _ = z[0]; //~ ERROR cannot index into a value of type `({integer},)`
44
}

tests/ui/index_message.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0608]: cannot index into a value of type `()`
1+
error[E0608]: cannot index into a value of type `({integer},)`
22
--> $DIR/index_message.rs:3:13
33
|
44
LL | let _ = z[0];

tests/ui/issues/issue-27842.rs

+5
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ fn main() {
88
let i = 0_usize;
99
let _ = tup[i];
1010
//~^ ERROR cannot index into a value of type
11+
12+
// the case where the index is out of bounds
13+
let tup = (10,);
14+
let _ = tup[3];
15+
//~^ ERROR cannot index into a value of type
1116
}

tests/ui/issues/issue-27842.stderr

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,20 @@ error[E0608]: cannot index into a value of type `({integer}, {integer}, {integer
88
--> $DIR/issue-27842.rs:9:13
99
|
1010
LL | let _ = tup[i];
11+
| ^^^^-^
12+
| |
13+
| cannot access tuple elements at a variable index
14+
|
15+
= help: to access tuple elements, use tuple indexing syntax (e.g., `tuple.0`)
16+
17+
error[E0608]: cannot index into a value of type `({integer},)`
18+
--> $DIR/issue-27842.rs:14:13
19+
|
20+
LL | let _ = tup[3];
1121
| ^^^^^^
1222
|
1323
= help: to access tuple elements, use tuple indexing syntax (e.g., `tuple.0`)
1424

15-
error: aborting due to 2 previous errors
25+
error: aborting due to 3 previous errors
1626

1727
For more information about this error, try `rustc --explain E0608`.

0 commit comments

Comments
 (0)