Skip to content

Commit 1bbb4d6

Browse files
committed
---
yaml --- r: 176045 b: refs/heads/try c: 683d20c h: refs/heads/master i: 176043: bdcd9c8 v: v3
1 parent beeceef commit 1bbb4d6

File tree

8 files changed

+88
-43
lines changed

8 files changed

+88
-43
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: a530cc9706324ad44dba464d541a807eb5afdb08
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 777435990e0e91df6b72ce80c9b6fa485eeb5daa
5-
refs/heads/try: f3d71be65cccfddd232e733c11129ed53961f980
5+
refs/heads/try: 683d20c3c5c82043a36b3d328324599261912580
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/doc/trpl/ownership.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ valid for. For example:
326326

327327
```rust
328328
fn main() {
329-
let y = &5; // -+ y goes into scope
329+
let y = &5; // -+ y goes into scope
330330
// |
331331
// stuff // |
332332
// |
@@ -341,7 +341,7 @@ struct Foo<'a> {
341341
}
342342

343343
fn main() {
344-
let y = &5; // -+ y goes into scope
344+
let y = &5; // -+ y goes into scope
345345
let f = Foo { x: y }; // -+ f goes into scope
346346
// stuff // |
347347
// |
@@ -360,7 +360,7 @@ fn main() {
360360
let x; // -+ x goes into scope
361361
// |
362362
{ // |
363-
let y = &5; // ---+ y goes into scope
363+
let y = &5; // ---+ y goes into scope
364364
let f = Foo { x: y }; // ---+ f goes into scope
365365
x = &f.x; // | | error here
366366
} // ---+ f and y go out of scope

branches/try/src/librustc/metadata/csearch.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@ pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: ast::DefId,
262262
}
263263
}
264264

265+
pub fn get_impl_polarity<'tcx>(tcx: &ty::ctxt<'tcx>,
266+
def: ast::DefId)
267+
-> Option<ast::ImplPolarity>
268+
{
269+
let cstore = &tcx.sess.cstore;
270+
let cdata = cstore.get_crate_data(def.krate);
271+
decoder::get_impl_polarity(&*cdata, def.node)
272+
}
273+
265274
// Given a def_id for an impl, return the trait it implements,
266275
// if there is one.
267276
pub fn get_impl_trait<'tcx>(tcx: &ty::ctxt<'tcx>,

branches/try/src/librustc/metadata/decoder.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,15 @@ fn parse_unsafety(item_doc: rbml::Doc) -> ast::Unsafety {
371371
}
372372
}
373373

374+
fn parse_polarity(item_doc: rbml::Doc) -> ast::ImplPolarity {
375+
let polarity_doc = reader::get_doc(item_doc, tag_polarity);
376+
if reader::doc_as_u8(polarity_doc) != 0 {
377+
ast::ImplPolarity::Negative
378+
} else {
379+
ast::ImplPolarity::Positive
380+
}
381+
}
382+
374383
fn parse_associated_type_names(item_doc: rbml::Doc) -> Vec<ast::Name> {
375384
let names_doc = reader::get_doc(item_doc, tag_associated_type_names);
376385
let mut names = Vec::new();
@@ -436,6 +445,20 @@ pub fn get_repr_attrs(cdata: Cmd, id: ast::NodeId) -> Vec<attr::ReprAttr> {
436445
}
437446
}
438447

448+
pub fn get_impl_polarity<'tcx>(cdata: Cmd,
449+
id: ast::NodeId)
450+
-> Option<ast::ImplPolarity>
451+
{
452+
let item_doc = lookup_item(id, cdata.data());
453+
let fam = item_family(item_doc);
454+
match fam {
455+
Family::Impl => {
456+
Some(parse_polarity(item_doc))
457+
}
458+
_ => None
459+
}
460+
}
461+
439462
pub fn get_impl_trait<'tcx>(cdata: Cmd,
440463
id: ast::NodeId,
441464
tcx: &ty::ctxt<'tcx>)

branches/try/src/librustc/middle/ty.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,9 @@ pub struct ctxt<'tcx> {
750750
/// Maps a trait onto a list of impls of that trait.
751751
pub trait_impls: RefCell<DefIdMap<Rc<RefCell<Vec<ast::DefId>>>>>,
752752

753+
/// Maps a trait onto a list of negative impls of that trait.
754+
pub trait_negative_impls: RefCell<DefIdMap<Rc<RefCell<Vec<ast::DefId>>>>>,
755+
753756
/// Maps a DefId of a type to a list of its inherent impls.
754757
/// Contains implementations of methods that are inherent to a type.
755758
/// Methods in these implementations don't need to be exported.
@@ -2412,6 +2415,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
24122415
destructor_for_type: RefCell::new(DefIdMap::new()),
24132416
destructors: RefCell::new(DefIdSet::new()),
24142417
trait_impls: RefCell::new(DefIdMap::new()),
2418+
trait_negative_impls: RefCell::new(DefIdMap::new()),
24152419
inherent_impls: RefCell::new(DefIdMap::new()),
24162420
impl_items: RefCell::new(DefIdMap::new()),
24172421
used_unsafe: RefCell::new(NodeSet::new()),
@@ -5035,6 +5039,23 @@ pub fn trait_items<'tcx>(cx: &ctxt<'tcx>, trait_did: ast::DefId)
50355039
}
50365040
}
50375041

5042+
pub fn trait_impl_polarity<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
5043+
-> Option<ast::ImplPolarity> {
5044+
if id.krate == ast::LOCAL_CRATE {
5045+
match cx.map.find(id.node) {
5046+
Some(ast_map::NodeItem(item)) => {
5047+
match item.node {
5048+
ast::ItemImpl(_, polarity, _, _, _, _) => Some(polarity),
5049+
_ => None
5050+
}
5051+
}
5052+
_ => None
5053+
}
5054+
} else {
5055+
csearch::get_impl_polarity(cx, id)
5056+
}
5057+
}
5058+
50385059
pub fn impl_or_trait_item<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
50395060
-> ImplOrTraitItem<'tcx> {
50405061
lookup_locally_or_in_crate_store("impl_or_trait_items",
@@ -5984,14 +6005,23 @@ pub fn item_variances(tcx: &ctxt, item_id: ast::DefId) -> Rc<ItemVariances> {
59846005
pub fn record_trait_implementation(tcx: &ctxt,
59856006
trait_def_id: DefId,
59866007
impl_def_id: DefId) {
5987-
match tcx.trait_impls.borrow().get(&trait_def_id) {
6008+
6009+
let trait_impls = match trait_impl_polarity(tcx, impl_def_id) {
6010+
Some(ast::ImplPolarity::Positive) => &tcx.trait_impls,
6011+
Some(ast::ImplPolarity::Negative) => &tcx.trait_negative_impls,
6012+
_ => tcx.sess.bug(&format!("tried to record a non-impl item with id {:?}",
6013+
impl_def_id)[])
6014+
};
6015+
6016+
match trait_impls.borrow().get(&trait_def_id) {
59886017
Some(impls_for_trait) => {
59896018
impls_for_trait.borrow_mut().push(impl_def_id);
59906019
return;
59916020
}
59926021
None => {}
59936022
}
5994-
tcx.trait_impls.borrow_mut().insert(trait_def_id, Rc::new(RefCell::new(vec!(impl_def_id))));
6023+
6024+
trait_impls.borrow_mut().insert(trait_def_id, Rc::new(RefCell::new(vec!(impl_def_id))));
59956025
}
59966026

59976027
/// Populates the type context with all the implementations for the given type

branches/try/src/librustc_trans/save/mod.rs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
278278
// The qualname for a method is the trait name or name of the struct in an impl in
279279
// which the method is declared in followed by the method's name.
280280
let mut qualname = match ty::impl_of_method(&self.analysis.ty_cx,
281-
ast_util::local_def(method.id)) {
281+
ast_util::local_def(method.id)) {
282282
Some(impl_id) => match self.analysis.ty_cx.map.get(impl_id.node) {
283283
NodeItem(item) => {
284284
scope_id = item.id;
@@ -349,7 +349,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
349349
.and_then(|def_id| {
350350
if match def_id {
351351
ty::MethodTraitItemId(def_id) => {
352-
def_id.node != 0 && def_id != ast_util::local_def(method.id)
352+
method.id != 0 && def_id.node == 0
353353
}
354354
ty::TypeTraitItemId(_) => false,
355355
} {
@@ -392,7 +392,8 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
392392
}
393393

394394
fn process_trait_ref(&mut self,
395-
trait_ref: &ast::TraitRef) {
395+
trait_ref: &ast::TraitRef,
396+
impl_id: Option<NodeId>) {
396397
match self.lookup_type_ref(trait_ref.ref_id) {
397398
Some(id) => {
398399
let sub_span = self.span.sub_span_for_type_name(trait_ref.path.span);
@@ -401,6 +402,14 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
401402
sub_span,
402403
id,
403404
self.cur_scope);
405+
match impl_id {
406+
Some(impl_id) => self.fmt.impl_str(trait_ref.path.span,
407+
sub_span,
408+
impl_id,
409+
id,
410+
self.cur_scope),
411+
None => (),
412+
}
404413
visit::walk_path(self, &trait_ref.path);
405414
},
406415
None => ()
@@ -643,9 +652,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
643652
trait_ref: &Option<ast::TraitRef>,
644653
typ: &ast::Ty,
645654
impl_items: &Vec<ast::ImplItem>) {
646-
let trait_id = trait_ref.as_ref().and_then(|tr| self.lookup_type_ref(tr.ref_id));
647655
match typ.node {
648-
// Common case impl for a struct or something basic.
649656
ast::TyPath(ref path, id) => {
650657
match self.lookup_type_ref(id) {
651658
Some(id) => {
@@ -658,29 +665,17 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
658665
self.fmt.impl_str(path.span,
659666
sub_span,
660667
item.id,
661-
Some(id),
662-
trait_id,
668+
id,
663669
self.cur_scope);
664670
},
665671
None => ()
666672
}
667673
},
668-
_ => {
669-
// Less useful case, impl for a compound type.
670-
self.visit_ty(&*typ);
671-
672-
let sub_span = self.span.sub_span_for_type_name(typ.span);
673-
self.fmt.impl_str(typ.span,
674-
sub_span,
675-
item.id,
676-
None,
677-
trait_id,
678-
self.cur_scope);
679-
}
674+
_ => self.visit_ty(&*typ),
680675
}
681676

682677
match *trait_ref {
683-
Some(ref trait_ref) => self.process_trait_ref(trait_ref),
678+
Some(ref trait_ref) => self.process_trait_ref(trait_ref, Some(item.id)),
684679
None => (),
685680
}
686681

@@ -1081,7 +1076,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
10811076
for param in generics.ty_params.iter() {
10821077
for bound in param.bounds.iter() {
10831078
if let ast::TraitTyParamBound(ref trait_ref, _) = *bound {
1084-
self.process_trait_ref(&trait_ref.trait_ref);
1079+
self.process_trait_ref(&trait_ref.trait_ref, None);
10851080
}
10861081
}
10871082
if let Some(ref ty) = param.default {

branches/try/src/librustc_trans/save/recorder.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ use syntax::ast;
1919
use syntax::ast::{NodeId,DefId};
2020
use syntax::codemap::*;
2121

22-
const ZERO_DEF_ID: DefId = DefId { node: 0, krate: 0 };
23-
2422
pub struct Recorder {
2523
// output file
2624
pub out: Box<Writer+'static>,
@@ -123,9 +121,7 @@ impl<'a> FmtStrs<'a> {
123121
MethodDecl => ("method_decl", vec!("id","qualname","scopeid"), true, true),
124122
Struct => ("struct", vec!("id","ctor_id","qualname","scopeid","value"), true, true),
125123
Trait => ("trait", vec!("id","qualname","scopeid","value"), true, true),
126-
Impl => ("impl",
127-
vec!("id","refid","refidcrate","traitid","traitidcrate","scopeid"),
128-
true, true),
124+
Impl => ("impl", vec!("id","refid","refidcrate","scopeid"), true, true),
129125
Module => ("module", vec!("id","qualname","scopeid","def_file"), true, false),
130126
UseAlias => ("use_alias",
131127
vec!("id","refid","refidcrate","name","scopeid"),
@@ -448,20 +444,12 @@ impl<'a> FmtStrs<'a> {
448444
span: Span,
449445
sub_span: Option<Span>,
450446
id: NodeId,
451-
ref_id: Option<DefId>,
452-
trait_id: Option<DefId>,
447+
ref_id: DefId,
453448
scope_id: NodeId) {
454-
let ref_id = ref_id.unwrap_or(ZERO_DEF_ID);
455-
let trait_id = trait_id.unwrap_or(ZERO_DEF_ID);
456449
self.check_and_record(Impl,
457450
span,
458451
sub_span,
459-
svec!(id,
460-
ref_id.node,
461-
ref_id.krate,
462-
trait_id.node,
463-
trait_id.krate,
464-
scope_id));
452+
svec!(id, ref_id.node, ref_id.krate, scope_id));
465453
}
466454

467455
pub fn mod_str(&mut self,

branches/try/src/libstd/sync/condvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl Condvar {
173173
/// be woken up from its call to `wait` or `wait_timeout`. Calls to
174174
/// `notify_one` are not buffered in any way.
175175
///
176-
/// To wake up all threads, see `notify_all()`.
176+
/// To wake up all threads, see `notify_one()`.
177177
#[stable]
178178
pub fn notify_one(&self) { unsafe { self.inner.inner.notify_one() } }
179179

0 commit comments

Comments
 (0)