From 8fcffffad980a18ff785ff6f5a8458f833f7ca6c Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 11 Apr 2024 13:32:17 -0400 Subject: [PATCH 1/4] Silence unused_imports lint for redundant imports (cherry picked from commit 0db2a4010a5a7a57372e9135d327da8c7d92c8ab) --- compiler/rustc_resolve/src/imports.rs | 2 + compiler/rustc_resolve/src/lib.rs | 2 +- .../redundant-import-issue-121915-2015.rs | 3 +- .../redundant-import-issue-121915-2015.stderr | 17 ------- .../imports/redundant-import-issue-121915.rs | 3 +- .../redundant-import-issue-121915.stderr | 14 ------ .../ui/imports/suggest-remove-issue-121315.rs | 9 ++-- .../suggest-remove-issue-121315.stderr | 50 +++---------------- tests/ui/lint/unused/issue-59896.rs | 3 +- tests/ui/lint/unused/issue-59896.stderr | 17 ------- .../use-redundant-glob-parent.rs | 2 +- .../use-redundant-glob-parent.stderr | 17 ------- .../lint/use-redundant/use-redundant-glob.rs | 2 +- .../use-redundant/use-redundant-glob.stderr | 16 ------ .../use-redundant-issue-71450.rs | 3 +- .../use-redundant-issue-71450.stderr | 17 ------- .../use-redundant-prelude-rust-2015.rs | 12 +++-- .../use-redundant-prelude-rust-2015.stderr | 44 ---------------- .../use-redundant-prelude-rust-2021.rs | 6 ++- .../use-redundant-prelude-rust-2021.stderr | 26 ---------- tests/ui/lint/use-redundant/use-redundant.rs | 2 +- .../lint/use-redundant/use-redundant.stderr | 11 +--- 22 files changed, 39 insertions(+), 239 deletions(-) delete mode 100644 tests/ui/imports/redundant-import-issue-121915-2015.stderr delete mode 100644 tests/ui/imports/redundant-import-issue-121915.stderr delete mode 100644 tests/ui/lint/unused/issue-59896.stderr delete mode 100644 tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr delete mode 100644 tests/ui/lint/use-redundant/use-redundant-glob.stderr delete mode 100644 tests/ui/lint/use-redundant/use-redundant-issue-71450.stderr delete mode 100644 tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr delete mode 100644 tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 9bf3e9ccabdf1..d9acfff26318c 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -1368,6 +1368,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let mut redundant_spans: Vec<_> = redundant_span.present_items().collect(); redundant_spans.sort(); redundant_spans.dedup(); + /* FIXME(unused_imports): Add this back as a new lint self.lint_buffer.buffer_lint_with_diagnostic( UNUSED_IMPORTS, id, @@ -1375,6 +1376,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { format!("the item `{source}` is imported redundantly"), BuiltinLintDiag::RedundantImport(redundant_spans, source), ); + */ return true; } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index dfc2d029d4cfd..9db02e215df89 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -177,7 +177,7 @@ enum ImplTraitContext { /// Used for tracking import use types which will be used for redundant import checking. /// ### Used::Scope Example -/// ```rust,compile_fail +/// ```rust,ignore (redundant_imports) /// #![deny(unused_imports)] /// use std::mem::drop; /// fn main() { diff --git a/tests/ui/imports/redundant-import-issue-121915-2015.rs b/tests/ui/imports/redundant-import-issue-121915-2015.rs index d41d190bb58c4..be3b8209ada99 100644 --- a/tests/ui/imports/redundant-import-issue-121915-2015.rs +++ b/tests/ui/imports/redundant-import-issue-121915-2015.rs @@ -1,3 +1,4 @@ +//@ check-pass //@ compile-flags: --extern aux_issue_121915 --edition 2015 //@ aux-build: aux-issue-121915.rs @@ -6,6 +7,6 @@ extern crate aux_issue_121915; #[deny(unused_imports)] fn main() { use aux_issue_121915; - //~^ ERROR the item `aux_issue_121915` is imported redundantly + //FIXME(unused_imports): ~^ ERROR the item `aux_issue_121915` is imported redundantly aux_issue_121915::item(); } diff --git a/tests/ui/imports/redundant-import-issue-121915-2015.stderr b/tests/ui/imports/redundant-import-issue-121915-2015.stderr deleted file mode 100644 index 174ed4fb96b11..0000000000000 --- a/tests/ui/imports/redundant-import-issue-121915-2015.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: the item `aux_issue_121915` is imported redundantly - --> $DIR/redundant-import-issue-121915-2015.rs:8:9 - | -LL | extern crate aux_issue_121915; - | ------------------------------ the item `aux_issue_121915` is already imported here -... -LL | use aux_issue_121915; - | ^^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/redundant-import-issue-121915-2015.rs:6:8 - | -LL | #[deny(unused_imports)] - | ^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/imports/redundant-import-issue-121915.rs b/tests/ui/imports/redundant-import-issue-121915.rs index 237acc4af2565..55e4bc4dd0c3a 100644 --- a/tests/ui/imports/redundant-import-issue-121915.rs +++ b/tests/ui/imports/redundant-import-issue-121915.rs @@ -1,9 +1,10 @@ +//@ check-pass //@ compile-flags: --extern aux_issue_121915 --edition 2018 //@ aux-build: aux-issue-121915.rs #[deny(unused_imports)] fn main() { use aux_issue_121915; - //~^ ERROR the item `aux_issue_121915` is imported redundantly + //FIXME(unused_imports): ~^ ERROR the item `aux_issue_121915` is imported redundantly aux_issue_121915::item(); } diff --git a/tests/ui/imports/redundant-import-issue-121915.stderr b/tests/ui/imports/redundant-import-issue-121915.stderr deleted file mode 100644 index 0047d7c34207c..0000000000000 --- a/tests/ui/imports/redundant-import-issue-121915.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: the item `aux_issue_121915` is imported redundantly - --> $DIR/redundant-import-issue-121915.rs:6:9 - | -LL | use aux_issue_121915; - | ^^^^^^^^^^^^^^^^ the item `aux_issue_121915` is already defined by prelude - | -note: the lint level is defined here - --> $DIR/redundant-import-issue-121915.rs:4:8 - | -LL | #[deny(unused_imports)] - | ^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/imports/suggest-remove-issue-121315.rs b/tests/ui/imports/suggest-remove-issue-121315.rs index 63533480ec127..2bb82833a5bc3 100644 --- a/tests/ui/imports/suggest-remove-issue-121315.rs +++ b/tests/ui/imports/suggest-remove-issue-121315.rs @@ -1,19 +1,20 @@ //@ compile-flags: --edition 2021 + #![deny(unused_imports)] #![allow(dead_code)] fn test0() { // Test remove FlatUnused use std::convert::TryFrom; - //~^ ERROR the item `TryFrom` is imported redundantly + //FIXME(unused_imports): ~^ ERROR the item `TryFrom` is imported redundantly let _ = u32::try_from(5i32); } fn test1() { // FIXME(yukang) Test remove NestedFullUnused use std::convert::{TryFrom, TryInto}; - //~^ ERROR the item `TryFrom` is imported redundantly - //~| ERROR the item `TryInto` is imported redundantly + //FIXME(unused_imports): ~^ ERROR the item `TryFrom` is imported redundantly + //FIXME(unused_imports): ~| ERROR the item `TryInto` is imported redundantly let _ = u32::try_from(5i32); let _a: i32 = u32::try_into(5u32).unwrap(); @@ -23,7 +24,7 @@ fn test2() { // FIXME(yukang): Test remove both redundant and unused use std::convert::{AsMut, Into}; //~^ ERROR unused import: `AsMut` - //~| ERROR the item `Into` is imported redundantly + //FIXME(unused_imports): ~| ERROR the item `Into` is imported redundantly let _a: u32 = (5u8).into(); } diff --git a/tests/ui/imports/suggest-remove-issue-121315.stderr b/tests/ui/imports/suggest-remove-issue-121315.stderr index dbd742f6c781f..5701514e1bd6e 100644 --- a/tests/ui/imports/suggest-remove-issue-121315.stderr +++ b/tests/ui/imports/suggest-remove-issue-121315.stderr @@ -1,56 +1,20 @@ -error: the item `TryFrom` is imported redundantly - --> $DIR/suggest-remove-issue-121315.rs:7:9 - | -LL | use std::convert::TryFrom; - | ^^^^^^^^^^^^^^^^^^^^^ - --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL - | - = note: the item `TryFrom` is already defined here - | -note: the lint level is defined here - --> $DIR/suggest-remove-issue-121315.rs:2:9 - | -LL | #![deny(unused_imports)] - | ^^^^^^^^^^^^^^ - -error: the item `TryFrom` is imported redundantly - --> $DIR/suggest-remove-issue-121315.rs:14:24 - | -LL | use std::convert::{TryFrom, TryInto}; - | ^^^^^^^ - --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL - | - = note: the item `TryFrom` is already defined here - -error: the item `TryInto` is imported redundantly - --> $DIR/suggest-remove-issue-121315.rs:14:33 - | -LL | use std::convert::{TryFrom, TryInto}; - | ^^^^^^^ - --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL - | - = note: the item `TryInto` is already defined here - error: unused import: `AsMut` - --> $DIR/suggest-remove-issue-121315.rs:24:24 + --> $DIR/suggest-remove-issue-121315.rs:25:24 | LL | use std::convert::{AsMut, Into}; | ^^^^^ - -error: the item `Into` is imported redundantly - --> $DIR/suggest-remove-issue-121315.rs:24:31 | -LL | use std::convert::{AsMut, Into}; - | ^^^^ - --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL +note: the lint level is defined here + --> $DIR/suggest-remove-issue-121315.rs:3:9 | - = note: the item `Into` is already defined here +LL | #![deny(unused_imports)] + | ^^^^^^^^^^^^^^ error: unused import: `From` - --> $DIR/suggest-remove-issue-121315.rs:33:24 + --> $DIR/suggest-remove-issue-121315.rs:34:24 | LL | use std::convert::{From, Infallible}; | ^^^^ -error: aborting due to 6 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/lint/unused/issue-59896.rs b/tests/ui/lint/unused/issue-59896.rs index ff9f19acf8471..a98017524f550 100644 --- a/tests/ui/lint/unused/issue-59896.rs +++ b/tests/ui/lint/unused/issue-59896.rs @@ -1,9 +1,10 @@ +//@ check-pass #![deny(unused_imports)] struct S; fn main() { - use S; //~ ERROR the item `S` is imported redundantly + use S; //FIXME(unused_imports): ~ ERROR the item `S` is imported redundantly let _s = S; } diff --git a/tests/ui/lint/unused/issue-59896.stderr b/tests/ui/lint/unused/issue-59896.stderr deleted file mode 100644 index 3e8298c6b72e6..0000000000000 --- a/tests/ui/lint/unused/issue-59896.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: the item `S` is imported redundantly - --> $DIR/issue-59896.rs:6:9 - | -LL | struct S; - | --------- the item `S` is already defined here -... -LL | use S; - | ^ - | -note: the lint level is defined here - --> $DIR/issue-59896.rs:1:9 - | -LL | #![deny(unused_imports)] - | ^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs b/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs index 28d1fea98b582..797e57f48e9d2 100644 --- a/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs +++ b/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs @@ -9,7 +9,7 @@ pub mod bar { use bar::*; pub fn warning() -> Foo { - use bar::Foo; //~ WARNING imported redundantly + use bar::Foo; //FIXME(unused_imports): ~ WARNING imported redundantly Foo(Bar('a')) } diff --git a/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr b/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr deleted file mode 100644 index 2c3b33452702b..0000000000000 --- a/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: the item `Foo` is imported redundantly - --> $DIR/use-redundant-glob-parent.rs:12:9 - | -LL | use bar::*; - | ------ the item `Foo` is already imported here -... -LL | use bar::Foo; - | ^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/use-redundant-glob-parent.rs:2:9 - | -LL | #![warn(unused_imports)] - | ^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/lint/use-redundant/use-redundant-glob.rs b/tests/ui/lint/use-redundant/use-redundant-glob.rs index 3d3fe2579b54c..e5835be89d841 100644 --- a/tests/ui/lint/use-redundant/use-redundant-glob.rs +++ b/tests/ui/lint/use-redundant/use-redundant-glob.rs @@ -8,7 +8,7 @@ pub mod bar { pub fn warning() -> bar::Foo { use bar::*; - use bar::Foo; //~ WARNING imported redundantly + use bar::Foo; //FIXME(unused_imports): ~ WARNING imported redundantly Foo(Bar('a')) } diff --git a/tests/ui/lint/use-redundant/use-redundant-glob.stderr b/tests/ui/lint/use-redundant/use-redundant-glob.stderr deleted file mode 100644 index d3b406d82b6db..0000000000000 --- a/tests/ui/lint/use-redundant/use-redundant-glob.stderr +++ /dev/null @@ -1,16 +0,0 @@ -warning: the item `Foo` is imported redundantly - --> $DIR/use-redundant-glob.rs:11:9 - | -LL | use bar::*; - | ------ the item `Foo` is already imported here -LL | use bar::Foo; - | ^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/use-redundant-glob.rs:2:9 - | -LL | #![warn(unused_imports)] - | ^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/lint/use-redundant/use-redundant-issue-71450.rs b/tests/ui/lint/use-redundant/use-redundant-issue-71450.rs index d0fb3454d3f2b..2db3435d46dbd 100644 --- a/tests/ui/lint/use-redundant/use-redundant-issue-71450.rs +++ b/tests/ui/lint/use-redundant/use-redundant-issue-71450.rs @@ -23,7 +23,8 @@ mod foo { fn main() { { - use std::string::String; //~ WARNING the item `String` is imported redundantly + use std::string::String; + //FIXME(unused_imports): ~^ WARNING the item `String` is imported redundantly // 'String' from 'std::string::String'. let s = String::new(); println!("{}", s); diff --git a/tests/ui/lint/use-redundant/use-redundant-issue-71450.stderr b/tests/ui/lint/use-redundant/use-redundant-issue-71450.stderr deleted file mode 100644 index b8832a3178371..0000000000000 --- a/tests/ui/lint/use-redundant/use-redundant-issue-71450.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: the item `String` is imported redundantly - --> $DIR/use-redundant-issue-71450.rs:26:13 - | -LL | use std::string::String; - | ^^^^^^^^^^^^^^^^^^^ - --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL - | - = note: the item `String` is already defined here - | -note: the lint level is defined here - --> $DIR/use-redundant-issue-71450.rs:3:9 - | -LL | #![warn(unused_imports)] - | ^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs index ae5118b2729b9..62f50c8a0df90 100644 --- a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs @@ -2,11 +2,15 @@ #![warn(unused_imports)] -use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly -use std::option::Option::None; //~ WARNING the item `None` is imported redundantly +use std::option::Option::Some; +//FIXME(unused_imports): ~^ WARNING the item `Some` is imported redundantly +use std::option::Option::None; +//FIXME(unused_imports): ~ WARNING the item `None` is imported redundantly -use std::result::Result::Ok;//~ WARNING the item `Ok` is imported redundantly -use std::result::Result::Err;//~ WARNING the item `Err` is imported redundantly +use std::result::Result::Ok; +//FIXME(unused_imports): ~^ WARNING the item `Ok` is imported redundantly +use std::result::Result::Err; +//FIXME(unused_imports): ~^ WARNING the item `Err` is imported redundantly use std::convert::{TryFrom, TryInto}; fn main() { diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr deleted file mode 100644 index 1b09df911eb03..0000000000000 --- a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr +++ /dev/null @@ -1,44 +0,0 @@ -warning: the item `Some` is imported redundantly - --> $DIR/use-redundant-prelude-rust-2015.rs:5:5 - | -LL | use std::option::Option::Some; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL - | - = note: the item `Some` is already defined here - | -note: the lint level is defined here - --> $DIR/use-redundant-prelude-rust-2015.rs:2:9 - | -LL | #![warn(unused_imports)] - | ^^^^^^^^^^^^^^ - -warning: the item `None` is imported redundantly - --> $DIR/use-redundant-prelude-rust-2015.rs:6:5 - | -LL | use std::option::Option::None; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL - | - = note: the item `None` is already defined here - -warning: the item `Ok` is imported redundantly - --> $DIR/use-redundant-prelude-rust-2015.rs:8:5 - | -LL | use std::result::Result::Ok; - | ^^^^^^^^^^^^^^^^^^^^^^^ - --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL - | - = note: the item `Ok` is already defined here - -warning: the item `Err` is imported redundantly - --> $DIR/use-redundant-prelude-rust-2015.rs:9:5 - | -LL | use std::result::Result::Err; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL - | - = note: the item `Err` is already defined here - -warning: 4 warnings emitted - diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs index cb4dcb6c0bd67..1baa1ac1b8cd3 100644 --- a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs @@ -2,8 +2,10 @@ //@ edition:2021 #![warn(unused_imports)] -use std::convert::TryFrom;//~ WARNING the item `TryFrom` is imported redundantly -use std::convert::TryInto;//~ WARNING the item `TryInto` is imported redundantly +use std::convert::TryFrom; +//FIXME(unused_imports): ~^ WARNING the item `TryFrom` is imported redundantly +use std::convert::TryInto; +//FIXME(unused_imports): ~^ WARNING the item `TryInto` is imported redundantly fn main() { let _e: Result = 8u8.try_into(); diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr deleted file mode 100644 index 542356dc996df..0000000000000 --- a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr +++ /dev/null @@ -1,26 +0,0 @@ -warning: the item `TryFrom` is imported redundantly - --> $DIR/use-redundant-prelude-rust-2021.rs:5:5 - | -LL | use std::convert::TryFrom; - | ^^^^^^^^^^^^^^^^^^^^^ - --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL - | - = note: the item `TryFrom` is already defined here - | -note: the lint level is defined here - --> $DIR/use-redundant-prelude-rust-2021.rs:3:9 - | -LL | #![warn(unused_imports)] - | ^^^^^^^^^^^^^^ - -warning: the item `TryInto` is imported redundantly - --> $DIR/use-redundant-prelude-rust-2021.rs:6:5 - | -LL | use std::convert::TryInto; - | ^^^^^^^^^^^^^^^^^^^^^ - --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL - | - = note: the item `TryInto` is already defined here - -warning: 2 warnings emitted - diff --git a/tests/ui/lint/use-redundant/use-redundant.rs b/tests/ui/lint/use-redundant/use-redundant.rs index 88d3ee75a3f2d..9e4902af34b7d 100644 --- a/tests/ui/lint/use-redundant/use-redundant.rs +++ b/tests/ui/lint/use-redundant/use-redundant.rs @@ -18,7 +18,7 @@ use m1::*; //~ WARNING unused import use m2::*; //~ WARNING unused import fn main() { - use crate::foo::Bar; //~ WARNING imported redundantly + use crate::foo::Bar; //FIXME(unused_imports): ~ WARNING imported redundantly let _a: Bar = 3; baz(); diff --git a/tests/ui/lint/use-redundant/use-redundant.stderr b/tests/ui/lint/use-redundant/use-redundant.stderr index c861a1956e1d1..224e841123748 100644 --- a/tests/ui/lint/use-redundant/use-redundant.stderr +++ b/tests/ui/lint/use-redundant/use-redundant.stderr @@ -16,14 +16,5 @@ warning: unused import: `m2::*` LL | use m2::*; | ^^^^^ -warning: the item `Bar` is imported redundantly - --> $DIR/use-redundant.rs:21:9 - | -LL | use crate::foo::Bar; - | --------------- the item `Bar` is already imported here -... -LL | use crate::foo::Bar; - | ^^^^^^^^^^^^^^^ - -warning: 3 warnings emitted +warning: 2 warnings emitted From 4a8f091c01d4d46798ac269c88e26ea605fd428b Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Thu, 11 Apr 2024 17:27:49 -0400 Subject: [PATCH 2/4] Call the panic hook for non-unwind panics in proc-macros (cherry picked from commit d8dc28b93e4cbfe2a3c26af06c73b0ea46f67a1e) --- library/proc_macro/src/bridge/client.rs | 6 +++++- library/proc_macro/src/lib.rs | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/library/proc_macro/src/bridge/client.rs b/library/proc_macro/src/bridge/client.rs index 8a1ba436f7261..a0928093d9ab2 100644 --- a/library/proc_macro/src/bridge/client.rs +++ b/library/proc_macro/src/bridge/client.rs @@ -286,7 +286,11 @@ fn maybe_install_panic_hook(force_show_panics: bool) { BridgeState::NotConnected => true, BridgeState::Connected(_) | BridgeState::InUse => force_show_panics, }); - if show { + // We normally report panics by catching unwinds and passing the payload from the + // unwind back to the compiler, but if the panic doesn't unwind we'll abort before + // the compiler has a chance to print an error. So we special-case PanicInfo where + // can_unwind is false. + if show || !info.can_unwind() { prev(info) } })); diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index e04bf69ef5117..f10c6c56029b6 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -30,6 +30,7 @@ #![feature(maybe_uninit_write_slice)] #![feature(negative_impls)] #![feature(new_uninit)] +#![feature(panic_can_unwind)] #![feature(restricted_std)] #![feature(rustc_attrs)] #![feature(min_specialization)] From 46515fd77833f274b81d6cc078715bd7097b0ca8 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 13 Apr 2024 18:41:14 -0700 Subject: [PATCH 3/4] rustdoc: check redundant explicit links with correct itemid Fixes a regression caused by 0a50dba50bedd24377bd1066da3b4b7066df4d28 (cherry picked from commit 0fea38a01f4015d310230b76984068b6fe8414d4) --- .../passes/lint/redundant_explicit_links.rs | 19 ++++++++----------- .../redundant-explicit-links-123677.rs | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 tests/rustdoc-ui/redundant-explicit-links-123677.rs diff --git a/src/librustdoc/passes/lint/redundant_explicit_links.rs b/src/librustdoc/passes/lint/redundant_explicit_links.rs index f7bc546470796..8cb605349c4c3 100644 --- a/src/librustdoc/passes/lint/redundant_explicit_links.rs +++ b/src/librustdoc/passes/lint/redundant_explicit_links.rs @@ -6,7 +6,7 @@ use rustc_errors::SuggestionStyle; use rustc_hir::def::{DefKind, DocLinkResMap, Namespace, Res}; use rustc_hir::HirId; use rustc_lint_defs::Applicability; -use rustc_resolve::rustdoc::source_span_for_markdown_range; +use rustc_resolve::rustdoc::{prepare_to_doc_link_resolution, source_span_for_markdown_range}; use rustc_span::def_id::DefId; use rustc_span::Symbol; @@ -29,16 +29,13 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) { return; }; - let doc = item.doc_value(); - if doc.is_empty() { - return; - } - - if let Some(item_id) = item.def_id() { - check_redundant_explicit_link_for_did(cx, item, item_id, hir_id, &doc); - } - if let Some(item_id) = item.inline_stmt_id { - check_redundant_explicit_link_for_did(cx, item, item_id, hir_id, &doc); + let hunks = prepare_to_doc_link_resolution(&item.attrs.doc_strings); + for (item_id, doc) in hunks { + if let Some(item_id) = item_id.or(item.def_id()) + && !doc.is_empty() + { + check_redundant_explicit_link_for_did(cx, item, item_id, hir_id, &doc); + } } } diff --git a/tests/rustdoc-ui/redundant-explicit-links-123677.rs b/tests/rustdoc-ui/redundant-explicit-links-123677.rs new file mode 100644 index 0000000000000..f3a5e81f89d8d --- /dev/null +++ b/tests/rustdoc-ui/redundant-explicit-links-123677.rs @@ -0,0 +1,14 @@ +//@ check-pass +#![deny(rustdoc::redundant_explicit_links)] + +mod bar { + /// [`Rc`](std::rc::Rc) + pub enum Baz {} +} + +pub use bar::*; + +use std::rc::Rc; + +/// [`Rc::allocator`] [foo](std::rc::Rc) +pub fn winit_runner() {} From c62334579147c40935cdecacb1ab5ed07c699aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Mon, 15 Apr 2024 11:44:14 +0000 Subject: [PATCH 4/4] disable two debuginfo tests under gdb 15 it seems gdb 15 regresses some of our debuginfo tests. disable them temporarily so that CI doesn't randomly start failing soon. (cherry picked from commit 6e19f82160c216fcb5f8eaff915b7fe274a5568e) --- tests/debuginfo/include_string.rs | 2 ++ tests/debuginfo/vec-slices.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/debuginfo/include_string.rs b/tests/debuginfo/include_string.rs index 6f7d2b28b4186..4b476fbb8bcac 100644 --- a/tests/debuginfo/include_string.rs +++ b/tests/debuginfo/include_string.rs @@ -1,4 +1,6 @@ //@ min-lldb-version: 310 +//@ ignore-gdb-version: 15.0 - 99.0 +// ^ test temporarily disabled as it fails under gdb 15 //@ compile-flags:-g // gdb-command:run diff --git a/tests/debuginfo/vec-slices.rs b/tests/debuginfo/vec-slices.rs index b044110fc7892..233add815bb43 100644 --- a/tests/debuginfo/vec-slices.rs +++ b/tests/debuginfo/vec-slices.rs @@ -1,4 +1,6 @@ //@ min-lldb-version: 310 +//@ ignore-gdb-version: 15.0 - 99.0 +// ^ test temporarily disabled as it fails under gdb 15 //@ compile-flags:-g