Skip to content

Commit 805e284

Browse files
committed
feat!: remove bool, char, and str variants from TypeKind
1 parent c6936c3 commit 805e284

11 files changed

Lines changed: 21 additions & 73 deletions

File tree

compiler/rustc_const_eval/src/const_eval/type_info.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,6 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
7474

7575
variant
7676
}
77-
ty::Bool => {
78-
let (variant, _variant_place) = downcast(sym::Bool)?;
79-
variant
80-
}
81-
ty::Char => {
82-
let (variant, _variant_place) = downcast(sym::Char)?;
83-
variant
84-
}
8577
ty::Int(int_ty) => {
8678
let (variant, variant_place) = downcast(sym::Int)?;
8779
let place = self.project_field(&variant_place, FieldIdx::ZERO)?;
@@ -108,10 +100,6 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
108100
self.write_float_type_info(place, float_ty.bit_width())?;
109101
variant
110102
}
111-
ty::Str => {
112-
let (variant, _variant_place) = downcast(sym::Str)?;
113-
variant
114-
}
115103
ty::Ref(_, ty, mutability) => {
116104
let (variant, variant_place) = downcast(sym::Reference)?;
117105
let reference_place =
@@ -136,6 +124,9 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
136124
variant
137125
}
138126
ty::Adt(_, _)
127+
| ty::Bool
128+
| ty::Char
129+
| ty::Str
139130
| ty::Foreign(_)
140131
| ty::Pat(_, _)
141132
| ty::FnDef(..)

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ symbols! {
190190
BTreeMap,
191191
BTreeSet,
192192
BinaryHeap,
193-
Bool,
194193
Borrow,
195194
BorrowMut,
196195
Break,
@@ -203,7 +202,6 @@ symbols! {
203202
Capture,
204203
Cell,
205204
Center,
206-
Char,
207205
Child,
208206
Cleanup,
209207
Clone,
@@ -370,7 +368,6 @@ symbols! {
370368
Some,
371369
SpanCtxt,
372370
Stdin,
373-
Str,
374371
String,
375372
StructuralPartialEq,
376373
SubdiagMessage,

library/core/src/mem/type_info.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,10 @@ pub enum TypeKind {
4949
Slice(Slice),
5050
/// Dynamic Traits.
5151
DynTrait(DynTrait),
52-
/// Primitive boolean type.
53-
Bool(Bool),
54-
/// Primitive character type.
55-
Char(Char),
5652
/// Primitive signed and unsigned integer type.
5753
Int(Int),
5854
/// Primitive floating-point type.
5955
Float(Float),
60-
/// String slice type.
61-
Str(Str),
6256
/// References.
6357
Reference(Reference),
6458
/// Pointers.
@@ -137,22 +131,6 @@ pub struct Trait {
137131
pub is_auto: bool,
138132
}
139133

140-
/// Compile-time type information about `bool`.
141-
#[derive(Debug)]
142-
#[non_exhaustive]
143-
#[unstable(feature = "type_info", issue = "146922")]
144-
pub struct Bool {
145-
// No additional information to provide for now.
146-
}
147-
148-
/// Compile-time type information about `char`.
149-
#[derive(Debug)]
150-
#[non_exhaustive]
151-
#[unstable(feature = "type_info", issue = "146922")]
152-
pub struct Char {
153-
// No additional information to provide for now.
154-
}
155-
156134
/// Compile-time type information about signed and unsigned integer types.
157135
#[derive(Debug)]
158136
#[non_exhaustive]
@@ -173,14 +151,6 @@ pub struct Float {
173151
pub bits: u32,
174152
}
175153

176-
/// Compile-time type information about string slice types.
177-
#[derive(Debug)]
178-
#[non_exhaustive]
179-
#[unstable(feature = "type_info", issue = "146922")]
180-
pub struct Str {
181-
// No additional information to provide for now.
182-
}
183-
184154
/// Compile-time type information about references.
185155
#[derive(Debug)]
186156
#[non_exhaustive]

library/coretests/tests/mem/type_info.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ fn test_tuples() {
7070
fn test_primitives() {
7171
use TypeKind::*;
7272

73-
let Type { kind: Bool(_ty), size, .. } = (const { Type::of::<bool>() }) else { panic!() };
73+
let Type { kind: Other, size, .. } = (const { Type::of::<bool>() }) else { panic!() };
7474
assert_eq!(size, Some(1));
7575

76-
let Type { kind: Char(_ty), size, .. } = (const { Type::of::<char>() }) else { panic!() };
76+
let Type { kind: Other, size, .. } = (const { Type::of::<char>() }) else { panic!() };
7777
assert_eq!(size, Some(4));
7878

7979
let Type { kind: Int(ty), size, .. } = (const { Type::of::<i32>() }) else { panic!() };
@@ -100,7 +100,7 @@ fn test_primitives() {
100100
assert_eq!(size, Some(4));
101101
assert_eq!(ty.bits, 32);
102102

103-
let Type { kind: Str(_ty), size, .. } = (const { Type::of::<str>() }) else { panic!() };
103+
let Type { kind: Other, size, .. } = (const { Type::of::<str>() }) else { panic!() };
104104
assert_eq!(size, None);
105105
}
106106

tests/ui/lint/recommend-literal.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//~vv HELP consider importing this struct
2-
31
type Real = double;
42
//~^ ERROR cannot find type `double` in this scope
53
//~| HELP perhaps you intended to use this type

tests/ui/lint/recommend-literal.stderr

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0425]: cannot find type `double` in this scope
2-
--> $DIR/recommend-literal.rs:3:13
2+
--> $DIR/recommend-literal.rs:1:13
33
|
44
LL | type Real = double;
55
| ^^^^^^
@@ -8,7 +8,7 @@ LL | type Real = double;
88
| help: perhaps you intended to use this type: `f64`
99

1010
error[E0425]: cannot find type `long` in this scope
11-
--> $DIR/recommend-literal.rs:9:12
11+
--> $DIR/recommend-literal.rs:7:12
1212
|
1313
LL | let y: long = 74802374902374923;
1414
| ^^^^
@@ -17,7 +17,7 @@ LL | let y: long = 74802374902374923;
1717
| help: perhaps you intended to use this type: `i64`
1818

1919
error[E0425]: cannot find type `Boolean` in this scope
20-
--> $DIR/recommend-literal.rs:12:13
20+
--> $DIR/recommend-literal.rs:10:13
2121
|
2222
LL | let v1: Boolean = true;
2323
| ^^^^^^^
@@ -26,7 +26,7 @@ LL | let v1: Boolean = true;
2626
| help: perhaps you intended to use this type: `bool`
2727

2828
error[E0425]: cannot find type `Bool` in this scope
29-
--> $DIR/recommend-literal.rs:15:13
29+
--> $DIR/recommend-literal.rs:13:13
3030
|
3131
LL | let v2: Bool = true;
3232
| ^^^^
@@ -41,13 +41,9 @@ help: perhaps you intended to use this type
4141
LL - let v2: Bool = true;
4242
LL + let v2: bool = true;
4343
|
44-
help: consider importing this struct
45-
|
46-
LL + use std::mem::type_info::Bool;
47-
|
4844

4945
error[E0425]: cannot find type `boolean` in this scope
50-
--> $DIR/recommend-literal.rs:21:9
46+
--> $DIR/recommend-literal.rs:19:9
5147
|
5248
LL | fn z(a: boolean) {
5349
| ^^^^^^^
@@ -56,7 +52,7 @@ LL | fn z(a: boolean) {
5652
| help: perhaps you intended to use this type: `bool`
5753

5854
error[E0425]: cannot find type `byte` in this scope
59-
--> $DIR/recommend-literal.rs:26:11
55+
--> $DIR/recommend-literal.rs:24:11
6056
|
6157
LL | fn a() -> byte {
6258
| ^^^^
@@ -65,7 +61,7 @@ LL | fn a() -> byte {
6561
| help: perhaps you intended to use this type: `u8`
6662

6763
error[E0425]: cannot find type `float` in this scope
68-
--> $DIR/recommend-literal.rs:33:12
64+
--> $DIR/recommend-literal.rs:31:12
6965
|
7066
LL | width: float,
7167
| ^^^^^
@@ -74,7 +70,7 @@ LL | width: float,
7470
| help: perhaps you intended to use this type: `f32`
7571

7672
error[E0425]: cannot find type `int` in this scope
77-
--> $DIR/recommend-literal.rs:36:19
73+
--> $DIR/recommend-literal.rs:34:19
7874
|
7975
LL | depth: Option<int>,
8076
| ^^^ not found in this scope
@@ -90,7 +86,7 @@ LL | struct Data<int> {
9086
| +++++
9187

9288
error[E0425]: cannot find type `short` in this scope
93-
--> $DIR/recommend-literal.rs:42:16
89+
--> $DIR/recommend-literal.rs:40:16
9490
|
9591
LL | impl Stuff for short {}
9692
| ^^^^^

tests/ui/reflection/dump.bit32.run.stdout

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ Type {
188188
),
189189
}
190190
Type {
191-
kind: Str(
192-
Str,
193-
),
191+
kind: Other,
194192
size: None,
195193
}
196194
Type {

tests/ui/reflection/dump.bit64.run.stdout

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ Type {
188188
),
189189
}
190190
Type {
191-
kind: Str(
192-
Str,
193-
),
191+
kind: Other,
194192
size: None,
195193
}
196194
Type {

tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ LL | .collect::<String>();
2121
|
2222
= help: the trait `FromIterator<()>` is not implemented for `String`
2323
= help: the following other types implement trait `FromIterator<A>`:
24+
`String` implements `FromIterator<&Char>`
2425
`String` implements `FromIterator<&char>`
25-
`String` implements `FromIterator<&std::ascii::Char>`
2626
`String` implements `FromIterator<&str>`
2727
`String` implements `FromIterator<Box<str, A>>`
28+
`String` implements `FromIterator<Char>`
2829
`String` implements `FromIterator<Cow<'_, str>>`
2930
`String` implements `FromIterator<String>`
3031
`String` implements `FromIterator<char>`
31-
`String` implements `FromIterator<std::ascii::Char>`
3232
note: the method call chain might not have had the expected associated types
3333
--> $DIR/semi-suggestion-when-stmt-and-expr-span-equal.rs:20:10
3434
|

tests/ui/traits/issue-77982.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect(
4444
| type must be known at this point
4545
|
4646
= note: multiple `impl`s satisfying `u32: From<_>` found in the `core` crate:
47+
- impl From<Char> for u32;
4748
- impl From<Ipv4Addr> for u32;
4849
- impl From<bool> for u32;
4950
- impl From<char> for u32;
50-
- impl From<std::ascii::Char> for u32;
5151
- impl From<u16> for u32;
5252
- impl From<u8> for u32;
5353
help: try using a fully qualified path to specify the expected types

0 commit comments

Comments
 (0)