@@ -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} ;
@@ -3401,7 +3401,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3401
3401
ast:: ExprPath ( None , ref path) => {
3402
3402
// FIXME(pcwalton): For now we hardcode the two permissible
3403
3403
// places: the exchange heap and the managed heap.
3404
- let definition = lookup_def ( fcx , path. span , place. id ) ;
3404
+ let definition = lookup_full_def ( tcx , path. span , place. id ) ;
3405
3405
let def_id = definition. def_id ( ) ;
3406
3406
let referent_ty = fcx. expr_ty ( & * * subexpr) ;
3407
3407
if tcx. lang_items . exchange_heap ( ) == Some ( def_id) {
@@ -3884,14 +3884,14 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3884
3884
}
3885
3885
ast:: ExprStruct ( ref path, ref fields, ref base_expr) => {
3886
3886
// Resolve the path.
3887
- let def = tcx . def_map . borrow ( ) . get ( & id ) . map ( |d| d . full_def ( ) ) ;
3887
+ let def = lookup_full_def ( tcx , path . span , id ) ;
3888
3888
let struct_id = match def {
3889
- Some ( def:: DefVariant ( enum_id, variant_id, true ) ) => {
3889
+ def:: DefVariant ( enum_id, variant_id, true ) => {
3890
3890
check_struct_enum_variant ( fcx, id, expr. span , enum_id,
3891
3891
variant_id, & fields[ ..] ) ;
3892
3892
enum_id
3893
3893
}
3894
- Some ( def:: DefTrait ( def_id) ) => {
3894
+ def:: DefTrait ( def_id) => {
3895
3895
span_err ! ( tcx. sess, path. span, E0159 ,
3896
3896
"use of trait `{}` as a struct constructor" ,
3897
3897
pprust:: path_to_string( path) ) ;
@@ -3901,7 +3901,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3901
3901
base_expr) ;
3902
3902
def_id
3903
3903
} ,
3904
- Some ( def) => {
3904
+ def => {
3905
3905
// Verify that this was actually a struct.
3906
3906
let typ = ty:: lookup_item_type ( fcx. ccx . tcx , def. def_id ( ) ) ;
3907
3907
match typ. ty . sty {
@@ -3926,10 +3926,6 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3926
3926
3927
3927
def. def_id ( )
3928
3928
}
3929
- _ => {
3930
- tcx. sess . span_bug ( path. span ,
3931
- "structure constructor wasn't resolved" )
3932
- }
3933
3929
} ;
3934
3930
3935
3931
// Turn the path into a type and verify that that type unifies with
@@ -4643,10 +4639,6 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
4643
4639
check_instantiable ( ccx. tcx , sp, id) ;
4644
4640
}
4645
4641
4646
- pub fn lookup_def ( fcx : & FnCtxt , sp : Span , id : ast:: NodeId ) -> def:: Def {
4647
- lookup_def_ccx ( fcx. ccx , sp, id)
4648
- }
4649
-
4650
4642
// Returns the type parameter count and the type for the given definition.
4651
4643
fn type_scheme_and_predicates_for_def < ' a , ' tcx > ( fcx : & FnCtxt < ' a , ' tcx > ,
4652
4644
sp : Span ,
@@ -5171,18 +5163,15 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &ast::Block) -> bool {
5171
5163
_ => false
5172
5164
}
5173
5165
} ) ) ||
5174
- // Second: is there a labeled break with label
5175
- // <id> nested anywhere inside the loop?
5166
+ // Second: is there a labeled break with label
5167
+ // <id> nested anywhere inside the loop?
5176
5168
( block_query ( b, |e| {
5177
- match e. node {
5178
- ast:: ExprBreak ( Some ( _) ) => {
5179
- match cx. def_map . borrow ( ) . get ( & e. id ) . map ( |d| d. full_def ( ) ) {
5180
- Some ( def:: DefLabel ( loop_id) ) if id == loop_id => true ,
5181
- _ => false ,
5182
- }
5183
- }
5184
- _ => false
5185
- } } ) )
5169
+ if let ast:: ExprBreak ( Some ( _) ) = e. node {
5170
+ lookup_full_def ( cx, e. span , e. id ) == def:: DefLabel ( id)
5171
+ } else {
5172
+ false
5173
+ }
5174
+ } ) )
5186
5175
}
5187
5176
5188
5177
pub fn check_bounds_are_used < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
0 commit comments