Skip to content

Commit 9734406

Browse files
committed
Assorted fixed after rebasing
1 parent c1df41e commit 9734406

File tree

12 files changed

+56
-56
lines changed

12 files changed

+56
-56
lines changed

src/librustc/middle/subst.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ impl<'tcx> Substs<'tcx> {
162162

163163
pub fn with_method_from_subst(self, other: &Substs<'tcx>) -> Substs<'tcx> {
164164
let Substs { types, regions } = self;
165-
let types = types.with_vec(FnSpace, other.types.get_slice(FnSpace).to_vec());
165+
let types = types.with_slice(FnSpace, other.types.get_slice(FnSpace));
166166
let regions = regions.map(|r| {
167-
r.with_vec(FnSpace, other.regions().get_slice(FnSpace).to_vec())
167+
r.with_slice(FnSpace, other.regions().get_slice(FnSpace))
168168
});
169169
Substs { types: types, regions: regions }
170170
}

src/librustc/middle/traits/select.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
16211621
true
16221622
},
16231623
ParamCandidate(..) => false,
1624-
ErrorCandidate => false // propagate errors
16251624
},
16261625
ImplCandidate(other_def) => {
16271626
// See if we can toss out `victim` based on specialization.

src/librustc/middle/traits/specialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl SpecializationGraph {
8787
for slot in possible_siblings.iter_mut() {
8888
let possible_sibling = *slot;
8989

90-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
90+
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
9191
let overlap = traits::overlapping_impls(&infcx, possible_sibling, impl_def_id);
9292

9393
if let Some(trait_ref) = overlap {

src/librustc/middle/ty/trait_def.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
use dep_graph::DepNode;
1212
use middle::def_id::DefId;
13+
use middle::traits;
1314
use middle::ty;
1415
use middle::ty::fast_reject;
15-
use middle::ty::{Ty, TyCtxt};
16+
use middle::ty::{Ty, TyCtxt, TraitRef};
1617
use std::borrow::{Borrow};
1718
use std::cell::{Cell, Ref, RefCell};
1819
use syntax::ast::Name;
@@ -128,6 +129,12 @@ impl<'tcx> TraitDef<'tcx> {
128129
debug!("TraitDef::record_impl for {:?}, from {:?}",
129130
self, impl_trait_ref);
130131

132+
// Record the write into the impl set, but only for local
133+
// impls: external impls are handled differently.
134+
if impl_def_id.is_local() {
135+
self.write_trait_impls(tcx);
136+
}
137+
131138
// We don't want to borrow_mut after we already populated all impls,
132139
// so check if an impl is present with an immutable borrow first.
133140
if let Some(sty) = fast_reject::simplify_type(tcx,

src/librustc_trans/trans/meth.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use trans::glue;
3333
use trans::machine;
3434
use trans::type_::Type;
3535
use trans::type_of::*;
36-
use middle::ty::{self, Ty, TyCtxt};
36+
use middle::ty::{self, Ty, TyCtxt, TypeFoldable};
37+
use middle::ty::MethodCall;
3738

3839
use syntax::ast::{self, Name};
3940
use syntax::attr;

src/librustc_typeck/check/mod.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -872,22 +872,24 @@ fn check_specialization_validity<'tcx, F>(tcx: &ty::ctxt<'tcx>,
872872
{
873873
let parent_item_opt = traits::get_parent_impl_item(tcx, impl_id, f);
874874
if let Some((Defaultness::Final, parent_impl)) = parent_item_opt {
875-
span_err!(tcx.sess, impl_item.span, E0520,
876-
"item `{}` is provided by an implementation that \
877-
specializes another, but the item in the parent \
878-
implementations is not marked `default` and so it \
879-
cannot be specialized.",
880-
impl_item.name);
875+
let mut err = struct_span_err!(
876+
tcx.sess, impl_item.span, E0520,
877+
"item `{}` is provided by an implementation that \
878+
specializes another, but the item in the parent \
879+
implementations is not marked `default` and so it \
880+
cannot be specialized.",
881+
impl_item.name);
881882

882883
match tcx.span_of_impl(parent_impl) {
883884
Ok(span) => {
884-
span_note!(tcx.sess, span, "parent implementation is here:");
885+
err.span_note(span, "parent implementation is here:");
885886
}
886887
Err(cname) => {
887-
tcx.sess.note(&format!("parent implementation is in crate `{}`",
888-
cname));
888+
err.note(&format!("parent implementation is in crate `{}`", cname));
889889
}
890890
}
891+
892+
err.emit();
891893
}
892894
}
893895

src/librustc_typeck/coherence/overlap.rs

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ use syntax::ast;
2020
use rustc::dep_graph::DepNode;
2121
use rustc_front::hir;
2222
use rustc_front::intravisit;
23-
use util::nodemap::{DefIdMap, DefIdSet};
23+
use util::nodemap::DefIdMap;
2424

2525
pub fn check(tcx: &TyCtxt) {
2626
let mut overlap = OverlapChecker { tcx: tcx,
27-
traits_checked: DefIdSet(),
2827
default_impls: DefIdMap() };
2928

3029
// this secondary walk specifically checks for some other cases,
@@ -35,14 +34,6 @@ pub fn check(tcx: &TyCtxt) {
3534
struct OverlapChecker<'cx, 'tcx:'cx> {
3635
tcx: &'cx TyCtxt<'tcx>,
3736

38-
// The set of traits where we have checked for overlap. This is
39-
// used to avoid checking the same trait twice.
40-
//
41-
// NB. It's ok to skip tracking this set because we fully
42-
// encapsulate it, and we always create a task
43-
// (`CoherenceOverlapCheck`) corresponding to each entry.
44-
traits_checked: DefIdSet,
45-
4637
// maps from a trait def-id to an impl id
4738
default_impls: DefIdMap<ast::NodeId>,
4839
}
@@ -120,20 +111,19 @@ impl<'cx, 'tcx,'v> intravisit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
120111
let impl_def_id = self.tcx.map.local_def_id(item.id);
121112
let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap();
122113

123-
self.check_for_overlapping_impls_of_trait(trait_ref.def_id);
124-
125114
let prev_default_impl = self.default_impls.insert(trait_ref.def_id, item.id);
126115
if let Some(prev_id) = prev_default_impl {
127-
span_err!(self.tcx.sess,
128-
self.span_of_def_id(impl_def_id), E0519,
129-
"redundant default implementations of trait `{}`:",
130-
trait_ref);
131-
span_note!(self.tcx.sess,
132-
self.span_of_def_id(self.tcx.map.local_def_id(prev_id)),
133-
"redundant implementation is here:");
116+
let mut err = struct_span_err!(
117+
self.tcx.sess,
118+
self.tcx.span_of_impl(impl_def_id).unwrap(), E0519,
119+
"redundant default implementations of trait `{}`:",
120+
trait_ref);
121+
err.span_note(self.tcx.span_of_impl(self.tcx.map.local_def_id(prev_id)).unwrap(),
122+
"redundant implementation is here:");
123+
err.emit();
134124
}
135125
}
136-
hir::ItemImpl(_, _, _, Some(_), ref self_ty, _) => {
126+
hir::ItemImpl(_, _, _, Some(_), _, _) => {
137127
let impl_def_id = self.tcx.map.local_def_id(item.id);
138128
let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap();
139129
let trait_def_id = trait_ref.def_id;
@@ -162,20 +152,22 @@ impl<'cx, 'tcx,'v> intravisit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
162152
}).unwrap_or(String::new())
163153
};
164154

165-
span_err!(self.tcx.sess, self.span_of_def_id(impl_def_id), E0119,
166-
"conflicting implementations of trait `{}`{}:",
167-
overlap.on_trait_ref,
168-
self_type);
155+
let mut err = struct_span_err!(
156+
self.tcx.sess, self.tcx.span_of_impl(impl_def_id).unwrap(), E0119,
157+
"conflicting implementations of trait `{}`{}:",
158+
overlap.on_trait_ref,
159+
self_type);
169160

170161
match self.tcx.span_of_impl(overlap.with_impl) {
171162
Ok(span) => {
172-
span_note!(self.tcx.sess, span, "conflicting implementation is here:");
163+
err.span_note(span, "conflicting implementation is here:");
173164
}
174165
Err(cname) => {
175-
self.tcx.sess.note(&format!("conflicting implementation in crate `{}`",
176-
cname));
166+
err.note(&format!("conflicting implementation in crate `{}`", cname));
177167
}
178168
}
169+
170+
err.emit();
179171
}
180172

181173
// check for overlap with the automatic `impl Trait for Trait`

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ use middle::resolve_lifetime;
6969
use middle::const_eval::{self, ConstVal};
7070
use middle::const_eval::EvalHint::UncheckedExprHint;
7171
use middle::subst::{Substs, FnSpace, ParamSpace, SelfSpace, TypeSpace, VecPerParamSpace};
72-
use middle::traits;
7372
use middle::ty::{ToPredicate, ImplContainer, ImplOrTraitItemContainer, TraitContainer};
7473
use middle::ty::{self, ToPolyTraitRef, Ty, TyCtxt, TypeScheme};
7574
use middle::ty::{VariantKind};
@@ -871,7 +870,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
871870
trait_item.id,
872871
hir::Inherited,
873872
sig,
874-
hir::Defaultness::Default
873+
hir::Defaultness::Default,
875874
tcx.mk_self_type(),
876875
&trait_def.generics,
877876
&trait_predicates);

src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -654,12 +654,12 @@ impl<'a> Parser<'a> {
654654
}
655655
}
656656

657-
pub fn eat_contextual_keyword(&mut self, ident: Ident) -> PResult<bool> {
657+
pub fn eat_contextual_keyword(&mut self, ident: Ident) -> bool {
658658
if self.check_contextual_keyword(ident) {
659-
try!(self.bump());
660-
Ok(true)
659+
self.bump();
660+
true
661661
} else {
662-
Ok(false)
662+
false
663663
}
664664
}
665665

@@ -5229,8 +5229,8 @@ impl<'a> Parser<'a> {
52295229
}
52305230

52315231
/// Parse defaultness: DEFAULT or nothing
5232-
fn parse_defaultness(&mut self) -> PResult<Defaultness> {
5233-
if try!(self.eat_contextual_keyword(special_idents::DEFAULT)) {
5232+
fn parse_defaultness(&mut self) -> PResult<'a, Defaultness> {
5233+
if self.eat_contextual_keyword(special_idents::DEFAULT) {
52345234
Ok(Defaultness::Default)
52355235
} else {
52365236
Ok(Defaultness::Final)

src/test/compile-fail/coherence-projection-conflict-orphan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pub trait Bar {
2121
type Output: 'static;
2222
}
2323

24-
impl Foo<i32> for i32 { } //~ ERROR E0119
24+
impl Foo<i32> for i32 { }
2525

26-
impl<A:Iterator> Foo<A::Item> for A { }
26+
impl<A:Iterator> Foo<A::Item> for A { } //~ ERROR E0119
2727

2828
fn main() {}

0 commit comments

Comments
 (0)