Skip to content

Commit 723bf51

Browse files
committed
---
yaml --- r: 152766 b: refs/heads/try2 c: 5466d13 h: refs/heads/master v: v3
1 parent d09f05a commit 723bf51

40 files changed

+1104
-1371
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: e8c12d32a2e989d02d26a80f91d2c49a8bc1aaad
8+
refs/heads/try2: 5466d13d4320252f57d276c566dbee44617b63b2
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/liballoc/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
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)]
73+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
7374

7475
#[phase(plugin, link)]
7576
extern crate core;

branches/try2/src/libcore/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +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)]
61+
#![allow(unknown_features)] // NOTE: remove after stage0 snapshot
6062

6163
#[cfg(test)] extern crate realcore = "core";
6264
#[cfg(test)] extern crate libc;

branches/try2/src/libnative/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555

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

5961
// NB this crate explicitly does *not* allow glob imports, please seriously
6062
// consider whether they're needed before adding that feature here (the

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/middle/ty.rs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -850,23 +850,17 @@ impl CLike for BuiltinBound {
850850
}
851851

852852
#[deriving(Clone, PartialEq, Eq, Hash)]
853-
pub struct TyVid {
854-
pub index: uint
855-
}
853+
pub struct TyVid(pub uint);
856854

857855
#[deriving(Clone, PartialEq, Eq, Hash)]
858-
pub struct IntVid {
859-
pub index: uint
860-
}
856+
pub struct IntVid(pub uint);
861857

862858
#[deriving(Clone, PartialEq, Eq, Hash)]
863-
pub struct FloatVid {
864-
pub index: uint
865-
}
859+
pub struct FloatVid(pub uint);
866860

867861
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
868862
pub struct RegionVid {
869-
pub index: uint
863+
pub id: uint
870864
}
871865

872866
#[deriving(Clone, PartialEq, Eq, Hash)]
@@ -899,27 +893,47 @@ impl cmp::PartialEq for InferRegion {
899893
}
900894
}
901895

896+
pub trait Vid {
897+
fn to_uint(&self) -> uint;
898+
}
899+
900+
impl Vid for TyVid {
901+
fn to_uint(&self) -> uint { let TyVid(v) = *self; v }
902+
}
903+
902904
impl fmt::Show for TyVid {
903905
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result{
904-
write!(f, "<generic #{}>", self.index)
906+
write!(f, "<generic #{}>", self.to_uint())
905907
}
906908
}
907909

910+
impl Vid for IntVid {
911+
fn to_uint(&self) -> uint { let IntVid(v) = *self; v }
912+
}
913+
908914
impl fmt::Show for IntVid {
909915
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
910-
write!(f, "<generic integer #{}>", self.index)
916+
write!(f, "<generic integer #{}>", self.to_uint())
911917
}
912918
}
913919

920+
impl Vid for FloatVid {
921+
fn to_uint(&self) -> uint { let FloatVid(v) = *self; v }
922+
}
923+
914924
impl fmt::Show for FloatVid {
915925
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
916-
write!(f, "<generic float #{}>", self.index)
926+
write!(f, "<generic float #{}>", self.to_uint())
917927
}
918928
}
919929

930+
impl Vid for RegionVid {
931+
fn to_uint(&self) -> uint { self.id }
932+
}
933+
920934
impl fmt::Show for RegionVid {
921935
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
922-
write!(f, "'<generic lifetime #{}>", self.index)
936+
self.id.fmt(f)
923937
}
924938
}
925939

branches/try2/src/librustc/middle/typeck/coherence.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,7 @@ impl<'a> CoherenceChecker<'a> {
519519
fn can_unify_universally_quantified<'a>(&self,
520520
a: &'a UniversalQuantificationResult,
521521
b: &'a UniversalQuantificationResult)
522-
-> bool
523-
{
522+
-> bool {
524523
infer::can_mk_subty(&self.inference_context,
525524
a.monotype,
526525
b.monotype).is_ok()

branches/try2/src/librustc/middle/typeck/infer/coercion.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ use middle::ty;
7171
use middle::typeck::infer::{CoerceResult, resolve_type, Coercion};
7272
use middle::typeck::infer::combine::{CombineFields, Combine};
7373
use middle::typeck::infer::sub::Sub;
74+
use middle::typeck::infer::to_str::InferStr;
7475
use middle::typeck::infer::resolve::try_resolve_tvar_shallow;
7576
use util::common::indenter;
76-
use util::ppaux::Repr;
7777

7878
use syntax::abi;
7979
use syntax::ast::MutImmutable;
@@ -91,8 +91,8 @@ impl<'f> Coerce<'f> {
9191

9292
pub fn tys(&self, a: ty::t, b: ty::t) -> CoerceResult {
9393
debug!("Coerce.tys({} => {})",
94-
a.repr(self.get_ref().infcx.tcx),
95-
b.repr(self.get_ref().infcx.tcx));
94+
a.inf_str(self.get_ref().infcx),
95+
b.inf_str(self.get_ref().infcx));
9696
let _indent = indenter();
9797

9898
// Examine the supertype and consider auto-borrowing.
@@ -233,8 +233,8 @@ impl<'f> Coerce<'f> {
233233
mt_b: ty::mt)
234234
-> CoerceResult {
235235
debug!("coerce_borrowed_pointer(a={}, sty_a={:?}, b={}, mt_b={:?})",
236-
a.repr(self.get_ref().infcx.tcx), sty_a,
237-
b.repr(self.get_ref().infcx.tcx), mt_b);
236+
a.inf_str(self.get_ref().infcx), sty_a,
237+
b.inf_str(self.get_ref().infcx), mt_b);
238238

239239
// If we have a parameter of type `&M T_a` and the value
240240
// provided is `expr`, we will be adding an implicit borrow,
@@ -270,8 +270,8 @@ impl<'f> Coerce<'f> {
270270
b: ty::t)
271271
-> CoerceResult {
272272
debug!("coerce_borrowed_string(a={}, sty_a={:?}, b={})",
273-
a.repr(self.get_ref().infcx.tcx), sty_a,
274-
b.repr(self.get_ref().infcx.tcx));
273+
a.inf_str(self.get_ref().infcx), sty_a,
274+
b.inf_str(self.get_ref().infcx));
275275

276276
match *sty_a {
277277
ty::ty_uniq(t) => match ty::get(t).sty {
@@ -300,8 +300,8 @@ impl<'f> Coerce<'f> {
300300
mutbl_b: ast::Mutability)
301301
-> CoerceResult {
302302
debug!("coerce_borrowed_vector(a={}, sty_a={:?}, b={})",
303-
a.repr(self.get_ref().infcx.tcx), sty_a,
304-
b.repr(self.get_ref().infcx.tcx));
303+
a.inf_str(self.get_ref().infcx), sty_a,
304+
b.inf_str(self.get_ref().infcx));
305305

306306
let sub = Sub(self.get_ref().clone());
307307
let coercion = Coercion(self.get_ref().trace.clone());
@@ -336,8 +336,8 @@ impl<'f> Coerce<'f> {
336336
b_mutbl: ast::Mutability) -> CoerceResult
337337
{
338338
debug!("coerce_borrowed_object(a={}, sty_a={:?}, b={})",
339-
a.repr(self.get_ref().infcx.tcx), sty_a,
340-
b.repr(self.get_ref().infcx.tcx));
339+
a.inf_str(self.get_ref().infcx), sty_a,
340+
b.inf_str(self.get_ref().infcx));
341341

342342
let tcx = self.get_ref().infcx.tcx;
343343
let coercion = Coercion(self.get_ref().trace.clone());
@@ -376,8 +376,8 @@ impl<'f> Coerce<'f> {
376376
b: ty::t)
377377
-> CoerceResult {
378378
debug!("coerce_borrowed_fn(a={}, sty_a={:?}, b={})",
379-
a.repr(self.get_ref().infcx.tcx), sty_a,
380-
b.repr(self.get_ref().infcx.tcx));
379+
a.inf_str(self.get_ref().infcx), sty_a,
380+
b.inf_str(self.get_ref().infcx));
381381

382382
match *sty_a {
383383
ty::ty_bare_fn(ref f) => {
@@ -400,7 +400,7 @@ impl<'f> Coerce<'f> {
400400
self.unpack_actual_value(b, |sty_b| {
401401

402402
debug!("coerce_from_bare_fn(a={}, b={})",
403-
a.repr(self.get_ref().infcx.tcx), b.repr(self.get_ref().infcx.tcx));
403+
a.inf_str(self.get_ref().infcx), b.inf_str(self.get_ref().infcx));
404404

405405
if fn_ty_a.abi != abi::Rust || fn_ty_a.fn_style != ast::NormalFn {
406406
return self.subtype(a, b);
@@ -429,8 +429,8 @@ impl<'f> Coerce<'f> {
429429
mt_b: ty::mt)
430430
-> CoerceResult {
431431
debug!("coerce_unsafe_ptr(a={}, sty_a={:?}, b={})",
432-
a.repr(self.get_ref().infcx.tcx), sty_a,
433-
b.repr(self.get_ref().infcx.tcx));
432+
a.inf_str(self.get_ref().infcx), sty_a,
433+
b.inf_str(self.get_ref().infcx));
434434

435435
let mt_a = match *sty_a {
436436
ty::ty_rptr(_, mt) => mt,
@@ -462,8 +462,8 @@ impl<'f> Coerce<'f> {
462462
bounds: ty::BuiltinBounds) -> CoerceResult {
463463

464464
debug!("coerce_object(a={}, sty_a={:?}, b={})",
465-
a.repr(self.get_ref().infcx.tcx), sty_a,
466-
b.repr(self.get_ref().infcx.tcx));
465+
a.inf_str(self.get_ref().infcx), sty_a,
466+
b.inf_str(self.get_ref().infcx));
467467

468468
Ok(Some(ty::AutoObject(trait_store, bounds,
469469
trait_def_id, trait_substs.clone())))

0 commit comments

Comments
 (0)