Skip to content

Commit 5b47e80

Browse files
committed
---
yaml --- r: 232830 b: refs/heads/try c: 2f74925 h: refs/heads/master v: v3
1 parent 9b476cd commit 5b47e80

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 8ae2b1d7dd9e25b09439d6494a3a9d2540c08dbf
4+
refs/heads/try: 2f749254cafd4940243548730afc02c5410611bf
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/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/try/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/try/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/try/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/try/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/try/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/try/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/try/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/try/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/try/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/try/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/try/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/try/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/try/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/try/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/try/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)