Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Say "trait" instead of "type" in diagnostics for `dyn Trait`
  • Loading branch information
petrochenkov committed Dec 31, 2018
1 parent 8b1c424 commit 60d1fa7
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 96 deletions.
3 changes: 3 additions & 0 deletions src/librustc/util/ppaux.rs
Expand Up @@ -709,6 +709,9 @@ define_print! {

define_print! {
('tcx) ty::ExistentialTraitRef<'tcx>, (self, f, cx) {
display {
cx.parameterized(f, self.substs, self.def_id, &[])
}
debug {
ty::tls::with(|tcx| {
let dummy_self = tcx.mk_infer(ty::FreshTy(0));
Expand Down
181 changes: 104 additions & 77 deletions src/librustc_privacy/lib.rs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/test/ui/privacy/associated-item-privacy-type-binding.rs
Expand Up @@ -9,19 +9,19 @@ mod priv_trait {

pub macro mac1() {
let _: Box<PubTr<AssocTy = u8>>;
//~^ ERROR type `(dyn priv_trait::PubTr<AssocTy=u8> + '<empty>)` is private
//~| ERROR type `(dyn priv_trait::PubTr<AssocTy=u8> + '<empty>)` is private
//~^ ERROR trait `priv_trait::PrivTr` is private
//~| ERROR trait `priv_trait::PrivTr` is private
type InSignatureTy2 = Box<PubTr<AssocTy = u8>>;
//~^ ERROR type `(dyn priv_trait::PubTr<AssocTy=u8> + 'static)` is private
//~^ ERROR trait `priv_trait::PrivTr` is private
trait InSignatureTr2: PubTr<AssocTy = u8> {}
//~^ ERROR trait `priv_trait::PrivTr` is private
}
pub macro mac2() {
let _: Box<PrivTr<AssocTy = u8>>;
//~^ ERROR type `(dyn priv_trait::PrivTr<AssocTy=u8> + '<empty>)` is private
//~| ERROR type `(dyn priv_trait::PrivTr<AssocTy=u8> + '<empty>)` is private
//~^ ERROR trait `priv_trait::PrivTr` is private
//~| ERROR trait `priv_trait::PrivTr` is private
type InSignatureTy1 = Box<PrivTr<AssocTy = u8>>;
//~^ ERROR type `(dyn priv_trait::PrivTr<AssocTy=u8> + 'static)` is private
//~^ ERROR trait `priv_trait::PrivTr` is private
trait InSignatureTr1: PrivTr<AssocTy = u8> {}
//~^ ERROR trait `priv_trait::PrivTr` is private
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/privacy/associated-item-privacy-type-binding.stderr
@@ -1,4 +1,4 @@
error: type `(dyn priv_trait::PubTr<AssocTy=u8> + '<empty>)` is private
error: trait `priv_trait::PrivTr` is private
--> $DIR/associated-item-privacy-type-binding.rs:11:13
|
LL | let _: Box<PubTr<AssocTy = u8>>;
Expand All @@ -7,7 +7,7 @@ LL | let _: Box<PubTr<AssocTy = u8>>;
LL | priv_trait::mac1!();
| -------------------- in this macro invocation

error: type `(dyn priv_trait::PubTr<AssocTy=u8> + '<empty>)` is private
error: trait `priv_trait::PrivTr` is private
--> $DIR/associated-item-privacy-type-binding.rs:11:16
|
LL | let _: Box<PubTr<AssocTy = u8>>;
Expand All @@ -16,7 +16,7 @@ LL | let _: Box<PubTr<AssocTy = u8>>;
LL | priv_trait::mac1!();
| -------------------- in this macro invocation

error: type `(dyn priv_trait::PubTr<AssocTy=u8> + 'static)` is private
error: trait `priv_trait::PrivTr` is private
--> $DIR/associated-item-privacy-type-binding.rs:14:31
|
LL | type InSignatureTy2 = Box<PubTr<AssocTy = u8>>;
Expand All @@ -34,7 +34,7 @@ LL | trait InSignatureTr2: PubTr<AssocTy = u8> {}
LL | priv_trait::mac1!();
| -------------------- in this macro invocation

error: type `(dyn priv_trait::PrivTr<AssocTy=u8> + '<empty>)` is private
error: trait `priv_trait::PrivTr` is private
--> $DIR/associated-item-privacy-type-binding.rs:20:13
|
LL | let _: Box<PrivTr<AssocTy = u8>>;
Expand All @@ -43,7 +43,7 @@ LL | let _: Box<PrivTr<AssocTy = u8>>;
LL | priv_trait::mac2!();
| -------------------- in this macro invocation

error: type `(dyn priv_trait::PrivTr<AssocTy=u8> + '<empty>)` is private
error: trait `priv_trait::PrivTr` is private
--> $DIR/associated-item-privacy-type-binding.rs:20:16
|
LL | let _: Box<PrivTr<AssocTy = u8>>;
Expand All @@ -52,7 +52,7 @@ LL | let _: Box<PrivTr<AssocTy = u8>>;
LL | priv_trait::mac2!();
| -------------------- in this macro invocation

error: type `(dyn priv_trait::PrivTr<AssocTy=u8> + 'static)` is private
error: trait `priv_trait::PrivTr` is private
--> $DIR/associated-item-privacy-type-binding.rs:23:31
|
LL | type InSignatureTy1 = Box<PrivTr<AssocTy = u8>>;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/privacy/private-in-public-non-principal-2.rs
Expand Up @@ -9,5 +9,5 @@ mod m {

fn main() {
m::leak_dyn_nonprincipal();
//~^ ERROR type `(dyn m::PubPrincipal + m::PrivNonPrincipal + 'static)` is private
//~^ ERROR trait `m::PrivNonPrincipal` is private
}
@@ -1,4 +1,4 @@
error: type `(dyn m::PubPrincipal + m::PrivNonPrincipal + 'static)` is private
error: trait `m::PrivNonPrincipal` is private
--> $DIR/private-in-public-non-principal-2.rs:11:5
|
LL | m::leak_dyn_nonprincipal();
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/privacy/private-in-public-non-principal.rs
Expand Up @@ -4,7 +4,7 @@ pub trait PubPrincipal {}
auto trait PrivNonPrincipal {}

pub fn leak_dyn_nonprincipal() -> Box<PubPrincipal + PrivNonPrincipal> { loop {} }
//~^ WARN private type `(dyn PubPrincipal + PrivNonPrincipal + 'static)` in public interface
//~^ WARN private trait `PrivNonPrincipal` in public interface
//~| WARN this was previously accepted

#[deny(missing_docs)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/privacy/private-in-public-non-principal.stderr
@@ -1,4 +1,4 @@
warning: private type `(dyn PubPrincipal + PrivNonPrincipal + 'static)` in public interface (error E0446)
warning: private trait `PrivNonPrincipal` in public interface (error E0445)
--> $DIR/private-in-public-non-principal.rs:6:1
|
LL | pub fn leak_dyn_nonprincipal() -> Box<PubPrincipal + PrivNonPrincipal> { loop {} }
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/privacy/private-inferred-type.rs
Expand Up @@ -119,7 +119,7 @@ fn main() {
m::leak_anon2(); //~ ERROR type `m::Priv` is private
m::leak_anon3(); //~ ERROR type `m::Priv` is private

m::leak_dyn1(); //~ ERROR type `(dyn m::Trait + 'static)` is private
m::leak_dyn1(); //~ ERROR trait `m::Trait` is private
m::leak_dyn2(); //~ ERROR type `m::Priv` is private
m::leak_dyn3(); //~ ERROR type `m::Priv` is private

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/privacy/private-inferred-type.stderr
Expand Up @@ -160,10 +160,10 @@ error: type `m::Priv` is private
LL | m::leak_anon3(); //~ ERROR type `m::Priv` is private
| ^^^^^^^^^^^^^^^

error: type `(dyn m::Trait + 'static)` is private
error: trait `m::Trait` is private
--> $DIR/private-inferred-type.rs:122:5
|
LL | m::leak_dyn1(); //~ ERROR type `(dyn m::Trait + 'static)` is private
LL | m::leak_dyn1(); //~ ERROR trait `m::Trait` is private
| ^^^^^^^^^^^^^^

error: type `m::Priv` is private
Expand Down

0 comments on commit 60d1fa7

Please sign in to comment.