Rollup merge of #93061 - estebank:macr-suggestion, r=cjgillot
Only suggest adding `!` to expressions that can be macro invocation
This commit is contained in:
commit
dc393b2ecc
6 changed files with 82 additions and 24 deletions
|
@ -2517,6 +2517,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||
self.visit_expr(elem);
|
||||
self.resolve_anon_const(ct, IsRepeatExpr::Yes);
|
||||
}
|
||||
ExprKind::Index(ref elem, ref idx) => {
|
||||
self.resolve_expr(elem, Some(expr));
|
||||
self.visit_expr(idx);
|
||||
}
|
||||
_ => {
|
||||
visit::walk_expr(self, expr);
|
||||
}
|
||||
|
|
|
@ -970,7 +970,13 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
};
|
||||
|
||||
match (res, source) {
|
||||
(Res::Def(DefKind::Macro(MacroKind::Bang), _), _) => {
|
||||
(
|
||||
Res::Def(DefKind::Macro(MacroKind::Bang), _),
|
||||
PathSource::Expr(Some(Expr {
|
||||
kind: ExprKind::Index(..) | ExprKind::Call(..), ..
|
||||
}))
|
||||
| PathSource::Struct,
|
||||
) => {
|
||||
err.span_label(span, fallback_label);
|
||||
err.span_suggestion_verbose(
|
||||
span.shrink_to_hi(),
|
||||
|
@ -982,6 +988,9 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
err.note("if you want the `try` keyword, you need Rust 2018 or later");
|
||||
}
|
||||
}
|
||||
(Res::Def(DefKind::Macro(MacroKind::Bang), _), _) => {
|
||||
err.span_label(span, fallback_label);
|
||||
}
|
||||
(Res::Def(DefKind::TyAlias, def_id), PathSource::Trait(_)) => {
|
||||
err.span_label(span, "type aliases cannot be used as traits");
|
||||
if self.r.session.is_nightly_build() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue