Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ad43389

Browse files
committedFeb 7, 2019
Auto merge of #58010 - Zoxc:parallel-passes, r=michaelwoerister
Move privacy checking later in the pipeline and make some passes run in parallel r? @michaelwoerister
2 parents 626e74d + 38bcd4b commit ad43389

File tree

15 files changed

+157
-104
lines changed

15 files changed

+157
-104
lines changed
 

‎src/librustc/hir/mod.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use syntax::util::parser::ExprPrecedence;
3030
use crate::ty::AdtKind;
3131
use crate::ty::query::Providers;
3232

33-
use rustc_data_structures::sync::{ParallelIterator, par_iter, Send, Sync, scope};
33+
use rustc_data_structures::sync::{ParallelIterator, par_iter, Send, Sync};
3434
use rustc_data_structures::thin_vec::ThinVec;
3535

3636
use serialize::{self, Encoder, Encodable, Decoder, Decodable};
@@ -763,23 +763,17 @@ impl Crate {
763763
pub fn par_visit_all_item_likes<'hir, V>(&'hir self, visitor: &V)
764764
where V: itemlikevisit::ParItemLikeVisitor<'hir> + Sync + Send
765765
{
766-
scope(|s| {
767-
s.spawn(|_| {
768-
par_iter(&self.items).for_each(|(_, item)| {
769-
visitor.visit_item(item);
770-
});
766+
parallel!({
767+
par_iter(&self.items).for_each(|(_, item)| {
768+
visitor.visit_item(item);
771769
});
772-
773-
s.spawn(|_| {
774-
par_iter(&self.trait_items).for_each(|(_, trait_item)| {
775-
visitor.visit_trait_item(trait_item);
776-
});
770+
}, {
771+
par_iter(&self.trait_items).for_each(|(_, trait_item)| {
772+
visitor.visit_trait_item(trait_item);
777773
});
778-
779-
s.spawn(|_| {
780-
par_iter(&self.impl_items).for_each(|(_, impl_item)| {
781-
visitor.visit_impl_item(impl_item);
782-
});
774+
}, {
775+
par_iter(&self.impl_items).for_each(|(_, impl_item)| {
776+
visitor.visit_impl_item(impl_item);
783777
});
784778
});
785779
}

‎src/librustc/middle/liveness.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
189189
for &module in tcx.hir().krate().modules.keys() {
190190
tcx.ensure().check_mod_liveness(tcx.hir().local_def_id(module));
191191
}
192-
tcx.sess.abort_if_errors();
193192
}
194193

195194
pub fn provide(providers: &mut Providers<'_>) {

‎src/librustc/session/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub struct Session {
8585
/// in order to avoid redundantly verbose output (Issue #24690, #44953).
8686
pub one_time_diagnostics: Lock<FxHashSet<(DiagnosticMessageId, Option<Span>, String)>>,
8787
pub plugin_llvm_passes: OneThread<RefCell<Vec<String>>>,
88-
pub plugin_attributes: OneThread<RefCell<Vec<(String, AttributeType)>>>,
88+
pub plugin_attributes: Lock<Vec<(String, AttributeType)>>,
8989
pub crate_types: Once<Vec<config::CrateType>>,
9090
pub dependency_formats: Once<dependency_format::Dependencies>,
9191
/// The crate_disambiguator is constructed out of all the `-C metadata`
@@ -1178,7 +1178,7 @@ pub fn build_session_(
11781178
buffered_lints: Lock::new(Some(Default::default())),
11791179
one_time_diagnostics: Default::default(),
11801180
plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())),
1181-
plugin_attributes: OneThread::new(RefCell::new(Vec::new())),
1181+
plugin_attributes: Lock::new(Vec::new()),
11821182
crate_types: Once::new(),
11831183
dependency_formats: Once::new(),
11841184
crate_disambiguator: Once::new(),

‎src/librustc_data_structures/sync.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ cfg_if! {
127127
pub use self::serial_join as join;
128128
pub use self::serial_scope as scope;
129129

130+
#[macro_export]
131+
macro_rules! parallel {
132+
($($blocks:tt),*) => {
133+
$($blocks)*;
134+
}
135+
}
136+
130137
pub use std::iter::Iterator as ParallelIterator;
131138

132139
pub fn par_iter<T: IntoIterator>(t: T) -> T::IntoIter {
@@ -271,6 +278,26 @@ cfg_if! {
271278
use std::thread;
272279
pub use rayon::{join, scope};
273280

281+
#[macro_export]
282+
macro_rules! parallel {
283+
(impl [$($c:tt,)*] [$block:tt $(, $rest:tt)*]) => {
284+
parallel!(impl [$block, $($c,)*] [$($rest),*])
285+
};
286+
(impl [$($blocks:tt,)*] []) => {
287+
::rustc_data_structures::sync::scope(|s| {
288+
$(
289+
s.spawn(|_| $blocks);
290+
)*
291+
})
292+
};
293+
($($blocks:tt),*) => {
294+
// Reverse the order of the blocks since Rayon executes them in reverse order
295+
// when using a single thread. This ensures the execution order matches that
296+
// of a single threaded rustc
297+
parallel!(impl [] [$($blocks),*]);
298+
};
299+
}
300+
274301
pub use rayon_core::WorkerLocal;
275302

276303
pub use rayon::iter::ParallelIterator;

‎src/librustc_driver/driver.rs

Lines changed: 58 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,26 +1222,28 @@ where
12221222
// tcx available.
12231223
time(sess, "dep graph tcx init", || rustc_incremental::dep_graph_tcx_init(tcx));
12241224

1225-
time(sess, "looking for entry point", || {
1226-
middle::entry::find_entry_point(tcx)
1227-
});
1228-
1229-
time(sess, "looking for plugin registrar", || {
1230-
plugin::build::find_plugin_registrar(tcx)
1231-
});
1232-
1233-
time(sess, "looking for derive registrar", || {
1234-
proc_macro_decls::find(tcx)
1235-
});
1236-
1237-
time(sess, "loop checking", || loops::check_crate(tcx));
1225+
parallel!({
1226+
time(sess, "looking for entry point", || {
1227+
middle::entry::find_entry_point(tcx)
1228+
});
12381229

1239-
time(sess, "attribute checking", || {
1240-
hir::check_attr::check_crate(tcx)
1241-
});
1230+
time(sess, "looking for plugin registrar", || {
1231+
plugin::build::find_plugin_registrar(tcx)
1232+
});
12421233

1243-
time(sess, "stability checking", || {
1244-
stability::check_unstable_api_usage(tcx)
1234+
time(sess, "looking for derive registrar", || {
1235+
proc_macro_decls::find(tcx)
1236+
});
1237+
}, {
1238+
time(sess, "loop checking", || loops::check_crate(tcx));
1239+
}, {
1240+
time(sess, "attribute checking", || {
1241+
hir::check_attr::check_crate(tcx)
1242+
});
1243+
}, {
1244+
time(sess, "stability checking", || {
1245+
stability::check_unstable_api_usage(tcx)
1246+
});
12451247
});
12461248

12471249
// passes are timed inside typeck
@@ -1253,27 +1255,31 @@ where
12531255
}
12541256
}
12551257

1256-
time(sess, "rvalue promotion", || {
1257-
rvalue_promotion::check_crate(tcx)
1258-
});
1259-
1260-
time(sess, "privacy checking", || {
1261-
rustc_privacy::check_crate(tcx)
1262-
});
1263-
1264-
time(sess, "intrinsic checking", || {
1265-
middle::intrinsicck::check_crate(tcx)
1258+
time(sess, "misc checking", || {
1259+
parallel!({
1260+
time(sess, "rvalue promotion", || {
1261+
rvalue_promotion::check_crate(tcx)
1262+
});
1263+
}, {
1264+
time(sess, "intrinsic checking", || {
1265+
middle::intrinsicck::check_crate(tcx)
1266+
});
1267+
}, {
1268+
time(sess, "match checking", || mir::matchck_crate(tcx));
1269+
}, {
1270+
// this must run before MIR dump, because
1271+
// "not all control paths return a value" is reported here.
1272+
//
1273+
// maybe move the check to a MIR pass?
1274+
time(sess, "liveness checking", || {
1275+
middle::liveness::check_crate(tcx)
1276+
});
1277+
});
12661278
});
12671279

1268-
time(sess, "match checking", || mir::matchck_crate(tcx));
1269-
1270-
// this must run before MIR dump, because
1271-
// "not all control paths return a value" is reported here.
1272-
//
1273-
// maybe move the check to a MIR pass?
1274-
time(sess, "liveness checking", || {
1275-
middle::liveness::check_crate(tcx)
1276-
});
1280+
// Abort so we don't try to construct MIR with liveness errors.
1281+
// We also won't want to continue with errors from rvalue promotion
1282+
tcx.sess.abort_if_errors();
12771283

12781284
time(sess, "borrow checking", || {
12791285
if tcx.use_ast_borrowck() {
@@ -1297,7 +1303,7 @@ where
12971303

12981304
time(sess, "layout testing", || layout_test::test_layout(tcx));
12991305

1300-
// Avoid overwhelming user with errors if type checking failed.
1306+
// Avoid overwhelming user with errors if borrow checking failed.
13011307
// I'm not sure how helpful this is, to be honest, but it avoids
13021308
// a
13031309
// lot of annoying errors in the compile-fail tests (basically,
@@ -1307,14 +1313,22 @@ where
13071313
return Ok(f(tcx, rx, sess.compile_status()));
13081314
}
13091315

1310-
time(sess, "death checking", || middle::dead::check_crate(tcx));
1311-
1312-
time(sess, "unused lib feature checking", || {
1313-
stability::check_unused_or_stable_features(tcx)
1316+
time(sess, "misc checking", || {
1317+
parallel!({
1318+
time(sess, "privacy checking", || {
1319+
rustc_privacy::check_crate(tcx)
1320+
});
1321+
}, {
1322+
time(sess, "death checking", || middle::dead::check_crate(tcx));
1323+
}, {
1324+
time(sess, "unused lib feature checking", || {
1325+
stability::check_unused_or_stable_features(tcx)
1326+
});
1327+
}, {
1328+
time(sess, "lint checking", || lint::check_crate(tcx));
1329+
});
13141330
});
13151331

1316-
time(sess, "lint checking", || lint::check_crate(tcx));
1317-
13181332
return Ok(f(tcx, rx, tcx.sess.compile_status()));
13191333
},
13201334
)

‎src/librustc_driver/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern crate rustc;
3030
extern crate rustc_allocator;
3131
extern crate rustc_target;
3232
extern crate rustc_borrowck;
33+
#[macro_use]
3334
extern crate rustc_data_structures;
3435
extern crate rustc_errors as errors;
3536
extern crate rustc_passes;

‎src/librustc_passes/rvalue_promotion.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
4444
let def_id = tcx.hir().body_owner_def_id(body_id);
4545
tcx.const_is_rvalue_promotable_to_static(def_id);
4646
}
47-
tcx.sess.abort_if_errors();
4847
}
4948

5049
fn const_is_rvalue_promotable_to_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

‎src/test/ui/error-codes/E0446.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mod Foo {
1+
mod foo {
22
struct Bar(u32);
33

44
pub fn bar() -> Bar { //~ ERROR E0446

‎src/test/ui/error-codes/E0446.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0446]: private type `Foo::Bar` in public interface
1+
error[E0446]: private type `foo::Bar` in public interface
22
--> $DIR/E0446.rs:4:5
33
|
44
LL | struct Bar(u32);
5-
| - `Foo::Bar` declared as private
5+
| - `foo::Bar` declared as private
66
LL |
77
LL | / pub fn bar() -> Bar { //~ ERROR E0446
88
LL | | Bar(0)

‎src/test/ui/error-codes/E0451.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mod Bar {
1+
mod bar {
22
pub struct Foo {
33
pub a: isize,
44
b: isize,
@@ -10,10 +10,10 @@ mod Bar {
1010
);
1111
}
1212

13-
fn pat_match(foo: Bar::Foo) {
14-
let Bar::Foo{a:a, b:b} = foo; //~ ERROR E0451
13+
fn pat_match(foo: bar::Foo) {
14+
let bar::Foo{a, b} = foo; //~ ERROR E0451
1515
}
1616

1717
fn main() {
18-
let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
18+
let f = bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
1919
}

‎src/test/ui/error-codes/E0451.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
error[E0451]: field `b` of struct `Bar::Foo` is private
2-
--> $DIR/E0451.rs:14:23
1+
error[E0451]: field `b` of struct `bar::Foo` is private
2+
--> $DIR/E0451.rs:14:21
33
|
4-
LL | let Bar::Foo{a:a, b:b} = foo; //~ ERROR E0451
5-
| ^^^ field `b` is private
4+
LL | let bar::Foo{a, b} = foo; //~ ERROR E0451
5+
| ^ field `b` is private
66

7-
error[E0451]: field `b` of struct `Bar::Foo` is private
7+
error[E0451]: field `b` of struct `bar::Foo` is private
88
--> $DIR/E0451.rs:18:29
99
|
10-
LL | let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
10+
LL | let f = bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
1111
| ^^^^ field `b` is private
1212

1313
error: aborting due to 2 previous errors

‎src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use self::foo::S;
66
mod foo {
77
use std::cell::{UnsafeCell};
88

9-
static mut count : UnsafeCell<u64> = UnsafeCell::new(1);
9+
static mut COUNT : UnsafeCell<u64> = UnsafeCell::new(1);
1010

1111
pub struct S { pub a: u8, pub b: String, secret_uid: u64 }
1212

1313
pub fn make_secrets(a: u8, b: String) -> S {
14-
let val = unsafe { let p = count.get(); let val = *p; *p = val + 1; val };
14+
let val = unsafe { let p = COUNT.get(); let val = *p; *p = val + 1; val };
1515
println!("creating {}, uid {}", b, val);
1616
S { a: a, b: b, secret_uid: val }
1717
}

‎src/test/ui/privacy/private-in-public-warn.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ mod traits {
4949

5050
pub type Alias<T: PrivTr> = T; //~ ERROR private trait `traits::PrivTr` in public interface
5151
//~| WARNING hard error
52+
//~| WARNING bounds on generic parameters are not enforced in type aliases
5253
pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface
5354
//~^ WARNING hard error
5455
pub trait Tr2<T: PrivTr> {} //~ ERROR private trait `traits::PrivTr` in public interface
@@ -74,6 +75,7 @@ mod traits_where {
7475
pub type Alias<T> where T: PrivTr = T;
7576
//~^ ERROR private trait `traits_where::PrivTr` in public interface
7677
//~| WARNING hard error
78+
//~| WARNING where clauses are not enforced in type aliases
7779
pub trait Tr2<T> where T: PrivTr {}
7880
//~^ ERROR private trait `traits_where::PrivTr` in public interface
7981
//~| WARNING hard error

‎src/test/ui/privacy/private-in-public-warn.stderr

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ LL | pub type Alias<T: PrivTr> = T; //~ ERROR private trait `traits::PrivTr`
112112
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
113113

114114
error: private trait `traits::PrivTr` in public interface (error E0445)
115-
--> $DIR/private-in-public-warn.rs:52:5
115+
--> $DIR/private-in-public-warn.rs:53:5
116116
|
117117
LL | pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface
118118
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -121,7 +121,7 @@ LL | pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in pu
121121
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
122122

123123
error: private trait `traits::PrivTr` in public interface (error E0445)
124-
--> $DIR/private-in-public-warn.rs:54:5
124+
--> $DIR/private-in-public-warn.rs:55:5
125125
|
126126
LL | pub trait Tr2<T: PrivTr> {} //~ ERROR private trait `traits::PrivTr` in public interface
127127
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -130,7 +130,7 @@ LL | pub trait Tr2<T: PrivTr> {} //~ ERROR private trait `traits::PrivTr` in
130130
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
131131

132132
error: private trait `traits::PrivTr` in public interface (error E0445)
133-
--> $DIR/private-in-public-warn.rs:56:5
133+
--> $DIR/private-in-public-warn.rs:57:5
134134
|
135135
LL | / pub trait Tr3 {
136136
LL | | //~^ ERROR private trait `traits::PrivTr` in public interface
@@ -145,7 +145,7 @@ LL | | }
145145
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
146146

147147
error: private trait `traits::PrivTr` in public interface (error E0445)
148-
--> $DIR/private-in-public-warn.rs:60:9
148+
--> $DIR/private-in-public-warn.rs:61:9
149149
|
150150
LL | fn f<T: PrivTr>(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface
151151
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -154,7 +154,7 @@ LL | fn f<T: PrivTr>(arg: T) {} //~ ERROR private trait `traits::PrivTr`
154154
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
155155

156156
error: private trait `traits::PrivTr` in public interface (error E0445)
157-
--> $DIR/private-in-public-warn.rs:63:5
157+
--> $DIR/private-in-public-warn.rs:64:5
158158
|
159159
LL | impl<T: PrivTr> Pub<T> {} //~ ERROR private trait `traits::PrivTr` in public interface
160160
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -163,7 +163,7 @@ LL | impl<T: PrivTr> Pub<T> {} //~ ERROR private trait `traits::PrivTr` in p
163163
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
164164

165165
error: private trait `traits::PrivTr` in public interface (error E0445)
166-
--> $DIR/private-in-public-warn.rs:65:5
166+
--> $DIR/private-in-public-warn.rs:66:5
167167
|
168168
LL | impl<T: PrivTr> PubTr for Pub<T> {} //~ ERROR private trait `traits::PrivTr` in public interface
169169
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -172,7 +172,7 @@ LL | impl<T: PrivTr> PubTr for Pub<T> {} //~ ERROR private trait `traits::Pr
172172
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
173173

174174
error: private trait `traits_where::PrivTr` in public interface (error E0445)
175-
--> $DIR/private-in-public-warn.rs:74:5
175+
--> $DIR/private-in-public-warn.rs:75:5
176176
|
177177
LL | pub type Alias<T> where T: PrivTr = T;
178178
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -181,7 +181,7 @@ LL | pub type Alias<T> where T: PrivTr = T;
181181
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
182182

183183
error: private trait `traits_where::PrivTr` in public interface (error E0445)
184-
--> $DIR/private-in-public-warn.rs:77:5
184+
--> $DIR/private-in-public-warn.rs:79:5
185185
|
186186
LL | pub trait Tr2<T> where T: PrivTr {}
187187
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -190,7 +190,7 @@ LL | pub trait Tr2<T> where T: PrivTr {}
190190
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
191191

192192
error: private trait `traits_where::PrivTr` in public interface (error E0445)
193-
--> $DIR/private-in-public-warn.rs:81:9
193+
--> $DIR/private-in-public-warn.rs:83:9
194194
|
195195
LL | fn f<T>(arg: T) where T: PrivTr {}
196196
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -199,7 +199,7 @@ LL | fn f<T>(arg: T) where T: PrivTr {}
199199
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
200200

201201
error: private trait `traits_where::PrivTr` in public interface (error E0445)
202-
--> $DIR/private-in-public-warn.rs:85:5
202+
--> $DIR/private-in-public-warn.rs:87:5
203203
|
204204
LL | impl<T> Pub<T> where T: PrivTr {}
205205
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -208,7 +208,7 @@ LL | impl<T> Pub<T> where T: PrivTr {}
208208
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
209209

210210
error: private trait `traits_where::PrivTr` in public interface (error E0445)
211-
--> $DIR/private-in-public-warn.rs:88:5
211+
--> $DIR/private-in-public-warn.rs:90:5
212212
|
213213
LL | impl<T> PubTr for Pub<T> where T: PrivTr {}
214214
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -217,7 +217,7 @@ LL | impl<T> PubTr for Pub<T> where T: PrivTr {}
217217
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
218218

219219
error: private trait `generics::PrivTr<generics::Pub>` in public interface (error E0445)
220-
--> $DIR/private-in-public-warn.rs:99:5
220+
--> $DIR/private-in-public-warn.rs:101:5
221221
|
222222
LL | pub trait Tr1: PrivTr<Pub> {}
223223
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -226,7 +226,7 @@ LL | pub trait Tr1: PrivTr<Pub> {}
226226
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
227227

228228
error: private type `generics::Priv` in public interface (error E0446)
229-
--> $DIR/private-in-public-warn.rs:102:5
229+
--> $DIR/private-in-public-warn.rs:104:5
230230
|
231231
LL | pub trait Tr2: PubTr<Priv> {} //~ ERROR private type `generics::Priv` in public interface
232232
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -235,7 +235,7 @@ LL | pub trait Tr2: PubTr<Priv> {} //~ ERROR private type `generics::Priv` i
235235
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
236236

237237
error: private type `generics::Priv` in public interface (error E0446)
238-
--> $DIR/private-in-public-warn.rs:104:5
238+
--> $DIR/private-in-public-warn.rs:106:5
239239
|
240240
LL | pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR private type `generics::Priv` in public interface
241241
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -244,7 +244,7 @@ LL | pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR private type `generics::Pr
244244
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
245245

246246
error: private type `generics::Priv` in public interface (error E0446)
247-
--> $DIR/private-in-public-warn.rs:106:5
247+
--> $DIR/private-in-public-warn.rs:108:5
248248
|
249249
LL | pub trait Tr4: PubTr<Pub<Priv>> {} //~ ERROR private type `generics::Priv` in public interface
250250
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -253,7 +253,7 @@ LL | pub trait Tr4: PubTr<Pub<Priv>> {} //~ ERROR private type `generics::Pr
253253
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
254254

255255
error[E0446]: private type `impls::Priv` in public interface
256-
--> $DIR/private-in-public-warn.rs:133:9
256+
--> $DIR/private-in-public-warn.rs:135:9
257257
|
258258
LL | struct Priv;
259259
| - `impls::Priv` declared as private
@@ -262,7 +262,7 @@ LL | type Alias = Priv; //~ ERROR private type `impls::Priv` in public i
262262
| ^^^^^^^^^^^^^^^^^^ can't leak private type
263263

264264
error: private type `aliases_pub::Priv` in public interface (error E0446)
265-
--> $DIR/private-in-public-warn.rs:204:9
265+
--> $DIR/private-in-public-warn.rs:206:9
266266
|
267267
LL | pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` in public interface
268268
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -271,7 +271,7 @@ LL | pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` i
271271
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
272272

273273
error[E0446]: private type `aliases_pub::Priv` in public interface
274-
--> $DIR/private-in-public-warn.rs:208:9
274+
--> $DIR/private-in-public-warn.rs:210:9
275275
|
276276
LL | struct Priv;
277277
| - `aliases_pub::Priv` declared as private
@@ -280,7 +280,7 @@ LL | type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in pu
280280
| ^^^^^^^^^^^^^^^^^^ can't leak private type
281281

282282
error[E0446]: private type `aliases_pub::Priv` in public interface
283-
--> $DIR/private-in-public-warn.rs:211:9
283+
--> $DIR/private-in-public-warn.rs:213:9
284284
|
285285
LL | struct Priv;
286286
| - `aliases_pub::Priv` declared as private
@@ -289,7 +289,7 @@ LL | type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in pu
289289
| ^^^^^^^^^^^^^^^^^^ can't leak private type
290290

291291
error[E0446]: private type `aliases_pub::Priv` in public interface
292-
--> $DIR/private-in-public-warn.rs:214:9
292+
--> $DIR/private-in-public-warn.rs:216:9
293293
|
294294
LL | struct Priv;
295295
| - `aliases_pub::Priv` declared as private
@@ -298,7 +298,7 @@ LL | type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in pu
298298
| ^^^^^^^^^^^^^^^^^^ can't leak private type
299299

300300
error[E0446]: private type `aliases_pub::Priv` in public interface
301-
--> $DIR/private-in-public-warn.rs:217:9
301+
--> $DIR/private-in-public-warn.rs:219:9
302302
|
303303
LL | struct Priv;
304304
| - `aliases_pub::Priv` declared as private
@@ -307,7 +307,7 @@ LL | type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in pu
307307
| ^^^^^^^^^^^^^^^^^^ can't leak private type
308308

309309
error: private trait `aliases_priv::PrivTr1` in public interface (error E0445)
310-
--> $DIR/private-in-public-warn.rs:247:5
310+
--> $DIR/private-in-public-warn.rs:249:5
311311
|
312312
LL | pub trait Tr1: PrivUseAliasTr {}
313313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -316,7 +316,7 @@ LL | pub trait Tr1: PrivUseAliasTr {}
316316
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
317317

318318
error: private trait `aliases_priv::PrivTr1<aliases_priv::Priv2>` in public interface (error E0445)
319-
--> $DIR/private-in-public-warn.rs:250:5
319+
--> $DIR/private-in-public-warn.rs:252:5
320320
|
321321
LL | pub trait Tr2: PrivUseAliasTr<PrivAlias> {}
322322
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -325,14 +325,31 @@ LL | pub trait Tr2: PrivUseAliasTr<PrivAlias> {}
325325
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
326326

327327
error: private type `aliases_priv::Priv2` in public interface (error E0446)
328-
--> $DIR/private-in-public-warn.rs:250:5
328+
--> $DIR/private-in-public-warn.rs:252:5
329329
|
330330
LL | pub trait Tr2: PrivUseAliasTr<PrivAlias> {}
331331
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
332332
|
333333
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
334334
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
335335

336+
warning: bounds on generic parameters are not enforced in type aliases
337+
--> $DIR/private-in-public-warn.rs:50:23
338+
|
339+
LL | pub type Alias<T: PrivTr> = T; //~ ERROR private trait `traits::PrivTr` in public interface
340+
| ^^^^^^
341+
|
342+
= note: #[warn(type_alias_bounds)] on by default
343+
= help: the bound will not be checked when the type alias is used, and should be removed
344+
345+
warning: where clauses are not enforced in type aliases
346+
--> $DIR/private-in-public-warn.rs:75:29
347+
|
348+
LL | pub type Alias<T> where T: PrivTr = T;
349+
| ^^^^^^^^^
350+
|
351+
= help: the clause will not be checked when the type alias is used, and should be removed
352+
336353
error: aborting due to 36 previous errors
337354

338355
For more information about this error, try `rustc --explain E0446`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(associated_consts)]
21
#![feature(decl_macro)]
32
#![allow(private_in_public)]
43

@@ -15,6 +14,7 @@ mod m {
1514
pub struct PubTupleStruct(u8);
1615
impl PubTupleStruct { fn method() {} }
1716

17+
#[derive(Clone, Copy)]
1818
struct Priv;
1919
pub type Alias = Priv;
2020
pub struct Pub<T = Alias>(pub T);

0 commit comments

Comments
 (0)
Please sign in to comment.