Auto merge of #142777 - jdonszelmann:restore-encode-cross-crate, r=oli-obk
Encode hir attributes cross-crate properly r? `@oli-obk` This should return the lost perf in rust-lang/rust#138165 cc: `@therealprof`
This commit is contained in:
commit
0fa4ec6cde
6 changed files with 55 additions and 10 deletions
|
|
@ -3724,6 +3724,7 @@ dependencies = [
|
||||||
name = "rustc_feature"
|
name = "rustc_feature"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"rustc_attr_data_structures",
|
||||||
"rustc_data_structures",
|
"rustc_data_structures",
|
||||||
"rustc_span",
|
"rustc_span",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
use crate::AttributeKind;
|
||||||
|
|
||||||
|
#[derive(PartialEq)]
|
||||||
|
pub enum EncodeCrossCrate {
|
||||||
|
Yes,
|
||||||
|
No,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AttributeKind {
|
||||||
|
pub fn encode_cross_crate(&self) -> EncodeCrossCrate {
|
||||||
|
use AttributeKind::*;
|
||||||
|
use EncodeCrossCrate::*;
|
||||||
|
|
||||||
|
match self {
|
||||||
|
Align { .. } => No,
|
||||||
|
AllowConstFnUnstable(..) => No,
|
||||||
|
AllowInternalUnstable(..) => Yes,
|
||||||
|
AsPtr(..) => Yes,
|
||||||
|
BodyStability { .. } => No,
|
||||||
|
Confusables { .. } => Yes,
|
||||||
|
ConstStability { .. } => Yes,
|
||||||
|
ConstStabilityIndirect => No,
|
||||||
|
Deprecation { .. } => Yes,
|
||||||
|
DocComment { .. } => Yes,
|
||||||
|
Inline(..) => No,
|
||||||
|
MacroTransparency(..) => Yes,
|
||||||
|
Repr(..) => No,
|
||||||
|
Stability { .. } => Yes,
|
||||||
|
Cold(..) => No,
|
||||||
|
ConstContinue(..) => No,
|
||||||
|
LoopMatch(..) => No,
|
||||||
|
MayDangle(..) => No,
|
||||||
|
MustUse { .. } => Yes,
|
||||||
|
Naked(..) => No,
|
||||||
|
NoMangle(..) => No,
|
||||||
|
Optimize(..) => No,
|
||||||
|
PubTransparent(..) => Yes,
|
||||||
|
SkipDuringMethodDispatch { .. } => No,
|
||||||
|
TrackCaller(..) => Yes,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
mod attributes;
|
mod attributes;
|
||||||
|
mod encode_cross_crate;
|
||||||
mod stability;
|
mod stability;
|
||||||
mod version;
|
mod version;
|
||||||
|
|
||||||
|
|
@ -17,6 +18,7 @@ pub mod lints;
|
||||||
use std::num::NonZero;
|
use std::num::NonZero;
|
||||||
|
|
||||||
pub use attributes::*;
|
pub use attributes::*;
|
||||||
|
pub use encode_cross_crate::EncodeCrossCrate;
|
||||||
use rustc_abi::Align;
|
use rustc_abi::Align;
|
||||||
use rustc_ast::token::CommentKind;
|
use rustc_ast::token::CommentKind;
|
||||||
use rustc_ast::{AttrStyle, IntTy, UintTy};
|
use rustc_ast::{AttrStyle, IntTy, UintTy};
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@ edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# tidy-alphabetical-start
|
# tidy-alphabetical-start
|
||||||
|
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||||
rustc_span = { path = "../rustc_span" }
|
rustc_span = { path = "../rustc_span" }
|
||||||
serde = { version = "1.0.125", features = [ "derive" ] }
|
serde = { version = "1.0.125", features = ["derive"] }
|
||||||
serde_json = "1.0.59"
|
serde_json = "1.0.59"
|
||||||
# tidy-alphabetical-end
|
# tidy-alphabetical-end
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use std::sync::LazyLock;
|
||||||
use AttributeDuplicates::*;
|
use AttributeDuplicates::*;
|
||||||
use AttributeGate::*;
|
use AttributeGate::*;
|
||||||
use AttributeType::*;
|
use AttributeType::*;
|
||||||
|
use rustc_attr_data_structures::EncodeCrossCrate;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
use rustc_span::{Symbol, sym};
|
use rustc_span::{Symbol, sym};
|
||||||
|
|
@ -368,12 +369,6 @@ macro_rules! experimental {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
|
||||||
pub enum EncodeCrossCrate {
|
|
||||||
Yes,
|
|
||||||
No,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct BuiltinAttribute {
|
pub struct BuiltinAttribute {
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
/// Whether this attribute is encode cross crate.
|
/// Whether this attribute is encode cross crate.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use std::io::{Read, Seek, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use rustc_ast::attr::AttributeExt;
|
use rustc_attr_data_structures::EncodeCrossCrate;
|
||||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||||
use rustc_data_structures::memmap::{Mmap, MmapMut};
|
use rustc_data_structures::memmap::{Mmap, MmapMut};
|
||||||
use rustc_data_structures::sync::{join, par_for_each_in};
|
use rustc_data_structures::sync::{join, par_for_each_in};
|
||||||
|
|
@ -839,9 +839,13 @@ struct AnalyzeAttrState<'a> {
|
||||||
/// visibility: this is a piece of data that can be computed once per defid, and not once per
|
/// visibility: this is a piece of data that can be computed once per defid, and not once per
|
||||||
/// attribute. Some attributes would only be usable downstream if they are public.
|
/// attribute. Some attributes would only be usable downstream if they are public.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn analyze_attr(attr: &impl AttributeExt, state: &mut AnalyzeAttrState<'_>) -> bool {
|
fn analyze_attr(attr: &hir::Attribute, state: &mut AnalyzeAttrState<'_>) -> bool {
|
||||||
let mut should_encode = false;
|
let mut should_encode = false;
|
||||||
if let Some(name) = attr.name()
|
if let hir::Attribute::Parsed(p) = attr
|
||||||
|
&& p.encode_cross_crate() == EncodeCrossCrate::No
|
||||||
|
{
|
||||||
|
// Attributes not marked encode-cross-crate don't need to be encoded for downstream crates.
|
||||||
|
} else if let Some(name) = attr.name()
|
||||||
&& !rustc_feature::encode_cross_crate(name)
|
&& !rustc_feature::encode_cross_crate(name)
|
||||||
{
|
{
|
||||||
// Attributes not marked encode-cross-crate don't need to be encoded for downstream crates.
|
// Attributes not marked encode-cross-crate don't need to be encoded for downstream crates.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue