You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of #136584 - oli-obk:pattern-types-generic, r=BoxyUwU
Prevent generic pattern types from being used in libstd
Pattern types should follow the same rules that patterns follow. So a pattern type range must not wrap and not be empty. While we reject such invalid ranges at layout computation time, that only happens during monomorphization in the case of const generics. This is the exact same issue as other const generic math has, and since there's no solution there yet, I put these pattern types behind a separate incomplete feature.
These are not necessary for the pattern types MVP (replacing the layout range attributes in libcore and rustc).
cc #136574 (new tracking issue for the `generic_pattern_types` feature gate)
r? ``@lcnr``
cc ``@scottmcm`` ``@joshtriplett``
= note: see issue #136574 <https://github.com/rust-lang/rust/issues/136574> for more information
8
+
= help: add `#![feature(generic_pattern_types)]` to the crate attributes to enable
9
+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10
+
11
+
error[E0658]: wraparound pattern type ranges cause monomorphization time errors
12
+
--> $DIR/assoc_const.rs:17:19
13
+
|
14
+
LL | fn foo<T: Foo>(_: pattern_type!(u32 is <T as Foo>::START..=<T as Foo>::END)) {}
= note: see issue #136574 <https://github.com/rust-lang/rust/issues/136574> for more information
18
+
= help: add `#![feature(generic_pattern_types)]` to the crate attributes to enable
19
+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20
+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
21
+
1
22
error: constant expression depends on a generic parameter
2
23
--> $DIR/assoc_const.rs:17:19
3
24
|
@@ -15,22 +36,44 @@ LL | fn foo<T: Foo>(_: pattern_type!(u32 is <T as Foo>::START..=<T as Foo>::END)
15
36
= note: this may fail depending on what value the parameter takes
16
37
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
17
38
39
+
error[E0658]: wraparound pattern type ranges cause monomorphization time errors
40
+
--> $DIR/assoc_const.rs:22:19
41
+
|
42
+
LL | fn bar<T: Foo>(_: pattern_type!(u32 is T::START..=T::END)) {}
43
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44
+
|
45
+
= note: see issue #136574 <https://github.com/rust-lang/rust/issues/136574> for more information
46
+
= help: add `#![feature(generic_pattern_types)]` to the crate attributes to enable
47
+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
48
+
49
+
error[E0658]: wraparound pattern type ranges cause monomorphization time errors
50
+
--> $DIR/assoc_const.rs:22:19
51
+
|
52
+
LL | fn bar<T: Foo>(_: pattern_type!(u32 is T::START..=T::END)) {}
53
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54
+
|
55
+
= note: see issue #136574 <https://github.com/rust-lang/rust/issues/136574> for more information
56
+
= help: add `#![feature(generic_pattern_types)]` to the crate attributes to enable
57
+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
58
+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
59
+
18
60
error: constant expression depends on a generic parameter
19
-
--> $DIR/assoc_const.rs:20:19
61
+
--> $DIR/assoc_const.rs:22:19
20
62
|
21
63
LL | fn bar<T: Foo>(_: pattern_type!(u32 is T::START..=T::END)) {}
22
64
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23
65
|
24
66
= note: this may fail depending on what value the parameter takes
25
67
26
68
error: constant expression depends on a generic parameter
27
-
--> $DIR/assoc_const.rs:20:19
69
+
--> $DIR/assoc_const.rs:22:19
28
70
|
29
71
LL | fn bar<T: Foo>(_: pattern_type!(u32 is T::START..=T::END)) {}
30
72
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31
73
|
32
74
= note: this may fail depending on what value the parameter takes
33
75
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
34
76
35
-
error: aborting due to 4 previous errors
77
+
error: aborting due to 8 previous errors
36
78
79
+
For more information about this error, try `rustc --explain E0658`.
0 commit comments