summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_resolve/src/macros.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /compiler/rustc_resolve/src/macros.rs
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_resolve/src/macros.rs')
-rw-r--r--compiler/rustc_resolve/src/macros.rs62
1 files changed, 37 insertions, 25 deletions
diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs
index 90ae08ce3..2ff6fb424 100644
--- a/compiler/rustc_resolve/src/macros.rs
+++ b/compiler/rustc_resolve/src/macros.rs
@@ -748,33 +748,45 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
path_res @ (PathResult::NonModule(..) | PathResult::Failed { .. }) => {
let mut suggestion = None;
- let (span, label, module) = if let PathResult::Failed { span, label, module, .. } = path_res {
- // try to suggest if it's not a macro, maybe a function
- if let PathResult::NonModule(partial_res) = self.maybe_resolve_path(&path, Some(ValueNS), &parent_scope)
- && partial_res.unresolved_segments() == 0 {
- let sm = self.tcx.sess.source_map();
- let exclamation_span = sm.next_point(span);
- suggestion = Some((
- vec![(exclamation_span, "".to_string())],
- format!("{} is not a macro, but a {}, try to remove `!`", Segment::names_to_string(&path), partial_res.base_res().descr()),
- Applicability::MaybeIncorrect
+ let (span, label, module) =
+ if let PathResult::Failed { span, label, module, .. } = path_res {
+ // try to suggest if it's not a macro, maybe a function
+ if let PathResult::NonModule(partial_res) =
+ self.maybe_resolve_path(&path, Some(ValueNS), &parent_scope)
+ && partial_res.unresolved_segments() == 0
+ {
+ let sm = self.tcx.sess.source_map();
+ let exclamation_span = sm.next_point(span);
+ suggestion = Some((
+ vec![(exclamation_span, "".to_string())],
+ format!(
+ "{} is not a macro, but a {}, try to remove `!`",
+ Segment::names_to_string(&path),
+ partial_res.base_res().descr()
+ ),
+ Applicability::MaybeIncorrect,
));
- }
- (span, label, module)
- } else {
- (
- path_span,
- format!(
- "partially resolved path in {} {}",
- kind.article(),
- kind.descr()
- ),
- None,
- )
- };
+ }
+ (span, label, module)
+ } else {
+ (
+ path_span,
+ format!(
+ "partially resolved path in {} {}",
+ kind.article(),
+ kind.descr()
+ ),
+ None,
+ )
+ };
self.report_error(
span,
- ResolutionError::FailedToResolve { last_segment: path.last().map(|segment| segment.ident.name), label, suggestion, module },
+ ResolutionError::FailedToResolve {
+ last_segment: path.last().map(|segment| segment.ident.name),
+ label,
+ suggestion,
+ module,
+ },
);
}
PathResult::Module(..) | PathResult::Indeterminate => unreachable!(),
@@ -854,7 +866,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let feature = stability.feature;
let is_allowed = |feature| {
- self.active_features.contains(&feature) || span.allows_unstable(feature)
+ self.declared_features.contains(&feature) || span.allows_unstable(feature)
};
let allowed_by_implication = implied_by.is_some_and(|feature| is_allowed(feature));
if !is_allowed(feature) && !allowed_by_implication {