Skip to content

Commit db4e77c

Browse files
committed
Rollup merge of #55199 - oli-obk:instance_printing, r=davidtwco
Impl items have generics
2 parents abf7243 + 5a48f20 commit db4e77c

16 files changed

+34
-35
lines changed

src/librustc/util/ppaux.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,17 @@ impl PrintContext {
251251
fn parameterized<F: fmt::Write>(&mut self,
252252
f: &mut F,
253253
substs: &subst::Substs<'_>,
254-
mut did: DefId,
254+
did: DefId,
255255
projections: &[ty::ProjectionPredicate<'_>])
256256
-> fmt::Result {
257257
let key = ty::tls::with(|tcx| tcx.def_key(did));
258-
let mut item_name = if let Some(name) = key.disambiguated_data.data.get_opt_name() {
259-
Some(name)
260-
} else {
261-
did.index = key.parent.unwrap_or_else(
262-
|| bug!("finding type for {:?}, encountered def-id {:?} with no parent",
263-
did, did));
264-
self.parameterized(f, substs, did, projections)?;
265-
return write!(f, "::{}", key.disambiguated_data.data.as_interned_str());
266-
};
267258

268259
let verbose = self.is_verbose;
269260
let mut num_supplied_defaults = 0;
270261
let mut has_self = false;
271262
let mut own_counts: GenericParamCount = Default::default();
272263
let mut is_value_path = false;
264+
let mut item_name = Some(key.disambiguated_data.data.as_interned_str());
273265
let fn_trait_kind = ty::tls::with(|tcx| {
274266
// Unfortunately, some kinds of items (e.g., closures) don't have
275267
// generics. So walk back up the find the closest parent that DOES
@@ -282,6 +274,7 @@ impl PrintContext {
282274
DefPathData::AssocTypeInImpl(_) |
283275
DefPathData::AssocExistentialInImpl(_) |
284276
DefPathData::Trait(_) |
277+
DefPathData::Impl |
285278
DefPathData::TypeNs(_) => {
286279
break;
287280
}
@@ -292,7 +285,6 @@ impl PrintContext {
292285
}
293286
DefPathData::CrateRoot |
294287
DefPathData::Misc |
295-
DefPathData::Impl |
296288
DefPathData::Module(_) |
297289
DefPathData::MacroDef(_) |
298290
DefPathData::ClosureExpr |

src/librustc_mir/const_eval.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,13 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
612612
other => return other,
613613
}
614614
}
615+
// the first trace is for replicating an ice
616+
// There's no tracking issue, but the next two lines concatenated link to the discussion on
617+
// zulip. It's not really possible to test this, because it doesn't show up in diagnostics
618+
// or MIR.
619+
// https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/
620+
// subject/anon_const_instance_printing/near/135980032
621+
trace!("const eval: {}", key.value.instance);
615622
trace!("const eval: {:?}", key);
616623

617624
let cid = key.value;

src/test/mir-opt/end_region_4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn foo(i: i32) {
4444
// let mut _5: i32;
4545
// bb0: {
4646
// StorageLive(_1);
47-
// _1 = D::{{constructor}}(const 0i32,);
47+
// _1 = D(const 0i32,);
4848
// FakeRead(ForLet, _1);
4949
// StorageLive(_2);
5050
// _2 = const 0i32;

src/test/mir-opt/end_region_5.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
3737
// let mut _4: &'18s D;
3838
// bb0: {
3939
// StorageLive(_1);
40-
// _1 = D::{{constructor}}(const 0i32,);
40+
// _1 = D(const 0i32,);
4141
// FakeRead(ForLet, _1);
4242
// StorageLive(_3);
4343
// StorageLive(_4);

src/test/mir-opt/end_region_6.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
3737
// let mut _4: &'24s D;
3838
// bb0: {
3939
// StorageLive(_1);
40-
// _1 = D::{{constructor}}(const 0i32,);
40+
// _1 = D(const 0i32,);
4141
// FakeRead(ForLet, _1);
4242
// StorageLive(_3);
4343
// StorageLive(_4);

src/test/mir-opt/end_region_7.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
3636
// let mut _3: [closure@NodeId(33) d:D];
3737
// bb0: {
3838
// StorageLive(_1);
39-
// _1 = D::{{constructor}}(const 0i32,);
39+
// _1 = D(const 0i32,);
4040
// FakeRead(ForLet, _1);
4141
// StorageLive(_3);
4242
// _3 = [closure@NodeId(33)] { d: move _1 };

src/test/mir-opt/end_region_8.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
3939
// let mut _4: [closure@NodeId(33) r:&'24s D];
4040
// bb0: {
4141
// StorageLive(_1);
42-
// _1 = D::{{constructor}}(const 0i32,);
42+
// _1 = D(const 0i32,);
4343
// FakeRead(ForLet, _1);
4444
// StorageLive(_2);
4545
// _2 = &'26_1rs _1;

src/test/mir-opt/end_region_destruction_extents_1.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ unsafe impl<'a, #[may_dangle] 'b> Drop for D1<'a, 'b> {
7979
// StorageLive(_3);
8080
// StorageLive(_4);
8181
// StorageLive(_5);
82-
// _5 = S1::{{constructor}}(const "ex1",);
82+
// _5 = S1(const "ex1",);
8383
// _4 = &'15ds _5;
8484
// _3 = &'15ds (*_4);
8585
// StorageLive(_6);
8686
// StorageLive(_7);
8787
// StorageLive(_8);
88-
// _8 = S1::{{constructor}}(const "dang1",);
88+
// _8 = S1(const "dang1",);
8989
// _7 = &'13s _8;
9090
// _6 = &'13s (*_7);
91-
// _2 = D1<'15ds, '13s>::{{constructor}}(move _3, move _6);
91+
// _2 = D1<'15ds, '13s>(move _3, move _6);
9292
// EndRegion('13s);
9393
// StorageDead(_6);
9494
// StorageDead(_3);
@@ -132,7 +132,7 @@ unsafe impl<'a, #[may_dangle] 'b> Drop for D1<'a, 'b> {
132132
// StorageLive(_7);
133133
// _7 = &'13s (promoted[0]: S1);
134134
// _6 = &'13s (*_7);
135-
// _2 = D1<'15ds, '13s>::{{constructor}}(move _3, move _6);
135+
// _2 = D1<'15ds, '13s>(move _3, move _6);
136136
// EndRegion('13s);
137137
// StorageDead(_6);
138138
// StorageDead(_3);

src/test/mir-opt/packed-struct-drop-aligned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Drop for Droppy {
4242
// bb0: {
4343
// StorageLive(_1);
4444
// ...
45-
// _1 = Packed::{{constructor}}(move _2,);
45+
// _1 = Packed(move _2,);
4646
// ...
4747
// StorageLive(_6);
4848
// _6 = move (_1.0: Aligned);

src/test/ui/issues/issue-21554.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0606]: casting `fn(i32) -> Inches {Inches::{{constructor}}}` as `f32` is invalid
1+
error[E0606]: casting `fn(i32) -> Inches {Inches}` as `f32` is invalid
22
--> $DIR/issue-21554.rs:14:5
33
|
44
LL | Inches as f32;

0 commit comments

Comments
 (0)