Skip to content

Commit 060acc9

Browse files
committed
rebase
1 parent 8093db6 commit 060acc9

File tree

10 files changed

+118
-44
lines changed

10 files changed

+118
-44
lines changed

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,8 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
703703
// but we get a deterministic, virtually unique value for the constant.
704704
let hcx = &mut tcx.create_stable_hashing_context();
705705
let mut hasher = StableHasher::new();
706-
hcx.while_hashing_spans(false, |hcx| ct.kind().hash_stable(hcx, &mut hasher));
706+
let ct = ct.eval(tcx, ty::ParamEnv::reveal_all());
707+
hcx.while_hashing_spans(false, |hcx| ct.to_valtree().hash_stable(hcx, &mut hasher));
707708
// Let's only emit 64 bits of the hash value. That should be plenty for
708709
// avoiding collisions and will make the emitted type names shorter.
709710
let hash: u64 = hasher.finish();

compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ use rustc_query_system::ich::StableHashingContext;
4242
use rustc_session::cstore::CrateStoreDyn;
4343
use rustc_span::symbol::{kw, sym, Ident, Symbol};
4444
use rustc_span::Span;
45-
pub use subst::*;
4645
use rustc_target::abi::{Align, VariantIdx};
46+
pub use subst::*;
4747
pub use vtable::*;
4848

4949
use std::fmt::Debug;

compiler/rustc_mir_build/src/build/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ pub(crate) use crate::build::expr::as_constant::lit_to_mir_constant;
33
use crate::build::expr::as_place::PlaceBuilder;
44
use crate::build::scope::DropKind;
55
use crate::thir::pattern::pat_from_hir;
6-
use rustc_data_structures::fx::FxHashMap;
76
use rustc_apfloat::ieee::{Double, Single};
7+
use rustc_apfloat::Float;
8+
use rustc_data_structures::fx::FxHashMap;
89
use rustc_errors::ErrorGuaranteed;
910
use rustc_hir as hir;
1011
use rustc_hir::def_id::{DefId, LocalDefId};

src/test/ui/associated-consts/defaults-cyclic-fail.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ LL | const B: u8 = Self::A;
1111
| ^^^^^^^^^^^^^^^^^^^^^^
1212
= note: ...which again requires const-evaluating + checking `Tr::A`, completing the cycle
1313
note: cycle used when const-evaluating + checking `main::promoted[1]`
14-
--> $DIR/defaults-cyclic-fail.rs:14:1
14+
--> $DIR/defaults-cyclic-fail.rs:16:16
1515
|
16-
LL | fn main() {
17-
| ^^^^^^^^^
16+
LL | assert_eq!(<() as Tr>::A, 0);
17+
| ^^^^^^^^^^^^^
1818

1919
error: aborting due to previous error
2020

src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0391]: cycle detected when elaborating drops for `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`
2-
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5
2+
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:22
33
|
44
LL | const BAR: u32 = IMPL_REF_BAR;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^
66
|
77
note: ...which requires const-evaluating + checking `IMPL_REF_BAR`...
88
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1

src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0391]: cycle detected when elaborating drops for `FooDefault::BAR`
2-
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5
2+
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:22
33
|
44
LL | const BAR: u32 = DEFAULT_REF_BAR;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^
66
|
77
note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`...
88
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1

src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0391]: cycle detected when elaborating drops for `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`
2-
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5
2+
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:22
33
|
44
LL | const BAR: u32 = TRAIT_REF_BAR;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^
66
|
77
note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`...
88
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1

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

+49-16
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,19 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
149149
╾─allocN─╼ │ ╾──╼
150150
}
151151

152+
error: any use of this value will cause an error
153+
--> $DIR/ub-wide-ptr.rs:87:40
154+
|
155+
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
156+
| ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
157+
| |
158+
| referenced constant has errors
159+
|
160+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
161+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
162+
152163
error[E0080]: it is undefined behavior to use this value
153-
--> $DIR/ub-wide-ptr.rs:93:1
164+
--> $DIR/ub-wide-ptr.rs:95:1
154165
|
155166
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
156167
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>.0: encountered 0x03, but expected a boolean
@@ -160,8 +171,19 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
160171
╾allocN─╼ │ ╾──╼
161172
}
162173

174+
error: any use of this value will cause an error
175+
--> $DIR/ub-wide-ptr.rs:95:42
176+
|
177+
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
178+
| -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
179+
| |
180+
| referenced constant has errors
181+
|
182+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
183+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
184+
163185
error[E0080]: it is undefined behavior to use this value
164-
--> $DIR/ub-wide-ptr.rs:96:1
186+
--> $DIR/ub-wide-ptr.rs:100:1
165187
|
166188
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
167189
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>.1[0]: encountered 0x03, but expected a boolean
@@ -171,8 +193,19 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
171193
╾allocN─╼ │ ╾──╼
172194
}
173195

196+
error: any use of this value will cause an error
197+
--> $DIR/ub-wide-ptr.rs:100:42
198+
|
199+
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
200+
| -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
201+
| |
202+
| referenced constant has errors
203+
|
204+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
205+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
206+
174207
error[E0080]: it is undefined behavior to use this value
175-
--> $DIR/ub-wide-ptr.rs:103:1
208+
--> $DIR/ub-wide-ptr.rs:109:1
176209
|
177210
LL | / const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
178211
LL | |
@@ -187,7 +220,7 @@ LL | | };
187220
}
188221

189222
error[E0080]: it is undefined behavior to use this value
190-
--> $DIR/ub-wide-ptr.rs:111:1
223+
--> $DIR/ub-wide-ptr.rs:117:1
191224
|
192225
LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
193226
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered too small vtable
@@ -198,7 +231,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((
198231
}
199232

200233
error[E0080]: it is undefined behavior to use this value
201-
--> $DIR/ub-wide-ptr.rs:114:1
234+
--> $DIR/ub-wide-ptr.rs:120:1
202235
|
203236
LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
204237
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered too small vtable
@@ -209,7 +242,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((
209242
}
210243

211244
error[E0080]: it is undefined behavior to use this value
212-
--> $DIR/ub-wide-ptr.rs:117:1
245+
--> $DIR/ub-wide-ptr.rs:123:1
213246
|
214247
LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
215248
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered dangling vtable pointer in wide pointer
@@ -220,7 +253,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u
220253
}
221254

222255
error[E0080]: it is undefined behavior to use this value
223-
--> $DIR/ub-wide-ptr.rs:119:1
256+
--> $DIR/ub-wide-ptr.rs:125:1
224257
|
225258
LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
226259
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered unaligned vtable pointer in wide pointer
@@ -231,7 +264,7 @@ LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92
231264
}
232265

233266
error[E0080]: it is undefined behavior to use this value
234-
--> $DIR/ub-wide-ptr.rs:121:1
267+
--> $DIR/ub-wide-ptr.rs:127:1
235268
|
236269
LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
237270
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
@@ -242,7 +275,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92
242275
}
243276

244277
error[E0080]: it is undefined behavior to use this value
245-
--> $DIR/ub-wide-ptr.rs:123:1
278+
--> $DIR/ub-wide-ptr.rs:129:1
246279
|
247280
LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
248281
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
@@ -253,7 +286,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u
253286
}
254287

255288
error[E0080]: it is undefined behavior to use this value
256-
--> $DIR/ub-wide-ptr.rs:125:1
289+
--> $DIR/ub-wide-ptr.rs:131:1
257290
|
258291
LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
259292
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .0: encountered invalid drop function pointer in vtable (not pointing to a function)
@@ -264,7 +297,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans
264297
}
265298

266299
error[E0080]: it is undefined behavior to use this value
267-
--> $DIR/ub-wide-ptr.rs:129:1
300+
--> $DIR/ub-wide-ptr.rs:135:1
268301
|
269302
LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
270303
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean
@@ -275,7 +308,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
275308
}
276309

277310
error[E0080]: it is undefined behavior to use this value
278-
--> $DIR/ub-wide-ptr.rs:133:1
311+
--> $DIR/ub-wide-ptr.rs:139:1
279312
|
280313
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
281314
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling vtable pointer in wide pointer
@@ -286,7 +319,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute
286319
}
287320

288321
error[E0080]: it is undefined behavior to use this value
289-
--> $DIR/ub-wide-ptr.rs:135:1
322+
--> $DIR/ub-wide-ptr.rs:141:1
290323
|
291324
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
292325
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered too small vtable
@@ -297,17 +330,17 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm
297330
}
298331

299332
error[E0080]: could not evaluate static initializer
300-
--> $DIR/ub-wide-ptr.rs:141:5
333+
--> $DIR/ub-wide-ptr.rs:147:5
301334
|
302335
LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
303336
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is not a valid pointer
304337

305338
error[E0080]: could not evaluate static initializer
306-
--> $DIR/ub-wide-ptr.rs:145:5
339+
--> $DIR/ub-wide-ptr.rs:151:5
307340
|
308341
LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
309342
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: allocN has size N, so pointer to 12 bytes starting at offset N is out-of-bounds
310343

311-
error: aborting due to 29 previous errors
344+
error: aborting due to 32 previous errors
312345

313346
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)