Rollup merge of #82090 - notriddle:consider-using-a-semicolon-here, r=estebank
Do not consider using a semicolon inside of a different-crate macro Fixes #81943
This commit is contained in:
commit
6b06e57f5f
5 changed files with 83 additions and 2 deletions
|
@ -42,6 +42,7 @@ use rustc_hir as hir;
|
|||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use rustc_infer::infer::{Coercion, InferOk, InferResult};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_middle::ty::adjustment::{
|
||||
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, PointerCast,
|
||||
};
|
||||
|
@ -1448,7 +1449,12 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
|||
expected.is_unit(),
|
||||
pointing_at_return_type,
|
||||
) {
|
||||
if cond_expr.span.desugaring_kind().is_none() {
|
||||
// If the block is from an external macro, then do not suggest
|
||||
// adding a semicolon, because there's nowhere to put it.
|
||||
// See issue #81943.
|
||||
if cond_expr.span.desugaring_kind().is_none()
|
||||
&& !in_external_macro(fcx.tcx.sess, cond_expr.span)
|
||||
{
|
||||
err.span_label(cond_expr.span, "expected this to be `()`");
|
||||
if expr.can_have_side_effects() {
|
||||
fcx.suggest_semicolon_at_end(cond_expr.span, &mut err);
|
||||
|
|
|
@ -10,6 +10,7 @@ use rustc_hir::def::{CtorOf, DefKind};
|
|||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_hir::{ExprKind, ItemKind, Node};
|
||||
use rustc_infer::infer;
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_span::symbol::kw;
|
||||
|
||||
|
@ -44,7 +45,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
blk_id: hir::HirId,
|
||||
) -> bool {
|
||||
let expr = expr.peel_drop_temps();
|
||||
if expr.can_have_side_effects() {
|
||||
// If the expression is from an external macro, then do not suggest
|
||||
// adding a semicolon, because there's nowhere to put it.
|
||||
// See issue #81943.
|
||||
if expr.can_have_side_effects() && !in_external_macro(self.tcx.sess, cause_span) {
|
||||
self.suggest_missing_semicolon(err, expr, expected, cause_span);
|
||||
}
|
||||
let mut pointing_at_return_type = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue