Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,7 @@ impl Expr<'_> {
.iter()
.map(|field| field.expr)
.chain(init.into_iter())
.all(|e| e.can_have_side_effects()),
.any(|e| e.can_have_side_effects()),

ExprKind::Array(args)
| ExprKind::Tup(args)
Expand All @@ -1857,7 +1857,7 @@ impl Expr<'_> {
..
},
args,
) => args.iter().all(|arg| arg.can_have_side_effects()),
) => args.iter().any(|arg| arg.can_have_side_effects()),
ExprKind::If(..)
| ExprKind::Match(..)
| ExprKind::MethodCall(..)
Expand Down
1 change: 0 additions & 1 deletion tests/ui/async-await/in-trait/return-type-suggestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ trait A {
async fn e() {
Ok(())
//~^ ERROR mismatched types
//~| HELP consider using a semicolon here
}
}

Expand Down
4 changes: 1 addition & 3 deletions tests/ui/async-await/in-trait/return-type-suggestion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ error[E0308]: mismatched types
--> $DIR/return-type-suggestion.rs:7:9
|
LL | Ok(())
| ^^^^^^- help: consider using a semicolon here: `;`
| |
| expected `()`, found `Result<(), _>`
| ^^^^^^ expected `()`, found `Result<(), _>`
|
= note: expected unit type `()`
found enum `Result<(), _>`
Expand Down
24 changes: 24 additions & 0 deletions tests/ui/return/return-struct.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
struct S;

enum Age {
Years(i64, i64)
}

fn foo() {
let mut age = 29;
Age::Years({age += 1; age}, 55)
//~^ ERROR mismatched types
}

fn bar() {
let mut age = 29;
Age::Years(age, 55)
//~^ ERROR mismatched types
}

fn baz() {
S
//~^ ERROR mismatched types
}

fn main() {}
35 changes: 35 additions & 0 deletions tests/ui/return/return-struct.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
error[E0308]: mismatched types
--> $DIR/return-struct.rs:9:5
|
LL | Age::Years({age += 1; age}, 55)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Age`
|
help: consider using a semicolon here
|
LL | Age::Years({age += 1; age}, 55);
| +
help: try adding a return type
|
LL | fn foo() -> Age {
| ++++++

error[E0308]: mismatched types
--> $DIR/return-struct.rs:15:5
|
LL | fn bar() {
| - help: try adding a return type: `-> Age`
LL | let mut age = 29;
LL | Age::Years(age, 55)
| ^^^^^^^^^^^^^^^^^^^ expected `()`, found `Age`

error[E0308]: mismatched types
--> $DIR/return-struct.rs:20:5
|
LL | fn baz() {
| - help: try adding a return type: `-> S`
LL | S
| ^ expected `()`, found `S`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0308`.