Skip to content

Commit 136dd8a

Browse files
committed
---
yaml --- r: 191401 b: refs/heads/try c: 1e9bef9 h: refs/heads/master i: 191399: 1ccd5dc v: v3
1 parent 7a07de7 commit 136dd8a

Some content is hidden

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

57 files changed

+903
-660
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 809a554fca2d0ebc2ba50077016fe282a4064752
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: c64d671671aea2e44ee7fc6eb00ee75fc30ed7b9
5-
refs/heads/try: f9a7bc58f89b9b15eb1269f0c0d68baf5fc7e966
5+
refs/heads/try: 1e9bef916f471e43fcd18593f95374ac42acf99e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/libarena/lib.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ extern crate alloc;
4242

4343
use std::cell::{Cell, RefCell};
4444
use std::cmp;
45+
use std::intrinsics::{TyDesc, get_tydesc};
4546
use std::intrinsics;
46-
#[cfg(stage0)] // SNAP 270a677
47-
use std::intrinsics::{get_tydesc, TyDesc};
4847
use std::marker;
4948
use std::mem;
5049
#[cfg(stage0)]
@@ -187,27 +186,6 @@ fn un_bitpack_tydesc_ptr(p: usize) -> (*const TyDesc, bool) {
187186
((p & !1) as *const TyDesc, p & 1 == 1)
188187
}
189188

190-
// HACK(eddyb) TyDesc replacement using a trait object vtable.
191-
// This could be replaced in the future with a custom DST layout,
192-
// or `&'static (drop_glue, size, align)` created by a `const fn`.
193-
#[cfg(not(stage0))] // SNAP 270a677
194-
struct TyDesc {
195-
drop_glue: fn(*const i8),
196-
size: usize,
197-
align: usize
198-
}
199-
200-
#[cfg(not(stage0))] // SNAP 270a677
201-
unsafe fn get_tydesc<T>() -> *const TyDesc {
202-
use std::raw::TraitObject;
203-
204-
let ptr = &*(1 as *const T);
205-
206-
// Can use any trait that is implemented for all types.
207-
let obj = mem::transmute::<&marker::MarkerTrait, TraitObject>(ptr);
208-
obj.vtable as *const TyDesc
209-
}
210-
211189
impl<'longer_than_self> Arena<'longer_than_self> {
212190
fn chunk_size(&self) -> usize {
213191
self.copy_head.borrow().capacity()

branches/try/src/libcore/intrinsics.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@
4444

4545
use marker::Sized;
4646

47-
#[cfg(stage0)] // SNAP 270a677
4847
pub type GlueFn = extern "Rust" fn(*const i8);
4948

5049
#[lang="ty_desc"]
5150
#[derive(Copy)]
52-
#[cfg(stage0)] // SNAP 270a677
5351
pub struct TyDesc {
5452
// sizeof(T)
5553
pub size: usize,
@@ -199,13 +197,8 @@ extern "rust-intrinsic" {
199197
pub fn pref_align_of<T>() -> usize;
200198

201199
/// Get a static pointer to a type descriptor.
202-
#[cfg(stage0)] // SNAP 270a677
203200
pub fn get_tydesc<T: ?Sized>() -> *const TyDesc;
204201

205-
/// Gets a static string slice containing the name of a type.
206-
#[cfg(not(stage0))] // SNAP 270a677
207-
pub fn type_name<T: ?Sized>() -> &'static str;
208-
209202
/// Gets an identifier which is globally unique to the specified type. This
210203
/// function will return the same value for a type regardless of whichever
211204
/// crate it is invoked in.

branches/try/src/librustc/middle/astencode.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -993,14 +993,8 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
993993
})
994994
}
995995

996-
ty::AdjustUnsafeFnPointer => {
997-
this.emit_enum_variant("AdjustUnsafeFnPointer", 2, 0, |_| {
998-
Ok(())
999-
})
1000-
}
1001-
1002996
ty::AdjustDerefRef(ref auto_deref_ref) => {
1003-
this.emit_enum_variant("AdjustDerefRef", 3, 2, |this| {
997+
this.emit_enum_variant("AdjustDerefRef", 2, 2, |this| {
1004998
this.emit_enum_variant_arg(0,
1005999
|this| Ok(this.emit_auto_deref_ref(ecx, auto_deref_ref)))
10061000
})
@@ -1625,9 +1619,6 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
16251619
ty::AdjustReifyFnPointer(def_id)
16261620
}
16271621
2 => {
1628-
ty::AdjustUnsafeFnPointer
1629-
}
1630-
3 => {
16311622
let auto_deref_ref: ty::AutoDerefRef =
16321623
this.read_enum_variant_arg(0,
16331624
|this| Ok(this.read_auto_deref_ref(dcx))).unwrap();

branches/try/src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
790790
None => { }
791791
Some(adjustment) => {
792792
match *adjustment {
793-
ty::AdjustReifyFnPointer(..) |
794-
ty::AdjustUnsafeFnPointer(..) => {
793+
ty::AdjustReifyFnPointer(..) => {
795794
// Creating a closure/fn-pointer consumes the
796795
// input and stores it into the resulting
797796
// rvalue.

branches/try/src/librustc/middle/infer/bivariate.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ use middle::infer::{cres};
3333
use middle::infer::type_variable::{BiTo};
3434
use util::ppaux::{Repr};
3535

36+
use syntax::ast::{Unsafety};
37+
3638
pub struct Bivariate<'f, 'tcx: 'f> {
3739
fields: CombineFields<'f, 'tcx>
3840
}
@@ -72,6 +74,24 @@ impl<'f, 'tcx> Combine<'tcx> for Bivariate<'f, 'tcx> {
7274
Ok(a)
7375
}
7476

77+
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
78+
debug!("mts({} <: {})",
79+
a.repr(self.fields.infcx.tcx),
80+
b.repr(self.fields.infcx.tcx));
81+
82+
if a.mutbl != b.mutbl { return Err(ty::terr_mutability); }
83+
let t = try!(self.tys(a.ty, b.ty));
84+
Ok(ty::mt { mutbl: a.mutbl, ty: t })
85+
}
86+
87+
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
88+
if a != b {
89+
Err(ty::terr_unsafety_mismatch(expected_found(self, a, b)))
90+
} else {
91+
Ok(a)
92+
}
93+
}
94+
7595
fn builtin_bounds(&self,
7696
a: BuiltinBounds,
7797
b: BuiltinBounds)

branches/try/src/librustc/middle/infer/combine.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,7 @@ pub trait Combine<'tcx> : Sized {
7474
fn lub<'a>(&'a self) -> Lub<'a, 'tcx> { Lub(self.fields().clone()) }
7575
fn glb<'a>(&'a self) -> Glb<'a, 'tcx> { Glb(self.fields().clone()) }
7676

77-
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
78-
debug!("{}.mts({}, {})",
79-
self.tag(),
80-
a.repr(self.tcx()),
81-
b.repr(self.tcx()));
82-
83-
if a.mutbl != b.mutbl {
84-
Err(ty::terr_mutability)
85-
} else {
86-
let mutbl = a.mutbl;
87-
let variance = match mutbl {
88-
ast::MutImmutable => ty::Covariant,
89-
ast::MutMutable => ty::Invariant,
90-
};
91-
let ty = try!(self.tys_with_variance(variance, a.ty, b.ty));
92-
Ok(ty::mt {ty: ty, mutbl: mutbl})
93-
}
94-
}
77+
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>>;
9578

9679
fn tys_with_variance(&self, variance: ty::Variance, a: Ty<'tcx>, b: Ty<'tcx>)
9780
-> cres<'tcx, Ty<'tcx>>;
@@ -263,13 +246,7 @@ pub trait Combine<'tcx> : Sized {
263246
self.tys_with_variance(ty::Contravariant, a, b).and_then(|t| Ok(t))
264247
}
265248

266-
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
267-
if a != b {
268-
Err(ty::terr_unsafety_mismatch(expected_found(self, a, b)))
269-
} else {
270-
Ok(a)
271-
}
272-
}
249+
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety>;
273250

274251
fn abi(&self, a: abi::Abi, b: abi::Abi) -> cres<'tcx, abi::Abi> {
275252
if a == b {

branches/try/src/librustc/middle/infer/equate.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use middle::infer::{Subtype};
1616
use middle::infer::type_variable::{EqTo};
1717
use util::ppaux::{Repr};
1818

19+
use syntax::ast::Unsafety;
20+
1921
pub struct Equate<'f, 'tcx: 'f> {
2022
fields: CombineFields<'f, 'tcx>
2123
}
@@ -52,6 +54,24 @@ impl<'f, 'tcx> Combine<'tcx> for Equate<'f, 'tcx> {
5254
Ok(a)
5355
}
5456

57+
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
58+
debug!("mts({} <: {})",
59+
a.repr(self.fields.infcx.tcx),
60+
b.repr(self.fields.infcx.tcx));
61+
62+
if a.mutbl != b.mutbl { return Err(ty::terr_mutability); }
63+
let t = try!(self.tys(a.ty, b.ty));
64+
Ok(ty::mt { mutbl: a.mutbl, ty: t })
65+
}
66+
67+
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
68+
if a != b {
69+
Err(ty::terr_unsafety_mismatch(expected_found(self, a, b)))
70+
} else {
71+
Ok(a)
72+
}
73+
}
74+
5575
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
5676
debug!("{}.tys({}, {})", self.tag(),
5777
a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx));

branches/try/src/librustc/middle/infer/glb.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use super::{cres};
1515
use super::Subtype;
1616

1717
use middle::ty::{self, Ty};
18+
use syntax::ast::{MutImmutable, MutMutable, Unsafety};
19+
use util::ppaux::mt_to_string;
1820
use util::ppaux::Repr;
1921

2022
/// "Greatest lower bound" (common subtype)
@@ -53,6 +55,44 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> {
5355
}
5456
}
5557

58+
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
59+
let tcx = self.fields.infcx.tcx;
60+
61+
debug!("{}.mts({}, {})",
62+
self.tag(),
63+
mt_to_string(tcx, a),
64+
mt_to_string(tcx, b));
65+
66+
match (a.mutbl, b.mutbl) {
67+
// If one side or both is mut, then the GLB must use
68+
// the precise type from the mut side.
69+
(MutMutable, MutMutable) => {
70+
let t = try!(self.equate().tys(a.ty, b.ty));
71+
Ok(ty::mt {ty: t, mutbl: MutMutable})
72+
}
73+
74+
// If one side or both is immutable, we can use the GLB of
75+
// both sides but mutbl must be `MutImmutable`.
76+
(MutImmutable, MutImmutable) => {
77+
let t = try!(self.tys(a.ty, b.ty));
78+
Ok(ty::mt {ty: t, mutbl: MutImmutable})
79+
}
80+
81+
// There is no mutual subtype of these combinations.
82+
(MutMutable, MutImmutable) |
83+
(MutImmutable, MutMutable) => {
84+
Err(ty::terr_mutability)
85+
}
86+
}
87+
}
88+
89+
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
90+
match (a, b) {
91+
(Unsafety::Normal, _) | (_, Unsafety::Normal) => Ok(Unsafety::Normal),
92+
(Unsafety::Unsafe, Unsafety::Unsafe) => Ok(Unsafety::Unsafe)
93+
}
94+
}
95+
5696
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
5797
debug!("{}.regions({}, {})",
5898
self.tag(),

branches/try/src/librustc/middle/infer/lub.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use super::{cres};
1515
use super::{Subtype};
1616

1717
use middle::ty::{self, Ty};
18+
use syntax::ast::{MutMutable, MutImmutable, Unsafety};
19+
use util::ppaux::mt_to_string;
1820
use util::ppaux::Repr;
1921

2022
/// "Least upper bound" (common supertype)
@@ -53,6 +55,39 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> {
5355
}
5456
}
5557

58+
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
59+
let tcx = self.tcx();
60+
61+
debug!("{}.mts({}, {})",
62+
self.tag(),
63+
mt_to_string(tcx, a),
64+
mt_to_string(tcx, b));
65+
66+
if a.mutbl != b.mutbl {
67+
return Err(ty::terr_mutability)
68+
}
69+
70+
let m = a.mutbl;
71+
match m {
72+
MutImmutable => {
73+
let t = try!(self.tys(a.ty, b.ty));
74+
Ok(ty::mt {ty: t, mutbl: m})
75+
}
76+
77+
MutMutable => {
78+
let t = try!(self.equate().tys(a.ty, b.ty));
79+
Ok(ty::mt {ty: t, mutbl: m})
80+
}
81+
}
82+
}
83+
84+
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
85+
match (a, b) {
86+
(Unsafety::Unsafe, _) | (_, Unsafety::Unsafe) => Ok(Unsafety::Unsafe),
87+
(Unsafety::Normal, Unsafety::Normal) => Ok(Unsafety::Normal),
88+
}
89+
}
90+
5691
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
5792
debug!("{}.regions({}, {})",
5893
self.tag(),

branches/try/src/librustc/middle/infer/sub.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use super::combine::*;
12-
use super::{cres};
12+
use super::{cres, CresCompare};
1313
use super::higher_ranked::HigherRankedRelations;
1414
use super::{Subtype};
1515
use super::type_variable::{SubtypeOf, SupertypeOf};
@@ -18,6 +18,9 @@ use middle::ty::{self, Ty};
1818
use middle::ty::TyVar;
1919
use util::ppaux::{Repr};
2020

21+
use syntax::ast::{MutImmutable, MutMutable, Unsafety};
22+
23+
2124
/// "Greatest lower bound" (common subtype)
2225
pub struct Sub<'f, 'tcx: 'f> {
2326
fields: CombineFields<'f, 'tcx>
@@ -63,6 +66,36 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> {
6366
Ok(a)
6467
}
6568

69+
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
70+
debug!("mts({} <: {})",
71+
a.repr(self.tcx()),
72+
b.repr(self.tcx()));
73+
74+
if a.mutbl != b.mutbl {
75+
return Err(ty::terr_mutability);
76+
}
77+
78+
match b.mutbl {
79+
MutMutable => {
80+
// If supertype is mut, subtype must match exactly
81+
// (i.e., invariant if mut):
82+
try!(self.equate().tys(a.ty, b.ty));
83+
}
84+
MutImmutable => {
85+
// Otherwise we can be covariant:
86+
try!(self.tys(a.ty, b.ty));
87+
}
88+
}
89+
90+
Ok(*a) // return is meaningless in sub, just return *a
91+
}
92+
93+
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
94+
self.lub().unsafeties(a, b).compare(b, || {
95+
ty::terr_unsafety_mismatch(expected_found(self, a, b))
96+
})
97+
}
98+
6699
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
67100
debug!("{}.tys({}, {})", self.tag(),
68101
a.repr(self.tcx()), b.repr(self.tcx()));

branches/try/src/librustc/middle/lang_items.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ lets_do_this! {
316316

317317
StartFnLangItem, "start", start_fn;
318318

319+
TyDescStructLangItem, "ty_desc", ty_desc;
320+
OpaqueStructLangItem, "opaque", opaque;
321+
319322
EhPersonalityLangItem, "eh_personality", eh_personality;
320323

321324
ExchangeHeapLangItem, "exchange_heap", exchange_heap;

branches/try/src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
428428

429429
Some(adjustment) => {
430430
match *adjustment {
431-
ty::AdjustReifyFnPointer(..) |
432-
ty::AdjustUnsafeFnPointer(..) => {
431+
ty::AdjustReifyFnPointer(..) => {
433432
debug!("cat_expr(AdjustReifyFnPointer): {}",
434433
expr.repr(self.tcx()));
435434
// Convert a bare fn to a closure by adding NULL env.

0 commit comments

Comments
 (0)