From 4123d33fbd66fcf2f13e0fcb3543fd518ee98f42 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Tue, 22 Mar 2022 21:07:43 +0100 Subject: [PATCH 01/10] Remove impossible panic note from `Vec::append` Neither the number of elements in a vector can overflow a `usize`, nor can the amount of elements in two vectors. --- library/alloc/src/vec/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 5131168db0c82..6c730ab3c8688 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -1767,7 +1767,7 @@ impl Vec { /// /// # Panics /// - /// Panics if the number of elements in the vector overflows a `usize`. + /// Panics if the new capacity exceeds `isize::MAX` bytes. /// /// # Examples /// From d25f64ae993dfdd6a55b912fa1d46a6085205d2b Mon Sep 17 00:00:00 2001 From: Raiyan Date: Wed, 25 May 2022 22:01:55 -0400 Subject: [PATCH 02/10] feat: refactored bootstrap files to use stderr consistently --- src/bootstrap/builder.rs | 2 +- src/bootstrap/compile.rs | 2 +- src/bootstrap/config.rs | 2 +- src/bootstrap/dist.rs | 2 +- src/bootstrap/flags.rs | 8 ++++---- src/bootstrap/format.rs | 6 +++--- src/bootstrap/lib.rs | 4 ++-- src/bootstrap/native.rs | 8 ++++---- src/bootstrap/setup.rs | 24 ++++++++++++------------ src/bootstrap/tool.rs | 20 ++++++++++---------- src/bootstrap/util.rs | 2 +- 11 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 2224bf5f66e90..0b0e53f39c860 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -227,7 +227,7 @@ impl StepDescription { fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool { if builder.config.exclude.iter().any(|e| pathset.has(&e.path, e.kind)) { - eprintln!("Skipping {:?} because it is excluded", pathset); + println!("Skipping {:?} because it is excluded", pathset); return true; } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 53933e4cd7d20..a00877b297051 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -1426,7 +1426,7 @@ pub fn stream_cargo( cb(msg) } // If this was informational, just print it out and continue - Err(_) => println!("{}", line), + Err(_) => eprintln!("{}", line), } } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index e39c9fa1c5a6d..342f1d4d505ea 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -766,7 +766,7 @@ impl Config { { Ok(table) => table, Err(err) => { - println!("failed to parse TOML configuration '{}': {}", file.display(), err); + eprintln!("failed to parse TOML configuration '{}': {}", file.display(), err); process::exit(2); } } diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index d37a59426f895..9684332e6fbb6 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -37,7 +37,7 @@ pub fn tmpdir(builder: &Builder<'_>) -> PathBuf { fn missing_tool(tool_name: &str, skip: bool) { if skip { - println!("Unable to build {}, skipping dist", tool_name) + eprintln!("Unable to build {}, skipping dist", tool_name) } else { panic!("Unable to build {}", tool_name) } diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 58571ea129c19..8ffd559fb89bf 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -365,8 +365,8 @@ To learn more about a subcommand, run `./x.py -h`", } } if !pass_sanity_check { - println!("{}\n", subcommand_help); - println!( + eprintln!("{}\n", subcommand_help); + eprintln!( "Sorry, I couldn't figure out which subcommand you were trying to specify.\n\ You may need to move some options to after the subcommand.\n" ); @@ -530,7 +530,7 @@ Arguments: Kind::Build => Subcommand::Build { paths }, Kind::Check => { if matches.opt_present("all-targets") { - eprintln!( + println!( "Warning: --all-targets is now on by default and does not need to be passed explicitly." ); } @@ -603,7 +603,7 @@ Arguments: if matches.opt_str("keep-stage").is_some() || matches.opt_str("keep-stage-std").is_some() { - println!("--keep-stage not yet supported for x.py check"); + eprintln!("--keep-stage not yet supported for x.py check"); process::exit(1); } } diff --git a/src/bootstrap/format.rs b/src/bootstrap/format.rs index 10b846e6db208..d1a450f1bff8e 100644 --- a/src/bootstrap/format.rs +++ b/src/bootstrap/format.rs @@ -96,7 +96,7 @@ pub fn format(build: &Build, check: bool, paths: &[PathBuf]) { entry.split(' ').nth(1).expect("every git status entry should list a path") }); for untracked_path in untracked_paths { - eprintln!("skip untracked path {} during rustfmt invocations", untracked_path); + println!("skip untracked path {} during rustfmt invocations", untracked_path); // The leading `/` makes it an exact match against the // repository root, rather than a glob. Without that, if you // have `foo.rs` in the repository root it will also match @@ -105,10 +105,10 @@ pub fn format(build: &Build, check: bool, paths: &[PathBuf]) { ignore_fmt.add(&format!("!/{}", untracked_path)).expect(&untracked_path); } } else { - eprintln!("Not in git tree. Skipping git-aware format checks"); + println!("Not in git tree. Skipping git-aware format checks"); } } else { - eprintln!("Could not find usable git. Skipping git-aware format checks"); + println!("Could not find usable git. Skipping git-aware format checks"); } let ignore_fmt = ignore_fmt.build().unwrap(); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index b4b973b42479e..188b80d8b3ae8 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -686,9 +686,9 @@ impl Build { // Check for postponed failures from `test --no-fail-fast`. let failures = self.delayed_failures.borrow(); if failures.len() > 0 { - println!("\n{} command(s) did not execute successfully:\n", failures.len()); + eprintln!("\n{} command(s) did not execute successfully:\n", failures.len()); for failure in failures.iter() { - println!(" - {}\n", failure); + eprintln!(" - {}\n", failure); } process::exit(1); } diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 64e25f803b27f..ab8d36afde721 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -138,10 +138,10 @@ pub(crate) fn maybe_download_ci_llvm(builder: &Builder<'_>) { let llvm_sha = llvm_sha.trim(); if llvm_sha == "" { - println!("error: could not find commit hash for downloading LLVM"); - println!("help: maybe your repository history is too shallow?"); - println!("help: consider disabling `download-ci-llvm`"); - println!("help: or fetch enough history to include one upstream commit"); + eprintln!("error: could not find commit hash for downloading LLVM"); + eprintln!("help: maybe your repository history is too shallow?"); + eprintln!("help: consider disabling `download-ci-llvm`"); + eprintln!("help: or fetch enough history to include one upstream commit"); panic!(); } diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs index b730730854f14..82f55440ce50c 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -85,12 +85,12 @@ pub fn setup(config: &Config, profile: Profile) { let path = &config.config; if path.exists() { - println!( + eprintln!( "error: you asked `x.py` to setup a new config file, but one already exists at `{}`", path.display() ); - println!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display()); - println!( + eprintln!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display()); + eprintln!( "note: this will use the configuration in {}", profile.include_path(&config.src).display() ); @@ -115,7 +115,7 @@ pub fn setup(config: &Config, profile: Profile) { println!(); if !rustup_installed() && profile != Profile::User { - println!("`rustup` is not installed; cannot link `stage1` toolchain"); + eprintln!("`rustup` is not installed; cannot link `stage1` toolchain"); } else if stage_dir_exists(&stage_path[..]) { attempt_toolchain_link(&stage_path[..]); } @@ -173,7 +173,7 @@ fn attempt_toolchain_link(stage_path: &str) { } if !ensure_stage1_toolchain_placeholder_exists(stage_path) { - println!( + eprintln!( "Failed to create a template for stage 1 toolchain or confirm that it already exists" ); return; @@ -184,8 +184,8 @@ fn attempt_toolchain_link(stage_path: &str) { "Added `stage1` rustup toolchain; try `cargo +stage1 build` on a separate rust project to run a newly-built toolchain" ); } else { - println!("`rustup` failed to link stage 1 build to `stage1` toolchain"); - println!( + eprintln!("`rustup` failed to link stage 1 build to `stage1` toolchain"); + eprintln!( "To manually link stage 1 build to `stage1` toolchain, run:\n `rustup toolchain link stage1 {}`", &stage_path @@ -292,8 +292,8 @@ pub fn interactive_path() -> io::Result { break match parse_with_abbrev(&input) { Ok(profile) => profile, Err(err) => { - println!("error: {}", err); - println!("note: press Ctrl+C to exit"); + eprintln!("error: {}", err); + eprintln!("note: press Ctrl+C to exit"); continue; } }; @@ -320,8 +320,8 @@ undesirable, simply delete the `pre-push` file from .git/hooks." "y" | "yes" => true, "n" | "no" | "" => false, _ => { - println!("error: unrecognized option '{}'", input.trim()); - println!("note: press Ctrl+C to exit"); + eprintln!("error: unrecognized option '{}'", input.trim()); + eprintln!("note: press Ctrl+C to exit"); continue; } }; @@ -337,7 +337,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks." )); let dst = git.join("hooks").join("pre-push"); match fs::hard_link(src, &dst) { - Err(e) => println!( + Err(e) => eprintln!( "error: could not create hook {}: do you already have the git hook installed?\n{}", dst.display(), e diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index fc1c2f04fabff..9dd4533c6d2d6 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -152,43 +152,43 @@ impl Step for ToolBuild { }); if is_expected && !duplicates.is_empty() { - println!( + eprintln!( "duplicate artifacts found when compiling a tool, this \ typically means that something was recompiled because \ a transitive dependency has different features activated \ than in a previous build:\n" ); - println!( + eprintln!( "the following dependencies are duplicated although they \ have the same features enabled:" ); let (same, different): (Vec<_>, Vec<_>) = duplicates.into_iter().partition(|(_, cur, prev)| cur.2 == prev.2); for (id, cur, prev) in same { - println!(" {}", id); + eprintln!(" {}", id); // same features - println!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1); + eprintln!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1); } - println!("the following dependencies have different features:"); + eprintln!("the following dependencies have different features:"); for (id, cur, prev) in different { - println!(" {}", id); + eprintln!(" {}", id); let cur_features: HashSet<_> = cur.2.into_iter().collect(); let prev_features: HashSet<_> = prev.2.into_iter().collect(); - println!( + eprintln!( " `{}` additionally enabled features {:?} at {:?}", cur.0, &cur_features - &prev_features, cur.1 ); - println!( + eprintln!( " `{}` additionally enabled features {:?} at {:?}", prev.0, &prev_features - &cur_features, prev.1 ); } - println!(); - println!( + eprintln!(); + eprintln!( "to fix this you will probably want to edit the local \ src/tools/rustc-workspace-hack/Cargo.toml crate, as \ that will update the dependency graph to ensure that \ diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index b78ca3712bd45..51d9a83527bff 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -437,7 +437,7 @@ fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool { } fn fail(s: &str) -> ! { - println!("\n\n{}\n\n", s); + eprintln!("\n\n{}\n\n", s); std::process::exit(1); } From 392077df24785f2539c4c994d0ba6563a1ba6fb3 Mon Sep 17 00:00:00 2001 From: Raiyan Date: Wed, 25 May 2022 22:12:50 -0400 Subject: [PATCH 03/10] fix: undo old changes --- src/bootstrap/compile.rs | 2 +- src/bootstrap/dist.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index a00877b297051..53933e4cd7d20 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -1426,7 +1426,7 @@ pub fn stream_cargo( cb(msg) } // If this was informational, just print it out and continue - Err(_) => eprintln!("{}", line), + Err(_) => println!("{}", line), } } diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 9684332e6fbb6..d37a59426f895 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -37,7 +37,7 @@ pub fn tmpdir(builder: &Builder<'_>) -> PathBuf { fn missing_tool(tool_name: &str, skip: bool) { if skip { - eprintln!("Unable to build {}, skipping dist", tool_name) + println!("Unable to build {}, skipping dist", tool_name) } else { panic!("Unable to build {}", tool_name) } From 4781246a2c53d5ada354139861234e0a8e391133 Mon Sep 17 00:00:00 2001 From: lcnr Date: Fri, 27 May 2022 16:36:59 +0200 Subject: [PATCH 04/10] fix comment --- compiler/rustc_middle/src/ty/sty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index a973a5c9b5053..2dabc69638841 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1469,7 +1469,7 @@ impl ParamConst { } } -/// Use this rather than `TyKind`, whenever possible. +/// Use this rather than `RegionKind`, whenever possible. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)] #[rustc_pass_by_value] pub struct Region<'tcx>(pub Interned<'tcx, RegionKind>); From 6ba9ed86c37d4e8befe50474c619b24891f3c6f2 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 28 May 2022 01:32:15 +0900 Subject: [PATCH 05/10] Add regression test for #81899 --- src/test/ui/borrowck/issue-81899.rs | 13 +++++++++++++ src/test/ui/borrowck/issue-81899.stderr | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/test/ui/borrowck/issue-81899.rs create mode 100644 src/test/ui/borrowck/issue-81899.stderr diff --git a/src/test/ui/borrowck/issue-81899.rs b/src/test/ui/borrowck/issue-81899.rs new file mode 100644 index 0000000000000..356517745ffcd --- /dev/null +++ b/src/test/ui/borrowck/issue-81899.rs @@ -0,0 +1,13 @@ +// Regression test for #81899. +// The `panic!()` below is important to trigger the fixed ICE. + +const _CONST: &[u8] = &f(&[], |_| {}); + +const fn f(_: &[u8], _: F) -> &[u8] +where + F: FnMut(&u8), +{ + panic!() //~ ERROR: evaluation of constant value failed +} + +fn main() {} diff --git a/src/test/ui/borrowck/issue-81899.stderr b/src/test/ui/borrowck/issue-81899.stderr new file mode 100644 index 0000000000000..59bf00d0012cd --- /dev/null +++ b/src/test/ui/borrowck/issue-81899.stderr @@ -0,0 +1,17 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/issue-81899.rs:10:5 + | +LL | const _CONST: &[u8] = &f(&[], |_| {}); + | -------------- inside `_CONST` at $DIR/issue-81899.rs:4:24 +... +LL | panic!() + | ^^^^^^^^ + | | + | the evaluated program panicked at 'explicit panic', $DIR/issue-81899.rs:10:5 + | inside `f::<[closure@$DIR/issue-81899.rs:4:31: 4:37]>` at $SRC_DIR/std/src/panic.rs:LL:COL + | + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. From d21bc6562a03917073bd1fd4f65f447cf5a92aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 27 May 2022 10:47:05 -0700 Subject: [PATCH 06/10] Add test for #97343 --- src/test/ui/derives/issue-97343.rs | 8 ++++++++ src/test/ui/derives/issue-97343.stderr | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/test/ui/derives/issue-97343.rs create mode 100644 src/test/ui/derives/issue-97343.stderr diff --git a/src/test/ui/derives/issue-97343.rs b/src/test/ui/derives/issue-97343.rs new file mode 100644 index 0000000000000..6c5626f4796ad --- /dev/null +++ b/src/test/ui/derives/issue-97343.rs @@ -0,0 +1,8 @@ +use std::fmt::Debug; + +#[derive(Debug)] //~ ERROR expected struct, variant or union type, found type parameter `Irrelevant` +pub struct Irrelevant { //~ ERROR type arguments are not allowed for this type + irrelevant: Irrelevant, +} + +fn main() {} diff --git a/src/test/ui/derives/issue-97343.stderr b/src/test/ui/derives/issue-97343.stderr new file mode 100644 index 0000000000000..418178b01b910 --- /dev/null +++ b/src/test/ui/derives/issue-97343.stderr @@ -0,0 +1,22 @@ +error[E0574]: expected struct, variant or union type, found type parameter `Irrelevant` + --> $DIR/issue-97343.rs:3:10 + | +LL | #[derive(Debug)] + | ^^^^^ not a struct, variant or union type + | + = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0109]: type arguments are not allowed for this type + --> $DIR/issue-97343.rs:4:23 + | +LL | #[derive(Debug)] + | ----- in this derive macro expansion +LL | pub struct Irrelevant { + | ^^^^^^^^^^ type argument not allowed + | + = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0109, E0574. +For more information about an error, try `rustc --explain E0109`. From f2a1b7b7724fef2876094f9b4a6c356345d7dd67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 27 May 2022 10:48:12 -0700 Subject: [PATCH 07/10] Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error #97343 --- .../src/deriving/generic/mod.rs | 4 +++- src/test/ui/derives/issue-97343.rs | 2 +- src/test/ui/derives/issue-97343.stderr | 13 ++----------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index 0832fdad8b871..53369afae278c 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -1039,7 +1039,9 @@ impl<'a> MethodDef<'a> { let span = trait_.span; let mut patterns = Vec::new(); for i in 0..self_args.len() { - let struct_path = cx.path(span, vec![type_ident]); + // We could use `type_ident` instead of `Self`, but in the case of a type parameter + // shadowing the struct name, that causes a second, unnecessary E0578 error. #97343 + let struct_path = cx.path(span, vec![Ident::new(kw::SelfUpper, type_ident.span)]); let (pat, ident_expr) = trait_.create_struct_pattern( cx, struct_path, diff --git a/src/test/ui/derives/issue-97343.rs b/src/test/ui/derives/issue-97343.rs index 6c5626f4796ad..adec6c7a5c5a3 100644 --- a/src/test/ui/derives/issue-97343.rs +++ b/src/test/ui/derives/issue-97343.rs @@ -1,6 +1,6 @@ use std::fmt::Debug; -#[derive(Debug)] //~ ERROR expected struct, variant or union type, found type parameter `Irrelevant` +#[derive(Debug)] pub struct Irrelevant { //~ ERROR type arguments are not allowed for this type irrelevant: Irrelevant, } diff --git a/src/test/ui/derives/issue-97343.stderr b/src/test/ui/derives/issue-97343.stderr index 418178b01b910..eedd54f1e9f0c 100644 --- a/src/test/ui/derives/issue-97343.stderr +++ b/src/test/ui/derives/issue-97343.stderr @@ -1,11 +1,3 @@ -error[E0574]: expected struct, variant or union type, found type parameter `Irrelevant` - --> $DIR/issue-97343.rs:3:10 - | -LL | #[derive(Debug)] - | ^^^^^ not a struct, variant or union type - | - = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) - error[E0109]: type arguments are not allowed for this type --> $DIR/issue-97343.rs:4:23 | @@ -16,7 +8,6 @@ LL | pub struct Irrelevant { | = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0109, E0574. -For more information about an error, try `rustc --explain E0109`. +For more information about this error, try `rustc --explain E0109`. From b7d6a429b5abd50fa62e50c72117a8387e43c032 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 May 2022 22:21:41 +0200 Subject: [PATCH 08/10] Add "arrow-parens" eslint rule --- src/librustdoc/html/static/.eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index 7afd09b34d30d..3ad7f4d9e064d 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -54,5 +54,6 @@ module.exports = { "comma-style": ["error", "last"], "max-len": ["error", { "code": 100, "tabWidth": 4 }], "eol-last": ["error", "always"], + "arrow-parens": ["error", "as-needed"], } }; From 3741a88ad7d6d8b636e997ec7ebe6739718ebddf Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 May 2022 22:22:22 +0200 Subject: [PATCH 09/10] Add "no-unused-vars" eslint rule --- src/librustdoc/html/static/.eslintrc.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index 3ad7f4d9e064d..5a79610b73633 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -55,5 +55,12 @@ module.exports = { "max-len": ["error", { "code": 100, "tabWidth": 4 }], "eol-last": ["error", "always"], "arrow-parens": ["error", "as-needed"], + "no-unused-vars": [ + "error", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_" + } + ], } }; From 334f12c28e0aec80f29b43ad289362c484269a8d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 May 2022 22:30:19 +0200 Subject: [PATCH 10/10] Add "eqeqeq" eslint rule --- src/librustdoc/html/static/.eslintrc.js | 1 + src/librustdoc/html/static/js/main.js | 4 ++-- src/librustdoc/html/static/js/search.js | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index 5a79610b73633..997def1657fa0 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -62,5 +62,6 @@ module.exports = { "varsIgnorePattern": "^_" } ], + "eqeqeq": "error", } }; diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 0fbc2d0e33c90..548aeedd03384 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -97,12 +97,12 @@ function showMain() { // // So I guess you could say things are getting pretty interoperable. function getVirtualKey(ev) { - if ("key" in ev && typeof ev.key != "undefined") { + if ("key" in ev && typeof ev.key !== "undefined") { return ev.key; } const c = ev.charCode || ev.keyCode; - if (c == 27) { + if (c === 27) { return "Escape"; } return String.fromCharCode(c); diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index c784d69dcd66f..c726aeeff4729 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -70,7 +70,7 @@ function printTab(nb) { }); if (foundCurrentTab && foundCurrentResultSet) { searchState.currentTab = nb; - } else if (nb != 0) { + } else if (nb !== 0) { printTab(0); } } @@ -200,7 +200,7 @@ function initSearch(rawSearchIndex) { * @return {boolean} */ function isPathStart(parserState) { - return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "::"; + return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) === "::"; } /** @@ -211,7 +211,7 @@ function initSearch(rawSearchIndex) { * @return {boolean} */ function isReturnArrow(parserState) { - return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "->"; + return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) === "->"; } /** @@ -1726,7 +1726,7 @@ function initSearch(rawSearchIndex) { crates = " in "; }