Skip to content

Commit 3f38b99

Browse files
authored
Rollup merge of #71810 - estebank:issue-71798, r=davidtwco
Do not try to find binop method on RHS `TyErr` Fix #71798.
2 parents 35e7745 + 16a0349 commit 3f38b99

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/librustc_typeck/check/op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
251251
}
252252
Err(()) => {
253253
// error types are considered "builtin"
254-
if !lhs_ty.references_error() {
254+
if !lhs_ty.references_error() && !rhs_ty.references_error() {
255255
let source_map = self.tcx.sess.source_map();
256256
match is_assign {
257257
IsAssign::Yes => {

src/test/ui/issues-71798.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ {
2+
*x //~^ ERROR the trait bound `u32: std::future::Future` is not satisfied
3+
}
4+
5+
fn main() {
6+
let _ = test_ref & u; //~ ERROR cannot find value `u` in this scope
7+
}

src/test/ui/issues-71798.stderr

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0425]: cannot find value `u` in this scope
2+
--> $DIR/issues-71798.rs:6:24
3+
|
4+
LL | let _ = test_ref & u;
5+
| ^ not found in this scope
6+
7+
error[E0277]: the trait bound `u32: std::future::Future` is not satisfied
8+
--> $DIR/issues-71798.rs:1:25
9+
|
10+
LL | fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `u32`
12+
LL | *x
13+
| -- this returned value is of type `u32`
14+
|
15+
= note: the return type of a function must have a statically known size
16+
17+
error: aborting due to 2 previous errors
18+
19+
Some errors have detailed explanations: E0277, E0425.
20+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)