@@ -2154,6 +2154,10 @@ pub fn autoderef<T>(fcx: &FnCtxt, sp: Span, base_ty: ty::t,
2154
2154
for autoderefs in range( 0 , fcx. tcx( ) . sess. recursion_limit. get( ) ) {
2155
2155
let resolved_t = structurally_resolved_type( fcx, sp, t) ;
2156
2156
2157
+ if ty:: type_is_bot( resolved_t) {
2158
+ return ( resolved_t, autoderefs, None ) ;
2159
+ }
2160
+
2157
2161
match should_stop( resolved_t, autoderefs) {
2158
2162
Some ( x) => return ( resolved_t, autoderefs, Some ( x) ) ,
2159
2163
None => { }
@@ -3951,13 +3955,18 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
3951
3955
check_expr_with_expectation_and_lvalue_pref (
3952
3956
fcx, & * * oprnd, expected_inner, lvalue_pref) ;
3953
3957
let mut oprnd_t = fcx. expr_ty ( & * * oprnd) ;
3954
- if !ty:: type_is_error ( oprnd_t) && !ty:: type_is_bot ( oprnd_t) {
3958
+
3959
+ if !ty:: type_is_error ( oprnd_t) {
3955
3960
match unop {
3956
3961
ast:: UnBox => {
3957
- oprnd_t = ty:: mk_box ( tcx, oprnd_t)
3962
+ if !ty:: type_is_bot ( oprnd_t) {
3963
+ oprnd_t = ty:: mk_box ( tcx, oprnd_t)
3964
+ }
3958
3965
}
3959
3966
ast:: UnUniq => {
3960
- oprnd_t = ty:: mk_uniq ( tcx, oprnd_t) ;
3967
+ if !ty:: type_is_bot ( oprnd_t) {
3968
+ oprnd_t = ty:: mk_uniq ( tcx, oprnd_t) ;
3969
+ }
3961
3970
}
3962
3971
ast:: UnDeref => {
3963
3972
oprnd_t = structurally_resolved_type ( fcx, expr. span , oprnd_t) ;
@@ -3994,23 +4003,27 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
3994
4003
} ;
3995
4004
}
3996
4005
ast:: UnNot => {
3997
- oprnd_t = structurally_resolved_type ( fcx, oprnd. span ,
3998
- oprnd_t) ;
3999
- if !( ty:: type_is_integral ( oprnd_t) ||
4000
- ty:: get ( oprnd_t) . sty == ty:: ty_bool) {
4001
- oprnd_t = check_user_unop ( fcx, "!" , "not" ,
4002
- tcx. lang_items . not_trait ( ) ,
4003
- expr, & * * oprnd, oprnd_t) ;
4006
+ if !ty:: type_is_bot ( oprnd_t) {
4007
+ oprnd_t = structurally_resolved_type ( fcx, oprnd. span ,
4008
+ oprnd_t) ;
4009
+ if !( ty:: type_is_integral ( oprnd_t) ||
4010
+ ty:: get ( oprnd_t) . sty == ty:: ty_bool) {
4011
+ oprnd_t = check_user_unop ( fcx, "!" , "not" ,
4012
+ tcx. lang_items . not_trait ( ) ,
4013
+ expr, & * * oprnd, oprnd_t) ;
4014
+ }
4004
4015
}
4005
4016
}
4006
4017
ast:: UnNeg => {
4007
- oprnd_t = structurally_resolved_type ( fcx, oprnd. span ,
4008
- oprnd_t) ;
4009
- if !( ty:: type_is_integral ( oprnd_t) ||
4010
- ty:: type_is_fp ( oprnd_t) ) {
4011
- oprnd_t = check_user_unop ( fcx, "-" , "neg" ,
4012
- tcx. lang_items . neg_trait ( ) ,
4013
- expr, & * * oprnd, oprnd_t) ;
4018
+ if !ty:: type_is_bot ( oprnd_t) {
4019
+ oprnd_t = structurally_resolved_type ( fcx, oprnd. span ,
4020
+ oprnd_t) ;
4021
+ if !( ty:: type_is_integral ( oprnd_t) ||
4022
+ ty:: type_is_fp ( oprnd_t) ) {
4023
+ oprnd_t = check_user_unop ( fcx, "-" , "neg" ,
4024
+ tcx. lang_items . neg_trait ( ) ,
4025
+ expr, & * * oprnd, oprnd_t) ;
4026
+ }
4014
4027
}
4015
4028
}
4016
4029
}
@@ -4468,21 +4481,21 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
4468
4481
check_expr ( fcx, & * * idx) ;
4469
4482
let raw_base_t = fcx. expr_ty ( & * * base) ;
4470
4483
let idx_t = fcx. expr_ty ( & * * idx) ;
4471
- if ty:: type_is_error ( raw_base_t) || ty :: type_is_bot ( raw_base_t ) {
4484
+ if ty:: type_is_error ( raw_base_t) {
4472
4485
fcx. write_ty ( id, raw_base_t) ;
4473
- } else if ty:: type_is_error ( idx_t) || ty :: type_is_bot ( idx_t ) {
4486
+ } else if ty:: type_is_error ( idx_t) {
4474
4487
fcx. write_ty ( id, idx_t) ;
4475
4488
} else {
4476
4489
let ( _, autoderefs, field_ty) =
4477
4490
autoderef ( fcx, expr. span , raw_base_t, Some ( base. id ) ,
4478
4491
lvalue_pref, |base_t, _| ty:: index ( base_t) ) ;
4479
4492
match field_ty {
4480
- Some ( ty) => {
4493
+ Some ( ty) if !ty :: type_is_bot ( ty ) => {
4481
4494
check_expr_has_type ( fcx, & * * idx, ty:: mk_uint ( ) ) ;
4482
4495
fcx. write_ty ( id, ty) ;
4483
4496
fcx. write_autoderef_adjustment ( base. id , base. span , autoderefs) ;
4484
4497
}
4485
- None => {
4498
+ _ => {
4486
4499
// This is an overloaded method.
4487
4500
let base_t = structurally_resolved_type ( fcx,
4488
4501
expr. span ,
0 commit comments