Skip to content

Commit 0e209ce

Browse files
authored
Rollup merge of rust-lang#104383 - WaffleLapkin:rustc_undiagnostic_item, r=compiler-errors
Remove unused symbols and diagnostic items As the title suggests, this removes unused symbols from `sym::` and `#[rustc_diagnostic_item]` annotations that weren't mentioned anywhere. Originally I tried to use grep, to find symbols and item names that are never mentioned via `sym::name`, however this produced a lot of false positives (?), for example clippy matching on `Symbol::as_str` or macros "implicitly" adding `sym::`. I ended up fixing all these false positives (?) by hand, but tbh I'm not sure if it was worth it...
2 parents b15a49d + 406d351 commit 0e209ce

File tree

5 files changed

+0
-22
lines changed

5 files changed

+0
-22
lines changed

core/src/fmt/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,6 @@ pub trait UpperHex {
10541054
pub trait Pointer {
10551055
/// Formats the value using the given formatter.
10561056
#[stable(feature = "rust1", since = "1.0.0")]
1057-
#[rustc_diagnostic_item = "pointer_trait_fmt"]
10581057
fn fmt(&self, f: &mut Formatter<'_>) -> Result;
10591058
}
10601059

core/src/macros/mod.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ pub macro debug_assert_matches($($arg:tt)*) {
338338
/// ```
339339
#[macro_export]
340340
#[stable(feature = "matches_macro", since = "1.42.0")]
341-
#[cfg_attr(not(test), rustc_diagnostic_item = "matches_macro")]
342341
macro_rules! matches {
343342
($expression:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
344343
match $expression {
@@ -820,7 +819,6 @@ pub(crate) mod builtin {
820819
#[stable(feature = "compile_error_macro", since = "1.20.0")]
821820
#[rustc_builtin_macro]
822821
#[macro_export]
823-
#[cfg_attr(not(test), rustc_diagnostic_item = "compile_error_macro")]
824822
macro_rules! compile_error {
825823
($msg:expr $(,)?) => {{ /* compiler built-in */ }};
826824
}
@@ -944,7 +942,6 @@ pub(crate) mod builtin {
944942
#[stable(feature = "rust1", since = "1.0.0")]
945943
#[rustc_builtin_macro]
946944
#[macro_export]
947-
#[cfg_attr(not(test), rustc_diagnostic_item = "env_macro")]
948945
macro_rules! env {
949946
($name:expr $(,)?) => {{ /* compiler built-in */ }};
950947
($name:expr, $error_msg:expr $(,)?) => {{ /* compiler built-in */ }};
@@ -973,7 +970,6 @@ pub(crate) mod builtin {
973970
#[stable(feature = "rust1", since = "1.0.0")]
974971
#[rustc_builtin_macro]
975972
#[macro_export]
976-
#[cfg_attr(not(test), rustc_diagnostic_item = "option_env_macro")]
977973
macro_rules! option_env {
978974
($name:expr $(,)?) => {{ /* compiler built-in */ }};
979975
}
@@ -1058,7 +1054,6 @@ pub(crate) mod builtin {
10581054
#[stable(feature = "rust1", since = "1.0.0")]
10591055
#[rustc_builtin_macro]
10601056
#[macro_export]
1061-
#[cfg_attr(not(test), rustc_diagnostic_item = "concat_macro")]
10621057
macro_rules! concat {
10631058
($($e:expr),* $(,)?) => {{ /* compiler built-in */ }};
10641059
}
@@ -1084,7 +1079,6 @@ pub(crate) mod builtin {
10841079
#[stable(feature = "rust1", since = "1.0.0")]
10851080
#[rustc_builtin_macro]
10861081
#[macro_export]
1087-
#[cfg_attr(not(test), rustc_diagnostic_item = "line_macro")]
10881082
macro_rules! line {
10891083
() => {
10901084
/* compiler built-in */
@@ -1124,7 +1118,6 @@ pub(crate) mod builtin {
11241118
#[stable(feature = "rust1", since = "1.0.0")]
11251119
#[rustc_builtin_macro]
11261120
#[macro_export]
1127-
#[cfg_attr(not(test), rustc_diagnostic_item = "column_macro")]
11281121
macro_rules! column {
11291122
() => {
11301123
/* compiler built-in */
@@ -1150,7 +1143,6 @@ pub(crate) mod builtin {
11501143
#[stable(feature = "rust1", since = "1.0.0")]
11511144
#[rustc_builtin_macro]
11521145
#[macro_export]
1153-
#[cfg_attr(not(test), rustc_diagnostic_item = "file_macro")]
11541146
macro_rules! file {
11551147
() => {
11561148
/* compiler built-in */
@@ -1175,7 +1167,6 @@ pub(crate) mod builtin {
11751167
#[stable(feature = "rust1", since = "1.0.0")]
11761168
#[rustc_builtin_macro]
11771169
#[macro_export]
1178-
#[cfg_attr(not(test), rustc_diagnostic_item = "stringify_macro")]
11791170
macro_rules! stringify {
11801171
($($t:tt)*) => {
11811172
/* compiler built-in */
@@ -1282,7 +1273,6 @@ pub(crate) mod builtin {
12821273
#[stable(feature = "rust1", since = "1.0.0")]
12831274
#[rustc_builtin_macro]
12841275
#[macro_export]
1285-
#[cfg_attr(not(test), rustc_diagnostic_item = "module_path_macro")]
12861276
macro_rules! module_path {
12871277
() => {
12881278
/* compiler built-in */
@@ -1316,7 +1306,6 @@ pub(crate) mod builtin {
13161306
#[stable(feature = "rust1", since = "1.0.0")]
13171307
#[rustc_builtin_macro]
13181308
#[macro_export]
1319-
#[cfg_attr(not(test), rustc_diagnostic_item = "cfg_macro")]
13201309
macro_rules! cfg {
13211310
($($cfg:tt)*) => {
13221311
/* compiler built-in */
@@ -1367,7 +1356,6 @@ pub(crate) mod builtin {
13671356
#[stable(feature = "rust1", since = "1.0.0")]
13681357
#[rustc_builtin_macro]
13691358
#[macro_export]
1370-
#[cfg_attr(not(test), rustc_diagnostic_item = "include_macro")]
13711359
macro_rules! include {
13721360
($file:expr $(,)?) => {{ /* compiler built-in */ }};
13731361
}

core/src/ops/function.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ use crate::marker::Tuple;
5757
#[cfg(bootstrap)]
5858
#[lang = "fn"]
5959
#[stable(feature = "rust1", since = "1.0.0")]
60-
#[rustc_diagnostic_item = "Fn"]
6160
#[rustc_paren_sugar]
6261
#[rustc_on_unimplemented(
6362
on(
@@ -138,7 +137,6 @@ pub trait Fn<Args>: FnMut<Args> {
138137
#[cfg(not(bootstrap))]
139138
#[lang = "fn"]
140139
#[stable(feature = "rust1", since = "1.0.0")]
141-
#[rustc_diagnostic_item = "Fn"]
142140
#[rustc_paren_sugar]
143141
#[rustc_on_unimplemented(
144142
on(
@@ -227,7 +225,6 @@ pub trait Fn<Args: Tuple>: FnMut<Args> {
227225
#[cfg(bootstrap)]
228226
#[lang = "fn_mut"]
229227
#[stable(feature = "rust1", since = "1.0.0")]
230-
#[rustc_diagnostic_item = "FnMut"]
231228
#[rustc_paren_sugar]
232229
#[rustc_on_unimplemented(
233230
on(
@@ -316,7 +313,6 @@ pub trait FnMut<Args>: FnOnce<Args> {
316313
#[cfg(not(bootstrap))]
317314
#[lang = "fn_mut"]
318315
#[stable(feature = "rust1", since = "1.0.0")]
319-
#[rustc_diagnostic_item = "FnMut"]
320316
#[rustc_paren_sugar]
321317
#[rustc_on_unimplemented(
322318
on(
@@ -397,7 +393,6 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> {
397393
#[cfg(bootstrap)]
398394
#[lang = "fn_once"]
399395
#[stable(feature = "rust1", since = "1.0.0")]
400-
#[rustc_diagnostic_item = "FnOnce"]
401396
#[rustc_paren_sugar]
402397
#[rustc_on_unimplemented(
403398
on(
@@ -483,7 +478,6 @@ pub trait FnOnce<Args> {
483478
#[cfg(not(bootstrap))]
484479
#[lang = "fn_once"]
485480
#[stable(feature = "rust1", since = "1.0.0")]
486-
#[rustc_diagnostic_item = "FnOnce"]
487481
#[rustc_paren_sugar]
488482
#[rustc_on_unimplemented(
489483
on(

core/src/panic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ pub macro unreachable_2015 {
8080
#[doc(hidden)]
8181
#[unstable(feature = "edition_panic", issue = "none", reason = "use unreachable!() instead")]
8282
#[allow_internal_unstable(core_panic)]
83-
#[rustc_diagnostic_item = "unreachable_2021_macro"]
8483
#[rustc_macro_transparency = "semitransparent"]
8584
pub macro unreachable_2021 {
8685
() => (

std/src/net/ip_addr.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ pub enum IpAddr {
7373
/// assert!("0xcb.0x0.0x71.0x00".parse::<Ipv4Addr>().is_err()); // all octets are in hex
7474
/// ```
7575
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
76-
#[cfg_attr(not(test), rustc_diagnostic_item = "Ipv4Addr")]
7776
#[stable(feature = "rust1", since = "1.0.0")]
7877
pub struct Ipv4Addr {
7978
octets: [u8; 4],
@@ -156,7 +155,6 @@ pub struct Ipv4Addr {
156155
/// assert_eq!(localhost.is_loopback(), true);
157156
/// ```
158157
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
159-
#[cfg_attr(not(test), rustc_diagnostic_item = "Ipv6Addr")]
160158
#[stable(feature = "rust1", since = "1.0.0")]
161159
pub struct Ipv6Addr {
162160
octets: [u8; 16],

0 commit comments

Comments
 (0)