Skip to content

Commit 50a22d9

Browse files
bless tests, add fixme comment
1 parent 0e0251e commit 50a22d9

File tree

7 files changed

+55
-22
lines changed

7 files changed

+55
-22
lines changed

compiler/rustc_middle/src/mir/interpret/structural_impls.rs

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for ConstValue<'_> {
3030
let (ptr, offset) = ptr.into_parts();
3131
tcx.get_global_alloc(ptr).hash_stable(hcx, hasher);
3232
offset.hash_stable(hcx, hasher);
33+
// FIXME(compiler-errors): Do we need to hash `size`?
3334
size.hash_stable(hcx, hasher);
3435
}
3536
}
@@ -322,6 +323,7 @@ impl Hash for ConstValue<'_> {
322323
let (ptr, offset) = ptr.into_parts();
323324
tcx.get_global_alloc(ptr).hash(state);
324325
offset.hash(state);
326+
// FIXME(compiler-errors): Do we need to hash `size`?
325327
size.hash(state);
326328
}
327329
}

src/test/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ error[E0080]: it is undefined behavior to use this value
4747
--> $DIR/const-pointer-values-in-various-types.rs:41:5
4848
|
4949
LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 };
50-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc19, but expected initialized plain (non-pointer) bytes
50+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc3, but expected initialized plain (non-pointer) bytes
5151
|
5252
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
5353
= note: the raw bytes of the constant (size: 8, align: 8) {
54-
╾───────alloc19───────╼ │ ╾──────╼
54+
╾───────alloc3────────╼ │ ╾──────╼
5555
}
5656

5757
error[E0080]: it is undefined behavior to use this value
@@ -102,11 +102,11 @@ error[E0080]: it is undefined behavior to use this value
102102
--> $DIR/const-pointer-values-in-various-types.rs:59:5
103103
|
104104
LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 };
105-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc39, but expected initialized plain (non-pointer) bytes
105+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc3, but expected initialized plain (non-pointer) bytes
106106
|
107107
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
108108
= note: the raw bytes of the constant (size: 8, align: 8) {
109-
╾───────alloc39───────╼ │ ╾──────╼
109+
╾───────alloc3────────╼ │ ╾──────╼
110110
}
111111

112112
error[E0080]: it is undefined behavior to use this value
@@ -135,11 +135,11 @@ error[E0080]: it is undefined behavior to use this value
135135
--> $DIR/const-pointer-values-in-various-types.rs:69:5
136136
|
137137
LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 };
138-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc51, but expected initialized plain (non-pointer) bytes
138+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc3, but expected initialized plain (non-pointer) bytes
139139
|
140140
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
141141
= note: the raw bytes of the constant (size: 8, align: 8) {
142-
╾───────alloc51───────╼ │ ╾──────╼
142+
╾───────alloc3────────╼ │ ╾──────╼
143143
}
144144

145145
error: any use of this value will cause an error

src/test/ui/consts/const-eval/ub-enum.64bit.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ error[E0080]: it is undefined behavior to use this value
2424
--> $DIR/ub-enum.rs:30:1
2525
|
2626
LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) };
27-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0.<enum-tag>: encountered pointer to alloc13, but expected initialized plain (non-pointer) bytes
27+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0.<enum-tag>: encountered pointer to alloc9, but expected initialized plain (non-pointer) bytes
2828
|
2929
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
3030
= note: the raw bytes of the constant (size: 8, align: 8) {
31-
╾───────alloc13───────╼ │ ╾──────╼
31+
╾───────alloc9────────╼ │ ╾──────╼
3232
}
3333

3434
error[E0080]: it is undefined behavior to use this value
@@ -57,11 +57,11 @@ error[E0080]: it is undefined behavior to use this value
5757
--> $DIR/ub-enum.rs:47:1
5858
|
5959
LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) };
60-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0.<enum-tag>: encountered pointer to alloc23, but expected initialized plain (non-pointer) bytes
60+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0.<enum-tag>: encountered pointer to alloc19, but expected initialized plain (non-pointer) bytes
6161
|
6262
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
6363
= note: the raw bytes of the constant (size: 8, align: 8) {
64-
╾───────alloc23───────╼ │ ╾──────╼
64+
╾───────alloc19───────╼ │ ╾──────╼
6565
}
6666

6767
error[E0080]: it is undefined behavior to use this value
@@ -79,11 +79,11 @@ error[E0080]: it is undefined behavior to use this value
7979
--> $DIR/ub-enum.rs:60:1
8080
|
8181
LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) };
82-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<enum-tag>: encountered pointer to alloc29, but expected initialized plain (non-pointer) bytes
82+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<enum-tag>: encountered pointer to alloc19, but expected initialized plain (non-pointer) bytes
8383
|
8484
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
8585
= note: the raw bytes of the constant (size: 8, align: 8) {
86-
╾───────alloc29───────╼ │ ╾──────╼
86+
╾───────alloc19───────╼ │ ╾──────╼
8787
}
8888

8989
error[E0080]: it is undefined behavior to use this value

src/test/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1us
1919
|
2020
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
2121
= note: the raw bytes of the constant (size: 16, align: 8) {
22-
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
22+
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
2323
}
2424

2525
error[E0080]: it is undefined behavior to use this value
@@ -31,7 +31,7 @@ LL | | unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usi
3131
|
3232
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
3333
= note: the raw bytes of the constant (size: 16, align: 8) {
34-
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
34+
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
3535
}
3636

3737
error: aborting due to 4 previous errors

src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
1717
|
1818
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
1919
= note: the raw bytes of the constant (size: 8, align: 8) {
20-
╾───────alloc7────────╼ │ ╾──────╼
20+
╾───────alloc3────────╼ │ ╾──────╼
2121
}
2222

2323
error[E0080]: it is undefined behavior to use this value

src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
2828
|
2929
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
3030
= note: the raw bytes of the constant (size: 16, align: 8) {
31-
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
31+
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
3232
}
3333

3434
error[E0080]: it is undefined behavior to use this value
@@ -39,7 +39,7 @@ LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
3939
|
4040
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
4141
= note: the raw bytes of the constant (size: 16, align: 8) {
42-
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
42+
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
4343
}
4444

4545
error[E0080]: it is undefined behavior to use this value
@@ -50,7 +50,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize:
5050
|
5151
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
5252
= note: the raw bytes of the constant (size: 16, align: 8) {
53-
╾───────allocN───────╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
53+
╾───────allocN───────╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
5454
}
5555

5656
error[E0080]: it is undefined behavior to use this value
@@ -98,7 +98,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
9898
|
9999
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
100100
= note: the raw bytes of the constant (size: 16, align: 8) {
101-
╾───────allocN───────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
101+
╾───────allocN───────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
102102
}
103103

104104
error[E0080]: it is undefined behavior to use this value
@@ -109,7 +109,7 @@ LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
109109
|
110110
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
111111
= note: the raw bytes of the constant (size: 16, align: 8) {
112-
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
112+
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
113113
}
114114

115115
error[E0080]: it is undefined behavior to use this value
@@ -120,7 +120,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us
120120
|
121121
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
122122
= note: the raw bytes of the constant (size: 16, align: 8) {
123-
╾───────allocN───────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
123+
╾───────allocN───────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
124124
}
125125

126126
error[E0080]: it is undefined behavior to use this value
@@ -131,7 +131,7 @@ LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)
131131
|
132132
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
133133
= note: the raw bytes of the constant (size: 16, align: 8) {
134-
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
134+
╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
135135
}
136136

137137
error[E0080]: it is undefined behavior to use this value

src/test/ui/consts/issue-93470.rs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// check-pass
2+
// incremental
3+
4+
#[derive(PartialEq, Eq)]
5+
pub struct Key {
6+
path: &'static str,
7+
}
8+
9+
pub const CONST_A: Key = Key {
10+
path: "time_zone/formats@1",
11+
};
12+
13+
pub const CONST_B: Key = Key {
14+
path: "time_zone/formats@1",
15+
};
16+
17+
fn foo(key: Key) -> Result<(), &'static str> {
18+
match key {
19+
CONST_B => Ok(()),
20+
_ => Err(""),
21+
}
22+
}
23+
24+
fn bar(key: Key) -> Result<(), &'static str> {
25+
match key {
26+
CONST_A => Ok(()),
27+
_ => Err(""),
28+
}
29+
}
30+
31+
fn main() {}

0 commit comments

Comments
 (0)