@@ -103,7 +103,7 @@ use middle::ty::{MethodCall, MethodCallee, MethodMap, ObjectCastMap};
103
103
use middle:: ty_fold:: { TypeFolder , TypeFoldable } ;
104
104
use rscope:: RegionScope ;
105
105
use session:: Session ;
106
- use { CrateCtxt , lookup_def_ccx , require_same_types} ;
106
+ use { CrateCtxt , lookup_full_def , require_same_types} ;
107
107
use TypeAndSubsts ;
108
108
use lint;
109
109
use util:: common:: { block_query, indenter, loop_query} ;
@@ -3397,7 +3397,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3397
3397
ast:: ExprPath ( None , ref path) => {
3398
3398
// FIXME(pcwalton): For now we hardcode the two permissible
3399
3399
// places: the exchange heap and the managed heap.
3400
- let definition = lookup_def ( fcx , path. span , place. id ) ;
3400
+ let definition = lookup_full_def ( tcx , path. span , place. id ) ;
3401
3401
let def_id = definition. def_id ( ) ;
3402
3402
let referent_ty = fcx. expr_ty ( & * * subexpr) ;
3403
3403
if tcx. lang_items . exchange_heap ( ) == Some ( def_id) {
@@ -3880,14 +3880,14 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3880
3880
}
3881
3881
ast:: ExprStruct ( ref path, ref fields, ref base_expr) => {
3882
3882
// Resolve the path.
3883
- let def = tcx . def_map . borrow ( ) . get ( & id ) . map ( |d| d . full_def ( ) ) ;
3883
+ let def = lookup_full_def ( tcx , path . span , id ) ;
3884
3884
let struct_id = match def {
3885
- Some ( def:: DefVariant ( enum_id, variant_id, true ) ) => {
3885
+ def:: DefVariant ( enum_id, variant_id, true ) => {
3886
3886
check_struct_enum_variant ( fcx, id, expr. span , enum_id,
3887
3887
variant_id, & fields[ ..] ) ;
3888
3888
enum_id
3889
3889
}
3890
- Some ( def:: DefTrait ( def_id) ) => {
3890
+ def:: DefTrait ( def_id) => {
3891
3891
span_err ! ( tcx. sess, path. span, E0159 ,
3892
3892
"use of trait `{}` as a struct constructor" ,
3893
3893
pprust:: path_to_string( path) ) ;
@@ -3897,7 +3897,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3897
3897
base_expr) ;
3898
3898
def_id
3899
3899
} ,
3900
- Some ( def) => {
3900
+ def => {
3901
3901
// Verify that this was actually a struct.
3902
3902
let typ = ty:: lookup_item_type ( fcx. ccx . tcx , def. def_id ( ) ) ;
3903
3903
match typ. ty . sty {
@@ -3922,10 +3922,6 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3922
3922
3923
3923
def. def_id ( )
3924
3924
}
3925
- _ => {
3926
- tcx. sess . span_bug ( path. span ,
3927
- "structure constructor wasn't resolved" )
3928
- }
3929
3925
} ;
3930
3926
3931
3927
// Turn the path into a type and verify that that type unifies with
@@ -4639,10 +4635,6 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
4639
4635
check_instantiable ( ccx. tcx , sp, id) ;
4640
4636
}
4641
4637
4642
- pub fn lookup_def ( fcx : & FnCtxt , sp : Span , id : ast:: NodeId ) -> def:: Def {
4643
- lookup_def_ccx ( fcx. ccx , sp, id)
4644
- }
4645
-
4646
4638
// Returns the type parameter count and the type for the given definition.
4647
4639
fn type_scheme_and_predicates_for_def < ' a , ' tcx > ( fcx : & FnCtxt < ' a , ' tcx > ,
4648
4640
sp : Span ,
@@ -5167,18 +5159,15 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &ast::Block) -> bool {
5167
5159
_ => false
5168
5160
}
5169
5161
} ) ) ||
5170
- // Second: is there a labeled break with label
5171
- // <id> nested anywhere inside the loop?
5162
+ // Second: is there a labeled break with label
5163
+ // <id> nested anywhere inside the loop?
5172
5164
( block_query ( b, |e| {
5173
- match e. node {
5174
- ast:: ExprBreak ( Some ( _) ) => {
5175
- match cx. def_map . borrow ( ) . get ( & e. id ) . map ( |d| d. full_def ( ) ) {
5176
- Some ( def:: DefLabel ( loop_id) ) if id == loop_id => true ,
5177
- _ => false ,
5178
- }
5179
- }
5180
- _ => false
5181
- } } ) )
5165
+ if let ast:: ExprBreak ( Some ( _) ) = e. node {
5166
+ lookup_full_def ( cx, e. span , e. id ) == def:: DefLabel ( id)
5167
+ } else {
5168
+ false
5169
+ }
5170
+ } ) )
5182
5171
}
5183
5172
5184
5173
pub fn check_bounds_are_used < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
0 commit comments