]> git.lizzy.rs Git - rust.git/commit
Do not suggest `;` if expression is side effect free
authorEsteban Küber <esteban@kuber.com.ar>
Fri, 5 Feb 2021 01:36:06 +0000 (17:36 -0800)
committerEsteban Küber <esteban@kuber.com.ar>
Mon, 22 Feb 2021 00:34:37 +0000 (16:34 -0800)
commitd669882f386e26d214284fbe8f7696519b802778
treeed34cebfa34e64eced6e6f0bc9a572d99f169bb5
parent020edd91a911cebf8aeada9f04dff047dc76171e
Do not suggest `;` if expression is side effect free

When a tail expression isn't unit, we previously always suggested adding
a trailing `;` to turn it into a statement. This suggestion isn't
appropriate for any expression that doesn't have side-effects, as the
user will have likely wanted to call something else or do something with
the resulting value, instead of just discarding it.
compiler/rustc_hir/src/hir.rs
compiler/rustc_typeck/src/check/coercion.rs
compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs
src/test/ui/block-result/block-must-not-have-result-while.stderr
src/test/ui/parser/expr-as-stmt-2.stderr
src/test/ui/parser/struct-literal-variant-in-if.stderr
src/test/ui/return/tail-expr-as-potential-return.stderr
src/test/ui/suggestions/match-needing-semi.fixed [deleted file]
src/test/ui/suggestions/match-needing-semi.rs
src/test/ui/suggestions/match-needing-semi.stderr