Don't suggest deref macro since it's unstable
This commit is contained in:
parent
2d633317f3
commit
a4db3ffdcb
@ -1592,18 +1592,23 @@ fn smart_resolve_context_dependent_help(
|
|||||||
|
|
||||||
match (res, source) {
|
match (res, source) {
|
||||||
(
|
(
|
||||||
Res::Def(DefKind::Macro(MacroKind::Bang), _),
|
Res::Def(DefKind::Macro(MacroKind::Bang), def_id),
|
||||||
PathSource::Expr(Some(Expr {
|
PathSource::Expr(Some(Expr {
|
||||||
kind: ExprKind::Index(..) | ExprKind::Call(..), ..
|
kind: ExprKind::Index(..) | ExprKind::Call(..), ..
|
||||||
}))
|
}))
|
||||||
| PathSource::Struct,
|
| 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());
|
err.span_label(span, fallback_label.to_string());
|
||||||
|
|
||||||
// Don't suggest `!` for a macro invocation if there are generic args
|
// Don't suggest `!` for a macro invocation if there are generic args
|
||||||
if path
|
if path
|
||||||
.last()
|
.last()
|
||||||
.is_some_and(|segment| !segment.has_generic_args && !segment.has_lifetime_args)
|
.is_some_and(|segment| !segment.has_generic_args && !segment.has_lifetime_args)
|
||||||
|
&& suggestable
|
||||||
{
|
{
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
|
@ -32,10 +32,6 @@ error[E0423]: expected function, found macro `deref`
|
|||||||
LL | deref(p);
|
LL | deref(p);
|
||||||
| ^^^^^ not a function
|
| ^^^^^ not a function
|
||||||
|
|
|
|
||||||
help: use `!` to invoke the macro
|
|
||||||
|
|
|
||||||
LL | deref!(p);
|
|
||||||
| +
|
|
||||||
help: use the `.` operator to call the method `Deref::deref` on `&&()`
|
help: use the `.` operator to call the method `Deref::deref` on `&&()`
|
||||||
|
|
|
|
||||||
LL - deref(p);
|
LL - deref(p);
|
||||||
|
Loading…
Reference in New Issue
Block a user