-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Fix for ICE: eii: fn / macro rules None in find_attr() #150822
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
Changes from all commits
3c8265a
5e5c724
e3cff18
5ddda0c
52b3ac4
7791bc2
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 |
|---|---|---|
|
|
@@ -3,7 +3,9 @@ use std::str::FromStr; | |
| use rustc_abi::{Align, ExternAbi}; | ||
| use rustc_ast::expand::autodiff_attrs::{AutoDiffAttrs, DiffActivity, DiffMode}; | ||
| use rustc_ast::{LitKind, MetaItem, MetaItemInner, attr}; | ||
| use rustc_hir::attrs::{AttributeKind, InlineAttr, Linkage, RtsanSetting, UsedBy}; | ||
| use rustc_hir::attrs::{ | ||
| AttributeKind, EiiImplResolution, InlineAttr, Linkage, RtsanSetting, UsedBy, | ||
| }; | ||
| use rustc_hir::def::DefKind; | ||
| use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId}; | ||
| use rustc_hir::{self as hir, Attribute, LangItem, find_attr, lang_items}; | ||
|
|
@@ -285,11 +287,23 @@ fn process_builtin_attrs( | |
| } | ||
| AttributeKind::EiiImpls(impls) => { | ||
| for i in impls { | ||
| let extern_item = find_attr!( | ||
| tcx.get_all_attrs(i.eii_macro), | ||
| AttributeKind::EiiExternTarget(target) => target.eii_extern_target | ||
| ) | ||
| .expect("eii should have declaration macro with extern target attribute"); | ||
| let extern_item = match i.resolution { | ||
| EiiImplResolution::Macro(def_id) => { | ||
| let Some(extern_item) = find_attr!( | ||
| tcx.get_all_attrs(def_id), | ||
| AttributeKind::EiiExternTarget(target) => target.eii_extern_target | ||
| ) else { | ||
| tcx.dcx().span_delayed_bug( | ||
| i.span, | ||
| "resolved to something that's not an EII", | ||
| ); | ||
| continue; | ||
| }; | ||
| extern_item | ||
| } | ||
| EiiImplResolution::Known(decl) => decl.eii_extern_target, | ||
| EiiImplResolution::Error(_eg) => continue, | ||
|
Member
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. was this also it would be nice to clean up this unusable variables a bit
Contributor
Author
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. no, it's just a good reminder that if we get there, we're allowed to skip it because an error is already emitted.
Contributor
Author
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. And yea, the eg is technically never used. I just wanted to make sure for myself I wouldn't accidentally skip EIIs without having a very good reason for it
Member
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. yeah, that makes sense, will continue looking into this pr, not sure how much time it will take, i hopefully might finish it later today (it's a jan 9th and it's a bit late at my place) i dit a quick glance a first 4-5 commits, looks fine overall
Contributor
Author
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. thanks kivoo! You're amazing |
||
| }; | ||
|
|
||
| // this is to prevent a bug where a single crate defines both the default and explicit implementation | ||
| // for an EII. In that case, both of them may be part of the same final object file. I'm not 100% sure | ||
|
|
@@ -302,7 +316,7 @@ fn process_builtin_attrs( | |
| // iterate over all implementations *in the current crate* | ||
| // (this is ok since we generate codegen fn attrs in the local crate) | ||
| // if any of them is *not default* then don't emit the alias. | ||
| && tcx.externally_implementable_items(LOCAL_CRATE).get(&i.eii_macro).expect("at least one").1.iter().any(|(_, imp)| !imp.is_default) | ||
| && tcx.externally_implementable_items(LOCAL_CRATE).get(&extern_item).expect("at least one").1.iter().any(|(_, imp)| !imp.is_default) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.