Skip to content

Commit 8b69e4a

Browse files
Ariel Ben-Yehudaarielb1
authored andcommitted
---
yaml --- r: 236500 b: refs/heads/auto c: 346088b h: refs/heads/master v: v3
1 parent cd7b459 commit 8b69e4a

File tree

5 files changed

+46
-4
lines changed

5 files changed

+46
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: fe6ad097c654d2655ad11610b2c96d577a3fcc2b
11+
refs/heads/auto: 346088b555b5dd7ec2a156d82c5362632f9b8972
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc/middle/traits/error_reporting.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ use middle::def_id::DefId;
2828
use middle::infer::InferCtxt;
2929
use middle::ty::{self, ToPredicate, HasTypeFlags, ToPolyTraitRef, TraitRef, Ty};
3030
use middle::ty::fold::TypeFoldable;
31-
use std::collections::HashMap;
31+
use util::nodemap::{FnvHashMap, FnvHashSet};
32+
3233
use std::fmt;
3334
use syntax::codemap::Span;
3435
use syntax::attr::{AttributeMethods, AttrMetaMethods};
@@ -124,7 +125,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
124125
(gen.name.as_str().to_string(),
125126
trait_ref.substs.types.get(param, i)
126127
.to_string())
127-
}).collect::<HashMap<String, String>>();
128+
}).collect::<FnvHashMap<String, String>>();
128129
generic_map.insert("Self".to_string(),
129130
trait_ref.self_ty().to_string());
130131
let parser = Parser::new(&istring);
@@ -335,7 +336,11 @@ pub fn report_object_safety_error<'tcx>(tcx: &ty::ctxt<'tcx>,
335336
"the trait `{}` cannot be made into an object",
336337
tcx.item_path_str(trait_def_id));
337338

339+
let mut reported_violations = FnvHashSet();
338340
for violation in violations {
341+
if !reported_violations.insert(violation.clone()) {
342+
continue;
343+
}
339344
match violation {
340345
ObjectSafetyViolation::SizedSelf => {
341346
tcx.sess.fileline_note(

branches/auto/src/librustc/middle/traits/object_safety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use middle::ty::{self, ToPolyTraitRef, Ty};
2727
use std::rc::Rc;
2828
use syntax::ast;
2929

30-
#[derive(Debug)]
30+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
3131
pub enum ObjectSafetyViolation<'tcx> {
3232
/// Self : Sized declared on the trait
3333
SizedSelf,

branches/auto/src/librustc/middle/ty/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,20 @@ impl<'tcx> Method<'tcx> {
272272
}
273273
}
274274

275+
impl<'tcx> PartialEq for Method<'tcx> {
276+
#[inline]
277+
fn eq(&self, other: &Self) -> bool { self.def_id == other.def_id }
278+
}
279+
280+
impl<'tcx> Eq for Method<'tcx> {}
281+
282+
impl<'tcx> Hash for Method<'tcx> {
283+
#[inline]
284+
fn hash<H: Hasher>(&self, s: &mut H) {
285+
self.def_id.hash(s)
286+
}
287+
}
288+
275289
#[derive(Clone, Copy, Debug)]
276290
pub struct AssociatedConst<'tcx> {
277291
pub name: Name,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Array: Sized {}
12+
13+
fn f<T: Array>(x: &T) {
14+
let _ = x
15+
//~^ ERROR `Array` cannot be made into an object
16+
//~| NOTE the trait cannot require that `Self : Sized`
17+
as
18+
&Array;
19+
//~^ ERROR `Array` cannot be made into an object
20+
//~| NOTE the trait cannot require that `Self : Sized`
21+
}
22+
23+
fn main() {}

0 commit comments

Comments
 (0)