Skip to content

Commit fb53b79

Browse files
committed
---
yaml --- r: 233829 b: refs/heads/beta c: 2f74925 h: refs/heads/master i: 233827: 02f9b19 v: v3
1 parent 7403d18 commit fb53b79

File tree

21 files changed

+195
-130
lines changed

21 files changed

+195
-130
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 8ae2b1d7dd9e25b09439d6494a3a9d2540c08dbf
26+
refs/heads/beta: 2f749254cafd4940243548730afc02c5410611bf
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc/diagnostics.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,26 @@ fn main() {
14871487
```
14881488
"##,
14891489

1490+
E0281: r##"
1491+
You tried to supply a type which doesn't implement some trait in a location
1492+
which expected that trait. This error typically occurs when working with
1493+
`Fn`-based types. Erroneous code example:
1494+
1495+
```
1496+
fn foo<F: Fn()>(x: F) { }
1497+
1498+
fn main() {
1499+
// type mismatch: the type ... implements the trait `core::ops::Fn<(_,)>`,
1500+
// but the trait `core::ops::Fn<()>` is required (expected (), found tuple
1501+
// [E0281]
1502+
foo(|y| { });
1503+
}
1504+
```
1505+
1506+
The issue in this case is that `foo` is defined as accepting a `Fn` with no
1507+
arguments, but the closure we attempted to pass to it requires one argument.
1508+
"##,
1509+
14901510
E0282: r##"
14911511
This error indicates that type inference did not result in one unique possible
14921512
type, and extra information is required. In most cases this can be provided
@@ -1867,7 +1887,6 @@ register_diagnostics! {
18671887
E0278, // requirement is not satisfied
18681888
E0279, // requirement is not satisfied
18691889
E0280, // requirement is not satisfied
1870-
E0281, // type implements trait but other trait is required
18711890
E0283, // cannot resolve type
18721891
E0284, // cannot resolve type
18731892
E0285, // overflow evaluation builtin bounds

branches/beta/src/librustc/plugin/registry.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,6 @@ impl<'a> Registry<'a> {
145145
/// `Whitelisted` attributes will additionally not trigger the `unused_attribute`
146146
/// lint. `CrateLevel` attributes will not be allowed on anything other than a crate.
147147
pub fn register_attribute(&mut self, name: String, ty: AttributeType) {
148-
if let AttributeType::Gated(..) = ty {
149-
self.sess.span_err(self.krate_span, "plugin tried to register a gated \
150-
attribute. Only `Normal`, `Whitelisted`, \
151-
and `CrateLevel` attributes are allowed");
152-
}
153148
self.attributes.push((name, ty));
154149
}
155150
}

branches/beta/src/librustc_lint/builtin.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,10 +887,9 @@ impl LintPass for UnusedAttributes {
887887

888888
fn check_attribute(&mut self, cx: &Context, attr: &ast::Attribute) {
889889
// Note that check_name() marks the attribute as used if it matches.
890-
for &(ref name, ty) in KNOWN_ATTRIBUTES {
890+
for &(ref name, ty, _) in KNOWN_ATTRIBUTES {
891891
match ty {
892-
AttributeType::Whitelisted
893-
| AttributeType::Gated(_, _) if attr.check_name(name) => {
892+
AttributeType::Whitelisted if attr.check_name(name) => {
894893
break;
895894
},
896895
_ => ()
@@ -907,8 +906,11 @@ impl LintPass for UnusedAttributes {
907906
if !attr::is_used(attr) {
908907
cx.span_lint(UNUSED_ATTRIBUTES, attr.span, "unused attribute");
909908
// Is it a builtin attribute that must be used at the crate level?
910-
let known_crate = KNOWN_ATTRIBUTES.contains(&(&attr.name(),
911-
AttributeType::CrateLevel));
909+
let known_crate = KNOWN_ATTRIBUTES.iter().find(|&&(name, ty, _)| {
910+
attr.name() == name &&
911+
ty == AttributeType::CrateLevel
912+
}).is_some();
913+
912914
// Has a plugin registered this attribute as one which must be used at
913915
// the crate level?
914916
let plugin_crate = plugin_attributes.iter()

branches/beta/src/libsyntax/ext/deriving/bounds.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub fn expand_deriving_copy(cx: &mut ExtCtxt,
4040
path: path,
4141
additional_bounds: Vec::new(),
4242
generics: LifetimeBounds::empty(),
43+
is_unsafe: false,
4344
methods: Vec::new(),
4445
associated_types: Vec::new(),
4546
};

branches/beta/src/libsyntax/ext/deriving/clone.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
3131
path: path_std!(cx, core::clone::Clone),
3232
additional_bounds: Vec::new(),
3333
generics: LifetimeBounds::empty(),
34+
is_unsafe: false,
3435
methods: vec!(
3536
MethodDef {
3637
name: "clone",

branches/beta/src/libsyntax/ext/deriving/cmp/eq.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
5151
path: path_std!(cx, core::cmp::Eq),
5252
additional_bounds: Vec::new(),
5353
generics: LifetimeBounds::empty(),
54+
is_unsafe: false,
5455
methods: vec!(
5556
MethodDef {
5657
name: "assert_receiver_is_total_eq",

branches/beta/src/libsyntax/ext/deriving/cmp/ord.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
3232
path: path_std!(cx, core::cmp::Ord),
3333
additional_bounds: Vec::new(),
3434
generics: LifetimeBounds::empty(),
35+
is_unsafe: false,
3536
methods: vec!(
3637
MethodDef {
3738
name: "cmp",

branches/beta/src/libsyntax/ext/deriving/cmp/partial_eq.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
8585
path: path_std!(cx, core::cmp::PartialEq),
8686
additional_bounds: Vec::new(),
8787
generics: LifetimeBounds::empty(),
88+
is_unsafe: false,
8889
methods: vec!(
8990
md!("eq", cs_eq),
9091
md!("ne", cs_ne)

branches/beta/src/libsyntax/ext/deriving/cmp/partial_ord.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt,
7373
path: path_std!(cx, core::cmp::PartialOrd),
7474
additional_bounds: vec![],
7575
generics: LifetimeBounds::empty(),
76+
is_unsafe: false,
7677
methods: vec![
7778
partial_cmp_def,
7879
md!("lt", true, false),

branches/beta/src/libsyntax/ext/deriving/decodable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt,
5959
path: Path::new_(vec!(krate, "Decodable"), None, vec!(), true),
6060
additional_bounds: Vec::new(),
6161
generics: LifetimeBounds::empty(),
62+
is_unsafe: false,
6263
methods: vec!(
6364
MethodDef {
6465
name: "decode",

branches/beta/src/libsyntax/ext/deriving/default.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt,
3131
path: path_std!(cx, core::default::Default),
3232
additional_bounds: Vec::new(),
3333
generics: LifetimeBounds::empty(),
34+
is_unsafe: false,
3435
methods: vec!(
3536
MethodDef {
3637
name: "default",

branches/beta/src/libsyntax/ext/deriving/encodable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt,
135135
path: Path::new_(vec!(krate, "Encodable"), None, vec!(), true),
136136
additional_bounds: Vec::new(),
137137
generics: LifetimeBounds::empty(),
138+
is_unsafe: false,
138139
methods: vec!(
139140
MethodDef {
140141
name: "encode",

branches/beta/src/libsyntax/ext/deriving/generic/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ pub struct TraitDef<'a> {
229229
/// Any extra lifetimes and/or bounds, e.g. `D: serialize::Decoder`
230230
pub generics: LifetimeBounds<'a>,
231231

232+
/// Is it an `unsafe` trait?
233+
pub is_unsafe: bool,
234+
232235
pub methods: Vec<MethodDef<'a>>,
233236

234237
pub associated_types: Vec<(ast::Ident, Ty<'a>)>,
@@ -625,11 +628,18 @@ impl<'a> TraitDef<'a> {
625628
InternedString::new("unused_qualifications"))]));
626629
let mut a = vec![attr, unused_qual];
627630
a.extend(self.attributes.iter().cloned());
631+
632+
let unsafety = if self.is_unsafe {
633+
ast::Unsafety::Unsafe
634+
} else {
635+
ast::Unsafety::Normal
636+
};
637+
628638
cx.item(
629639
self.span,
630640
ident,
631641
a,
632-
ast::ItemImpl(ast::Unsafety::Normal,
642+
ast::ItemImpl(unsafety,
633643
ast::ImplPolarity::Positive,
634644
trait_generics,
635645
opt_trait_ref,

branches/beta/src/libsyntax/ext/deriving/hash.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt,
3232
path: path,
3333
additional_bounds: Vec::new(),
3434
generics: LifetimeBounds::empty(),
35+
is_unsafe: false,
3536
methods: vec!(
3637
MethodDef {
3738
name: "hash",

branches/beta/src/libsyntax/ext/deriving/primitive.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
3232
path: path_std!(cx, core::num::FromPrimitive),
3333
additional_bounds: Vec::new(),
3434
generics: LifetimeBounds::empty(),
35+
is_unsafe: false,
3536
methods: vec!(
3637
MethodDef {
3738
name: "from_i64",

branches/beta/src/libsyntax/ext/deriving/show.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub fn expand_deriving_show(cx: &mut ExtCtxt,
3434
path: path_std!(cx, core::fmt::Debug),
3535
additional_bounds: Vec::new(),
3636
generics: LifetimeBounds::empty(),
37+
is_unsafe: false,
3738
methods: vec![
3839
MethodDef {
3940
name: "fmt",

0 commit comments

Comments
 (0)