From 16f6cf819b43366c6cb2f596dd3823636e26d501 Mon Sep 17 00:00:00 2001 From: SATVIKsynopsis Date: Sun, 14 Dec 2025 17:18:31 +0530 Subject: [PATCH 1/4] fixed ICE for more than one eii implementations --- compiler/rustc_passes/src/eii.rs | 9 +++++++- e -i HEAD~2 | 10 +++++++++ tests/ui/eii/multiple-default-impls.rs | 12 ++++++++++ tests/ui/eii/multiple-default-impls.stderr | 26 ++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 e -i HEAD~2 create mode 100644 tests/ui/eii/multiple-default-impls.rs create mode 100644 tests/ui/eii/multiple-default-impls.stderr diff --git a/compiler/rustc_passes/src/eii.rs b/compiler/rustc_passes/src/eii.rs index 691576e6a05fc..e0a4796e43e08 100644 --- a/compiler/rustc_passes/src/eii.rs +++ b/compiler/rustc_passes/src/eii.rs @@ -116,7 +116,14 @@ pub(crate) fn check_externally_implementable_items<'tcx>(tcx: TyCtxt<'tcx>, (): } if default_impls.len() > 1 { - panic!("multiple not supported right now"); + tcx.dcx().span_err( + decl.span, + format!( + "`{}` has more than one default implementation which is not supported", + tcx.item_name(decl_did) + ), + ); + return; } let (local_impl, is_default) = diff --git a/e -i HEAD~2 b/e -i HEAD~2 new file mode 100644 index 0000000000000..c04fda91ad7d3 --- /dev/null +++ b/e -i HEAD~2 @@ -0,0 +1,10 @@ +49b9580aa04 (HEAD -> main, origin/main, origin/HEAD) fixed the diagnostic message and fluent message inconsistency +22a10e199b8 lint: treat binders in improper_ctypes instead of ICE +ba86c0460b0 Auto merge of #149704 - matthiaskrgr:rollup-u4zhw99, r=matthiaskrgr +da2544bfbe8 Auto merge of #149495 - scottmcm:assume-filter-count, r=Mark-Simulacrum +60a4413ff0e Rollup merge of #149683 - korken89:fix-armv8r-tier, r=jieyouxu +4c8c967225b Rollup merge of #149401 - celinval:smir-109-name, r=scottmcm +8a6f82efac8 Rollup merge of #148814 - bend-n:stabilize_array_windows, r=scottmcm +f278da83859 Rollup merge of #148487 - Qelxiros:148441-option-into-flat-iter, r=scottmcm +865650a52f5 Rollup merge of #146826 - bluurryy:impl-allocator-for-mut-a, r=scottmcm +fbab541a7ad Auto merge of #149701 - jhpratt:rollup-cnlzfbv, r=jhpratt diff --git a/tests/ui/eii/multiple-default-impls.rs b/tests/ui/eii/multiple-default-impls.rs new file mode 100644 index 0000000000000..2d1d98ae186ab --- /dev/null +++ b/tests/ui/eii/multiple-default-impls.rs @@ -0,0 +1,12 @@ +//@ check-fail + +#![feature(extern_item_impls)] + +#[eii(eii1)] +//~^ ERROR `eii1` has more than one default implementation which is not supported +fn a() {} + +#[eii(eii1)] +//~^ ERROR the name `eii1` is defined multiple times +fn main() {} +//~^ ERROR the `main` function cannot be declared in an `extern` block \ No newline at end of file diff --git a/tests/ui/eii/multiple-default-impls.stderr b/tests/ui/eii/multiple-default-impls.stderr new file mode 100644 index 0000000000000..e9e8f3dc0a983 --- /dev/null +++ b/tests/ui/eii/multiple-default-impls.stderr @@ -0,0 +1,26 @@ +error[E0428]: the name `eii1` is defined multiple times + --> $DIR/multiple-default-impls.rs:9:1 + | +LL | #[eii(eii1)] + | ------------ previous definition of the macro `eii1` here +... +LL | #[eii(eii1)] + | ^^^^^^^^^^^^ `eii1` redefined here + | + = note: `eii1` must be defined only once in the macro namespace of this module + +error: the `main` function cannot be declared in an `extern` block + --> $DIR/multiple-default-impls.rs:11:1 + | +LL | fn main() {} + | ^^^^^^^^^ + +error: `eii1` has more than one default implementation which is not supported + --> $DIR/multiple-default-impls.rs:5:1 + | +LL | #[eii(eii1)] + | ^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0428`. From ddda03c79e3a0b9c57545fac91856513be353aa8 Mon Sep 17 00:00:00 2001 From: SATVIKsynopsis Date: Sun, 14 Dec 2025 17:36:13 +0530 Subject: [PATCH 2/4] tidy fix done --- tests/ui/eii/multiple-default-impls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/eii/multiple-default-impls.rs b/tests/ui/eii/multiple-default-impls.rs index 2d1d98ae186ab..cc6e8f13599c4 100644 --- a/tests/ui/eii/multiple-default-impls.rs +++ b/tests/ui/eii/multiple-default-impls.rs @@ -9,4 +9,4 @@ fn a() {} #[eii(eii1)] //~^ ERROR the name `eii1` is defined multiple times fn main() {} -//~^ ERROR the `main` function cannot be declared in an `extern` block \ No newline at end of file +//~^ ERROR the `main` function cannot be declared in an `extern` block From 534c9e290d5fcf905417f820e37246e939269304 Mon Sep 17 00:00:00 2001 From: SATVIKsynopsis Date: Sun, 14 Dec 2025 17:44:15 +0530 Subject: [PATCH 3/4] chneges return to continue to better diagnostic checkings and compiler standards --- compiler/rustc_passes/src/eii.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_passes/src/eii.rs b/compiler/rustc_passes/src/eii.rs index e0a4796e43e08..0e2d495924b67 100644 --- a/compiler/rustc_passes/src/eii.rs +++ b/compiler/rustc_passes/src/eii.rs @@ -123,7 +123,7 @@ pub(crate) fn check_externally_implementable_items<'tcx>(tcx: TyCtxt<'tcx>, (): tcx.item_name(decl_did) ), ); - return; + continue; } let (local_impl, is_default) = From 830d294fd956ebd55a05bc439a41edbd4ebac6c7 Mon Sep 17 00:00:00 2001 From: SATVIKsynopsis Date: Sun, 14 Dec 2025 21:51:39 +0530 Subject: [PATCH 4/4] CI + diagnostics fix --- tests/ui/eii/multiple-default-impls.rs | 1 + tests/ui/eii/multiple-default-impls.stderr | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/ui/eii/multiple-default-impls.rs b/tests/ui/eii/multiple-default-impls.rs index cc6e8f13599c4..bf9cbfc7cb449 100644 --- a/tests/ui/eii/multiple-default-impls.rs +++ b/tests/ui/eii/multiple-default-impls.rs @@ -8,5 +8,6 @@ fn a() {} #[eii(eii1)] //~^ ERROR the name `eii1` is defined multiple times +//~| ERROR `#[eii1]` required, but not found fn main() {} //~^ ERROR the `main` function cannot be declared in an `extern` block diff --git a/tests/ui/eii/multiple-default-impls.stderr b/tests/ui/eii/multiple-default-impls.stderr index e9e8f3dc0a983..010720d36445b 100644 --- a/tests/ui/eii/multiple-default-impls.stderr +++ b/tests/ui/eii/multiple-default-impls.stderr @@ -10,7 +10,7 @@ LL | #[eii(eii1)] = note: `eii1` must be defined only once in the macro namespace of this module error: the `main` function cannot be declared in an `extern` block - --> $DIR/multiple-default-impls.rs:11:1 + --> $DIR/multiple-default-impls.rs:12:1 | LL | fn main() {} | ^^^^^^^^^ @@ -21,6 +21,14 @@ error: `eii1` has more than one default implementation which is not supported LL | #[eii(eii1)] | ^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: `#[eii1]` required, but not found + --> $DIR/multiple-default-impls.rs:9:1 + | +LL | #[eii(eii1)] + | ^^^^^^^^^^^^ expected because `#[eii1]` was declared here in crate `multiple_default_impls` + | + = help: expected at least one implementation in crate `multiple_default_impls` or any of its dependencies + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0428`.