Skip to content

Commit 6ef518f

Browse files
committed
---
yaml --- r: 236221 b: refs/heads/stable c: ebc3a87 h: refs/heads/master i: 236219: 1cb3771 v: v3
1 parent 18fa001 commit 6ef518f

File tree

47 files changed

+896
-368
lines changed

Some content is hidden

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

47 files changed

+896
-368
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 354cf4b56b8e2af67cc68965eb816deec0e79e4b
32+
refs/heads/stable: ebc3a87fb45b37e0016a0e85210b55fca97e2cdd
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/doc/reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,8 +1199,8 @@ An example of an `enum` item and its use:
11991199

12001200
```
12011201
enum Animal {
1202-
Dog,
1203-
Cat
1202+
Dog,
1203+
Cat,
12041204
}
12051205
12061206
let mut a: Animal = Animal::Dog;

branches/stable/src/doc/trpl/lang-items.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ fn main(argc: isize, argv: *const *const u8) -> isize {
5454
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
5555
#[lang = "eh_personality"] extern fn eh_personality() {}
5656
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
57+
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
5758
```
5859

5960
Note the use of `abort`: the `exchange_malloc` lang item is assumed to

branches/stable/src/doc/trpl/no-stdlib.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
3939
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
4040
#[lang = "eh_personality"] extern fn eh_personality() {}
4141
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
42+
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
4243
# // fn main() {} tricked you, rustdoc!
4344
```
4445

@@ -63,6 +64,7 @@ pub extern fn main(argc: i32, argv: *const *const u8) -> i32 {
6364
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
6465
#[lang = "eh_personality"] extern fn eh_personality() {}
6566
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
67+
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
6668
# // fn main() {} tricked you, rustdoc!
6769
```
6870

@@ -150,6 +152,7 @@ extern fn panic_fmt(args: &core::fmt::Arguments,
150152
151153
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
152154
#[lang = "eh_personality"] extern fn eh_personality() {}
155+
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
153156
# #[start] fn start(argc: isize, argv: *const *const u8) -> isize { 0 }
154157
# fn main() {}
155158
```

branches/stable/src/librustc/metadata/decoder.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,7 @@ fn item_to_def_like(cdata: Cmd, item: rbml::Doc, did: ast::DefId) -> DefLike {
299299
Constant => {
300300
// Check whether we have an associated const item.
301301
if item_sort(item) == Some('C') {
302-
// Check whether the associated const is from a trait or impl.
303-
// See the comment for methods below.
304-
let provenance = if reader::maybe_get_doc(
305-
item, tag_item_trait_parent_sort).is_some() {
306-
def::FromTrait(item_require_parent_item(cdata, item))
307-
} else {
308-
def::FromImpl(item_require_parent_item(cdata, item))
309-
};
310-
DlDef(def::DefAssociatedConst(did, provenance))
302+
DlDef(def::DefAssociatedConst(did))
311303
} else {
312304
// Regular const item.
313305
DlDef(def::DefConst(did))
@@ -319,18 +311,7 @@ fn item_to_def_like(cdata: Cmd, item: rbml::Doc, did: ast::DefId) -> DefLike {
319311
Fn => DlDef(def::DefFn(did, false)),
320312
CtorFn => DlDef(def::DefFn(did, true)),
321313
Method | StaticMethod => {
322-
// def_static_method carries an optional field of its enclosing
323-
// trait or enclosing impl (if this is an inherent static method).
324-
// So we need to detect whether this is in a trait or not, which
325-
// we do through the mildly hacky way of checking whether there is
326-
// a trait_parent_sort.
327-
let provenance = if reader::maybe_get_doc(
328-
item, tag_item_trait_parent_sort).is_some() {
329-
def::FromTrait(item_require_parent_item(cdata, item))
330-
} else {
331-
def::FromImpl(item_require_parent_item(cdata, item))
332-
};
333-
DlDef(def::DefMethod(did, provenance))
314+
DlDef(def::DefMethod(did))
334315
}
335316
Type => {
336317
if item_sort(item) == Some('t') {

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,7 @@ impl tr for def::Def {
444444
fn tr(&self, dcx: &DecodeContext) -> def::Def {
445445
match *self {
446446
def::DefFn(did, is_ctor) => def::DefFn(did.tr(dcx), is_ctor),
447-
def::DefMethod(did, p) => {
448-
def::DefMethod(did.tr(dcx), p.map(|did2| did2.tr(dcx)))
449-
}
447+
def::DefMethod(did) => def::DefMethod(did.tr(dcx)),
450448
def::DefSelfTy(opt_did, impl_ids) => { def::DefSelfTy(opt_did.map(|did| did.tr(dcx)),
451449
impl_ids.map(|(nid1, nid2)| {
452450
(dcx.tr_id(nid1),
@@ -456,9 +454,7 @@ impl tr for def::Def {
456454
def::DefForeignMod(did) => { def::DefForeignMod(did.tr(dcx)) }
457455
def::DefStatic(did, m) => { def::DefStatic(did.tr(dcx), m) }
458456
def::DefConst(did) => { def::DefConst(did.tr(dcx)) }
459-
def::DefAssociatedConst(did, p) => {
460-
def::DefAssociatedConst(did.tr(dcx), p.map(|did2| did2.tr(dcx)))
461-
}
457+
def::DefAssociatedConst(did) => def::DefAssociatedConst(did.tr(dcx)),
462458
def::DefLocal(nid) => { def::DefLocal(dcx.tr_id(nid)) }
463459
def::DefVariant(e_did, v_did, is_s) => {
464460
def::DefVariant(e_did.tr(dcx), v_did.tr(dcx), is_s)

branches/stable/src/librustc/middle/check_const.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
650650
}
651651
}
652652
Some(def::DefConst(did)) |
653-
Some(def::DefAssociatedConst(did, _)) => {
653+
Some(def::DefAssociatedConst(did)) => {
654654
if let Some(expr) = const_eval::lookup_const_by_id(v.tcx, did,
655655
Some(e.id)) {
656656
let inner = v.global_expr(Mode::Const, expr);
@@ -696,10 +696,17 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
696696
v.add_qualif(ConstQualif::NON_ZERO_SIZED);
697697
true
698698
}
699-
Some(def::DefMethod(did, def::FromImpl(_))) |
700699
Some(def::DefFn(did, _)) => {
701700
v.handle_const_fn_call(e, did, node_ty)
702701
}
702+
Some(def::DefMethod(did)) => {
703+
match v.tcx.impl_or_trait_item(did).container() {
704+
ty::ImplContainer(_) => {
705+
v.handle_const_fn_call(e, did, node_ty)
706+
}
707+
ty::TraitContainer(_) => false
708+
}
709+
}
703710
_ => false
704711
};
705712
if !is_const {

branches/stable/src/librustc/middle/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> {
442442
ast::PatIdent(..) | ast::PatEnum(..) | ast::PatQPath(..) => {
443443
let def = self.tcx.def_map.borrow().get(&pat.id).map(|d| d.full_def());
444444
match def {
445-
Some(DefAssociatedConst(did, _)) |
445+
Some(DefAssociatedConst(did)) |
446446
Some(DefConst(did)) => match lookup_const_by_id(self.tcx, did, Some(pat.id)) {
447447
Some(const_expr) => {
448448
const_expr_to_pat(self.tcx, const_expr, pat.span).map(|new_pat| {

branches/stable/src/librustc/middle/check_static_recursion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
238238
ast::ExprPath(..) => {
239239
match self.def_map.borrow().get(&e.id).map(|d| d.base_def) {
240240
Some(DefStatic(def_id, _)) |
241-
Some(DefAssociatedConst(def_id, _)) |
241+
Some(DefAssociatedConst(def_id)) |
242242
Some(DefConst(def_id))
243243
if ast_util::is_local(def_id) => {
244244
match self.ast_map.get(def_id.node) {

branches/stable/src/librustc/middle/const_eval.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn lookup_const<'a>(tcx: &'a ty::ctxt, e: &Expr) -> Option<&'a Expr> {
4141
let opt_def = tcx.def_map.borrow().get(&e.id).map(|d| d.full_def());
4242
match opt_def {
4343
Some(def::DefConst(def_id)) |
44-
Some(def::DefAssociatedConst(def_id, _)) => {
44+
Some(def::DefAssociatedConst(def_id)) => {
4545
lookup_const_by_id(tcx, def_id, Some(e.id))
4646
}
4747
Some(def::DefVariant(enum_def, variant_def, _)) => {
@@ -929,10 +929,10 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
929929
(lookup_const_by_id(tcx, def_id, Some(e.id)), None)
930930
}
931931
}
932-
Some(def::DefAssociatedConst(def_id, provenance)) => {
932+
Some(def::DefAssociatedConst(def_id)) => {
933933
if ast_util::is_local(def_id) {
934-
match provenance {
935-
def::FromTrait(trait_id) => match tcx.map.find(def_id.node) {
934+
match tcx.impl_or_trait_item(def_id).container() {
935+
ty::TraitContainer(trait_id) => match tcx.map.find(def_id.node) {
936936
Some(ast_map::NodeTraitItem(ti)) => match ti.node {
937937
ast::ConstTraitItem(ref ty, _) => {
938938
if let ExprTypeChecked = ty_hint {
@@ -950,7 +950,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
950950
},
951951
_ => (None, None)
952952
},
953-
def::FromImpl(_) => match tcx.map.find(def_id.node) {
953+
ty::ImplContainer(_) => match tcx.map.find(def_id.node) {
954954
Some(ast_map::NodeImplItem(ii)) => match ii.node {
955955
ast::ConstImplItem(ref ty, ref expr) => {
956956
(Some(&**expr), Some(&**ty))

branches/stable/src/librustc/middle/def.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
pub use self::Def::*;
12-
pub use self::MethodProvenance::*;
1312

1413
use middle::privacy::LastPrivate;
1514
use middle::subst::ParamSpace;
@@ -28,7 +27,7 @@ pub enum Def {
2827
DefForeignMod(ast::DefId),
2928
DefStatic(ast::DefId, bool /* is_mutbl */),
3029
DefConst(ast::DefId),
31-
DefAssociatedConst(ast::DefId /* const */, MethodProvenance),
30+
DefAssociatedConst(ast::DefId),
3231
DefLocal(ast::NodeId),
3332
DefVariant(ast::DefId /* enum */, ast::DefId /* variant */, bool /* is_structure */),
3433
DefTy(ast::DefId, bool /* is_enum */),
@@ -51,7 +50,7 @@ pub enum Def {
5150
DefStruct(ast::DefId),
5251
DefRegion(ast::NodeId),
5352
DefLabel(ast::NodeId),
54-
DefMethod(ast::DefId /* method */, MethodProvenance),
53+
DefMethod(ast::DefId),
5554
}
5655

5756
/// The result of resolving a path.
@@ -112,23 +111,6 @@ pub struct Export {
112111
pub def_id: ast::DefId, // The definition of the target.
113112
}
114113

115-
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
116-
pub enum MethodProvenance {
117-
FromTrait(ast::DefId),
118-
FromImpl(ast::DefId),
119-
}
120-
121-
impl MethodProvenance {
122-
pub fn map<F>(self, f: F) -> MethodProvenance where
123-
F: FnOnce(ast::DefId) -> ast::DefId,
124-
{
125-
match self {
126-
FromTrait(did) => FromTrait(f(did)),
127-
FromImpl(did) => FromImpl(f(did))
128-
}
129-
}
130-
}
131-
132114
impl Def {
133115
pub fn local_node_id(&self) -> ast::NodeId {
134116
let def_id = self.def_id();
@@ -141,7 +123,7 @@ impl Def {
141123
DefFn(id, _) | DefMod(id) | DefForeignMod(id) | DefStatic(id, _) |
142124
DefVariant(_, id, _) | DefTy(id, _) | DefAssociatedTy(_, id) |
143125
DefTyParam(_, _, id, _) | DefUse(id) | DefStruct(id) | DefTrait(id) |
144-
DefMethod(id, _) | DefConst(id) | DefAssociatedConst(id, _) |
126+
DefMethod(id) | DefConst(id) | DefAssociatedConst(id) |
145127
DefSelfTy(Some(id), None)=> {
146128
id
147129
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ lets_do_this! {
327327

328328
EhPersonalityLangItem, "eh_personality", eh_personality;
329329
EhPersonalityCatchLangItem, "eh_personality_catch", eh_personality_catch;
330+
EhUnwindResumeLangItem, "eh_unwind_resume", eh_unwind_resume;
330331
MSVCTryFilterLangItem, "msvc_try_filter", msvc_try_filter;
331332

332333
ExchangeHeapLangItem, "exchange_heap", exchange_heap;

branches/stable/src/librustc/middle/weak_lang_items.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ pub fn check_crate(krate: &ast::Crate,
4545
if items.eh_personality().is_none() {
4646
items.missing.push(lang_items::EhPersonalityLangItem);
4747
}
48+
if sess.target.target.options.custom_unwind_resume &
49+
items.eh_unwind_resume().is_none() {
50+
items.missing.push(lang_items::EhUnwindResumeLangItem);
51+
}
4852

4953
{
5054
let mut cx = Context { sess: sess, items: items };
@@ -122,4 +126,5 @@ weak_lang_items! {
122126
panic_fmt, PanicFmtLangItem, rust_begin_unwind;
123127
stack_exhausted, StackExhaustedLangItem, rust_stack_exhausted;
124128
eh_personality, EhPersonalityLangItem, rust_eh_personality;
129+
eh_unwind_resume, EhUnwindResumeLangItem, rust_eh_unwind_resume;
125130
}

branches/stable/src/librustc_back/target/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ pub struct TargetOptions {
171171
/// currently only "gnu" is used to fall into LLVM. Unknown strings cause
172172
/// the system linker to be used.
173173
pub archive_format: String,
174+
/// Whether the target uses a custom unwind resumption routine.
175+
/// By default LLVM lowers `resume` instructions into calls to `_Unwind_Resume`
176+
/// defined in libgcc. If this option is enabled, the target must provide
177+
/// `eh_unwind_resume` lang item.
178+
pub custom_unwind_resume: bool,
174179
}
175180

176181
impl Default for TargetOptions {
@@ -209,6 +214,7 @@ impl Default for TargetOptions {
209214
pre_link_objects: Vec::new(),
210215
post_link_objects: Vec::new(),
211216
archive_format: String::new(),
217+
custom_unwind_resume: false,
212218
}
213219
}
214220
}

branches/stable/src/librustc_back/target/x86_64_pc_windows_gnu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub fn target() -> Target {
1616
// On Win64 unwinding is handled by the OS, so we can link libgcc statically.
1717
base.pre_link_args.push("-static-libgcc".to_string());
1818
base.pre_link_args.push("-m64".to_string());
19+
base.custom_unwind_resume = true;
1920

2021
Target {
2122
llvm_target: "x86_64-pc-windows-gnu".to_string(),

0 commit comments

Comments
 (0)