Skip to content

Commit

Permalink
Don't suggest deref macro since it's unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Mar 20, 2024
1 parent 0e954cd commit 33292c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 6 additions & 1 deletion compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1604,18 +1604,23 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {

match (res, source) {
(
Res::Def(DefKind::Macro(MacroKind::Bang), _),
Res::Def(DefKind::Macro(MacroKind::Bang), def_id),
PathSource::Expr(Some(Expr {
kind: ExprKind::Index(..) | ExprKind::Call(..), ..
}))
| PathSource::Struct,
) => {
// Don't suggest macro if it's unstable.
let suggestable = def_id.is_local()
|| self.r.tcx.lookup_stability(def_id).map_or(true, |s| s.is_stable());

err.span_label(span, fallback_label.to_string());

// Don't suggest `!` for a macro invocation if there are generic args
if path
.last()
.is_some_and(|segment| !segment.has_generic_args && !segment.has_lifetime_args)
&& suggestable
{
err.span_suggestion_verbose(
span.shrink_to_hi(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ error[E0423]: expected function, found macro `deref`
LL | deref(p);
| ^^^^^ not a function
|
help: use `!` to invoke the macro
|
LL | deref!(p);
| +
help: use the `.` operator to call the method `Deref::deref` on `&&()`
|
LL - deref(p);
Expand Down

0 comments on commit 33292c3

Please sign in to comment.