rustc: support impl's in PrintCx::parameterized.
This commit is contained in:
parent
fbbc7e915d
commit
1c2a3c5d79
12 changed files with 32 additions and 16 deletions
|
@ -352,6 +352,22 @@ impl PrintCx<'a, 'gcx, 'tcx> {
|
|||
|
||||
write!(f, "::{}", key.disambiguated_data.data.as_interned_str())?;
|
||||
} else {
|
||||
// Try to print `impl`s more like how you'd refer to their associated items.
|
||||
if let DefPathData::Impl = key.disambiguated_data.data {
|
||||
if let Some(trait_ref) = self.tcx.impl_trait_ref(def_id) {
|
||||
// HACK(eddyb) this is in lieu of more specific disambiguation.
|
||||
print!(f, self, write("{}", self.tcx.item_path_str(def_id)))?;
|
||||
|
||||
let trait_ref = trait_ref.subst(self.tcx, substs);
|
||||
print!(f, self, print_debug(trait_ref))?;
|
||||
} else {
|
||||
let self_ty = self.tcx.type_of(def_id).subst(self.tcx, substs);
|
||||
// FIXME(eddyb) omit the <> where possible.
|
||||
print!(f, self, write("<"), print(self_ty), write(">"))?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
print!(f, self, write("{}", self.tcx.item_path_str(def_id)))?;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ mod foo {
|
|||
}
|
||||
|
||||
pub macro m() {
|
||||
let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
|
||||
let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {<foo::S>::f}` is private
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
|
||||
error: type `for<'r> fn(&'r foo::S) {<foo::S>::f}` is private
|
||||
--> $DIR/impl_items.rs:12:23
|
||||
|
|
||||
LL | let _: () = S.f();
|
||||
|
|
|
@ -50,7 +50,7 @@ struct D (Box<A>);
|
|||
|
||||
impl D {
|
||||
pub fn matches<F: Fn()>(&self, f: &F) {
|
||||
//~^ ERROR reached the type-length limit while instantiating `D::matches::<[closure
|
||||
//~^ ERROR reached the type-length limit while instantiating `<D>::matches::<[closure
|
||||
let &D(ref a) = self;
|
||||
a.matches(f)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: reached the type-length limit while instantiating `D::matches::$CLOSURE`
|
||||
error: reached the type-length limit while instantiating `<D>::matches::$CLOSURE`
|
||||
--> $DIR/issue-22638.rs:52:5
|
||||
|
|
||||
LL | / pub fn matches<F: Fn()>(&self, f: &F) {
|
||||
|
|
|
@ -5,7 +5,7 @@ LL | let x: &fn(&B) -> u32 = &B::func;
|
|||
| ^^^^^^^^ expected fn pointer, found fn item
|
||||
|
|
||||
= note: expected type `&for<'r> fn(&'r B) -> u32`
|
||||
found type `&for<'r> fn(&'r B) -> u32 {B::func}`
|
||||
found type `&for<'r> fn(&'r B) -> u32 {<B>::func}`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ fn func() -> Ret {
|
|||
|
||||
fn main() {
|
||||
Obj::func.x();
|
||||
//~^ ERROR no method named `x` found for type `fn() -> Ret {Obj::func}` in the current scope
|
||||
//~^ ERROR no method named `x` found for type `fn() -> Ret {<Obj>::func}` in the current scope
|
||||
func.x();
|
||||
//~^ ERROR no method named `x` found for type `fn() -> Ret {func}` in the current scope
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0599]: no method named `x` found for type `fn() -> Ret {Obj::func}` in the current scope
|
||||
error[E0599]: no method named `x` found for type `fn() -> Ret {<Obj>::func}` in the current scope
|
||||
--> $DIR/issue-29124.rs:15:15
|
||||
|
|
||||
LL | Obj::func.x();
|
||||
|
|
|
@ -8,7 +8,7 @@ error[E0080]: evaluation of constant value failed
|
|||
--> $DIR/issue-39559-2.rs:14:24
|
||||
|
|
||||
LL | let array: [usize; Dim3::dim()]
|
||||
| ^^^^^^^^^^^ calling non-const function `<Dim3 as Dim>::dim`
|
||||
| ^^^^^^^^^^^ calling non-const function `<Dim3 as Dim><Dim3 as Dim>::dim`
|
||||
|
||||
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||
--> $DIR/issue-39559-2.rs:17:15
|
||||
|
@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed
|
|||
--> $DIR/issue-39559-2.rs:17:15
|
||||
|
|
||||
LL | = [0; Dim3::dim()];
|
||||
| ^^^^^^^^^^^ calling non-const function `<Dim3 as Dim>::dim`
|
||||
| ^^^^^^^^^^^ calling non-const function `<Dim3 as Dim><Dim3 as Dim>::dim`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ mod priv_nominal {
|
|||
|
||||
pub macro mac() {
|
||||
let value = Pub::method;
|
||||
//~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
|
||||
//~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private
|
||||
value;
|
||||
//~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
|
||||
//~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private
|
||||
Pub.method();
|
||||
//~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
|
||||
//~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private
|
||||
Pub::CONST;
|
||||
//~^ ERROR associated constant `CONST` is private
|
||||
// let _: Pub::AssocTy;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
|
||||
error: type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private
|
||||
--> $DIR/associated-item-privacy-inherent.rs:13:21
|
||||
|
|
||||
LL | let value = Pub::method;
|
||||
|
@ -7,7 +7,7 @@ LL | let value = Pub::method;
|
|||
LL | priv_nominal::mac!();
|
||||
| --------------------- in this macro invocation
|
||||
|
||||
error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
|
||||
error: type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private
|
||||
--> $DIR/associated-item-privacy-inherent.rs:15:9
|
||||
|
|
||||
LL | value;
|
||||
|
@ -16,7 +16,7 @@ LL | value;
|
|||
LL | priv_nominal::mac!();
|
||||
| --------------------- in this macro invocation
|
||||
|
||||
error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
|
||||
error: type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private
|
||||
--> $DIR/associated-item-privacy-inherent.rs:17:13
|
||||
|
|
||||
LL | Pub.method();
|
||||
|
|
|
@ -11,7 +11,7 @@ LL | 0 ..= <S as Tr>::A::f::<u8> => {}
|
|||
| ^^^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types
|
||||
|
|
||||
= note: start type: {integer}
|
||||
= note: end type: fn() {S::f::<u8>}
|
||||
= note: end type: fn() {<S>::f::<u8>}
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue