Skip to content

Commit 9c1dfed

Browse files
committed
Use node_ty instead of expr_ty in binary expr fixup
1 parent 9e1a078 commit 9c1dfed

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/librustc_typeck/check/writeback.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
9292
// operating on scalars, we clear the overload.
9393
fn fix_scalar_binary_expr(&mut self, e: &ast::Expr) {
9494
if let ast::ExprBinary(ref op, ref lhs, ref rhs) = e.node {
95-
let lhs_ty = self.fcx.expr_ty(lhs.id);
95+
let lhs_ty = self.fcx.node_ty(lhs.id);
9696
let lhs_ty = self.fcx.infcx().resolve_type_vars_if_possible(&lhs_ty);
9797

98-
let rhs_ty = self.fcx.expr_ty(rhs.id);
98+
let rhs_ty = self.fcx.node_ty(rhs.id);
9999
let rhs_ty = self.fcx.infcx().resolve_type_vars_if_possible(&rhs_ty);
100100

101101
if ty::type_is_scalar(lhs_ty) && ty::type_is_scalar(rhs_ty) {

src/test/compile-fail/issue-24363.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
1.create_a_type_error[ //~ ERROR attempted access of field
13+
()+() //~ ERROR binary operation `+` cannot be applied
14+
// ^ ensure that we typeck the inner expression ^
15+
];
16+
}

0 commit comments

Comments
 (0)