Skip to content

Commit 8ea8a17

Browse files
committed
---
yaml --- r: 232543 b: refs/heads/try c: 0fdc4a8 h: refs/heads/master i: 232541: 54c78a9 232539: 189d901 232535: 6486113 232527: 49a9daa 232511: 82b5f87 v: v3
1 parent 849d8bd commit 8ea8a17

File tree

7 files changed

+39
-163
lines changed

7 files changed

+39
-163
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: c8c14f207b7abac93f16237fea48fe435ebe826c
4+
refs/heads/try: 0fdc4a89f52ceb9fad5a6329c8c83651b72aa218
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_resolve/lib.rs

Lines changed: 28 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,6 @@ mod record_exports;
109109
mod build_reduced_graph;
110110
mod resolve_imports;
111111

112-
// Perform the callback, not walking deeper if the return is true
113-
macro_rules! execute_callback {
114-
($node: expr, $walker: expr) => (
115-
if let Some(ref callback) = $walker.callback {
116-
if callback($node, &mut $walker.resolved) {
117-
return;
118-
}
119-
}
120-
)
121-
}
122-
123112
pub enum ResolutionError<'a> {
124113
/// error E0401: can't use type parameters from outer function
125114
TypeParametersFromOuterFunction,
@@ -408,7 +397,7 @@ enum PatternBindingMode {
408397
}
409398

410399
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
411-
pub enum Namespace {
400+
enum Namespace {
412401
TypeNS,
413402
ValueNS
414403
}
@@ -456,22 +445,18 @@ enum NameDefinition {
456445

457446
impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
458447
fn visit_item(&mut self, item: &Item) {
459-
execute_callback!(ast_map::Node::NodeItem(item), self);
460448
self.resolve_item(item);
461449
}
462450
fn visit_arm(&mut self, arm: &Arm) {
463451
self.resolve_arm(arm);
464452
}
465453
fn visit_block(&mut self, block: &Block) {
466-
execute_callback!(ast_map::Node::NodeBlock(block), self);
467454
self.resolve_block(block);
468455
}
469456
fn visit_expr(&mut self, expr: &Expr) {
470-
execute_callback!(ast_map::Node::NodeExpr(expr), self);
471457
self.resolve_expr(expr);
472458
}
473459
fn visit_local(&mut self, local: &Local) {
474-
execute_callback!(ast_map::Node::NodeLocal(&*local.pat), self);
475460
self.resolve_local(local);
476461
}
477462
fn visit_ty(&mut self, ty: &Ty) {
@@ -490,7 +475,6 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
490475
visit::walk_poly_trait_ref(self, tref, m);
491476
}
492477
fn visit_variant(&mut self, variant: &ast::Variant, generics: &Generics) {
493-
execute_callback!(ast_map::Node::NodeVariant(variant), self);
494478
if let Some(ref dis_expr) = variant.node.disr_expr {
495479
// resolve the discriminator expr as a constant
496480
self.with_constant_rib(|this| {
@@ -514,7 +498,6 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
514498
}
515499
}
516500
fn visit_foreign_item(&mut self, foreign_item: &ast::ForeignItem) {
517-
execute_callback!(ast_map::Node::NodeForeignItem(foreign_item), self);
518501
let type_parameters = match foreign_item.node {
519502
ForeignItemFn(_, ref generics) => {
520503
HasTypeParameters(generics, FnSpace, ItemRibKind)
@@ -1164,13 +1147,6 @@ pub struct Resolver<'a, 'tcx:'a> {
11641147

11651148
used_imports: HashSet<(NodeId, Namespace)>,
11661149
used_crates: HashSet<CrateNum>,
1167-
1168-
// Callback function for intercepting walks
1169-
callback: Option<Box<Fn(ast_map::Node, &mut bool) -> bool>>,
1170-
// The intention is that the callback modifies this flag.
1171-
// Once set, the resolver falls out of the walk, preserving the ribs.
1172-
resolved: bool,
1173-
11741150
}
11751151

11761152
#[derive(PartialEq)]
@@ -1232,10 +1208,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12321208
emit_errors: true,
12331209
make_glob_map: make_glob_map == MakeGlobMap::Yes,
12341210
glob_map: HashMap::new(),
1235-
1236-
callback: None,
1237-
resolved: false,
1238-
12391211
}
12401212
}
12411213

@@ -2262,7 +2234,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
22622234
f(self);
22632235

22642236
match type_parameters {
2265-
HasTypeParameters(..) => { if !self.resolved { self.type_ribs.pop(); } }
2237+
HasTypeParameters(..) => { self.type_ribs.pop(); }
22662238
NoTypeParameters => { }
22672239
}
22682240
}
@@ -2272,9 +2244,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
22722244
{
22732245
self.label_ribs.push(Rib::new(NormalRibKind));
22742246
f(self);
2275-
if !self.resolved {
2276-
self.label_ribs.pop();
2277-
}
2247+
self.label_ribs.pop();
22782248
}
22792249

22802250
fn with_constant_rib<F>(&mut self, f: F) where
@@ -2283,10 +2253,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
22832253
self.value_ribs.push(Rib::new(ConstantItemRibKind));
22842254
self.type_ribs.push(Rib::new(ConstantItemRibKind));
22852255
f(self);
2286-
if !self.resolved {
2287-
self.type_ribs.pop();
2288-
self.value_ribs.pop();
2289-
}
2256+
self.type_ribs.pop();
2257+
self.value_ribs.pop();
22902258
}
22912259

22922260
fn resolve_function(&mut self,
@@ -2317,10 +2285,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
23172285

23182286
debug!("(resolving function) leaving function");
23192287

2320-
if !self.resolved {
2321-
self.label_ribs.pop();
2322-
self.value_ribs.pop();
2323-
}
2288+
self.label_ribs.pop();
2289+
self.value_ribs.pop();
23242290
}
23252291

23262292
fn resolve_trait_reference(&mut self,
@@ -2423,9 +2389,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
24232389
self_type_rib.bindings.insert(name, DlDef(self_def));
24242390
self.type_ribs.push(self_type_rib);
24252391
f(self);
2426-
if !self.resolved {
2427-
self.type_ribs.pop();
2428-
}
2392+
self.type_ribs.pop();
24292393
}
24302394

24312395
fn resolve_implementation(&mut self,
@@ -2594,9 +2558,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
25942558
visit::walk_expr_opt(self, &arm.guard);
25952559
self.visit_expr(&*arm.body);
25962560

2597-
if !self.resolved {
2598-
self.value_ribs.pop();
2599-
}
2561+
self.value_ribs.pop();
26002562
}
26012563

26022564
fn resolve_block(&mut self, block: &Block) {
@@ -2638,10 +2600,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
26382600
visit::walk_block(self, block);
26392601

26402602
// Move back up.
2641-
if !self.resolved {
2642-
self.current_module = orig_module;
2643-
self.value_ribs.pop();
2644-
}
2603+
self.current_module = orig_module;
2604+
2605+
self.value_ribs.pop();
26452606
debug!("(resolving block) leaving block");
26462607
}
26472608

@@ -3083,12 +3044,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30833044
/// doesn't skip straight to the containing module.
30843045
/// Skips `path_depth` trailing segments, which is also reflected in the
30853046
/// returned value. See `middle::def::PathResolution` for more info.
3086-
pub fn resolve_path(&mut self,
3087-
id: NodeId,
3088-
path: &Path,
3089-
path_depth: usize,
3090-
namespace: Namespace,
3091-
check_ribs: bool) -> Option<PathResolution> {
3047+
fn resolve_path(&mut self,
3048+
id: NodeId,
3049+
path: &Path,
3050+
path_depth: usize,
3051+
namespace: Namespace,
3052+
check_ribs: bool) -> Option<PathResolution> {
30923053
let span = path.span;
30933054
let segments = &path.segments[..path.segments.len()-path_depth];
30943055

@@ -4027,7 +3988,16 @@ pub fn resolve_crate<'a, 'tcx>(session: &'a Session,
40273988
make_glob_map: MakeGlobMap)
40283989
-> CrateMap {
40293990
let krate = ast_map.krate();
4030-
let mut resolver = create_resolver(session, ast_map, krate, make_glob_map, None);
3991+
let mut resolver = Resolver::new(session, ast_map, krate.span, make_glob_map);
3992+
3993+
build_reduced_graph::build_reduced_graph(&mut resolver, krate);
3994+
session.abort_if_errors();
3995+
3996+
resolve_imports::resolve_imports(&mut resolver);
3997+
session.abort_if_errors();
3998+
3999+
record_exports::record(&mut resolver);
4000+
session.abort_if_errors();
40314001

40324002
resolver.resolve_crate(krate);
40334003
session.abort_if_errors();
@@ -4048,34 +4018,4 @@ pub fn resolve_crate<'a, 'tcx>(session: &'a Session,
40484018
}
40494019
}
40504020

4051-
/// Builds a name resolution walker to be used within this module,
4052-
/// or used externally, with an optional callback function.
4053-
///
4054-
/// The callback takes a &mut bool which allows callbacks to end a
4055-
/// walk when set to true, passing through the rest of the walk, while
4056-
/// preserving the ribs + current module. This allows resolve_path
4057-
/// calls to be made with the correct scope info. The node in the
4058-
/// callback corresponds to the current node in the walk.
4059-
pub fn create_resolver<'a, 'tcx>(session: &'a Session,
4060-
ast_map: &'a ast_map::Map<'tcx>,
4061-
krate: &'a Crate,
4062-
make_glob_map: MakeGlobMap,
4063-
callback: Option<Box<Fn(ast_map::Node, &mut bool) -> bool>>)
4064-
-> Resolver<'a, 'tcx> {
4065-
let mut resolver = Resolver::new(session, ast_map, krate.span, make_glob_map);
4066-
4067-
resolver.callback = callback;
4068-
4069-
build_reduced_graph::build_reduced_graph(&mut resolver, krate);
4070-
session.abort_if_errors();
4071-
4072-
resolve_imports::resolve_imports(&mut resolver);
4073-
session.abort_if_errors();
4074-
4075-
record_exports::record(&mut resolver);
4076-
session.abort_if_errors();
4077-
4078-
resolver
4079-
}
4080-
40814021
__build_diagnostic_array! { librustc_resolve, DIAGNOSTICS }

branches/try/src/librustc_trans/save/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ use syntax::print::pprust::ty_to_string;
2828
use self::span_utils::SpanUtils;
2929

3030

31-
pub mod span_utils;
32-
pub mod recorder;
31+
mod span_utils;
32+
mod recorder;
3333

3434
mod dump_csv;
3535

@@ -645,7 +645,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
645645
}
646646

647647
#[inline]
648-
pub fn enclosing_scope(&self, id: NodeId) -> NodeId {
648+
fn enclosing_scope(&self, id: NodeId) -> NodeId {
649649
self.tcx.map.get_enclosing_scope(id).unwrap_or(0)
650650
}
651651
}

branches/try/src/librustc_trans/trans/expr.rs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ use trans::cleanup::{self, CleanupMethods, DropHintMethods};
6565
use trans::common::*;
6666
use trans::datum::*;
6767
use trans::debuginfo::{self, DebugLoc, ToDebugLoc};
68-
use trans::declare;
6968
use trans::glue;
7069
use trans::machine;
7170
use trans::meth;
@@ -1768,43 +1767,7 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
17681767
}
17691768
ast::BiRem => {
17701769
if is_float {
1771-
// LLVM currently always lowers the `frem` instructions appropriate
1772-
// library calls typically found in libm. Notably f64 gets wired up
1773-
// to `fmod` and f32 gets wired up to `fmodf`. Inconveniently for
1774-
// us, 32-bit MSVC does not actually have a `fmodf` symbol, it's
1775-
// instead just an inline function in a header that goes up to a
1776-
// f64, uses `fmod`, and then comes back down to a f32.
1777-
//
1778-
// Although LLVM knows that `fmodf` doesn't exist on MSVC, it will
1779-
// still unconditionally lower frem instructions over 32-bit floats
1780-
// to a call to `fmodf`. To work around this we special case MSVC
1781-
// 32-bit float rem instructions and instead do the call out to
1782-
// `fmod` ourselves.
1783-
//
1784-
// Note that this is currently duplicated with src/libcore/ops.rs
1785-
// which does the same thing, and it would be nice to perhaps unify
1786-
// these two implementations on day! Also note that we call `fmod`
1787-
// for both 32 and 64-bit floats because if we emit any FRem
1788-
// instruction at all then LLVM is capable of optimizing it into a
1789-
// 32-bit FRem (which we're trying to avoid).
1790-
let use_fmod = tcx.sess.target.target.options.is_like_msvc &&
1791-
tcx.sess.target.target.arch == "x86";
1792-
if use_fmod {
1793-
let f64t = Type::f64(bcx.ccx());
1794-
let fty = Type::func(&[f64t, f64t], &f64t);
1795-
let llfn = declare::declare_cfn(bcx.ccx(), "fmod", fty,
1796-
tcx.types.f64);
1797-
if lhs_t == tcx.types.f32 {
1798-
let lhs = FPExt(bcx, lhs, f64t);
1799-
let rhs = FPExt(bcx, rhs, f64t);
1800-
let res = Call(bcx, llfn, &[lhs, rhs], None, binop_debug_loc);
1801-
FPTrunc(bcx, res, Type::f32(bcx.ccx()))
1802-
} else {
1803-
Call(bcx, llfn, &[lhs, rhs], None, binop_debug_loc)
1804-
}
1805-
} else {
1806-
FRem(bcx, lhs, rhs, binop_debug_loc)
1807-
}
1770+
FRem(bcx, lhs, rhs, binop_debug_loc)
18081771
} else {
18091772
// Only zero-check integers; fp %0 is NaN
18101773
bcx = base::fail_if_zero_or_overflows(bcx,

branches/try/src/test/codegen/loads.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ pub struct Bytes {
2020
// CHECK-LABEL: @borrow
2121
#[no_mangle]
2222
pub fn borrow(x: &i32) -> &i32 {
23-
// CHECK: load i32*, i32** %x{{.*}}, !nonnull
23+
// CHECK: load {{(i32\*, )?}}i32** %x{{.*}}, !nonnull
2424
x
2525
}
2626

2727
// CHECK-LABEL: @_box
2828
#[no_mangle]
2929
pub fn _box(x: Box<i32>) -> i32 {
30-
// CHECK: load i32*, i32** %x{{.*}}, !nonnull
30+
// CHECK: load {{(i32\*, )?}}i32** %x{{.*}}, !nonnull
3131
*x
3232
}
3333

@@ -36,7 +36,7 @@ pub fn _box(x: Box<i32>) -> i32 {
3636
// dependent alignment
3737
#[no_mangle]
3838
pub fn small_array_alignment(x: [i8; 4]) -> [i8; 4] {
39-
// CHECK: [[VAR:%[0-9]+]] = load i32, i32* %{{.*}}, align 1
39+
// CHECK: [[VAR:%[0-9]+]] = load {{(i32, )?}}i32* %{{.*}}, align 1
4040
// CHECK: ret i32 [[VAR]]
4141
x
4242
}
@@ -46,7 +46,7 @@ pub fn small_array_alignment(x: [i8; 4]) -> [i8; 4] {
4646
// dependent alignment
4747
#[no_mangle]
4848
pub fn small_struct_alignment(x: Bytes) -> Bytes {
49-
// CHECK: [[VAR:%[0-9]+]] = load i32, i32* %{{.*}}, align 1
49+
// CHECK: [[VAR:%[0-9]+]] = load {{(i32, )?}}i32* %{{.*}}, align 1
5050
// CHECK: ret i32 [[VAR]]
5151
x
5252
}

branches/try/src/test/codegen/stores.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub struct Bytes {
2222
// dependent alignment
2323
#[no_mangle]
2424
pub fn small_array_alignment(x: &mut [i8; 4]) {
25-
// CHECK: [[VAR:%[0-9]+]] = load [4 x i8]*, [4 x i8]** %x
25+
// CHECK: [[VAR:%[0-9]+]] = load {{(\[4 x i8\]\*, )?}}[4 x i8]** %x
2626
// CHECK: [[VAR2:%[0-9]+]] = bitcast [4 x i8]* [[VAR]] to i32*
2727
// CHECK: store i32 %{{.*}}, i32* [[VAR2]], align 1
2828
*x = [0; 4];
@@ -33,7 +33,7 @@ pub fn small_array_alignment(x: &mut [i8; 4]) {
3333
// dependent alignment
3434
#[no_mangle]
3535
pub fn small_struct_alignment(x: &mut Bytes) {
36-
// CHECK: [[VAR:%[0-9]+]] = load %Bytes*, %Bytes** %x
36+
// CHECK: [[VAR:%[0-9]+]] = load {{(%Bytes\*, )?}}%Bytes** %x
3737
// CHECK: [[VAR2:%[0-9]+]] = bitcast %Bytes* [[VAR]] to i32*
3838
// CHECK: store i32 %{{.*}}, i32* [[VAR2]], align 1
3939
*x = Bytes {

0 commit comments

Comments
 (0)