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

+3-11
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

+7
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+4-4
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

+1-1
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

+1-1
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;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | fn test() -> Foo { Foo } //~ ERROR mismatched types
99
| expected `Foo` because of return type
1010
|
1111
= note: expected type `Foo`
12-
found type `fn(u32) -> Foo {Foo::{{constructor}}}`
12+
found type `fn(u32) -> Foo {Foo}`
1313

1414
error: aborting due to previous error
1515

src/test/ui/namespace/namespace-mix.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ note: required by `check`
144144
LL | fn check<T: Impossible>(_: T) {}
145145
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146146

147-
error[E0277]: the trait bound `fn() -> c::TS {c::TS::{{constructor}}}: Impossible` is not satisfied
147+
error[E0277]: the trait bound `fn() -> c::TS {c::TS}: Impossible` is not satisfied
148148
--> $DIR/namespace-mix.rs:66:5
149149
|
150150
LL | check(m3::TS); //~ ERROR c::TS
151-
| ^^^^^ the trait `Impossible` is not implemented for `fn() -> c::TS {c::TS::{{constructor}}}`
151+
| ^^^^^ the trait `Impossible` is not implemented for `fn() -> c::TS {c::TS}`
152152
|
153153
note: required by `check`
154154
--> $DIR/namespace-mix.rs:31:1
@@ -192,11 +192,11 @@ note: required by `check`
192192
LL | fn check<T: Impossible>(_: T) {}
193193
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
194194

195-
error[E0277]: the trait bound `fn() -> namespace_mix::c::TS {namespace_mix::c::TS::{{constructor}}}: Impossible` is not satisfied
195+
error[E0277]: the trait bound `fn() -> namespace_mix::c::TS {namespace_mix::c::TS}: Impossible` is not satisfied
196196
--> $DIR/namespace-mix.rs:72:5
197197
|
198198
LL | check(xm3::TS); //~ ERROR c::TS
199-
| ^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::TS {namespace_mix::c::TS::{{constructor}}}`
199+
| ^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::TS {namespace_mix::c::TS}`
200200
|
201201
note: required by `check`
202202
--> $DIR/namespace-mix.rs:31:1

src/test/ui/privacy/private-inferred-type-3.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
// error-pattern:static `PRIV_STATIC` is private
1515
// error-pattern:type `ext::PrivEnum` is private
1616
// error-pattern:type `fn() {<u8 as ext::PrivTrait>::method}` is private
17-
// error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct::{{constructor}}}` is pr
18-
// error-pattern:type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct::{{constructor}}}` is priv
17+
// error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private
18+
// error-pattern:type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct}` is private
1919
// error-pattern:type `for<'r> fn(&'r ext::Pub<u8>) {<ext::Pub<u8>>::priv_method}` is private
2020

2121
#![feature(decl_macro)]

src/test/ui/privacy/private-inferred-type-3.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ LL | ext::m!();
3030
|
3131
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
3232

33-
error: type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct::{{constructor}}}` is private
33+
error: type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private
3434
--> $DIR/private-inferred-type-3.rs:26:5
3535
|
3636
LL | ext::m!();
3737
| ^^^^^^^^^^
3838
|
3939
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
4040

41-
error: type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct::{{constructor}}}` is private
41+
error: type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct}` is private
4242
--> $DIR/private-inferred-type-3.rs:26:5
4343
|
4444
LL | ext::m!();

src/test/ui/privacy/private-inferred-type.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ mod m {
5353
<u8 as PrivTrait>::method; //~ ERROR type `fn() {<u8 as m::PrivTrait>::method}` is private
5454
<u8 as PubTrait>::method; // OK
5555
PrivTupleStruct;
56-
//~^ ERROR type `fn(u8) -> m::PrivTupleStruct {m::PrivTupleStruct::{{constructor}}}` is priv
56+
//~^ ERROR type `fn(u8) -> m::PrivTupleStruct {m::PrivTupleStruct}` is private
5757
PubTupleStruct;
58-
//~^ ERROR type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct::{{constructor}}}` is privat
58+
//~^ ERROR type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct}` is private
5959
Pub(0u8).priv_method();
6060
//~^ ERROR type `for<'r> fn(&'r m::Pub<u8>) {<m::Pub<u8>>::priv_method}` is private
6161
}

src/test/ui/privacy/private-inferred-type.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ LL | <u8 as PrivTrait>::method; //~ ERROR type `fn() {<u8 as m::PrivTrai
115115
LL | m::m!();
116116
| -------- in this macro invocation
117117

118-
error: type `fn(u8) -> m::PrivTupleStruct {m::PrivTupleStruct::{{constructor}}}` is private
118+
error: type `fn(u8) -> m::PrivTupleStruct {m::PrivTupleStruct}` is private
119119
--> $DIR/private-inferred-type.rs:55:9
120120
|
121121
LL | PrivTupleStruct;
@@ -124,7 +124,7 @@ LL | PrivTupleStruct;
124124
LL | m::m!();
125125
| -------- in this macro invocation
126126

127-
error: type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct::{{constructor}}}` is private
127+
error: type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct}` is private
128128
--> $DIR/private-inferred-type.rs:57:9
129129
|
130130
LL | PubTupleStruct;

0 commit comments

Comments
 (0)