Skip to content

Commit 72be1e3

Browse files
Don't suggest deref macro since it's unstable
1 parent ea14acd commit 72be1e3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1604,18 +1604,23 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
16041604

16051605
match (res, source) {
16061606
(
1607-
Res::Def(DefKind::Macro(MacroKind::Bang), _),
1607+
Res::Def(DefKind::Macro(MacroKind::Bang), def_id),
16081608
PathSource::Expr(Some(Expr {
16091609
kind: ExprKind::Index(..) | ExprKind::Call(..), ..
16101610
}))
16111611
| PathSource::Struct,
16121612
) => {
1613+
// Don't suggest macro if it's unstable.
1614+
let suggestable = def_id.is_local()
1615+
|| self.r.tcx.lookup_stability(def_id).map_or(true, |s| s.is_stable());
1616+
16131617
err.span_label(span, fallback_label.to_string());
16141618

16151619
// Don't suggest `!` for a macro invocation if there are generic args
16161620
if path
16171621
.last()
16181622
.is_some_and(|segment| !segment.has_generic_args && !segment.has_lifetime_args)
1623+
&& suggestable
16191624
{
16201625
err.span_suggestion_verbose(
16211626
span.shrink_to_hi(),

tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr

-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ error[E0423]: expected function, found macro `deref`
3232
LL | deref(p);
3333
| ^^^^^ not a function
3434
|
35-
help: use `!` to invoke the macro
36-
|
37-
LL | deref!(p);
38-
| +
3935
help: use the `.` operator to call the method `Deref::deref` on `&&()`
4036
|
4137
LL - deref(p);

0 commit comments

Comments
 (0)