Skip to content

Commit 948969e

Browse files
committed
---
yaml --- r: 152771 b: refs/heads/try2 c: 71fe44d h: refs/heads/master i: 152769: b125603 152767: 99960f1 v: v3
1 parent 1d9291d commit 948969e

File tree

84 files changed

+1728
-1119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1728
-1119
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 7be2019428ff888ea26075a065fa3cebb66c5ead
8+
refs/heads/try2: 71fe44def9676d519f5ce5d7304e581a42cf2c70
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/guide-unsafe.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ in the same format as a C:
451451

452452
```
453453
#![no_std]
454+
#![feature(lang_items)]
454455
455456
// Pull in the system libc library for what crt0.o likely requires
456457
extern crate libc;
@@ -477,6 +478,7 @@ compiler's name mangling too:
477478
```ignore
478479
#![no_std]
479480
#![no_main]
481+
#![feature(lang_items)]
480482
481483
extern crate libc;
482484
@@ -528,6 +530,7 @@ vectors provided from C, using idiomatic Rust practices.
528530
```
529531
#![no_std]
530532
#![feature(globs)]
533+
#![feature(lang_items)]
531534
532535
# extern crate libc;
533536
extern crate core;
@@ -619,6 +622,9 @@ perform efficient pointer arithmetic, one would import those functions
619622
via a declaration like
620623

621624
```
625+
# #![feature(intrinsics)]
626+
# fn main() {}
627+
622628
extern "rust-intrinsic" {
623629
fn transmute<T, U>(x: T) -> U;
624630
@@ -647,6 +653,7 @@ sugar for dynamic allocations via `malloc` and `free`:
647653

648654
```
649655
#![no_std]
656+
#![feature(lang_items)]
650657
651658
extern crate libc;
652659

branches/try2/src/doc/rust.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ block_comment_body : [block_comment | character] * ;
160160
line_comment : "//" non_eol * ;
161161
~~~~
162162

163-
Comments in Rust code follow the general C++ style of line and block-comment forms.
163+
Comments in Rust code follow the general C++ style of line and block-comment forms.
164164
Nested block comments are supported.
165165

166166
Line comments beginning with exactly _three_ slashes (`///`), and block
@@ -3004,7 +3004,7 @@ ten_times(|j| println!("hello, {}", j));
30043004
### While loops
30053005

30063006
~~~~ {.ebnf .gram}
3007-
while_expr : "while" expr '{' block '}' ;
3007+
while_expr : "while" no_struct_literal_expr '{' block '}' ;
30083008
~~~~
30093009

30103010
A `while` loop begins by evaluating the boolean loop conditional expression.
@@ -3071,7 +3071,7 @@ A `continue` expression is only permitted in the body of a loop.
30713071
### For expressions
30723072

30733073
~~~~ {.ebnf .gram}
3074-
for_expr : "for" pat "in" expr '{' block '}' ;
3074+
for_expr : "for" pat "in" no_struct_literal_expr '{' block '}' ;
30753075
~~~~
30763076

30773077
A `for` expression is a syntactic construct for looping over elements
@@ -3105,7 +3105,7 @@ for i in range(0u, 256) {
31053105
### If expressions
31063106

31073107
~~~~ {.ebnf .gram}
3108-
if_expr : "if" expr '{' block '}'
3108+
if_expr : "if" no_struct_literal_expr '{' block '}'
31093109
else_tail ? ;
31103110
31113111
else_tail : "else" [ if_expr
@@ -3126,7 +3126,7 @@ then any `else` block is executed.
31263126
### Match expressions
31273127

31283128
~~~~ {.ebnf .gram}
3129-
match_expr : "match" expr '{' match_arm * '}' ;
3129+
match_expr : "match" no_struct_literal_expr '{' match_arm * '}' ;
31303130
31313131
match_arm : attribute * match_pat "=>" [ expr "," | '{' block '}' ] ;
31323132
@@ -3563,10 +3563,11 @@ There are four varieties of pointer in Rust:
35633563

35643564
* Raw pointers (`*`)
35653565
: Raw pointers are pointers without safety or liveness guarantees.
3566-
Raw pointers are written `*content`,
3567-
for example `*int` means a raw pointer to an integer.
3568-
Copying or dropping a raw pointer has no effect on the lifecycle of any other value.
3569-
Dereferencing a raw pointer or converting it to any other pointer type is an [`unsafe` operation](#unsafe-functions).
3566+
Raw pointers are written as `*const T` or `*mut T`,
3567+
for example `*const int` means a raw pointer to an integer.
3568+
Copying or dropping a raw pointer has no effect on the lifecycle of any
3569+
other value. Dereferencing a raw pointer or converting it to any other
3570+
pointer type is an [`unsafe` operation](#unsafe-functions).
35703571
Raw pointers are generally discouraged in Rust code;
35713572
they exist to support interoperability with foreign code,
35723573
and writing performance-critical or low-level functions.

branches/try2/src/doc/tutorial.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,7 +2522,7 @@ fn sendable_foo(f: Box<Foo + Send>) { /* ... */ }
25222522
fn shareable_bar<T: Share>(b: &Bar<T> + Share) { /* ... */ }
25232523
~~~
25242524

2525-
When no colon is specified (such as the type `~Foo`), it is inferred that the
2525+
When no colon is specified (such as the type `Box<Foo>`), it is inferred that the
25262526
value ascribes to no bounds. They must be added manually if any bounds are
25272527
necessary for usage.
25282528

@@ -2579,17 +2579,18 @@ fn radius_times_area<T: Circle>(c: T) -> f64 {
25792579

25802580
Likewise, supertrait methods may also be called on trait objects.
25812581

2582-
~~~ {.ignore}
2582+
~~~
25832583
use std::f64::consts::PI;
25842584
# trait Shape { fn area(&self) -> f64; }
25852585
# trait Circle : Shape { fn radius(&self) -> f64; }
25862586
# struct Point { x: f64, y: f64 }
25872587
# struct CircleStruct { center: Point, radius: f64 }
25882588
# impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / PI).sqrt() } }
25892589
# impl Shape for CircleStruct { fn area(&self) -> f64 { PI * square(self.radius) } }
2590+
# fn square(x: f64) -> f64 { x * x }
25902591
2591-
let concrete = ~CircleStruct{center:Point{x:3.0,y:4.0},radius:5.0};
2592-
let mycircle: ~Circle = concrete as ~Circle;
2592+
let concrete = box CircleStruct{center:Point{x:3.0,y:4.0},radius:5.0};
2593+
let mycircle: Box<Circle> = concrete as Box<Circle>;
25932594
let nonsense = mycircle.radius() * mycircle.area();
25942595
~~~
25952596

branches/try2/src/etc/2014-06-rewrite-bytes-macros.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/env python
1+
#!/usr/bin/env python
22
#
33
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
44
# file at the top-level directory of this distribution and at

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ syn keyword rustKeyword unsafe virtual while
3030
syn keyword rustKeyword use nextgroup=rustModPath skipwhite skipempty
3131
" FIXME: Scoped impl's name is also fallen in this category
3232
syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite skipempty
33-
syn keyword rustStorage mut ref static
34-
syn keyword rustObsoleteStorage const
33+
syn keyword rustStorage mut ref static const
3534

3635
syn keyword rustInvalidBareKeyword crate
3736

branches/try2/src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
html_root_url = "http://doc.rust-lang.org/")]
7070

7171
#![no_std]
72-
#![feature(phase, unsafe_destructor)]
72+
#![feature(lang_items, phase, unsafe_destructor)]
7373
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
7474

7575
#[phase(plugin, link)]

branches/try2/src/libarena/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
#![feature(unsafe_destructor)]
3232
#![allow(missing_doc)]
33-
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
3433

3534
use std::cell::{Cell, RefCell};
3635
use std::cmp;

branches/try2/src/libcollections/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#![feature(macro_rules, managed_boxes, default_type_params, phase, globs)]
2525
#![feature(unsafe_destructor)]
2626
#![no_std]
27-
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
2827

2928
#[phase(plugin, link)] extern crate core;
3029
extern crate alloc;

branches/try2/src/libcore/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@
5555
html_playground_url = "http://play.rust-lang.org/")]
5656

5757
#![no_std]
58-
#![feature(globs, macro_rules, managed_boxes, phase, simd, unsafe_destructor)]
58+
#![feature(globs, intrinsics, lang_items, macro_rules, managed_boxes, phase)]
59+
#![feature(simd, unsafe_destructor)]
5960
#![deny(missing_doc)]
60-
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
61+
#![allow(unknown_features)] // NOTE: remove after stage0 snapshot
6162

6263
#[cfg(test)] extern crate realcore = "core";
6364
#[cfg(test)] extern crate libc;

branches/try2/src/libnative/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,14 @@
5454
html_root_url = "http://doc.rust-lang.org/")]
5555

5656
#![deny(unused_result, unused_must_use)]
57-
#![allow(non_camel_case_types)]
58-
#![allow(deprecated)]
57+
#![allow(non_camel_case_types, deprecated)]
5958
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
60-
#![feature(default_type_params)]
59+
#![feature(default_type_params, lang_items)]
6160

6261
// NB this crate explicitly does *not* allow glob imports, please seriously
6362
// consider whether they're needed before adding that feature here (the
6463
// answer is that you don't need them)
65-
#![feature(macro_rules, unsafe_destructor)]
64+
#![feature(macro_rules, unsafe_destructor, default_type_params)]
6665

6766
extern crate alloc;
6867
extern crate libc;

branches/try2/src/librlibc/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2727
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2828
html_root_url = "http://doc.rust-lang.org/")]
29+
#![feature(intrinsics)]
30+
#![allow(unknown_features)] // NOTE: remove after stage0 snapshot
2931

3032
#![no_std]
3133
#![experimental]

branches/try2/src/librustc/front/feature_gate.rs

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
2121
use middle::lint;
2222

23+
use syntax::abi::RustIntrinsic;
24+
use syntax::ast::NodeId;
2325
use syntax::ast;
2426
use syntax::attr;
2527
use syntax::attr::AttrMetaMethods;
@@ -51,6 +53,8 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
5153
("trace_macros", Active),
5254
("concat_idents", Active),
5355
("unsafe_destructor", Active),
56+
("intrinsics", Active),
57+
("lang_items", Active),
5458

5559
("simd", Active),
5660
("default_type_params", Active),
@@ -187,13 +191,18 @@ impl<'a> Visitor<()> for Context<'a> {
187191
}
188192
}
189193

190-
ast::ItemForeignMod(..) => {
194+
ast::ItemForeignMod(ref foreign_module) => {
191195
if attr::contains_name(i.attrs.as_slice(), "link_args") {
192196
self.gate_feature("link_args", i.span,
193197
"the `link_args` attribute is not portable \
194198
across platforms, it is recommended to \
195199
use `#[link(name = \"foo\")]` instead")
196200
}
201+
if foreign_module.abi == RustIntrinsic {
202+
self.gate_feature("intrinsics",
203+
i.span,
204+
"intrinsics are subject to change")
205+
}
197206
}
198207

199208
ast::ItemFn(..) => {
@@ -283,14 +292,10 @@ impl<'a> Visitor<()> for Context<'a> {
283292
}
284293

285294
fn visit_foreign_item(&mut self, i: &ast::ForeignItem, _: ()) {
286-
match i.node {
287-
ast::ForeignItemFn(..) | ast::ForeignItemStatic(..) => {
288-
if attr::contains_name(i.attrs.as_slice(), "linkage") {
289-
self.gate_feature("linkage", i.span,
290-
"the `linkage` attribute is experimental \
291-
and not portable across platforms")
292-
}
293-
}
295+
if attr::contains_name(i.attrs.as_slice(), "linkage") {
296+
self.gate_feature("linkage", i.span,
297+
"the `linkage` attribute is experimental \
298+
and not portable across platforms")
294299
}
295300
visit::walk_foreign_item(self, i, ())
296301
}
@@ -338,6 +343,32 @@ impl<'a> Visitor<()> for Context<'a> {
338343
}
339344
visit::walk_generics(self, generics, ());
340345
}
346+
347+
fn visit_attribute(&mut self, attr: &ast::Attribute, _: ()) {
348+
if attr::contains_name([*attr], "lang") {
349+
self.gate_feature("lang_items",
350+
attr.span,
351+
"language items are subject to change");
352+
}
353+
}
354+
355+
fn visit_fn(&mut self,
356+
fn_kind: &visit::FnKind,
357+
fn_decl: &ast::FnDecl,
358+
block: &ast::Block,
359+
span: Span,
360+
_: NodeId,
361+
(): ()) {
362+
match *fn_kind {
363+
visit::FkItemFn(_, _, _, ref abi) if *abi == RustIntrinsic => {
364+
self.gate_feature("intrinsics",
365+
span,
366+
"intrinsics are subject to change")
367+
}
368+
_ => {}
369+
}
370+
visit::walk_fn(self, fn_kind, fn_decl, block, span, ());
371+
}
341372
}
342373

343374
pub fn check_crate(sess: &Session, krate: &ast::Crate) {

branches/try2/src/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ This API is completely unstable and subject to change.
2929
html_root_url = "http://doc.rust-lang.org/")]
3030

3131
#![allow(deprecated)]
32-
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
3332
#![feature(macro_rules, globs, struct_variant, managed_boxes, quote)]
3433
#![feature(default_type_params, phase, unsafe_destructor)]
3534

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3894,8 +3894,31 @@ impl<'a> Resolver<'a> {
38943894
self.resolve_error(trait_reference.path.span, msg.as_slice());
38953895
}
38963896
Some(def) => {
3897-
debug!("(resolving trait) found trait def: {:?}", def);
3898-
self.record_def(trait_reference.ref_id, def);
3897+
match def {
3898+
(DefTrait(_), _) => {
3899+
debug!("(resolving trait) found trait def: {:?}", def);
3900+
self.record_def(trait_reference.ref_id, def);
3901+
}
3902+
(def, _) => {
3903+
self.resolve_error(trait_reference.path.span,
3904+
format!("`{}` is not a trait",
3905+
self.path_idents_to_str(
3906+
&trait_reference.path)));
3907+
3908+
// If it's a typedef, give a note
3909+
match def {
3910+
DefTy(_) => {
3911+
self.session.span_note(
3912+
trait_reference.path.span,
3913+
format!("`type` aliases cannot \
3914+
be used for traits")
3915+
.as_slice());
3916+
}
3917+
_ => {}
3918+
}
3919+
}
3920+
}
3921+
38993922
}
39003923
}
39013924
}
@@ -4021,6 +4044,9 @@ impl<'a> Resolver<'a> {
40214044

40224045
this.with_current_self_type(self_type, |this| {
40234046
for method in methods.iter() {
4047+
// If this is a trait impl, ensure the method exists in trait
4048+
this.check_trait_method(&**method);
4049+
40244050
// We also need a new scope for the method-specific type parameters.
40254051
this.resolve_method(MethodRibKind(id, Provided(method.id)),
40264052
&**method);
@@ -4030,6 +4056,21 @@ impl<'a> Resolver<'a> {
40304056
});
40314057
}
40324058

4059+
fn check_trait_method(&self, method: &Method) {
4060+
// If there is a TraitRef in scope for an impl, then the method must be in the trait.
4061+
for &(did, ref trait_ref) in self.current_trait_ref.iter() {
4062+
let method_name = method.ident.name;
4063+
4064+
if self.method_map.borrow().find(&(method_name, did)).is_none() {
4065+
let path_str = self.path_idents_to_str(&trait_ref.path);
4066+
self.resolve_error(method.span,
4067+
format!("method `{}` is not a member of trait `{}`",
4068+
token::get_name(method_name),
4069+
path_str).as_slice());
4070+
}
4071+
}
4072+
}
4073+
40334074
fn resolve_module(&mut self, module: &Mod, _span: Span,
40344075
_name: Ident, id: NodeId) {
40354076
// Write the implementations in scope into the module metadata.

0 commit comments

Comments
 (0)