Skip to content

Commit 6af8fb7

Browse files
committed
address review again
1 parent ba00189 commit 6af8fb7

File tree

20 files changed

+118
-519
lines changed

20 files changed

+118
-519
lines changed

Diff for: Cargo.lock

+38-46
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ dependencies = [
288288

289289
[[package]]
290290
name = "cargo"
291-
version = "0.65.0"
291+
version = "0.66.0"
292292
dependencies = [
293293
"anyhow",
294294
"atty",
@@ -299,7 +299,6 @@ dependencies = [
299299
"cargo-util",
300300
"clap",
301301
"crates-io",
302-
"crossbeam-utils",
303302
"curl",
304303
"curl-sys",
305304
"env_logger 0.9.0",
@@ -323,7 +322,6 @@ dependencies = [
323322
"libgit2-sys",
324323
"log",
325324
"memchr",
326-
"num_cpus",
327325
"opener",
328326
"openssl",
329327
"os_info",
@@ -383,6 +381,7 @@ dependencies = [
383381
name = "cargo-miri"
384382
version = "0.1.0"
385383
dependencies = [
384+
"cargo_metadata 0.15.0",
386385
"directories",
387386
"rustc-workspace-hack",
388387
"rustc_version",
@@ -431,6 +430,7 @@ dependencies = [
431430
"termcolor",
432431
"toml_edit",
433432
"url",
433+
"winapi",
434434
]
435435

436436
[[package]]
@@ -1003,16 +1003,6 @@ dependencies = [
10031003
"quote",
10041004
]
10051005

1006-
[[package]]
1007-
name = "ctor"
1008-
version = "0.1.22"
1009-
source = "registry+https://github.com/rust-lang/crates.io-index"
1010-
checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c"
1011-
dependencies = [
1012-
"quote",
1013-
"syn",
1014-
]
1015-
10161006
[[package]]
10171007
name = "curl"
10181008
version = "0.4.43"
@@ -1570,9 +1560,9 @@ dependencies = [
15701560

15711561
[[package]]
15721562
name = "git2"
1573-
version = "0.14.4"
1563+
version = "0.15.0"
15741564
source = "registry+https://github.com/rust-lang/crates.io-index"
1575-
checksum = "d0155506aab710a86160ddb504a480d2964d7ab5b9e62419be69e0032bc5931c"
1565+
checksum = "2994bee4a3a6a51eb90c218523be382fd7ea09b16380b9312e9dbe955ff7c7d1"
15761566
dependencies = [
15771567
"bitflags",
15781568
"libc",
@@ -1585,9 +1575,9 @@ dependencies = [
15851575

15861576
[[package]]
15871577
name = "git2-curl"
1588-
version = "0.15.0"
1578+
version = "0.16.0"
15891579
source = "registry+https://github.com/rust-lang/crates.io-index"
1590-
checksum = "1ee51709364c341fbb6fe2a385a290fb9196753bdde2fc45447d27cd31b11b13"
1580+
checksum = "ed817a00721e2f8037ba722e60358d4956dae9cca10315fc982f967907d3b0cd"
15911581
dependencies = [
15921582
"curl",
15931583
"git2",
@@ -1944,11 +1934,30 @@ dependencies = [
19441934
"rustc-std-workspace-core",
19451935
]
19461936

1937+
[[package]]
1938+
name = "libffi"
1939+
version = "3.0.1"
1940+
source = "registry+https://github.com/rust-lang/crates.io-index"
1941+
checksum = "1e454b3efb16fba3b17810ae5e41df02b649e564ab3c5a34b3b93ed07ad287e6"
1942+
dependencies = [
1943+
"libc",
1944+
"libffi-sys",
1945+
]
1946+
1947+
[[package]]
1948+
name = "libffi-sys"
1949+
version = "2.0.0"
1950+
source = "registry+https://github.com/rust-lang/crates.io-index"
1951+
checksum = "ab4106b7f09d7b87d021334d5618fac1dfcfb824d4c5fe111ff0074dfd242e15"
1952+
dependencies = [
1953+
"cc",
1954+
]
1955+
19471956
[[package]]
19481957
name = "libgit2-sys"
1949-
version = "0.13.4+1.4.2"
1958+
version = "0.14.0+1.5.0"
19501959
source = "registry+https://github.com/rust-lang/crates.io-index"
1951-
checksum = "d0fa6563431ede25f5cc7f6d803c6afbc1c5d3ad3d4925d12c882bf2b526f5d1"
1960+
checksum = "47a00859c70c8a4f7218e6d1cc32875c4b55f6799445b842b0d8ed5e4c3d959b"
19521961
dependencies = [
19531962
"cc",
19541963
"libc",
@@ -2238,6 +2247,8 @@ dependencies = [
22382247
"getrandom 0.2.0",
22392248
"lazy_static",
22402249
"libc",
2250+
"libffi",
2251+
"libloading",
22412252
"log",
22422253
"measureme",
22432254
"rand 0.8.5",
@@ -2410,15 +2421,6 @@ version = "6.0.0"
24102421
source = "registry+https://github.com/rust-lang/crates.io-index"
24112422
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
24122423

2413-
[[package]]
2414-
name = "output_vt100"
2415-
version = "0.1.3"
2416-
source = "registry+https://github.com/rust-lang/crates.io-index"
2417-
checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66"
2418-
dependencies = [
2419-
"winapi",
2420-
]
2421-
24222424
[[package]]
24232425
name = "owo-colors"
24242426
version = "3.4.0"
@@ -2660,18 +2662,6 @@ version = "0.1.1"
26602662
source = "registry+https://github.com/rust-lang/crates.io-index"
26612663
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
26622664

2663-
[[package]]
2664-
name = "pretty_assertions"
2665-
version = "1.3.0"
2666-
source = "registry+https://github.com/rust-lang/crates.io-index"
2667-
checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755"
2668-
dependencies = [
2669-
"ctor",
2670-
"diff",
2671-
"output_vt100",
2672-
"yansi",
2673-
]
2674-
26752665
[[package]]
26762666
name = "pretty_env_logger"
26772667
version = "0.4.0"
@@ -4550,9 +4540,9 @@ checksum = "da73c8f77aebc0e40c300b93f0a5f1bece7a248a36eee287d4e095f35c7b7d6e"
45504540

45514541
[[package]]
45524542
name = "snapbox"
4553-
version = "0.2.10"
4543+
version = "0.3.3"
45544544
source = "registry+https://github.com/rust-lang/crates.io-index"
4555-
checksum = "767a1d5da232b6959cd1bd5c9e8db8a7cce09c3038e89deedb49a549a2aefd93"
4545+
checksum = "44d199ccf8f606592df2d145db26f2aa45344e23c64b074cc5a4047f1d99b0f7"
45564546
dependencies = [
45574547
"concolor",
45584548
"content_inspector",
@@ -4568,9 +4558,9 @@ dependencies = [
45684558

45694559
[[package]]
45704560
name = "snapbox-macros"
4571-
version = "0.2.1"
4561+
version = "0.3.0"
45724562
source = "registry+https://github.com/rust-lang/crates.io-index"
4573-
checksum = "c01dea7e04cbb27ef4c86e9922184608185f7cd95c1763bc30d727cda4a5e930"
4563+
checksum = "8a253e6f894cfa440cba00600a249fa90869d8e0ec45ab274a456e043a0ce8f2"
45744564

45754565
[[package]]
45764566
name = "socket2"
@@ -5049,14 +5039,16 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
50495039

50505040
[[package]]
50515041
name = "ui_test"
5052-
version = "0.1.0"
5042+
version = "0.3.1"
5043+
source = "registry+https://github.com/rust-lang/crates.io-index"
5044+
checksum = "7d1f546a5883ae78da735bba529ec1116661e2f73582f23920d994dc97da3a22"
50535045
dependencies = [
50545046
"cargo_metadata 0.15.0",
50555047
"color-eyre",
50565048
"colored",
50575049
"crossbeam",
5050+
"diff",
50585051
"lazy_static",
5059-
"pretty_assertions",
50605052
"regex",
50615053
"rustc_version",
50625054
"serde",

Diff for: compiler/rustc_borrowck/src/renumber.rs

+18-23
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ where
3838
})
3939
}
4040

41+
fn renumber_regions_in_mir_constant<'tcx>(
42+
infcx: &InferCtxt<'_, 'tcx>,
43+
value: ConstantKind<'tcx>,
44+
) -> ConstantKind<'tcx> {
45+
infcx.tcx.super_fold_regions(value, |_region, _depth| {
46+
let origin = NllRegionVariableOrigin::Existential { from_forall: false };
47+
infcx.next_nll_region_var(origin)
48+
})
49+
}
50+
4151
struct NllVisitor<'a, 'tcx> {
4252
infcx: &'a InferCtxt<'a, 'tcx>,
4353
}
@@ -49,6 +59,13 @@ impl<'a, 'tcx> NllVisitor<'a, 'tcx> {
4959
{
5060
renumber_regions(self.infcx, value)
5161
}
62+
63+
fn renumber_regions_in_mir_constant(
64+
&mut self,
65+
value: ConstantKind<'tcx>,
66+
) -> ConstantKind<'tcx> {
67+
renumber_regions_in_mir_constant(self.infcx, value)
68+
}
5269
}
5370

5471
impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
@@ -81,29 +98,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
8198
#[instrument(skip(self), level = "debug")]
8299
fn visit_constant(&mut self, constant: &mut Constant<'tcx>, _location: Location) {
83100
let literal = constant.literal;
84-
debug!("{:#?}", literal);
85-
86-
match literal {
87-
ConstantKind::Ty(ct) => {
88-
let ct = self.renumber_regions(ct);
89-
debug!("renumbered ct {:#?}", ct);
90-
91-
constant.literal = ConstantKind::Ty(ct);
92-
}
93-
ConstantKind::Unevaluated(uv, ty) => {
94-
debug!("uv: {:#?}, ty: {:#?}", uv, ty);
95-
let uv = self.renumber_regions(uv);
96-
debug!("uv: {:#?}", uv);
97-
let ty = self.renumber_regions(ty);
98-
debug!("{:#?}", ty);
99-
constant.literal = ConstantKind::Unevaluated(uv, ty);
100-
}
101-
ConstantKind::Val(val, ty) => {
102-
let ty = self.renumber_regions(ty);
103-
constant.literal = ConstantKind::Val(val, ty);
104-
}
105-
}
106-
101+
constant.literal = self.renumber_regions_in_mir_constant(literal);
107102
debug!("constant: {:#?}", constant);
108103
}
109104
}

Diff for: compiler/rustc_borrowck/src/type_check/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
354354
let tcx = self.tcx();
355355
let maybe_uneval = match constant.literal {
356356
ConstantKind::Ty(ct) => match ct.kind() {
357-
ty::ConstKind::Unevaluated(uv) => Some(uv.expand()),
357+
ty::ConstKind::Unevaluated(_) => {
358+
bug!("should not encounter unevaluated ConstantKind::Ty here, got {:?}", ct)
359+
}
358360
_ => None,
359361
},
360362
ConstantKind::Unevaluated(uv, _) => Some(uv),

Diff for: compiler/rustc_codegen_cranelift/src/constant.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,7 @@ pub(crate) fn codegen_constant<'tcx>(
121121
ConstKind::Value(valtree) => {
122122
(fx.tcx.valtree_to_const_val((const_.ty(), valtree)), const_.ty())
123123
}
124-
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
125-
if fx.tcx.is_static(def.did) =>
126-
{
127-
assert!(substs.is_empty());
128-
assert_eq!(promoted, ());
129-
return codegen_static_ref(fx, def.did, fx.layout_of(const_.ty())).to_cvalue(fx);
130-
}
131-
ConstKind::Unevaluated(unevaluated) => {
132-
match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated.expand(), None)
133-
{
134-
Ok(const_val) => (const_val, const_.ty()),
135-
Err(_) => {
136-
span_bug!(
137-
constant.span,
138-
"erroneous constant not captured by required_consts"
139-
);
140-
}
141-
}
142-
}
124+
ConstKind::Unevaluated(_) => bug!("expected constant to be evaluated at this stage"),
143125
ConstKind::Param(_)
144126
| ConstKind::Infer(_)
145127
| ConstKind::Bound(_, _)

Diff for: compiler/rustc_const_eval/src/interpret/operand.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,16 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
564564
throw_inval!(AlreadyReported(reported))
565565
}
566566
ty::ConstKind::Unevaluated(uv) => {
567+
// NOTE: We evaluate to a `ValTree` here as a check to ensure
568+
// we're working with valid constants, even though we never need it.
567569
let instance = self.resolve(uv.def, uv.substs)?;
568-
Ok(self.eval_to_allocation(GlobalId { instance, promoted: None })?.into())
570+
let cid = GlobalId { instance, promoted: None };
571+
let _valtree = self
572+
.tcx
573+
.eval_to_valtree(self.param_env.and(cid))?
574+
.unwrap_or_else(|| bug!("unable to create ValTree for {:?}", uv));
575+
576+
Ok(self.eval_to_allocation(cid)?.into())
569577
}
570578
ty::ConstKind::Bound(..) | ty::ConstKind::Infer(..) => {
571579
span_bug!(self.cur_span(), "const_to_op: Unexpected ConstKind {:?}", c)
@@ -578,16 +586,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
578586
}
579587
}
580588

581-
/// Tries to evaluate an unevaluated constant from the MIR (and not the type-system).
582-
#[inline]
583-
pub fn uneval_to_op(
584-
&self,
585-
uneval: &ty::Unevaluated<'tcx>,
586-
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
587-
let instance = self.resolve(uneval.def, uneval.substs)?;
588-
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uneval.promoted })?.into())
589-
}
590-
591589
pub fn mir_const_to_op(
592590
&self,
593591
val: &mir::ConstantKind<'tcx>,
@@ -596,7 +594,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
596594
match val {
597595
mir::ConstantKind::Ty(ct) => self.const_to_op(*ct, layout),
598596
mir::ConstantKind::Val(val, ty) => self.const_val_to_op(*val, *ty, layout),
599-
mir::ConstantKind::Unevaluated(uv, _) => self.uneval_to_op(uv),
597+
mir::ConstantKind::Unevaluated(uv, _) => {
598+
let instance = self.resolve(uv.def, uv.substs)?;
599+
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into())
600+
}
600601
}
601602
}
602603

Diff for: compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ where
346346
};
347347

348348
// Check the qualifs of the value of `const` items.
349+
// FIXME(valtrees): check whether const qualifs should behave the same
350+
// way for type and mir constants.
349351
let uneval = match constant.literal {
350352
ConstantKind::Ty(ct) if matches!(ct.kind(), ty::ConstKind::Unevaluated(_)) => {
351353
let ty::ConstKind::Unevaluated(uv) = ct.kind() else { unreachable!() };

Diff for: compiler/rustc_middle/src/mir/mod.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -2090,15 +2090,6 @@ impl<'tcx> Constant<'tcx> {
20902090
}
20912091

20922092
impl<'tcx> ConstantKind<'tcx> {
2093-
/// Returns `None` if the constant is not trivially safe for use in the type system.
2094-
#[inline]
2095-
pub fn const_for_ty(&self) -> Option<ty::Const<'tcx>> {
2096-
match self {
2097-
ConstantKind::Ty(c) => Some(*c),
2098-
ConstantKind::Val(..) | ConstantKind::Unevaluated(..) => None,
2099-
}
2100-
}
2101-
21022093
#[inline(always)]
21032094
pub fn ty(&self) -> Ty<'tcx> {
21042095
match self {
@@ -2433,14 +2424,14 @@ impl<'tcx> ConstantKind<'tcx> {
24332424
debug!("error encountered during evaluation");
24342425
// Error was handled in `const_eval_resolve`. Here we just create a
24352426
// new unevaluated const and error hard later in codegen
2436-
Self::Ty(tcx.mk_const(ty::ConstS {
2437-
kind: ty::ConstKind::Unevaluated(ty::Unevaluated {
2427+
Self::Unevaluated(
2428+
ty::Unevaluated {
24382429
def: def.to_global(),
24392430
substs: InternalSubsts::identity_for_item(tcx, def.did.to_def_id()),
2440-
promoted: (),
2441-
}),
2431+
promoted: None,
2432+
},
24422433
ty,
2443-
}))
2434+
)
24442435
}
24452436
}
24462437
}

0 commit comments

Comments
 (0)