Skip to content

Commit 1ccd5dc

Browse files
committed
---
yaml --- r: 191399 b: refs/heads/try c: 46aa621 h: refs/heads/master i: 191397: 8a48cf9 191395: bef3cfe 191391: 367eed3 v: v3
1 parent 04d7e9f commit 1ccd5dc

36 files changed

+286
-429
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: c10918905fda1344e78bc16e6e73294d096ee97d
5+
refs/heads/try: 46aa621452b591e5c504fd85dfe514b92c49c228
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

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/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.

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ pub enum Variance {
281281
#[derive(Clone, Debug)]
282282
pub enum AutoAdjustment<'tcx> {
283283
AdjustReifyFnPointer(ast::DefId), // go from a fn-item type to a fn-pointer type
284-
AdjustUnsafeFnPointer, // go from a safe fn pointer to an unsafe fn pointer
285284
AdjustDerefRef(AutoDerefRef<'tcx>)
286285
}
287286

@@ -2635,17 +2634,6 @@ impl<'tcx> ctxt<'tcx> {
26352634
substs
26362635
}
26372636

2638-
/// Create an unsafe fn ty based on a safe fn ty.
2639-
pub fn safe_to_unsafe_fn_ty(&self, bare_fn: &BareFnTy<'tcx>) -> Ty<'tcx> {
2640-
assert_eq!(bare_fn.unsafety, ast::Unsafety::Normal);
2641-
let unsafe_fn_ty_a = self.mk_bare_fn(ty::BareFnTy {
2642-
unsafety: ast::Unsafety::Unsafe,
2643-
abi: bare_fn.abi,
2644-
sig: bare_fn.sig.clone()
2645-
});
2646-
ty::mk_bare_fn(self, None, unsafe_fn_ty_a)
2647-
}
2648-
26492637
pub fn mk_bare_fn(&self, bare_fn: BareFnTy<'tcx>) -> &'tcx BareFnTy<'tcx> {
26502638
if let Some(bare_fn) = self.bare_fn_interner.borrow().get(&bare_fn) {
26512639
return *bare_fn;
@@ -4535,18 +4523,6 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>,
45354523
}
45364524
}
45374525

4538-
AdjustUnsafeFnPointer => {
4539-
match unadjusted_ty.sty {
4540-
ty::ty_bare_fn(None, b) => cx.safe_to_unsafe_fn_ty(b),
4541-
ref b => {
4542-
cx.sess.bug(
4543-
&format!("AdjustReifyFnPointer adjustment on non-fn-item: \
4544-
{:?}",
4545-
b));
4546-
}
4547-
}
4548-
}
4549-
45504526
AdjustDerefRef(ref adj) => {
45514527
let mut adjusted_ty = unadjusted_ty;
45524528

@@ -6709,7 +6685,6 @@ impl<'tcx> AutoAdjustment<'tcx> {
67096685
pub fn is_identity(&self) -> bool {
67106686
match *self {
67116687
AdjustReifyFnPointer(..) => false,
6712-
AdjustUnsafeFnPointer(..) => false,
67136688
AdjustDerefRef(ref r) => r.is_identity(),
67146689
}
67156690
}
@@ -6859,9 +6834,6 @@ impl<'tcx> Repr<'tcx> for AutoAdjustment<'tcx> {
68596834
AdjustReifyFnPointer(def_id) => {
68606835
format!("AdjustReifyFnPointer({})", def_id.repr(tcx))
68616836
}
6862-
AdjustUnsafeFnPointer => {
6863-
format!("AdjustUnsafeFnPointer")
6864-
}
68656837
AdjustDerefRef(ref data) => {
68666838
data.repr(tcx)
68676839
}

branches/try/src/librustc/session/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,8 @@ mod opt {
736736
use getopts;
737737
use super::RustcOptGroup;
738738

739-
type R = RustcOptGroup;
740-
type S<'a> = &'a str;
739+
pub type R = RustcOptGroup;
740+
pub type S<'a> = &'a str;
741741

742742
fn stable(g: getopts::OptGroup) -> R { RustcOptGroup::stable(g) }
743743
fn unstable(g: getopts::OptGroup) -> R { RustcOptGroup::unstable(g) }

0 commit comments

Comments
 (0)