Skip to content

Commit 9962c99

Browse files
committed
Add missing match alternatives to alias_term_kind
1 parent e263457 commit 9962c99

File tree

6 files changed

+19
-33
lines changed

6 files changed

+19
-33
lines changed

compiler/rustc_middle/src/ty/context.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_errors::{
3030
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, LintDiagnostic, MultiSpan,
3131
};
3232
use rustc_hir as hir;
33-
use rustc_hir::def::DefKind;
33+
use rustc_hir::def::{CtorKind, DefKind};
3434
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId};
3535
use rustc_hir::definitions::Definitions;
3636
use rustc_hir::intravisit::Visitor;
@@ -239,7 +239,9 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
239239
DefKind::OpaqueTy => ty::AliasTermKind::OpaqueTy,
240240
DefKind::TyAlias => ty::AliasTermKind::WeakTy,
241241
DefKind::AssocConst => ty::AliasTermKind::ProjectionConst,
242-
DefKind::AnonConst => ty::AliasTermKind::UnevaluatedConst,
242+
DefKind::AnonConst | DefKind::Const | DefKind::Ctor(_, CtorKind::Const) => {
243+
ty::AliasTermKind::UnevaluatedConst
244+
}
243245
kind => bug!("unexpected DefKind in AliasTy: {kind:?}"),
244246
}
245247
}

tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ mod v20 {
99
pub type v11 = [[usize; v4]; v4];
1010
//~^ WARN type `v11` should have an upper camel case name
1111
const v2: v11 = [[256; v4]; v4];
12+
//~^ ERROR maximum number of nodes exceeded in constant v20::v2
13+
//~| ERROR maximum number of nodes exceeded in constant v20::v2
1214

1315
const v0: [[usize; v4]; v4] = v6(v8);
1416
//~^ ERROR cannot find value `v8` in this scope
@@ -26,8 +28,6 @@ mod v20 {
2628
}
2729

2830
impl<const v10: usize> v17<v10, v2> {
29-
//~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
30-
//~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
3131
pub const fn v21() -> v18 {
3232
//~^ ERROR cannot find type `v18` in this scope
3333
v18 { _p: () }

tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr

+6-22
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ LL | pub use v20::{v13, v17};
88
| help: a similar name exists in the module: `v11`
99

1010
error[E0425]: cannot find value `v8` in this scope
11-
--> $DIR/unevaluated-const-ice-119731.rs:13:38
11+
--> $DIR/unevaluated-const-ice-119731.rs:15:38
1212
|
1313
LL | const v0: [[usize; v4]; v4] = v6(v8);
1414
| ^^ not found in this scope
1515

1616
error[E0412]: cannot find type `v18` in this scope
17-
--> $DIR/unevaluated-const-ice-119731.rs:23:31
17+
--> $DIR/unevaluated-const-ice-119731.rs:25:31
1818
|
1919
LL | pub type v11 = [[usize; v4]; v4];
2020
| --------------------------------- similarly named type alias `v11` defined here
@@ -49,19 +49,19 @@ LL | pub type v11 = [[usize; v4]; v4];
4949
= note: `#[warn(non_camel_case_types)]` on by default
5050

5151
warning: type `v17` should have an upper camel case name
52-
--> $DIR/unevaluated-const-ice-119731.rs:16:16
52+
--> $DIR/unevaluated-const-ice-119731.rs:18:16
5353
|
5454
LL | pub struct v17<const v10: usize, const v7: v11> {
5555
| ^^^ help: convert the identifier to upper camel case (notice the capitalization): `V17`
5656

5757
error[E0425]: cannot find function `v6` in this scope
58-
--> $DIR/unevaluated-const-ice-119731.rs:13:35
58+
--> $DIR/unevaluated-const-ice-119731.rs:15:35
5959
|
6060
LL | const v0: [[usize; v4]; v4] = v6(v8);
6161
| ^^ not found in this scope
6262

6363
error: `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter
64-
--> $DIR/unevaluated-const-ice-119731.rs:16:48
64+
--> $DIR/unevaluated-const-ice-119731.rs:18:48
6565
|
6666
LL | pub struct v17<const v10: usize, const v7: v11> {
6767
| ^^^
@@ -72,38 +72,22 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
7272
LL + #![feature(adt_const_params)]
7373
|
7474

75-
<<<<<<< HEAD
76-
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
77-
--> $DIR/unevaluated-const-ice-119731.rs:28:37
78-
||||||| parent of 883a4baff18 (Begin to use `ConstArgKind::Path` for all paths, not just params)
79-
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
80-
--> $DIR/unevaluated-const-ice-119731.rs:27:37
81-
=======
8275
error: maximum number of nodes exceeded in constant v20::v2
8376
--> $DIR/unevaluated-const-ice-119731.rs:11:5
84-
>>>>>>> 883a4baff18 (Begin to use `ConstArgKind::Path` for all paths, not just params)
8577
|
8678
LL | const v2: v11 = [[256; v4]; v4];
8779
| ^^^^^^^^^^^^^
8880

89-
<<<<<<< HEAD
90-
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
91-
--> $DIR/unevaluated-const-ice-119731.rs:28:37
92-
||||||| parent of 883a4baff18 (Begin to use `ConstArgKind::Path` for all paths, not just params)
93-
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
94-
--> $DIR/unevaluated-const-ice-119731.rs:27:37
95-
=======
9681
error: maximum number of nodes exceeded in constant v20::v2
9782
--> $DIR/unevaluated-const-ice-119731.rs:11:5
98-
>>>>>>> 883a4baff18 (Begin to use `ConstArgKind::Path` for all paths, not just params)
9983
|
10084
LL | const v2: v11 = [[256; v4]; v4];
10185
| ^^^^^^^^^^^^^
10286
|
10387
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
10488

10589
error[E0592]: duplicate definitions with name `v21`
106-
--> $DIR/unevaluated-const-ice-119731.rs:23:9
90+
--> $DIR/unevaluated-const-ice-119731.rs:25:9
10791
|
10892
LL | pub const fn v21() -> v18 {}
10993
| ^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `v21`

tests/ui/const-generics/opaque_types2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![feature(type_alias_impl_trait)]
22

33
type Foo = impl Sized;
4+
//~^ ERROR: cycle detected when computing type of `Foo::{opaque#0}`
45

56
fn foo<const C: u32>() {}
67

@@ -11,7 +12,6 @@ where
1112
Foo:,
1213
{
1314
foo::<C>();
14-
//~^ ERROR: mismatched types
1515
}
1616

1717
fn main() {}

tests/ui/const-generics/opaque_types2.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@ note: ...which requires computing type of opaque `Foo::{opaque#0}`...
1010
LL | type Foo = impl Sized;
1111
| ^^^^^^^^^^
1212
note: ...which requires type-checking `bar`...
13-
--> $DIR/opaque_types2.rs:9:1
13+
--> $DIR/opaque_types2.rs:10:1
1414
|
1515
LL | / fn bar()
1616
LL | | where
1717
LL | | Foo:,
1818
| |_________^
1919
note: ...which requires evaluating type-level constant...
20-
--> $DIR/opaque_types2.rs:7:1
20+
--> $DIR/opaque_types2.rs:8:1
2121
|
2222
LL | const C: Foo = 42;
2323
| ^^^^^^^^^^^^
2424
note: ...which requires const-evaluating + checking `C`...
25-
--> $DIR/opaque_types2.rs:7:1
25+
--> $DIR/opaque_types2.rs:8:1
2626
|
2727
LL | const C: Foo = 42;
2828
| ^^^^^^^^^^^^
2929
note: ...which requires caching mir of `C` for CTFE...
30-
--> $DIR/opaque_types2.rs:7:1
30+
--> $DIR/opaque_types2.rs:8:1
3131
|
3232
LL | const C: Foo = 42;
3333
| ^^^^^^^^^^^^
3434
note: ...which requires elaborating drops for `C`...
35-
--> $DIR/opaque_types2.rs:7:1
35+
--> $DIR/opaque_types2.rs:8:1
3636
|
3737
LL | const C: Foo = 42;
3838
| ^^^^^^^^^^^^

tests/ui/consts/refs_check_const_value_eq-issue-88876.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![allow(incomplete_features)]
44
#![feature(adt_const_params, unsized_const_params)]
55

6-
struct FooConst<const ARRAY: &'static [&'static str]> {}
6+
struct FooConst<const ARRAY: &'static [&'static str; 2]> {}
77

88
const FOO_ARR: &[&'static str; 2] = &["Hello", "Friend"];
99

0 commit comments

Comments
 (0)