about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2019-01-29 16:47:30 +0100
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2019-01-30 21:19:02 +0100
commit38bcd4b42a1d0a5546122e78efb266161aa4c731 (patch)
tree71af7251790abf71b5fa37fed4eada6af644771c
parentd9a2e3b1ccf16c6d43f56f503bd80c1ad137d523 (diff)
downloadrust-38bcd4b42a1d0a5546122e78efb266161aa4c731.tar.gz
rust-38bcd4b42a1d0a5546122e78efb266161aa4c731.zip
Move privacy checking later in the pipeline and make some passes run in parallel
-rw-r--r--src/librustc/hir/mod.rs26
-rw-r--r--src/librustc/middle/liveness.rs1
-rw-r--r--src/librustc/session/mod.rs4
-rw-r--r--src/librustc_data_structures/sync.rs27
-rw-r--r--src/librustc_driver/driver.rs102
-rw-r--r--src/librustc_driver/lib.rs1
-rw-r--r--src/librustc_passes/rvalue_promotion.rs1
-rw-r--r--src/test/ui/error-codes/E0446.rs2
-rw-r--r--src/test/ui/error-codes/E0446.stderr4
-rw-r--r--src/test/ui/error-codes/E0451.rs8
-rw-r--r--src/test/ui/error-codes/E0451.stderr12
-rw-r--r--src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.rs4
-rw-r--r--src/test/ui/privacy/private-in-public-warn.rs2
-rw-r--r--src/test/ui/privacy/private-in-public-warn.stderr65
-rw-r--r--src/test/ui/privacy/private-inferred-type.rs2
15 files changed, 157 insertions, 104 deletions
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index 657e6e5dcde..841124bb4a6 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -30,7 +30,7 @@ use syntax::util::parser::ExprPrecedence;
 use ty::AdtKind;
 use ty::query::Providers;
 
-use rustc_data_structures::sync::{ParallelIterator, par_iter, Send, Sync, scope};
+use rustc_data_structures::sync::{ParallelIterator, par_iter, Send, Sync};
 use rustc_data_structures::thin_vec::ThinVec;
 
 use serialize::{self, Encoder, Encodable, Decoder, Decodable};
@@ -754,23 +754,17 @@ impl Crate {
     pub fn par_visit_all_item_likes<'hir, V>(&'hir self, visitor: &V)
         where V: itemlikevisit::ParItemLikeVisitor<'hir> + Sync + Send
     {
-        scope(|s| {
-            s.spawn(|_| {
-                par_iter(&self.items).for_each(|(_, item)| {
-                    visitor.visit_item(item);
-                });
+        parallel!({
+            par_iter(&self.items).for_each(|(_, item)| {
+                visitor.visit_item(item);
             });
-
-            s.spawn(|_| {
-                par_iter(&self.trait_items).for_each(|(_, trait_item)| {
-                    visitor.visit_trait_item(trait_item);
-                });
+        }, {
+            par_iter(&self.trait_items).for_each(|(_, trait_item)| {
+                visitor.visit_trait_item(trait_item);
             });
-
-            s.spawn(|_| {
-                par_iter(&self.impl_items).for_each(|(_, impl_item)| {
-                    visitor.visit_impl_item(impl_item);
-                });
+        }, {
+            par_iter(&self.impl_items).for_each(|(_, impl_item)| {
+                visitor.visit_impl_item(impl_item);
             });
         });
     }
diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs
index 4ef8e1a0cf9..841a93cae1b 100644
--- a/src/librustc/middle/liveness.rs
+++ b/src/librustc/middle/liveness.rs
@@ -189,7 +189,6 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
     for &module in tcx.hir().krate().modules.keys() {
         queries::check_mod_liveness::ensure(tcx, tcx.hir().local_def_id(module));
     }
-    tcx.sess.abort_if_errors();
 }
 
 pub fn provide(providers: &mut Providers<'_>) {
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index c5034415d6f..b273c73332c 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -85,7 +85,7 @@ pub struct Session {
     /// in order to avoid redundantly verbose output (Issue #24690, #44953).
     pub one_time_diagnostics: Lock<FxHashSet<(DiagnosticMessageId, Option<Span>, String)>>,
     pub plugin_llvm_passes: OneThread<RefCell<Vec<String>>>,
-    pub plugin_attributes: OneThread<RefCell<Vec<(String, AttributeType)>>>,
+    pub plugin_attributes: Lock<Vec<(String, AttributeType)>>,
     pub crate_types: Once<Vec<config::CrateType>>,
     pub dependency_formats: Once<dependency_format::Dependencies>,
     /// The crate_disambiguator is constructed out of all the `-C metadata`
@@ -1178,7 +1178,7 @@ pub fn build_session_(
         buffered_lints: Lock::new(Some(Default::default())),
         one_time_diagnostics: Default::default(),
         plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())),
-        plugin_attributes: OneThread::new(RefCell::new(Vec::new())),
+        plugin_attributes: Lock::new(Vec::new()),
         crate_types: Once::new(),
         dependency_formats: Once::new(),
         crate_disambiguator: Once::new(),
diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs
index cae3087fe58..7fef1f374d6 100644
--- a/src/librustc_data_structures/sync.rs
+++ b/src/librustc_data_structures/sync.rs
@@ -127,6 +127,13 @@ cfg_if! {
         pub use self::serial_join as join;
         pub use self::serial_scope as scope;
 
+        #[macro_export]
+        macro_rules! parallel {
+            ($($blocks:tt),*) => {
+                $($blocks)*;
+            }
+        }
+
         pub use std::iter::Iterator as ParallelIterator;
 
         pub fn par_iter<T: IntoIterator>(t: T) -> T::IntoIter {
@@ -271,6 +278,26 @@ cfg_if! {
         use std::thread;
         pub use rayon::{join, scope};
 
+        #[macro_export]
+        macro_rules! parallel {
+            (impl [$($c:tt,)*] [$block:tt $(, $rest:tt)*]) => {
+                parallel!(impl [$block, $($c,)*] [$($rest),*])
+            };
+            (impl [$($blocks:tt,)*] []) => {
+                ::rustc_data_structures::sync::scope(|s| {
+                    $(
+                        s.spawn(|_| $blocks);
+                    )*
+                })
+            };
+            ($($blocks:tt),*) => {
+                // Reverse the order of the blocks since Rayon executes them in reverse order
+                // when using a single thread. This ensures the execution order matches that
+                // of a single threaded rustc
+                parallel!(impl [] [$($blocks),*]);
+            };
+        }
+
         pub use rayon_core::WorkerLocal;
 
         pub use rayon::iter::ParallelIterator;
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index c586c705676..a3fa55931f0 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -1222,26 +1222,28 @@ where
             // tcx available.
             time(sess, "dep graph tcx init", || rustc_incremental::dep_graph_tcx_init(tcx));
 
-            time(sess, "looking for entry point", || {
-                middle::entry::find_entry_point(tcx)
-            });
-
-            time(sess, "looking for plugin registrar", || {
-                plugin::build::find_plugin_registrar(tcx)
-            });
-
-            time(sess, "looking for derive registrar", || {
-                proc_macro_decls::find(tcx)
-            });
-
-            time(sess, "loop checking", || loops::check_crate(tcx));
+            parallel!({
+                time(sess, "looking for entry point", || {
+                    middle::entry::find_entry_point(tcx)
+                });
 
-            time(sess, "attribute checking", || {
-                hir::check_attr::check_crate(tcx)
-            });
+                time(sess, "looking for plugin registrar", || {
+                    plugin::build::find_plugin_registrar(tcx)
+                });
 
-            time(sess, "stability checking", || {
-                stability::check_unstable_api_usage(tcx)
+                time(sess, "looking for derive registrar", || {
+                    proc_macro_decls::find(tcx)
+                });
+            }, {
+                time(sess, "loop checking", || loops::check_crate(tcx));
+            }, {
+                time(sess, "attribute checking", || {
+                    hir::check_attr::check_crate(tcx)
+                });
+            }, {
+                time(sess, "stability checking", || {
+                    stability::check_unstable_api_usage(tcx)
+                });
             });
 
             // passes are timed inside typeck
@@ -1253,27 +1255,31 @@ where
                 }
             }
 
-            time(sess, "rvalue promotion", || {
-                rvalue_promotion::check_crate(tcx)
-            });
-
-            time(sess, "privacy checking", || {
-                rustc_privacy::check_crate(tcx)
-            });
-
-            time(sess, "intrinsic checking", || {
-                middle::intrinsicck::check_crate(tcx)
+            time(sess, "misc checking", || {
+                parallel!({
+                    time(sess, "rvalue promotion", || {
+                        rvalue_promotion::check_crate(tcx)
+                    });
+                }, {
+                    time(sess, "intrinsic checking", || {
+                        middle::intrinsicck::check_crate(tcx)
+                    });
+                }, {
+                    time(sess, "match checking", || mir::matchck_crate(tcx));
+                }, {
+                    // this must run before MIR dump, because
+                    // "not all control paths return a value" is reported here.
+                    //
+                    // maybe move the check to a MIR pass?
+                    time(sess, "liveness checking", || {
+                        middle::liveness::check_crate(tcx)
+                    });
+                });
             });
 
-            time(sess, "match checking", || mir::matchck_crate(tcx));
-
-            // this must run before MIR dump, because
-            // "not all control paths return a value" is reported here.
-            //
-            // maybe move the check to a MIR pass?
-            time(sess, "liveness checking", || {
-                middle::liveness::check_crate(tcx)
-            });
+            // Abort so we don't try to construct MIR with liveness errors.
+            // We also won't want to continue with errors from rvalue promotion
+            tcx.sess.abort_if_errors();
 
             time(sess, "borrow checking", || {
                 if tcx.use_ast_borrowck() {
@@ -1297,7 +1303,7 @@ where
 
             time(sess, "layout testing", || layout_test::test_layout(tcx));
 
-            // Avoid overwhelming user with errors if type checking failed.
+            // Avoid overwhelming user with errors if borrow checking failed.
             // I'm not sure how helpful this is, to be honest, but it avoids
             // a
             // lot of annoying errors in the compile-fail tests (basically,
@@ -1307,14 +1313,22 @@ where
                 return Ok(f(tcx, rx, sess.compile_status()));
             }
 
-            time(sess, "death checking", || middle::dead::check_crate(tcx));
-
-            time(sess, "unused lib feature checking", || {
-                stability::check_unused_or_stable_features(tcx)
+            time(sess, "misc checking", || {
+                parallel!({
+                    time(sess, "privacy checking", || {
+                        rustc_privacy::check_crate(tcx)
+                    });
+                }, {
+                    time(sess, "death checking", || middle::dead::check_crate(tcx));
+                },  {
+                    time(sess, "unused lib feature checking", || {
+                        stability::check_unused_or_stable_features(tcx)
+                    });
+                }, {
+                    time(sess, "lint checking", || lint::check_crate(tcx));
+                });
             });
 
-            time(sess, "lint checking", || lint::check_crate(tcx));
-
             return Ok(f(tcx, rx, tcx.sess.compile_status()));
         },
     )
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index a95ce810ffa..5f98ea29d2e 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -30,6 +30,7 @@ extern crate rustc;
 extern crate rustc_allocator;
 extern crate rustc_target;
 extern crate rustc_borrowck;
+#[macro_use]
 extern crate rustc_data_structures;
 extern crate rustc_errors as errors;
 extern crate rustc_passes;
diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs
index c11b1af9776..739c96934e6 100644
--- a/src/librustc_passes/rvalue_promotion.rs
+++ b/src/librustc_passes/rvalue_promotion.rs
@@ -44,7 +44,6 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
         let def_id = tcx.hir().body_owner_def_id(body_id);
         tcx.const_is_rvalue_promotable_to_static(def_id);
     }
-    tcx.sess.abort_if_errors();
 }
 
 fn const_is_rvalue_promotable_to_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
diff --git a/src/test/ui/error-codes/E0446.rs b/src/test/ui/error-codes/E0446.rs
index 33bd6144716..f61c7e54616 100644
--- a/src/test/ui/error-codes/E0446.rs
+++ b/src/test/ui/error-codes/E0446.rs
@@ -1,4 +1,4 @@
-mod Foo {
+mod foo {
     struct Bar(u32);
 
     pub fn bar() -> Bar { //~ ERROR E0446
diff --git a/src/test/ui/error-codes/E0446.stderr b/src/test/ui/error-codes/E0446.stderr
index 8f381320cf9..9c7399515f4 100644
--- a/src/test/ui/error-codes/E0446.stderr
+++ b/src/test/ui/error-codes/E0446.stderr
@@ -1,8 +1,8 @@
-error[E0446]: private type `Foo::Bar` in public interface
+error[E0446]: private type `foo::Bar` in public interface
   --> $DIR/E0446.rs:4:5
    |
 LL |       struct Bar(u32);
-   |       - `Foo::Bar` declared as private
+   |       - `foo::Bar` declared as private
 LL | 
 LL | /     pub fn bar() -> Bar { //~ ERROR E0446
 LL | |         Bar(0)
diff --git a/src/test/ui/error-codes/E0451.rs b/src/test/ui/error-codes/E0451.rs
index 7c1c326fb5b..aa8f051afa7 100644
--- a/src/test/ui/error-codes/E0451.rs
+++ b/src/test/ui/error-codes/E0451.rs
@@ -1,4 +1,4 @@
-mod Bar {
+mod bar {
     pub struct Foo {
         pub a: isize,
         b: isize,
@@ -10,10 +10,10 @@ mod Bar {
     );
 }
 
-fn pat_match(foo: Bar::Foo) {
-    let Bar::Foo{a:a, b:b} = foo; //~ ERROR E0451
+fn pat_match(foo: bar::Foo) {
+    let bar::Foo{a, b} = foo; //~ ERROR E0451
 }
 
 fn main() {
-    let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
+    let f = bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
 }
diff --git a/src/test/ui/error-codes/E0451.stderr b/src/test/ui/error-codes/E0451.stderr
index 11bc7e31803..11f08677246 100644
--- a/src/test/ui/error-codes/E0451.stderr
+++ b/src/test/ui/error-codes/E0451.stderr
@@ -1,13 +1,13 @@
-error[E0451]: field `b` of struct `Bar::Foo` is private
-  --> $DIR/E0451.rs:14:23
+error[E0451]: field `b` of struct `bar::Foo` is private
+  --> $DIR/E0451.rs:14:21
    |
-LL |     let Bar::Foo{a:a, b:b} = foo; //~ ERROR E0451
-   |                       ^^^ field `b` is private
+LL |     let bar::Foo{a, b} = foo; //~ ERROR E0451
+   |                     ^ field `b` is private
 
-error[E0451]: field `b` of struct `Bar::Foo` is private
+error[E0451]: field `b` of struct `bar::Foo` is private
   --> $DIR/E0451.rs:18:29
    |
-LL |     let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
+LL |     let f = bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
    |                             ^^^^ field `b` is private
 
 error: aborting due to 2 previous errors
diff --git a/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.rs b/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.rs
index 00606af9048..7ae53020fe0 100644
--- a/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.rs
+++ b/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.rs
@@ -6,12 +6,12 @@ use self::foo::S;
 mod foo {
     use std::cell::{UnsafeCell};
 
-    static mut count : UnsafeCell<u64> = UnsafeCell::new(1);
+    static mut COUNT : UnsafeCell<u64> = UnsafeCell::new(1);
 
     pub struct S { pub a: u8, pub b: String, secret_uid: u64 }
 
     pub fn make_secrets(a: u8, b: String) -> S {
-        let val = unsafe { let p = count.get(); let val = *p; *p = val + 1; val };
+        let val = unsafe { let p = COUNT.get(); let val = *p; *p = val + 1; val };
         println!("creating {}, uid {}", b, val);
         S { a: a, b: b, secret_uid: val }
     }
diff --git a/src/test/ui/privacy/private-in-public-warn.rs b/src/test/ui/privacy/private-in-public-warn.rs
index 29f365b69be..467b8374670 100644
--- a/src/test/ui/privacy/private-in-public-warn.rs
+++ b/src/test/ui/privacy/private-in-public-warn.rs
@@ -49,6 +49,7 @@ mod traits {
 
     pub type Alias<T: PrivTr> = T; //~ ERROR private trait `traits::PrivTr` in public interface
     //~| WARNING hard error
+    //~| WARNING bounds on generic parameters are not enforced in type aliases
     pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface
     //~^ WARNING hard error
     pub trait Tr2<T: PrivTr> {} //~ ERROR private trait `traits::PrivTr` in public interface
@@ -74,6 +75,7 @@ mod traits_where {
     pub type Alias<T> where T: PrivTr = T;
         //~^ ERROR private trait `traits_where::PrivTr` in public interface
         //~| WARNING hard error
+        //~| WARNING where clauses are not enforced in type aliases
     pub trait Tr2<T> where T: PrivTr {}
         //~^ ERROR private trait `traits_where::PrivTr` in public interface
         //~| WARNING hard error
diff --git a/src/test/ui/privacy/private-in-public-warn.stderr b/src/test/ui/privacy/private-in-public-warn.stderr
index 8f9e7cd74f9..621d9a57fa0 100644
--- a/src/test/ui/privacy/private-in-public-warn.stderr
+++ b/src/test/ui/privacy/private-in-public-warn.stderr
@@ -112,7 +112,7 @@ LL |     pub type Alias<T: PrivTr> = T; //~ ERROR private trait `traits::PrivTr`
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `traits::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:52:5
+  --> $DIR/private-in-public-warn.rs:53:5
    |
 LL |     pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -121,7 +121,7 @@ LL |     pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in pu
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `traits::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:54:5
+  --> $DIR/private-in-public-warn.rs:55:5
    |
 LL |     pub trait Tr2<T: PrivTr> {} //~ ERROR private trait `traits::PrivTr` in public interface
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -130,7 +130,7 @@ LL |     pub trait Tr2<T: PrivTr> {} //~ ERROR private trait `traits::PrivTr` in
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `traits::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:56:5
+  --> $DIR/private-in-public-warn.rs:57:5
    |
 LL | /     pub trait Tr3 {
 LL | |         //~^ ERROR private trait `traits::PrivTr` in public interface
@@ -145,7 +145,7 @@ LL | |     }
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `traits::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:60:9
+  --> $DIR/private-in-public-warn.rs:61:9
    |
 LL |         fn f<T: PrivTr>(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -154,7 +154,7 @@ LL |         fn f<T: PrivTr>(arg: T) {} //~ ERROR private trait `traits::PrivTr`
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `traits::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:63:5
+  --> $DIR/private-in-public-warn.rs:64:5
    |
 LL |     impl<T: PrivTr> Pub<T> {} //~ ERROR private trait `traits::PrivTr` in public interface
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -163,7 +163,7 @@ LL |     impl<T: PrivTr> Pub<T> {} //~ ERROR private trait `traits::PrivTr` in p
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `traits::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:65:5
+  --> $DIR/private-in-public-warn.rs:66:5
    |
 LL |     impl<T: PrivTr> PubTr for Pub<T> {} //~ ERROR private trait `traits::PrivTr` in public interface
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -172,7 +172,7 @@ LL |     impl<T: PrivTr> PubTr for Pub<T> {} //~ ERROR private trait `traits::Pr
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `traits_where::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:74:5
+  --> $DIR/private-in-public-warn.rs:75:5
    |
 LL |     pub type Alias<T> where T: PrivTr = T;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -181,7 +181,7 @@ LL |     pub type Alias<T> where T: PrivTr = T;
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `traits_where::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:77:5
+  --> $DIR/private-in-public-warn.rs:79:5
    |
 LL |     pub trait Tr2<T> where T: PrivTr {}
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -190,7 +190,7 @@ LL |     pub trait Tr2<T> where T: PrivTr {}
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `traits_where::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:81:9
+  --> $DIR/private-in-public-warn.rs:83:9
    |
 LL |         fn f<T>(arg: T) where T: PrivTr {}
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -199,7 +199,7 @@ LL |         fn f<T>(arg: T) where T: PrivTr {}
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `traits_where::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:85:5
+  --> $DIR/private-in-public-warn.rs:87:5
    |
 LL |     impl<T> Pub<T> where T: PrivTr {}
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -208,7 +208,7 @@ LL |     impl<T> Pub<T> where T: PrivTr {}
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `traits_where::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:88:5
+  --> $DIR/private-in-public-warn.rs:90:5
    |
 LL |     impl<T> PubTr for Pub<T> where T: PrivTr {}
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -217,7 +217,7 @@ LL |     impl<T> PubTr for Pub<T> where T: PrivTr {}
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `generics::PrivTr<generics::Pub>` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:99:5
+  --> $DIR/private-in-public-warn.rs:101:5
    |
 LL |     pub trait Tr1: PrivTr<Pub> {}
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -226,7 +226,7 @@ LL |     pub trait Tr1: PrivTr<Pub> {}
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private type `generics::Priv` in public interface (error E0446)
-  --> $DIR/private-in-public-warn.rs:102:5
+  --> $DIR/private-in-public-warn.rs:104:5
    |
 LL |     pub trait Tr2: PubTr<Priv> {} //~ ERROR private type `generics::Priv` in public interface
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -235,7 +235,7 @@ LL |     pub trait Tr2: PubTr<Priv> {} //~ ERROR private type `generics::Priv` i
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private type `generics::Priv` in public interface (error E0446)
-  --> $DIR/private-in-public-warn.rs:104:5
+  --> $DIR/private-in-public-warn.rs:106:5
    |
 LL |     pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR private type `generics::Priv` in public interface
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -244,7 +244,7 @@ LL |     pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR private type `generics::Pr
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private type `generics::Priv` in public interface (error E0446)
-  --> $DIR/private-in-public-warn.rs:106:5
+  --> $DIR/private-in-public-warn.rs:108:5
    |
 LL |     pub trait Tr4: PubTr<Pub<Priv>> {} //~ ERROR private type `generics::Priv` in public interface
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -253,7 +253,7 @@ LL |     pub trait Tr4: PubTr<Pub<Priv>> {} //~ ERROR private type `generics::Pr
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error[E0446]: private type `impls::Priv` in public interface
-  --> $DIR/private-in-public-warn.rs:133:9
+  --> $DIR/private-in-public-warn.rs:135:9
    |
 LL |     struct Priv;
    |     - `impls::Priv` declared as private
@@ -262,7 +262,7 @@ LL |         type Alias = Priv; //~ ERROR private type `impls::Priv` in public i
    |         ^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error: private type `aliases_pub::Priv` in public interface (error E0446)
-  --> $DIR/private-in-public-warn.rs:204:9
+  --> $DIR/private-in-public-warn.rs:206:9
    |
 LL |         pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` in public interface
    |         ^^^^^^^^^^^^^^^^^^^^^^
@@ -271,7 +271,7 @@ LL |         pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` i
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error[E0446]: private type `aliases_pub::Priv` in public interface
-  --> $DIR/private-in-public-warn.rs:208:9
+  --> $DIR/private-in-public-warn.rs:210:9
    |
 LL |     struct Priv;
    |     - `aliases_pub::Priv` declared as private
@@ -280,7 +280,7 @@ LL |         type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in pu
    |         ^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `aliases_pub::Priv` in public interface
-  --> $DIR/private-in-public-warn.rs:211:9
+  --> $DIR/private-in-public-warn.rs:213:9
    |
 LL |     struct Priv;
    |     - `aliases_pub::Priv` declared as private
@@ -289,7 +289,7 @@ LL |         type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in pu
    |         ^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `aliases_pub::Priv` in public interface
-  --> $DIR/private-in-public-warn.rs:214:9
+  --> $DIR/private-in-public-warn.rs:216:9
    |
 LL |     struct Priv;
    |     - `aliases_pub::Priv` declared as private
@@ -298,7 +298,7 @@ LL |         type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in pu
    |         ^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `aliases_pub::Priv` in public interface
-  --> $DIR/private-in-public-warn.rs:217:9
+  --> $DIR/private-in-public-warn.rs:219:9
    |
 LL |     struct Priv;
    |     - `aliases_pub::Priv` declared as private
@@ -307,7 +307,7 @@ LL |         type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in pu
    |         ^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error: private trait `aliases_priv::PrivTr1` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:247:5
+  --> $DIR/private-in-public-warn.rs:249:5
    |
 LL |     pub trait Tr1: PrivUseAliasTr {}
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -316,7 +316,7 @@ LL |     pub trait Tr1: PrivUseAliasTr {}
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private trait `aliases_priv::PrivTr1<aliases_priv::Priv2>` in public interface (error E0445)
-  --> $DIR/private-in-public-warn.rs:250:5
+  --> $DIR/private-in-public-warn.rs:252:5
    |
 LL |     pub trait Tr2: PrivUseAliasTr<PrivAlias> {}
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -325,7 +325,7 @@ LL |     pub trait Tr2: PrivUseAliasTr<PrivAlias> {}
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error: private type `aliases_priv::Priv2` in public interface (error E0446)
-  --> $DIR/private-in-public-warn.rs:250:5
+  --> $DIR/private-in-public-warn.rs:252:5
    |
 LL |     pub trait Tr2: PrivUseAliasTr<PrivAlias> {}
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -333,6 +333,23 @@ LL |     pub trait Tr2: PrivUseAliasTr<PrivAlias> {}
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
+warning: bounds on generic parameters are not enforced in type aliases
+  --> $DIR/private-in-public-warn.rs:50:23
+   |
+LL |     pub type Alias<T: PrivTr> = T; //~ ERROR private trait `traits::PrivTr` in public interface
+   |                       ^^^^^^
+   |
+   = note: #[warn(type_alias_bounds)] on by default
+   = help: the bound will not be checked when the type alias is used, and should be removed
+
+warning: where clauses are not enforced in type aliases
+  --> $DIR/private-in-public-warn.rs:75:29
+   |
+LL |     pub type Alias<T> where T: PrivTr = T;
+   |                             ^^^^^^^^^
+   |
+   = help: the clause will not be checked when the type alias is used, and should be removed
+
 error: aborting due to 36 previous errors
 
 For more information about this error, try `rustc --explain E0446`.
diff --git a/src/test/ui/privacy/private-inferred-type.rs b/src/test/ui/privacy/private-inferred-type.rs
index 69b60a56c67..d98cf5991ef 100644
--- a/src/test/ui/privacy/private-inferred-type.rs
+++ b/src/test/ui/privacy/private-inferred-type.rs
@@ -1,4 +1,3 @@
-#![feature(associated_consts)]
 #![feature(decl_macro)]
 #![allow(private_in_public)]
 
@@ -15,6 +14,7 @@ mod m {
     pub struct PubTupleStruct(u8);
     impl PubTupleStruct { fn method() {} }
 
+    #[derive(Clone, Copy)]
     struct Priv;
     pub type Alias = Priv;
     pub struct Pub<T = Alias>(pub T);