Skip to content

Commit bd77fbf

Browse files
authored
Rollup merge of #92112 - SparrowLii:issue92010, r=cjgillot
Fix the error of checking `base_expr` twice in type_changing_struct_update Fixes #92010
2 parents b57a6b3 + 6434844 commit bd77fbf

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Diff for: compiler/rustc_typeck/src/check/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15081508
}
15091509
} else {
15101510
self.check_expr_has_type_or_error(base_expr, adt_ty, |_| {
1511-
let base_ty = self.check_expr(base_expr);
1511+
let base_ty = self.typeck_results.borrow().node_type(base_expr.hir_id);
15121512
let same_adt = match (adt_ty.kind(), base_ty.kind()) {
15131513
(ty::Adt(adt, _), ty::Adt(base_adt, _)) if adt == base_adt => true,
15141514
_ => false,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#[derive(Clone)]
2+
struct P<T> {
3+
x: T,
4+
y: f64,
5+
}
6+
7+
impl<T> P<T> {
8+
fn y(&self, y: f64) -> Self { P{y, .. self.clone() } }
9+
//~^ mismatched types [E0308]
10+
}
11+
12+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-92010-trait-bound-not-satisfied.rs:8:43
3+
|
4+
LL | fn y(&self, y: f64) -> Self { P{y, .. self.clone() } }
5+
| ^^^^^^^^^^^^ expected struct `P`, found `&P<T>`
6+
|
7+
= note: expected struct `P<T>`
8+
found reference `&P<T>`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)