From d0501418afc6feac3243f2ffb1b23959dfea3127 Mon Sep 17 00:00:00 2001 From: ROHITH Date: Wed, 12 Nov 2025 12:57:43 +0530 Subject: [PATCH 1/3] WIP: suggesting fix for deref pattern const block ICE --- compiler/rustc_hir_typeck/src/pat.rs | 5 +-- .../src/tempCodeRunnerFile.rs | 1 + ...djust-mode-unimplemented-for-constblock.rs | 15 +++++++ ...t-mode-unimplemented-for-constblock.stderr | 42 +++++++++++++++++++ 4 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 compiler/rustc_hir_typeck/src/tempCodeRunnerFile.rs create mode 100644 tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.rs create mode 100644 tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.stderr diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 88f6077c2ef5a..b488b62abc3c0 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -773,10 +773,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { && self.tcx.features().deref_patterns() && !matches!(lt.kind, PatExprKind::Lit { .. }) { - span_bug!( + self.dcx().span_delayed_bug( lt.span, - "FIXME(deref_patterns): adjust mode unimplemented for {:?}", - lt.kind + format!("FIXME(deref_patterns): adjust mode unimplemented for {:?}", lt.kind), ); } // Call `resolve_vars_if_possible` here for inline const blocks. diff --git a/compiler/rustc_hir_typeck/src/tempCodeRunnerFile.rs b/compiler/rustc_hir_typeck/src/tempCodeRunnerFile.rs new file mode 100644 index 0000000000000..f61312b122f8a --- /dev/null +++ b/compiler/rustc_hir_typeck/src/tempCodeRunnerFile.rs @@ -0,0 +1 @@ +delayed_ \ No newline at end of file diff --git a/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.rs b/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.rs new file mode 100644 index 0000000000000..754ec77c48804 --- /dev/null +++ b/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.rs @@ -0,0 +1,15 @@ +// compile-flags: --error-format=json +// error-pattern: expected a pattern +// or +//~ ERROR expected a pattern + +//~ ERROR expected a pattern, found a function call +//~ ERROR usage of qualified paths in this context is experimental +//~ WARN the feature `deref_patterns` is incomplete +//~ ERROR expected tuple struct or tuple variant, found associated function + +#![feature(deref_patterns)] + +fn main() { + let vec![const { vec![] }]: Vec = vec![]; +} diff --git a/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.stderr b/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.stderr new file mode 100644 index 0000000000000..e06a600bd21fb --- /dev/null +++ b/tests/ui/pattern/deref-patterns/ice-adjust-mode-unimplemented-for-constblock.stderr @@ -0,0 +1,42 @@ +error[E0532]: expected a pattern, found a function call + --> $DIR/ice-adjust-mode-unimplemented-for-constblock.rs:14:9 + | +LL | let vec![const { vec![] }]: Vec = vec![]; + | ^^^^^^^^^^^^^^^^^^^^^^ not a tuple struct or tuple variant + | + = note: function calls are not allowed in patterns: + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0658]: usage of qualified paths in this context is experimental + --> $DIR/ice-adjust-mode-unimplemented-for-constblock.rs:14:9 + | +LL | let vec![const { vec![] }]: Vec = vec![]; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #86935 for more information + = help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: the feature `deref_patterns` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/ice-adjust-mode-unimplemented-for-constblock.rs:11:12 + | +LL | #![feature(deref_patterns)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #87121 for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0164]: expected tuple struct or tuple variant, found associated function `<[_]>::into_vec` + --> $DIR/ice-adjust-mode-unimplemented-for-constblock.rs:14:9 + | +LL | let vec![const { vec![] }]: Vec = vec![]; + | ^^^^^^^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns + | + = help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0164, E0532, E0658. +For more information about an error, try `rustc --explain E0164`. From cfb0f09116c89eef4b555704e403da2887b353dd Mon Sep 17 00:00:00 2001 From: ROHITH Date: Wed, 12 Nov 2025 13:15:31 +0530 Subject: [PATCH 2/3] suggesting fix for deref pattern const block ICE --- compiler/rustc_hir_typeck/src/pat.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index b488b62abc3c0..14a4ce393a240 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -773,7 +773,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { && self.tcx.features().deref_patterns() && !matches!(lt.kind, PatExprKind::Lit { .. }) { - self.dcx().span_delayed_bug( + self.dcx().span_delayed_bug!( lt.span, format!("FIXME(deref_patterns): adjust mode unimplemented for {:?}", lt.kind), ); From bb4235308c193a1c08ccf010a809b43be786882c Mon Sep 17 00:00:00 2001 From: ROHITH Date: Wed, 12 Nov 2025 13:17:07 +0530 Subject: [PATCH 3/3] suggesting fix for deref pattern const block ICE --- compiler/rustc_hir_typeck/src/pat.rs | 2 +- compiler/rustc_hir_typeck/src/tempCodeRunnerFile.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 compiler/rustc_hir_typeck/src/tempCodeRunnerFile.rs diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 14a4ce393a240..d0045e4273aa4 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -773,7 +773,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { && self.tcx.features().deref_patterns() && !matches!(lt.kind, PatExprKind::Lit { .. }) { - self.dcx().span_delayed_bug!( + span_delayed_bug!( lt.span, format!("FIXME(deref_patterns): adjust mode unimplemented for {:?}", lt.kind), ); diff --git a/compiler/rustc_hir_typeck/src/tempCodeRunnerFile.rs b/compiler/rustc_hir_typeck/src/tempCodeRunnerFile.rs deleted file mode 100644 index f61312b122f8a..0000000000000 --- a/compiler/rustc_hir_typeck/src/tempCodeRunnerFile.rs +++ /dev/null @@ -1 +0,0 @@ -delayed_ \ No newline at end of file