about summary refs log tree commit diff
path: root/clippy_dev
diff options
context:
space:
mode:
authorPhilipp Krones <hello@philkrones.com>2025-04-17 18:36:59 +0200
committerPhilipp Krones <hello@philkrones.com>2025-04-17 18:36:59 +0200
commitde90fa42dd6dfaf029a689d8d1a19e76af461163 (patch)
tree127036684c14c0d80b7ea412bc0b78ace03d7478 /clippy_dev
parent4784074753159d55ff0ba7cbe22d343dd0999b5f (diff)
parent26f43ff346e911d8c5fc66e0fd9e2058ef82ca6e (diff)
downloadrust-de90fa42dd6dfaf029a689d8d1a19e76af461163.tar.gz
rust-de90fa42dd6dfaf029a689d8d1a19e76af461163.zip
Merge remote-tracking branch 'upstream/master' into rustup
Diffstat (limited to 'clippy_dev')
-rw-r--r--clippy_dev/src/lib.rs1
-rw-r--r--clippy_dev/src/main.rs2
-rw-r--r--clippy_dev/src/setup/toolchain.rs2
-rw-r--r--clippy_dev/src/sync.rs2
-rw-r--r--clippy_dev/src/update_lints.rs81
-rw-r--r--clippy_dev/src/utils.rs8
6 files changed, 49 insertions, 47 deletions
diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs
index 9280369c23b..c1ffaf269c6 100644
--- a/clippy_dev/src/lib.rs
+++ b/clippy_dev/src/lib.rs
@@ -13,6 +13,7 @@
 #[allow(unused_extern_crates)]
 extern crate rustc_driver;
 extern crate rustc_lexer;
+extern crate rustc_literal_escaper;
 
 pub mod dogfood;
 pub mod fmt;
diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs
index 074dea4ab77..0380b7e6a6d 100644
--- a/clippy_dev/src/main.rs
+++ b/clippy_dev/src/main.rs
@@ -334,7 +334,7 @@ struct SyncCommand {
 #[derive(Subcommand)]
 enum SyncSubcommand {
     #[command(name = "update_nightly")]
-    /// Update nightly version in rust-toolchain and `clippy_utils`
+    /// Update nightly version in `rust-toolchain.toml` and `clippy_utils`
     UpdateNightly,
 }
 
diff --git a/clippy_dev/src/setup/toolchain.rs b/clippy_dev/src/setup/toolchain.rs
index 2966629cf70..ecd80215f7e 100644
--- a/clippy_dev/src/setup/toolchain.rs
+++ b/clippy_dev/src/setup/toolchain.rs
@@ -62,7 +62,7 @@ pub fn create(standalone: bool, force: bool, release: bool, name: &str) {
 
     println!("Created toolchain {name}, use it in other projects with e.g. `cargo +{name} clippy`");
     if !standalone {
-        println!("Note: This will need to be re-run whenever the Clippy `rust-toolchain` changes");
+        println!("Note: This will need to be re-run whenever the Clippy `rust-toolchain.toml` changes");
     }
 }
 
diff --git a/clippy_dev/src/sync.rs b/clippy_dev/src/sync.rs
index 3522d182e90..a6b65e561c2 100644
--- a/clippy_dev/src/sync.rs
+++ b/clippy_dev/src/sync.rs
@@ -10,7 +10,7 @@ pub fn update_nightly() {
     let date = Utc::now().format("%Y-%m-%d").to_string();
     replace_region_in_file(
         UpdateMode::Change,
-        Path::new("rust-toolchain"),
+        Path::new("rust-toolchain.toml"),
         "# begin autogenerated nightly\n",
         "# end autogenerated nightly",
         |res| {
diff --git a/clippy_dev/src/update_lints.rs b/clippy_dev/src/update_lints.rs
index b80ee5aac7e..02a432b26da 100644
--- a/clippy_dev/src/update_lints.rs
+++ b/clippy_dev/src/update_lints.rs
@@ -1,7 +1,8 @@
 use crate::utils::{UpdateMode, clippy_project_root, exit_with_failure, replace_region_in_file};
 use aho_corasick::AhoCorasickBuilder;
 use itertools::Itertools;
-use rustc_lexer::{LiteralKind, TokenKind, tokenize, unescape};
+use rustc_lexer::{LiteralKind, TokenKind, tokenize};
+use rustc_literal_escaper::{Mode, unescape_unicode};
 use std::collections::{HashMap, HashSet};
 use std::ffi::OsStr;
 use std::fmt::{self, Write};
@@ -402,53 +403,53 @@ fn remove_lint_declaration(name: &str, path: &Path, lints: &mut Vec<Lint>) -> io
         }
     }
 
-    if path.exists() {
-        if let Some(lint) = lints.iter().find(|l| l.name == name) {
-            if lint.module == name {
-                // The lint name is the same as the file, we can just delete the entire file
-                fs::remove_file(path)?;
-            } else {
-                // We can't delete the entire file, just remove the declaration
-
-                if let Some(Some("mod.rs")) = path.file_name().map(OsStr::to_str) {
-                    // Remove clippy_lints/src/some_mod/some_lint.rs
-                    let mut lint_mod_path = path.to_path_buf();
-                    lint_mod_path.set_file_name(name);
-                    lint_mod_path.set_extension("rs");
+    if path.exists()
+        && let Some(lint) = lints.iter().find(|l| l.name == name)
+    {
+        if lint.module == name {
+            // The lint name is the same as the file, we can just delete the entire file
+            fs::remove_file(path)?;
+        } else {
+            // We can't delete the entire file, just remove the declaration
 
-                    let _ = fs::remove_file(lint_mod_path);
-                }
+            if let Some(Some("mod.rs")) = path.file_name().map(OsStr::to_str) {
+                // Remove clippy_lints/src/some_mod/some_lint.rs
+                let mut lint_mod_path = path.to_path_buf();
+                lint_mod_path.set_file_name(name);
+                lint_mod_path.set_extension("rs");
 
-                let mut content =
-                    fs::read_to_string(path).unwrap_or_else(|_| panic!("failed to read `{}`", path.to_string_lossy()));
+                let _ = fs::remove_file(lint_mod_path);
+            }
 
-                eprintln!(
-                    "warn: you will have to manually remove any code related to `{name}` from `{}`",
-                    path.display()
-                );
+            let mut content =
+                fs::read_to_string(path).unwrap_or_else(|_| panic!("failed to read `{}`", path.to_string_lossy()));
 
-                assert!(
-                    content[lint.declaration_range.clone()].contains(&name.to_uppercase()),
-                    "error: `{}` does not contain lint `{}`'s declaration",
-                    path.display(),
-                    lint.name
-                );
+            eprintln!(
+                "warn: you will have to manually remove any code related to `{name}` from `{}`",
+                path.display()
+            );
 
-                // Remove lint declaration (declare_clippy_lint!)
-                content.replace_range(lint.declaration_range.clone(), "");
+            assert!(
+                content[lint.declaration_range.clone()].contains(&name.to_uppercase()),
+                "error: `{}` does not contain lint `{}`'s declaration",
+                path.display(),
+                lint.name
+            );
 
-                // Remove the module declaration (mod xyz;)
-                let mod_decl = format!("\nmod {name};");
-                content = content.replacen(&mod_decl, "", 1);
+            // Remove lint declaration (declare_clippy_lint!)
+            content.replace_range(lint.declaration_range.clone(), "");
 
-                remove_impl_lint_pass(&lint.name.to_uppercase(), &mut content);
-                fs::write(path, content).unwrap_or_else(|_| panic!("failed to write to `{}`", path.to_string_lossy()));
-            }
+            // Remove the module declaration (mod xyz;)
+            let mod_decl = format!("\nmod {name};");
+            content = content.replacen(&mod_decl, "", 1);
 
-            remove_test_assets(name);
-            remove_lint(name, lints);
-            return Ok(true);
+            remove_impl_lint_pass(&lint.name.to_uppercase(), &mut content);
+            fs::write(path, content).unwrap_or_else(|_| panic!("failed to write to `{}`", path.to_string_lossy()));
         }
+
+        remove_test_assets(name);
+        remove_lint(name, lints);
+        return Ok(true);
     }
 
     Ok(false)
@@ -830,7 +831,7 @@ fn remove_line_splices(s: &str) -> String {
         .and_then(|s| s.strip_suffix('"'))
         .unwrap_or_else(|| panic!("expected quoted string, found `{s}`"));
     let mut res = String::with_capacity(s.len());
-    unescape::unescape_unicode(s, unescape::Mode::Str, &mut |range, ch| {
+    unescape_unicode(s, Mode::Str, &mut |range, ch| {
         if ch.is_ok() {
             res.push_str(&s[range]);
         }
diff --git a/clippy_dev/src/utils.rs b/clippy_dev/src/utils.rs
index b87fcca13b1..206816398f5 100644
--- a/clippy_dev/src/utils.rs
+++ b/clippy_dev/src/utils.rs
@@ -30,10 +30,10 @@ pub fn clippy_project_root() -> PathBuf {
     let current_dir = std::env::current_dir().unwrap();
     for path in current_dir.ancestors() {
         let result = fs::read_to_string(path.join("Cargo.toml"));
-        if let Err(err) = &result {
-            if err.kind() == io::ErrorKind::NotFound {
-                continue;
-            }
+        if let Err(err) = &result
+            && err.kind() == io::ErrorKind::NotFound
+        {
+            continue;
         }
 
         let content = result.unwrap();