Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/rustc_mir_build/src/thir/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,9 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
}
};

if let Some(user_ty) = self.user_args_applied_to_ty_of_hir_id(hir_id) {
if !matches!(kind, PatKind::Error(_))
&& let Some(user_ty) = self.user_args_applied_to_ty_of_hir_id(hir_id)
{
debug!("lower_variant_or_leaf: kind={:?} user_ty={:?} span={:?}", kind, user_ty, span);
let annotation = CanonicalUserTypeAnnotation {
user_ty: Box::new(user_ty),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
struct Foo;

impl<'b> Foo {
fn bar<const V: u8>() {

let V; //~ ERROR constant parameters cannot be referenced in patterns
}
}
fn main() {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0158]: constant parameters cannot be referenced in patterns
--> $DIR/using-a-constant-as-a-pattern-issue-138048.rs:6:13
|
LL | fn bar<const V: u8>() {
| ----------- constant defined here
LL |
LL | let V;
| ^ can't be used in patterns

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0158`.
Loading