-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Detect missing derive
on unresolved attribute even when not imported
#142487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2014,6 +2014,16 @@ impl CrateMetadata { | |
self.root.is_proc_macro_crate() | ||
} | ||
|
||
pub(crate) fn proc_macros_for_crate(&self, krate: CrateNum, cstore: &CStore) -> Vec<DefId> { | ||
let Some(data) = self.root.proc_macro_data.as_ref() else { | ||
return vec![]; | ||
}; | ||
data.macros | ||
.decode(CrateMetadataRef { cdata: self, cstore }) | ||
.map(|index| DefId { index, krate }) | ||
.collect() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can return an iterator using |
||
} | ||
|
||
pub(crate) fn name(&self) -> Symbol { | ||
self.root.header.name | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,6 +210,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | |
} | ||
} | ||
|
||
/// Add every proc macro accessible from the current crate to the `macro_map` so diagnostics can | ||
/// find them for suggestions. | ||
pub(crate) fn register_macros_for_all_crates(&mut self) { | ||
if self.all_crate_macros_already_registered { | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
} | ||
self.all_crate_macros_already_registered = true; | ||
let def_ids = self.cstore().all_proc_macro_def_ids(); | ||
for def_id in def_ids { | ||
self.get_macro_by_def_id(def_id); | ||
} | ||
} | ||
|
||
pub(crate) fn build_reduced_graph( | ||
&mut self, | ||
fragment: &AstFragment, | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1266,6 +1266,10 @@ pub struct Resolver<'ra, 'tcx> { | |||||
|
||||||
mods_with_parse_errors: FxHashSet<DefId>, | ||||||
|
||||||
/// Whether `Resolver::register_macros_for_all_crates` has been called once already, as we | ||||||
/// don't need to run it more than once. | ||||||
all_crate_macros_already_registered: bool, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
// Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types | ||||||
// that were encountered during resolution. These names are used to generate item names | ||||||
// for APITs, so we don't want to leak details of resolution into these names. | ||||||
|
@@ -1662,6 +1666,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | |||||
all_macro_rules: Default::default(), | ||||||
delegation_fn_sigs: Default::default(), | ||||||
glob_delegation_invoc_ids: Default::default(), | ||||||
all_crate_macros_already_registered: false, | ||||||
impl_unexpanded_invocations: Default::default(), | ||||||
impl_binding_keys: Default::default(), | ||||||
current_crate_outer_attr_insert_span, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also can return an iterator.