Skip to content

Commit 2aae802

Browse files
committed
Auto merge of rust-lang#97468 - matthiaskrgr:rollup-8cu0hqr, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#95214 (Remove impossible panic note from `Vec::append`) - rust-lang#97411 (Print stderr consistently) - rust-lang#97453 (rename `TyKind` to `RegionKind` in comment in rustc_middle) - rust-lang#97457 (Add regression test for rust-lang#81899) - rust-lang#97458 (Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error) - rust-lang#97462 (Add more eslint rules) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents ebbcbfc + b37b735 commit 2aae802

File tree

19 files changed

+109
-47
lines changed

19 files changed

+109
-47
lines changed

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,9 @@ impl<'a> MethodDef<'a> {
10391039
let span = trait_.span;
10401040
let mut patterns = Vec::new();
10411041
for i in 0..self_args.len() {
1042-
let struct_path = cx.path(span, vec![type_ident]);
1042+
// We could use `type_ident` instead of `Self`, but in the case of a type parameter
1043+
// shadowing the struct name, that causes a second, unnecessary E0578 error. #97343
1044+
let struct_path = cx.path(span, vec![Ident::new(kw::SelfUpper, type_ident.span)]);
10431045
let (pat, ident_expr) = trait_.create_struct_pattern(
10441046
cx,
10451047
struct_path,

compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ impl ParamConst {
14691469
}
14701470
}
14711471

1472-
/// Use this rather than `TyKind`, whenever possible.
1472+
/// Use this rather than `RegionKind`, whenever possible.
14731473
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)]
14741474
#[rustc_pass_by_value]
14751475
pub struct Region<'tcx>(pub Interned<'tcx, RegionKind>);

library/alloc/src/vec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ impl<T, A: Allocator> Vec<T, A> {
17711771
///
17721772
/// # Panics
17731773
///
1774-
/// Panics if the number of elements in the vector overflows a `usize`.
1774+
/// Panics if the new capacity exceeds `isize::MAX` bytes.
17751775
///
17761776
/// # Examples
17771777
///

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl StepDescription {
227227

228228
fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
229229
if builder.config.exclude.iter().any(|e| pathset.has(&e.path, e.kind)) {
230-
eprintln!("Skipping {:?} because it is excluded", pathset);
230+
println!("Skipping {:?} because it is excluded", pathset);
231231
return true;
232232
}
233233

src/bootstrap/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ impl Config {
765765
{
766766
Ok(table) => table,
767767
Err(err) => {
768-
println!("failed to parse TOML configuration '{}': {}", file.display(), err);
768+
eprintln!("failed to parse TOML configuration '{}': {}", file.display(), err);
769769
process::exit(2);
770770
}
771771
}

src/bootstrap/flags.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
367367
}
368368
}
369369
if !pass_sanity_check {
370-
println!("{}\n", subcommand_help);
371-
println!(
370+
eprintln!("{}\n", subcommand_help);
371+
eprintln!(
372372
"Sorry, I couldn't figure out which subcommand you were trying to specify.\n\
373373
You may need to move some options to after the subcommand.\n"
374374
);
@@ -532,7 +532,7 @@ Arguments:
532532
Kind::Build => Subcommand::Build { paths },
533533
Kind::Check => {
534534
if matches.opt_present("all-targets") {
535-
eprintln!(
535+
println!(
536536
"Warning: --all-targets is now on by default and does not need to be passed explicitly."
537537
);
538538
}
@@ -606,7 +606,7 @@ Arguments:
606606
if matches.opt_str("keep-stage").is_some()
607607
|| matches.opt_str("keep-stage-std").is_some()
608608
{
609-
println!("--keep-stage not yet supported for x.py check");
609+
eprintln!("--keep-stage not yet supported for x.py check");
610610
process::exit(1);
611611
}
612612
}

src/bootstrap/format.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn format(build: &Build, check: bool, paths: &[PathBuf]) {
9696
entry.split(' ').nth(1).expect("every git status entry should list a path")
9797
});
9898
for untracked_path in untracked_paths {
99-
eprintln!("skip untracked path {} during rustfmt invocations", untracked_path);
99+
println!("skip untracked path {} during rustfmt invocations", untracked_path);
100100
// The leading `/` makes it an exact match against the
101101
// repository root, rather than a glob. Without that, if you
102102
// have `foo.rs` in the repository root it will also match
@@ -105,10 +105,10 @@ pub fn format(build: &Build, check: bool, paths: &[PathBuf]) {
105105
ignore_fmt.add(&format!("!/{}", untracked_path)).expect(&untracked_path);
106106
}
107107
} else {
108-
eprintln!("Not in git tree. Skipping git-aware format checks");
108+
println!("Not in git tree. Skipping git-aware format checks");
109109
}
110110
} else {
111-
eprintln!("Could not find usable git. Skipping git-aware format checks");
111+
println!("Could not find usable git. Skipping git-aware format checks");
112112
}
113113
let ignore_fmt = ignore_fmt.build().unwrap();
114114

src/bootstrap/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,9 @@ impl Build {
689689
// Check for postponed failures from `test --no-fail-fast`.
690690
let failures = self.delayed_failures.borrow();
691691
if failures.len() > 0 {
692-
println!("\n{} command(s) did not execute successfully:\n", failures.len());
692+
eprintln!("\n{} command(s) did not execute successfully:\n", failures.len());
693693
for failure in failures.iter() {
694-
println!(" - {}\n", failure);
694+
eprintln!(" - {}\n", failure);
695695
}
696696
process::exit(1);
697697
}

src/bootstrap/native.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ pub(crate) fn maybe_download_ci_llvm(builder: &Builder<'_>) {
138138
let llvm_sha = llvm_sha.trim();
139139

140140
if llvm_sha == "" {
141-
println!("error: could not find commit hash for downloading LLVM");
142-
println!("help: maybe your repository history is too shallow?");
143-
println!("help: consider disabling `download-ci-llvm`");
144-
println!("help: or fetch enough history to include one upstream commit");
141+
eprintln!("error: could not find commit hash for downloading LLVM");
142+
eprintln!("help: maybe your repository history is too shallow?");
143+
eprintln!("help: consider disabling `download-ci-llvm`");
144+
eprintln!("help: or fetch enough history to include one upstream commit");
145145
panic!();
146146
}
147147

src/bootstrap/setup.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ pub fn setup(config: &Config, profile: Profile) {
8585
let path = &config.config;
8686

8787
if path.exists() {
88-
println!(
88+
eprintln!(
8989
"error: you asked `x.py` to setup a new config file, but one already exists at `{}`",
9090
path.display()
9191
);
92-
println!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display());
93-
println!(
92+
eprintln!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display());
93+
eprintln!(
9494
"note: this will use the configuration in {}",
9595
profile.include_path(&config.src).display()
9696
);
@@ -115,7 +115,7 @@ pub fn setup(config: &Config, profile: Profile) {
115115
println!();
116116

117117
if !rustup_installed() && profile != Profile::User {
118-
println!("`rustup` is not installed; cannot link `stage1` toolchain");
118+
eprintln!("`rustup` is not installed; cannot link `stage1` toolchain");
119119
} else if stage_dir_exists(&stage_path[..]) {
120120
attempt_toolchain_link(&stage_path[..]);
121121
}
@@ -173,7 +173,7 @@ fn attempt_toolchain_link(stage_path: &str) {
173173
}
174174

175175
if !ensure_stage1_toolchain_placeholder_exists(stage_path) {
176-
println!(
176+
eprintln!(
177177
"Failed to create a template for stage 1 toolchain or confirm that it already exists"
178178
);
179179
return;
@@ -184,8 +184,8 @@ fn attempt_toolchain_link(stage_path: &str) {
184184
"Added `stage1` rustup toolchain; try `cargo +stage1 build` on a separate rust project to run a newly-built toolchain"
185185
);
186186
} else {
187-
println!("`rustup` failed to link stage 1 build to `stage1` toolchain");
188-
println!(
187+
eprintln!("`rustup` failed to link stage 1 build to `stage1` toolchain");
188+
eprintln!(
189189
"To manually link stage 1 build to `stage1` toolchain, run:\n
190190
`rustup toolchain link stage1 {}`",
191191
&stage_path
@@ -292,8 +292,8 @@ pub fn interactive_path() -> io::Result<Profile> {
292292
break match parse_with_abbrev(&input) {
293293
Ok(profile) => profile,
294294
Err(err) => {
295-
println!("error: {}", err);
296-
println!("note: press Ctrl+C to exit");
295+
eprintln!("error: {}", err);
296+
eprintln!("note: press Ctrl+C to exit");
297297
continue;
298298
}
299299
};
@@ -320,8 +320,8 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
320320
"y" | "yes" => true,
321321
"n" | "no" | "" => false,
322322
_ => {
323-
println!("error: unrecognized option '{}'", input.trim());
324-
println!("note: press Ctrl+C to exit");
323+
eprintln!("error: unrecognized option '{}'", input.trim());
324+
eprintln!("note: press Ctrl+C to exit");
325325
continue;
326326
}
327327
};
@@ -337,7 +337,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
337337
));
338338
let dst = git.join("hooks").join("pre-push");
339339
match fs::hard_link(src, &dst) {
340-
Err(e) => println!(
340+
Err(e) => eprintln!(
341341
"error: could not create hook {}: do you already have the git hook installed?\n{}",
342342
dst.display(),
343343
e

src/bootstrap/tool.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -152,43 +152,43 @@ impl Step for ToolBuild {
152152
});
153153

154154
if is_expected && !duplicates.is_empty() {
155-
println!(
155+
eprintln!(
156156
"duplicate artifacts found when compiling a tool, this \
157157
typically means that something was recompiled because \
158158
a transitive dependency has different features activated \
159159
than in a previous build:\n"
160160
);
161-
println!(
161+
eprintln!(
162162
"the following dependencies are duplicated although they \
163163
have the same features enabled:"
164164
);
165165
let (same, different): (Vec<_>, Vec<_>) =
166166
duplicates.into_iter().partition(|(_, cur, prev)| cur.2 == prev.2);
167167
for (id, cur, prev) in same {
168-
println!(" {}", id);
168+
eprintln!(" {}", id);
169169
// same features
170-
println!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1);
170+
eprintln!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1);
171171
}
172-
println!("the following dependencies have different features:");
172+
eprintln!("the following dependencies have different features:");
173173
for (id, cur, prev) in different {
174-
println!(" {}", id);
174+
eprintln!(" {}", id);
175175
let cur_features: HashSet<_> = cur.2.into_iter().collect();
176176
let prev_features: HashSet<_> = prev.2.into_iter().collect();
177-
println!(
177+
eprintln!(
178178
" `{}` additionally enabled features {:?} at {:?}",
179179
cur.0,
180180
&cur_features - &prev_features,
181181
cur.1
182182
);
183-
println!(
183+
eprintln!(
184184
" `{}` additionally enabled features {:?} at {:?}",
185185
prev.0,
186186
&prev_features - &cur_features,
187187
prev.1
188188
);
189189
}
190-
println!();
191-
println!(
190+
eprintln!();
191+
eprintln!(
192192
"to fix this you will probably want to edit the local \
193193
src/tools/rustc-workspace-hack/Cargo.toml crate, as \
194194
that will update the dependency graph to ensure that \

src/bootstrap/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool {
455455
}
456456

457457
fn fail(s: &str) -> ! {
458-
println!("\n\n{}\n\n", s);
458+
eprintln!("\n\n{}\n\n", s);
459459
std::process::exit(1);
460460
}
461461

src/librustdoc/html/static/.eslintrc.js

+9
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,14 @@ module.exports = {
5454
"comma-style": ["error", "last"],
5555
"max-len": ["error", { "code": 100, "tabWidth": 4 }],
5656
"eol-last": ["error", "always"],
57+
"arrow-parens": ["error", "as-needed"],
58+
"no-unused-vars": [
59+
"error",
60+
{
61+
"argsIgnorePattern": "^_",
62+
"varsIgnorePattern": "^_"
63+
}
64+
],
65+
"eqeqeq": "error",
5766
}
5867
};

src/librustdoc/html/static/js/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ function showMain() {
9797
//
9898
// So I guess you could say things are getting pretty interoperable.
9999
function getVirtualKey(ev) {
100-
if ("key" in ev && typeof ev.key != "undefined") {
100+
if ("key" in ev && typeof ev.key !== "undefined") {
101101
return ev.key;
102102
}
103103

104104
const c = ev.charCode || ev.keyCode;
105-
if (c == 27) {
105+
if (c === 27) {
106106
return "Escape";
107107
}
108108
return String.fromCharCode(c);

src/librustdoc/html/static/js/search.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function printTab(nb) {
7070
});
7171
if (foundCurrentTab && foundCurrentResultSet) {
7272
searchState.currentTab = nb;
73-
} else if (nb != 0) {
73+
} else if (nb !== 0) {
7474
printTab(0);
7575
}
7676
}
@@ -200,7 +200,7 @@ function initSearch(rawSearchIndex) {
200200
* @return {boolean}
201201
*/
202202
function isPathStart(parserState) {
203-
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "::";
203+
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) === "::";
204204
}
205205

206206
/**
@@ -211,7 +211,7 @@ function initSearch(rawSearchIndex) {
211211
* @return {boolean}
212212
*/
213213
function isReturnArrow(parserState) {
214-
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "->";
214+
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) === "->";
215215
}
216216

217217
/**
@@ -1726,7 +1726,7 @@ function initSearch(rawSearchIndex) {
17261726
crates = " in <select id=\"crate-search\"><option value=\"All crates\">" +
17271727
"All crates</option>";
17281728
for (const c of window.ALL_CRATES) {
1729-
crates += `<option value="${c}" ${c == filterCrates && "selected"}>${c}</option>`;
1729+
crates += `<option value="${c}" ${c === filterCrates && "selected"}>${c}</option>`;
17301730
}
17311731
crates += "</select>";
17321732
}

src/test/ui/borrowck/issue-81899.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Regression test for #81899.
2+
// The `panic!()` below is important to trigger the fixed ICE.
3+
4+
const _CONST: &[u8] = &f(&[], |_| {});
5+
6+
const fn f<F>(_: &[u8], _: F) -> &[u8]
7+
where
8+
F: FnMut(&u8),
9+
{
10+
panic!() //~ ERROR: evaluation of constant value failed
11+
}
12+
13+
fn main() {}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0080]: evaluation of constant value failed
2+
--> $DIR/issue-81899.rs:10:5
3+
|
4+
LL | const _CONST: &[u8] = &f(&[], |_| {});
5+
| -------------- inside `_CONST` at $DIR/issue-81899.rs:4:24
6+
...
7+
LL | panic!()
8+
| ^^^^^^^^
9+
| |
10+
| the evaluated program panicked at 'explicit panic', $DIR/issue-81899.rs:10:5
11+
| inside `f::<[closure@$DIR/issue-81899.rs:4:31: 4:37]>` at $SRC_DIR/std/src/panic.rs:LL:COL
12+
|
13+
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0080`.

src/test/ui/derives/issue-97343.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use std::fmt::Debug;
2+
3+
#[derive(Debug)]
4+
pub struct Irrelevant<Irrelevant> { //~ ERROR type arguments are not allowed for this type
5+
irrelevant: Irrelevant,
6+
}
7+
8+
fn main() {}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0109]: type arguments are not allowed for this type
2+
--> $DIR/issue-97343.rs:4:23
3+
|
4+
LL | #[derive(Debug)]
5+
| ----- in this derive macro expansion
6+
LL | pub struct Irrelevant<Irrelevant> {
7+
| ^^^^^^^^^^ type argument not allowed
8+
|
9+
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0109`.

0 commit comments

Comments
 (0)