-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #103797 - Dylan-DPC:rollup-ps589fi, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #103338 (Fix unreachable_pub suggestion for enum with fields) - #103603 (Lang item cleanups) - #103732 (Revert "Make the `c` feature for `compiler-builtins` opt-in instead of inferred") - #103766 (Add tracking issue to `error_in_core`) - #103789 (Update E0382.md) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
49 changed files
with
300 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,31 @@ | ||
//! Validity checking for weak lang items | ||
|
||
use crate::def_id::DefId; | ||
use crate::{lang_items, LangItem, LanguageItems}; | ||
use crate::LangItem; | ||
|
||
use rustc_ast as ast; | ||
use rustc_data_structures::fx::FxIndexMap; | ||
use rustc_span::symbol::{sym, Symbol}; | ||
|
||
use std::sync::LazyLock; | ||
|
||
macro_rules! weak_lang_items { | ||
($($name:ident, $item:ident, $sym:ident;)*) => ( | ||
|
||
pub static WEAK_ITEMS_REFS: LazyLock<FxIndexMap<Symbol, LangItem>> = LazyLock::new(|| { | ||
let mut map = FxIndexMap::default(); | ||
$(map.insert(sym::$name, LangItem::$item);)* | ||
map | ||
}); | ||
|
||
pub static WEAK_ITEMS_SYMBOLS: LazyLock<FxIndexMap<LangItem, Symbol>> = LazyLock::new(|| { | ||
let mut map = FxIndexMap::default(); | ||
$(map.insert(LangItem::$item, sym::$sym);)* | ||
map | ||
}); | ||
|
||
pub fn link_name(attrs: &[ast::Attribute]) -> Option<Symbol> | ||
{ | ||
lang_items::extract(attrs).and_then(|(name, _)| { | ||
$(if name == sym::$name { | ||
Some(sym::$sym) | ||
} else)* { | ||
None | ||
($($item:ident, $sym:ident;)*) => { | ||
pub static WEAK_LANG_ITEMS: &[LangItem] = &[$(LangItem::$item,)*]; | ||
|
||
impl LangItem { | ||
pub fn is_weak(self) -> bool { | ||
matches!(self, $(LangItem::$item)|*) | ||
} | ||
|
||
pub fn link_name(self) -> Option<Symbol> { | ||
match self { | ||
$( LangItem::$item => Some(sym::$sym),)* | ||
_ => None, | ||
} | ||
} | ||
} | ||
}) | ||
} | ||
|
||
impl LanguageItems { | ||
pub fn is_weak_lang_item(&self, item_def_id: DefId) -> bool { | ||
let did = Some(item_def_id); | ||
|
||
$(self.$name() == did)||* | ||
} | ||
} | ||
|
||
) } | ||
|
||
weak_lang_items! { | ||
panic_impl, PanicImpl, rust_begin_unwind; | ||
eh_personality, EhPersonality, rust_eh_personality; | ||
eh_catch_typeinfo, EhCatchTypeinfo, rust_eh_catch_typeinfo; | ||
oom, Oom, rust_oom; | ||
PanicImpl, rust_begin_unwind; | ||
EhPersonality, rust_eh_personality; | ||
EhCatchTypeinfo, rust_eh_catch_typeinfo; | ||
Oom, rust_oom; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.