Skip to content

Commit 1b45b58

Browse files
committed
---
yaml --- r: 134120 b: refs/heads/master c: 5376b1c h: refs/heads/master v: v3
1 parent 62b0554 commit 1b45b58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+218
-185
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 2f9669c7489cc383bc6616c5f9ed217ae37e3d56
2+
refs/heads/master: 5376b1c79870c80d0081540c72ae060d3ed5d1f5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 437179ed8bf7f7672f84b19265df1ce569e70490
55
refs/heads/try: 777654cfccbfa39bc7f671d8e9629018ed8ca12d

trunk/src/doc/intro.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ Here's some code:
300300
use std::sync::Arc;
301301
302302
fn main() {
303-
let numbers = Arc::new(vec![1i, 2i, 3i]);
303+
let numbers = vec![1i, 2i, 3i];
304+
let numbers = Arc::new(numbers);
304305
305306
for num in range(0u, 3) {
306307
let (tx, rx) = channel();
@@ -345,7 +346,8 @@ and modify it to mutate the shared state:
345346
use std::sync::{Arc, Mutex};
346347
347348
fn main() {
348-
let numbers_lock = Arc::new(Mutex::new(vec![1i, 2i, 3i]));
349+
let numbers = vec![1i, 2i, 3i];
350+
let numbers_lock = Arc::new(Mutex::new(numbers));
349351
350352
for num in range(0u, 3) {
351353
let (tx, rx) = channel();

trunk/src/libcore/any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub enum Void { }
9494
pub trait Any: AnyPrivate {}
9595

9696
/// An inner trait to ensure that only this module can call `get_type_id()`.
97-
pub trait AnyPrivate {
97+
trait AnyPrivate {
9898
/// Get the `TypeId` of `self`
9999
fn get_type_id(&self) -> TypeId;
100100
}

trunk/src/libcore/clone.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ the `clone` method.
2525

2626
/// A common trait for cloning an object.
2727
pub trait Clone {
28-
/// Returns a copy of the value.
28+
/// Returns a copy of the value. The contents of owned pointers
29+
/// are copied to maintain uniqueness, while the contents of
30+
/// managed pointers are not copied.
2931
fn clone(&self) -> Self;
3032

3133
/// Perform copy-assignment from `source`.

trunk/src/libcore/iter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,6 +2178,7 @@ pub type Iterate<'a, T> = Unfold<'a, T, IterateState<'a, T>>;
21782178

21792179
/// Creates a new iterator that produces an infinite sequence of
21802180
/// repeated applications of the given function `f`.
2181+
#[allow(visible_private_types)]
21812182
pub fn iterate<'a, T: Clone>(seed: T, f: |T|: 'a -> T) -> Iterate<'a, T> {
21822183
Unfold::new((f, Some(seed), true), |st| {
21832184
let &(ref mut f, ref mut val, ref mut first) = st;

trunk/src/libdebug/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ macro_rules! try( ($me:expr, $e:expr) => (
3232

3333
/// Representations
3434
35-
pub trait Repr {
35+
trait Repr {
3636
fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()>;
3737
}
3838

trunk/src/libgreen/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218

219219
// NB this does *not* include globs, please keep it that way.
220220
#![feature(macro_rules, phase, default_type_params)]
221-
#![allow(deprecated)]
221+
#![allow(visible_private_types, deprecated)]
222222

223223
#[cfg(test)] #[phase(plugin, link)] extern crate log;
224224
#[cfg(test)] extern crate rustuv;
@@ -385,7 +385,7 @@ pub struct SchedPool {
385385
/// keep track of how many tasks are currently running in the pool and then
386386
/// sending on a channel once the entire pool has been drained of all tasks.
387387
#[deriving(Clone)]
388-
pub struct TaskState {
388+
struct TaskState {
389389
cnt: Arc<AtomicUint>,
390390
done: Sender<()>,
391391
}

trunk/src/libnative/io/timer_unix.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ pub struct Timer {
6666
inner: Option<Box<Inner>>,
6767
}
6868

69-
pub struct Inner {
69+
struct Inner {
7070
cb: Option<Box<rtio::Callback + Send>>,
7171
interval: u64,
7272
repeat: bool,
7373
target: u64,
7474
id: uint,
7575
}
7676

77+
#[allow(visible_private_types)]
7778
pub enum Req {
7879
// Add a new timer to the helper thread.
7980
NewTimer(Box<Inner>),

trunk/src/libregex/compile.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// Enable this to squash warnings due to exporting pieces of the representation
1212
// for use with the regex! macro. See lib.rs for explanation.
13+
#![allow(visible_private_types)]
1314

1415
use std::cmp;
1516
use parse;

trunk/src/libregex/re.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pub fn is_match(regex: &str, text: &str) -> Result<bool, parse::Error> {
102102
/// More details about the `regex!` macro can be found in the `regex` crate
103103
/// documentation.
104104
#[deriving(Clone)]
105+
#[allow(visible_private_types)]
105106
pub enum Regex {
106107
// The representation of `Regex` is exported to support the `regex!`
107108
// syntax extension. Do not rely on it.
@@ -515,6 +516,7 @@ impl Regex {
515516
}
516517

517518
#[doc(hidden)]
519+
#[allow(visible_private_types)]
518520
#[experimental]
519521
pub fn names_iter<'a>(&'a self) -> NamesIter<'a> {
520522
match *self {
@@ -532,7 +534,7 @@ impl Regex {
532534

533535
}
534536

535-
pub enum NamesIter<'a> {
537+
enum NamesIter<'a> {
536538
NamesIterNative(::std::slice::Items<'a, Option<&'static str>>),
537539
NamesIterDynamic(::std::slice::Items<'a, Option<String>>)
538540
}

trunk/src/librustc/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,8 @@ pub fn phase_6_link_output(sess: &Session,
560560
trans: &CrateTranslation,
561561
outputs: &OutputFilenames) {
562562
let old_path = os::getenv("PATH").unwrap_or_else(||String::new());
563-
let mut new_path = os::split_paths(old_path.as_slice());
564-
new_path.push_all_move(sess.host_filesearch().get_tools_search_paths());
563+
let mut new_path = sess.host_filesearch().get_tools_search_paths();
564+
new_path.push_all_move(os::split_paths(old_path.as_slice()));
565565
os::setenv("PATH", os::join_paths(new_path.as_slice()).unwrap());
566566

567567
time(sess.time_passes(), "linking", (), |_|

trunk/src/librustc/lint/builtin.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,9 @@ declare_lint!(pub DEAD_ASSIGNMENT, Warn,
16011601
declare_lint!(pub DEAD_CODE, Warn,
16021602
"detect piece of code that will never be used")
16031603

1604+
declare_lint!(pub VISIBLE_PRIVATE_TYPES, Warn,
1605+
"detect use of private types in exported type signatures")
1606+
16041607
declare_lint!(pub UNREACHABLE_CODE, Warn,
16051608
"detects unreachable code")
16061609

@@ -1633,6 +1636,7 @@ impl LintPass for HardwiredLints {
16331636
UNUSED_VARIABLE,
16341637
DEAD_ASSIGNMENT,
16351638
DEAD_CODE,
1639+
VISIBLE_PRIVATE_TYPES,
16361640
UNREACHABLE_CODE,
16371641
WARNINGS,
16381642
UNKNOWN_FEATURES,

trunk/src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ pub fn deref_kind(tcx: &ty::ctxt, t: ty::t) -> deref_kind {
224224
}
225225
}
226226

227-
pub trait ast_node {
227+
trait ast_node {
228228
fn id(&self) -> ast::NodeId;
229229
fn span(&self) -> Span;
230230
}

trunk/src/librustc/middle/privacy.rs

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::mem::replace;
1616

1717
use metadata::csearch;
1818
use middle::def;
19+
use lint;
1920
use middle::resolve;
2021
use middle::ty;
2122
use middle::typeck::{MethodCall, MethodMap, MethodOrigin, MethodParam, MethodTypeParam};
@@ -1288,38 +1289,19 @@ impl<'a, 'tcx> VisiblePrivateTypesVisitor<'a, 'tcx> {
12881289
};
12891290
// A path can only be private if:
12901291
// it's in this crate...
1291-
if !is_local(did) {
1292-
return false
1293-
}
1294-
// .. and it corresponds to a private type in the AST (this returns
1295-
// None for type parameters)
1296-
match self.tcx.map.find(did.node) {
1297-
Some(ast_map::NodeItem(ref item)) => item.vis != ast::Public,
1298-
Some(_) | None => false,
1299-
}
1292+
is_local(did) &&
1293+
// ... it's not exported (obviously) ...
1294+
!self.exported_items.contains(&did.node) &&
1295+
// .. and it corresponds to a type in the AST (this returns None for
1296+
// type parameters)
1297+
self.tcx.map.find(did.node).is_some()
13001298
}
13011299

13021300
fn trait_is_public(&self, trait_id: ast::NodeId) -> bool {
13031301
// FIXME: this would preferably be using `exported_items`, but all
13041302
// traits are exported currently (see `EmbargoVisitor.exported_trait`)
13051303
self.public_items.contains(&trait_id)
13061304
}
1307-
1308-
fn check_ty_param_bound(&self,
1309-
span: Span,
1310-
ty_param_bound: &ast::TyParamBound) {
1311-
match *ty_param_bound {
1312-
ast::TraitTyParamBound(ref trait_ref) => {
1313-
if !self.tcx.sess.features.borrow().visible_private_types &&
1314-
self.path_is_private_type(trait_ref.ref_id) {
1315-
self.tcx.sess.span_err(span,
1316-
"private type in exported type \
1317-
parameter bound");
1318-
}
1319-
}
1320-
_ => {}
1321-
}
1322-
}
13231305
}
13241306

13251307
impl<'a, 'b, 'tcx, 'v> Visitor<'v> for CheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> {
@@ -1356,15 +1338,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
13561338
// namespace (the contents have their own privacies).
13571339
ast::ItemForeignMod(_) => {}
13581340

1359-
ast::ItemTrait(_, _, ref bounds, _) => {
1360-
if !self.trait_is_public(item.id) {
1361-
return
1362-
}
1363-
1364-
for bound in bounds.iter() {
1365-
self.check_ty_param_bound(item.span, bound)
1366-
}
1367-
}
1341+
ast::ItemTrait(..) if !self.trait_is_public(item.id) => return,
13681342

13691343
// impls need some special handling to try to offer useful
13701344
// error messages without (too many) false positives
@@ -1497,19 +1471,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
14971471
visit::walk_item(self, item);
14981472
}
14991473

1500-
fn visit_generics(&mut self, generics: &ast::Generics) {
1501-
for ty_param in generics.ty_params.iter() {
1502-
for bound in ty_param.bounds.iter() {
1503-
self.check_ty_param_bound(ty_param.span, bound)
1504-
}
1505-
}
1506-
for predicate in generics.where_clause.predicates.iter() {
1507-
for bound in predicate.bounds.iter() {
1508-
self.check_ty_param_bound(predicate.span, bound)
1509-
}
1510-
}
1511-
}
1512-
15131474
fn visit_foreign_item(&mut self, item: &ast::ForeignItem) {
15141475
if self.exported_items.contains(&item.id) {
15151476
visit::walk_foreign_item(self, item)
@@ -1527,11 +1488,12 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
15271488
fn visit_ty(&mut self, t: &ast::Ty) {
15281489
match t.node {
15291490
ast::TyPath(ref p, _, path_id) => {
1530-
if !self.tcx.sess.features.borrow().visible_private_types &&
1531-
self.path_is_private_type(path_id) {
1532-
self.tcx.sess.span_err(p.span,
1533-
"private type in exported type \
1534-
signature");
1491+
if self.path_is_private_type(path_id) {
1492+
self.tcx.sess.add_lint(
1493+
lint::builtin::VISIBLE_PRIVATE_TYPES,
1494+
path_id, p.span,
1495+
"private type in exported type \
1496+
signature".to_string());
15351497
}
15361498
}
15371499
_ => {}

trunk/src/librustc/middle/resolve_lifetime.rs

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use driver::session::Session;
2121
use middle::subst;
2222
use syntax::ast;
2323
use syntax::codemap::Span;
24+
use syntax::owned_slice::OwnedSlice;
2425
use syntax::parse::token::special_idents;
2526
use syntax::parse::token;
2627
use syntax::print::pprust::{lifetime_to_string};
@@ -98,8 +99,22 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
9899
ast::ItemTy(_, ref generics) |
99100
ast::ItemEnum(_, ref generics) |
100101
ast::ItemStruct(_, ref generics) |
101-
ast::ItemImpl(ref generics, _, _, _) |
102-
ast::ItemTrait(ref generics, _, _, _) => &generics.lifetimes
102+
ast::ItemTrait(ref generics, _, _, _) => {
103+
self.with(|scope, f| {
104+
f(EarlyScope(subst::TypeSpace,
105+
&generics.lifetimes,
106+
scope))
107+
}, |v| v.check_lifetime_defs(&generics.lifetimes));
108+
&generics.lifetimes
109+
}
110+
ast::ItemImpl(ref generics, _, _, _) => {
111+
self.with(|scope, f| {
112+
f(EarlyScope(subst::TypeSpace,
113+
&generics.lifetimes,
114+
scope))
115+
}, |v| v.check_lifetime_defs(&generics.lifetimes));
116+
&generics.lifetimes
117+
}
103118
};
104119

105120
self.with(|_, f| f(EarlyScope(subst::TypeSpace, lifetimes, &ROOT_SCOPE)), |v| {
@@ -155,6 +170,20 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
155170
}
156171
self.resolve_lifetime_ref(lifetime_ref);
157172
}
173+
174+
fn visit_generics(&mut self, generics: &ast::Generics) {
175+
for ty_param in generics.ty_params.iter() {
176+
self.visit_ty_param_bounds(&ty_param.bounds);
177+
match ty_param.default {
178+
Some(ref ty) => self.visit_ty(&**ty),
179+
None => {}
180+
}
181+
}
182+
for predicate in generics.where_clause.predicates.iter() {
183+
self.visit_ident(predicate.span, predicate.ident);
184+
self.visit_ty_param_bounds(&predicate.bounds);
185+
}
186+
}
158187
}
159188

160189
impl<'a> LifetimeContext<'a> {
@@ -167,6 +196,47 @@ impl<'a> LifetimeContext<'a> {
167196
}))
168197
}
169198

199+
fn visit_ty_param_bounds(&mut self,
200+
bounds: &OwnedSlice<ast::TyParamBound>) {
201+
for bound in bounds.iter() {
202+
match *bound {
203+
ast::TraitTyParamBound(ref trait_ref) => {
204+
self.visit_trait_ref(trait_ref);
205+
}
206+
ast::UnboxedFnTyParamBound(ref fn_decl) => {
207+
self.visit_unboxed_fn_ty_param_bound(&**fn_decl);
208+
}
209+
ast::RegionTyParamBound(ref lifetime) => {
210+
self.visit_lifetime_ref(lifetime);
211+
}
212+
}
213+
}
214+
}
215+
216+
fn visit_trait_ref(&mut self, trait_ref: &ast::TraitRef) {
217+
self.with(|scope, f| {
218+
f(LateScope(trait_ref.ref_id, &trait_ref.lifetimes, scope))
219+
}, |v| {
220+
v.check_lifetime_defs(&trait_ref.lifetimes);
221+
for lifetime in trait_ref.lifetimes.iter() {
222+
v.visit_lifetime_decl(lifetime);
223+
}
224+
v.visit_path(&trait_ref.path, trait_ref.ref_id);
225+
})
226+
}
227+
228+
fn visit_unboxed_fn_ty_param_bound(&mut self,
229+
bound: &ast::UnboxedFnBound) {
230+
self.with(|scope, f| {
231+
f(LateScope(bound.ref_id, &bound.lifetimes, scope))
232+
}, |v| {
233+
for argument in bound.decl.inputs.iter() {
234+
v.visit_ty(&*argument.ty);
235+
}
236+
v.visit_ty(&*bound.decl.output);
237+
})
238+
}
239+
170240
/// Visits self by adding a scope and handling recursive walk over the contents with `walk`.
171241
fn visit_fn_decl(&mut self,
172242
n: ast::NodeId,

trunk/src/librustc/middle/typeck/infer/error_reporting.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
11101110
ast::TraitTyParamBound(ast::TraitRef {
11111111
path: new_path,
11121112
ref_id: tr.ref_id,
1113+
lifetimes: tr.lifetimes.clone(),
11131114
})
11141115
}
11151116
}
@@ -1645,7 +1646,7 @@ impl<'a, 'tcx> ErrorReportingHelpers for InferCtxt<'a, 'tcx> {
16451646
}
16461647
}
16471648

1648-
pub trait Resolvable {
1649+
trait Resolvable {
16491650
fn resolve(&self, infcx: &InferCtxt) -> Self;
16501651
fn contains_error(&self) -> bool;
16511652
}

0 commit comments

Comments
 (0)