Skip to content

Commit 18fa001

Browse files
---
yaml --- r: 236220 b: refs/heads/stable c: 354cf4b h: refs/heads/master v: v3
1 parent 1cb3771 commit 18fa001

File tree

48 files changed

+556
-896
lines changed

Some content is hidden

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

48 files changed

+556
-896
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: 38517944f0360c139dc9db89164361a909c0a180
32+
refs/heads/stable: 354cf4b56b8e2af67cc68965eb816deec0e79e4b
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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ 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() {}
5857
```
5958

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

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ 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() {}
4342
# // fn main() {} tricked you, rustdoc!
4443
```
4544

@@ -64,7 +63,6 @@ pub extern fn main(argc: i32, argv: *const *const u8) -> i32 {
6463
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
6564
#[lang = "eh_personality"] extern fn eh_personality() {}
6665
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
67-
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
6866
# // fn main() {} tricked you, rustdoc!
6967
```
7068

@@ -152,7 +150,6 @@ extern fn panic_fmt(args: &core::fmt::Arguments,
152150
153151
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
154152
#[lang = "eh_personality"] extern fn eh_personality() {}
155-
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
156153
# #[start] fn start(argc: isize, argv: *const *const u8) -> isize { 0 }
157154
# fn main() {}
158155
```

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,15 @@ 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-
DlDef(def::DefAssociatedConst(did))
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))
303311
} else {
304312
// Regular const item.
305313
DlDef(def::DefConst(did))
@@ -311,7 +319,18 @@ fn item_to_def_like(cdata: Cmd, item: rbml::Doc, did: ast::DefId) -> DefLike {
311319
Fn => DlDef(def::DefFn(did, false)),
312320
CtorFn => DlDef(def::DefFn(did, true)),
313321
Method | StaticMethod => {
314-
DlDef(def::DefMethod(did))
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))
315334
}
316335
Type => {
317336
if item_sort(item) == Some('t') {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,9 @@ 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) => def::DefMethod(did.tr(dcx)),
447+
def::DefMethod(did, p) => {
448+
def::DefMethod(did.tr(dcx), p.map(|did2| did2.tr(dcx)))
449+
}
448450
def::DefSelfTy(opt_did, impl_ids) => { def::DefSelfTy(opt_did.map(|did| did.tr(dcx)),
449451
impl_ids.map(|(nid1, nid2)| {
450452
(dcx.tr_id(nid1),
@@ -454,7 +456,9 @@ impl tr for def::Def {
454456
def::DefForeignMod(did) => { def::DefForeignMod(did.tr(dcx)) }
455457
def::DefStatic(did, m) => { def::DefStatic(did.tr(dcx), m) }
456458
def::DefConst(did) => { def::DefConst(did.tr(dcx)) }
457-
def::DefAssociatedConst(did) => def::DefAssociatedConst(did.tr(dcx)),
459+
def::DefAssociatedConst(did, p) => {
460+
def::DefAssociatedConst(did.tr(dcx), p.map(|did2| did2.tr(dcx)))
461+
}
458462
def::DefLocal(nid) => { def::DefLocal(dcx.tr_id(nid)) }
459463
def::DefVariant(e_did, v_did, is_s) => {
460464
def::DefVariant(e_did.tr(dcx), v_did.tr(dcx), is_s)

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

Lines changed: 2 additions & 9 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,17 +696,10 @@ 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(_))) |
699700
Some(def::DefFn(did, _)) => {
700701
v.handle_const_fn_call(e, did, node_ty)
701702
}
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-
}
710703
_ => false
711704
};
712705
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)) => {
932+
Some(def::DefAssociatedConst(def_id, provenance)) => {
933933
if ast_util::is_local(def_id) {
934-
match tcx.impl_or_trait_item(def_id).container() {
935-
ty::TraitContainer(trait_id) => match tcx.map.find(def_id.node) {
934+
match provenance {
935+
def::FromTrait(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-
ty::ImplContainer(_) => match tcx.map.find(def_id.node) {
953+
def::FromImpl(_) => 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: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
pub use self::Def::*;
12+
pub use self::MethodProvenance::*;
1213

1314
use middle::privacy::LastPrivate;
1415
use middle::subst::ParamSpace;
@@ -27,7 +28,7 @@ pub enum Def {
2728
DefForeignMod(ast::DefId),
2829
DefStatic(ast::DefId, bool /* is_mutbl */),
2930
DefConst(ast::DefId),
30-
DefAssociatedConst(ast::DefId),
31+
DefAssociatedConst(ast::DefId /* const */, MethodProvenance),
3132
DefLocal(ast::NodeId),
3233
DefVariant(ast::DefId /* enum */, ast::DefId /* variant */, bool /* is_structure */),
3334
DefTy(ast::DefId, bool /* is_enum */),
@@ -50,7 +51,7 @@ pub enum Def {
5051
DefStruct(ast::DefId),
5152
DefRegion(ast::NodeId),
5253
DefLabel(ast::NodeId),
53-
DefMethod(ast::DefId),
54+
DefMethod(ast::DefId /* method */, MethodProvenance),
5455
}
5556

5657
/// The result of resolving a path.
@@ -111,6 +112,23 @@ pub struct Export {
111112
pub def_id: ast::DefId, // The definition of the target.
112113
}
113114

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+
114132
impl Def {
115133
pub fn local_node_id(&self) -> ast::NodeId {
116134
let def_id = self.def_id();
@@ -123,7 +141,7 @@ impl Def {
123141
DefFn(id, _) | DefMod(id) | DefForeignMod(id) | DefStatic(id, _) |
124142
DefVariant(_, id, _) | DefTy(id, _) | DefAssociatedTy(_, id) |
125143
DefTyParam(_, _, id, _) | DefUse(id) | DefStruct(id) | DefTrait(id) |
126-
DefMethod(id) | DefConst(id) | DefAssociatedConst(id) |
144+
DefMethod(id, _) | DefConst(id) | DefAssociatedConst(id, _) |
127145
DefSelfTy(Some(id), None)=> {
128146
id
129147
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ 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;
331330
MSVCTryFilterLangItem, "msvc_try_filter", msvc_try_filter;
332331

333332
ExchangeHeapLangItem, "exchange_heap", exchange_heap;

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ 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-
}
5248

5349
{
5450
let mut cx = Context { sess: sess, items: items };
@@ -126,5 +122,4 @@ weak_lang_items! {
126122
panic_fmt, PanicFmtLangItem, rust_begin_unwind;
127123
stack_exhausted, StackExhaustedLangItem, rust_stack_exhausted;
128124
eh_personality, EhPersonalityLangItem, rust_eh_personality;
129-
eh_unwind_resume, EhUnwindResumeLangItem, rust_eh_unwind_resume;
130125
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ 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,
179174
}
180175

181176
impl Default for TargetOptions {
@@ -214,7 +209,6 @@ impl Default for TargetOptions {
214209
pre_link_objects: Vec::new(),
215210
post_link_objects: Vec::new(),
216211
archive_format: String::new(),
217-
custom_unwind_resume: false,
218212
}
219213
}
220214
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ 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;
2019

2120
Target {
2221
llvm_target: "x86_64-pc-windows-gnu".to_string(),

0 commit comments

Comments
 (0)