Auto merge of #141238 - Zalathar:rollup-zdqpazo, r=Zalathar
Rollup of 4 pull requests Successful merges: - #140049 (fix autodiff macro on generic functions) - #140874 (make `rustc_attr_parsing` less dominant in the rustc crate graph) - #141094 (add regression test for rust-lang#101650) - #141110 ([std] fix the presentation of `split_off_mut` and `split_off` documentation) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
5f292eea6d
78 changed files with 292 additions and 138 deletions
21
Cargo.lock
21
Cargo.lock
|
|
@ -3390,6 +3390,7 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"rustc_ast",
|
||||
"rustc_ast_pretty",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
|
|
@ -3424,7 +3425,7 @@ dependencies = [
|
|||
"rustc-demangle",
|
||||
"rustc_abi",
|
||||
"rustc_ast",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_codegen_ssa",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
|
|
@ -3467,6 +3468,7 @@ dependencies = [
|
|||
"rustc_abi",
|
||||
"rustc_arena",
|
||||
"rustc_ast",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
|
|
@ -3504,7 +3506,7 @@ dependencies = [
|
|||
"rustc_abi",
|
||||
"rustc_apfloat",
|
||||
"rustc_ast",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_fluent_macro",
|
||||
|
|
@ -3680,6 +3682,7 @@ dependencies = [
|
|||
"rustc_ast",
|
||||
"rustc_ast_passes",
|
||||
"rustc_ast_pretty",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
|
|
@ -3768,7 +3771,7 @@ dependencies = [
|
|||
"rustc_abi",
|
||||
"rustc_arena",
|
||||
"rustc_ast",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_feature",
|
||||
|
|
@ -3805,7 +3808,7 @@ dependencies = [
|
|||
"itertools",
|
||||
"rustc_abi",
|
||||
"rustc_ast",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_fluent_macro",
|
||||
|
|
@ -3950,6 +3953,7 @@ dependencies = [
|
|||
"rustc_abi",
|
||||
"rustc_ast",
|
||||
"rustc_ast_pretty",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
|
|
@ -4023,6 +4027,7 @@ dependencies = [
|
|||
"odht",
|
||||
"rustc_abi",
|
||||
"rustc_ast",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
|
|
@ -4136,7 +4141,7 @@ dependencies = [
|
|||
"rustc_abi",
|
||||
"rustc_arena",
|
||||
"rustc_ast",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_const_eval",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
|
|
@ -4162,7 +4167,7 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"rustc_abi",
|
||||
"rustc_ast",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_fluent_macro",
|
||||
|
|
@ -4232,7 +4237,7 @@ dependencies = [
|
|||
"rustc_ast",
|
||||
"rustc_ast_lowering",
|
||||
"rustc_ast_pretty",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_expand",
|
||||
|
|
@ -4278,7 +4283,7 @@ name = "rustc_privacy"
|
|||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"rustc_ast",
|
||||
"rustc_attr_parsing",
|
||||
"rustc_attr_data_structures",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_fluent_macro",
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@
|
|||
//! `#[stable(...)]` and `#[unstable()]` cannot occur together, and both semantically define
|
||||
//! a "stability" of an item. So, the stability attribute has an
|
||||
//! [`AttributeParser`](attributes::AttributeParser) that recognizes both the `#[stable()]`
|
||||
//! and `#[unstable()]` syntactic attributes, and at the end produce a single [`AttributeKind::Stability`].
|
||||
//! and `#[unstable()]` syntactic attributes, and at the end produce a single
|
||||
//! [`AttributeKind::Stability`](rustc_attr_data_structures::AttributeKind::Stability).
|
||||
//!
|
||||
//! As a rule of thumb, when a syntactical attribute can be applied more than once, they should be
|
||||
//! combined into a single semantic attribute. For example:
|
||||
|
|
@ -91,6 +92,5 @@ mod session_diagnostics;
|
|||
pub use attributes::cfg::*;
|
||||
pub use attributes::util::{find_crate_name, is_builtin_attr, parse_version};
|
||||
pub use context::{AttributeParser, OmitDoc};
|
||||
pub use rustc_attr_data_structures::*;
|
||||
|
||||
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ doctest = false
|
|||
# tidy-alphabetical-start
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
|
|
|
|||
|
|
@ -73,10 +73,10 @@ mod llvm_enzyme {
|
|||
}
|
||||
|
||||
// Get information about the function the macro is applied to
|
||||
fn extract_item_info(iitem: &P<ast::Item>) -> Option<(Visibility, FnSig, Ident)> {
|
||||
fn extract_item_info(iitem: &P<ast::Item>) -> Option<(Visibility, FnSig, Ident, Generics)> {
|
||||
match &iitem.kind {
|
||||
ItemKind::Fn(box ast::Fn { sig, ident, .. }) => {
|
||||
Some((iitem.vis.clone(), sig.clone(), ident.clone()))
|
||||
ItemKind::Fn(box ast::Fn { sig, ident, generics, .. }) => {
|
||||
Some((iitem.vis.clone(), sig.clone(), ident.clone(), generics.clone()))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -210,16 +210,18 @@ mod llvm_enzyme {
|
|||
}
|
||||
let dcx = ecx.sess.dcx();
|
||||
|
||||
// first get information about the annotable item:
|
||||
let Some((vis, sig, primal)) = (match &item {
|
||||
// first get information about the annotable item: visibility, signature, name and generic
|
||||
// parameters.
|
||||
// these will be used to generate the differentiated version of the function
|
||||
let Some((vis, sig, primal, generics)) = (match &item {
|
||||
Annotatable::Item(iitem) => extract_item_info(iitem),
|
||||
Annotatable::Stmt(stmt) => match &stmt.kind {
|
||||
ast::StmtKind::Item(iitem) => extract_item_info(iitem),
|
||||
_ => None,
|
||||
},
|
||||
Annotatable::AssocItem(assoc_item, Impl { .. }) => match &assoc_item.kind {
|
||||
ast::AssocItemKind::Fn(box ast::Fn { sig, ident, .. }) => {
|
||||
Some((assoc_item.vis.clone(), sig.clone(), ident.clone()))
|
||||
ast::AssocItemKind::Fn(box ast::Fn { sig, ident, generics, .. }) => {
|
||||
Some((assoc_item.vis.clone(), sig.clone(), ident.clone(), generics.clone()))
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
|
|
@ -303,6 +305,7 @@ mod llvm_enzyme {
|
|||
let (d_sig, new_args, idents, errored) = gen_enzyme_decl(ecx, &sig, &x, span);
|
||||
let d_body = gen_enzyme_body(
|
||||
ecx, &x, n_active, &sig, &d_sig, primal, &new_args, span, sig_span, idents, errored,
|
||||
&generics,
|
||||
);
|
||||
|
||||
// The first element of it is the name of the function to be generated
|
||||
|
|
@ -310,7 +313,7 @@ mod llvm_enzyme {
|
|||
defaultness: ast::Defaultness::Final,
|
||||
sig: d_sig,
|
||||
ident: first_ident(&meta_item_vec[0]),
|
||||
generics: Generics::default(),
|
||||
generics,
|
||||
contract: None,
|
||||
body: Some(d_body),
|
||||
define_opaque: None,
|
||||
|
|
@ -475,6 +478,7 @@ mod llvm_enzyme {
|
|||
new_decl_span: Span,
|
||||
idents: &[Ident],
|
||||
errored: bool,
|
||||
generics: &Generics,
|
||||
) -> (P<ast::Block>, P<ast::Expr>, P<ast::Expr>, P<ast::Expr>) {
|
||||
let blackbox_path = ecx.std_path(&[sym::hint, sym::black_box]);
|
||||
let noop = ast::InlineAsm {
|
||||
|
|
@ -497,7 +501,7 @@ mod llvm_enzyme {
|
|||
};
|
||||
let unsf_expr = ecx.expr_block(P(unsf_block));
|
||||
let blackbox_call_expr = ecx.expr_path(ecx.path(span, blackbox_path));
|
||||
let primal_call = gen_primal_call(ecx, span, primal, idents);
|
||||
let primal_call = gen_primal_call(ecx, span, primal, idents, generics);
|
||||
let black_box_primal_call = ecx.expr_call(
|
||||
new_decl_span,
|
||||
blackbox_call_expr.clone(),
|
||||
|
|
@ -546,6 +550,7 @@ mod llvm_enzyme {
|
|||
sig_span: Span,
|
||||
idents: Vec<Ident>,
|
||||
errored: bool,
|
||||
generics: &Generics,
|
||||
) -> P<ast::Block> {
|
||||
let new_decl_span = d_sig.span;
|
||||
|
||||
|
|
@ -566,6 +571,7 @@ mod llvm_enzyme {
|
|||
new_decl_span,
|
||||
&idents,
|
||||
errored,
|
||||
generics,
|
||||
);
|
||||
|
||||
if !has_ret(&d_sig.decl.output) {
|
||||
|
|
@ -608,7 +614,6 @@ mod llvm_enzyme {
|
|||
panic!("Did not expect Default ret ty: {:?}", span);
|
||||
}
|
||||
};
|
||||
|
||||
if x.mode.is_fwd() {
|
||||
// Fwd mode is easy. If the return activity is Const, we support arbitrary types.
|
||||
// Otherwise, we only support a scalar, a pair of scalars, or an array of scalars.
|
||||
|
|
@ -668,8 +673,10 @@ mod llvm_enzyme {
|
|||
span: Span,
|
||||
primal: Ident,
|
||||
idents: &[Ident],
|
||||
generics: &Generics,
|
||||
) -> P<ast::Expr> {
|
||||
let has_self = idents.len() > 0 && idents[0].name == kw::SelfLower;
|
||||
|
||||
if has_self {
|
||||
let args: ThinVec<_> =
|
||||
idents[1..].iter().map(|arg| ecx.expr_path(ecx.path_ident(span, *arg))).collect();
|
||||
|
|
@ -678,7 +685,51 @@ mod llvm_enzyme {
|
|||
} else {
|
||||
let args: ThinVec<_> =
|
||||
idents.iter().map(|arg| ecx.expr_path(ecx.path_ident(span, *arg))).collect();
|
||||
let primal_call_expr = ecx.expr_path(ecx.path_ident(span, primal));
|
||||
let mut primal_path = ecx.path_ident(span, primal);
|
||||
|
||||
let is_generic = !generics.params.is_empty();
|
||||
|
||||
match (is_generic, primal_path.segments.last_mut()) {
|
||||
(true, Some(function_path)) => {
|
||||
let primal_generic_types = generics
|
||||
.params
|
||||
.iter()
|
||||
.filter(|param| matches!(param.kind, ast::GenericParamKind::Type { .. }));
|
||||
|
||||
let generated_generic_types = primal_generic_types
|
||||
.map(|type_param| {
|
||||
let generic_param = TyKind::Path(
|
||||
None,
|
||||
ast::Path {
|
||||
span,
|
||||
segments: thin_vec![ast::PathSegment {
|
||||
ident: type_param.ident,
|
||||
args: None,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
}],
|
||||
tokens: None,
|
||||
},
|
||||
);
|
||||
|
||||
ast::AngleBracketedArg::Arg(ast::GenericArg::Type(P(ast::Ty {
|
||||
id: type_param.id,
|
||||
span,
|
||||
kind: generic_param,
|
||||
tokens: None,
|
||||
})))
|
||||
})
|
||||
.collect();
|
||||
|
||||
function_path.args =
|
||||
Some(P(ast::GenericArgs::AngleBracketed(ast::AngleBracketedArgs {
|
||||
span,
|
||||
args: generated_generic_types,
|
||||
})));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let primal_call_expr = ecx.expr_path(primal_path);
|
||||
ecx.expr_call(span, primal_call_expr, args)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,7 +185,8 @@ use rustc_ast::{
|
|||
self as ast, AnonConst, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind,
|
||||
Generics, Mutability, PatKind, VariantData,
|
||||
};
|
||||
use rustc_attr_parsing::{AttributeKind, AttributeParser, ReprPacked};
|
||||
use rustc_attr_data_structures::{AttributeKind, ReprPacked};
|
||||
use rustc_attr_parsing::AttributeParser;
|
||||
use rustc_expand::base::{Annotatable, ExtCtxt};
|
||||
use rustc_hir::Attribute;
|
||||
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
use gccjit::FnAttribute;
|
||||
use gccjit::Function;
|
||||
#[cfg(feature = "master")]
|
||||
use rustc_attr_parsing::InlineAttr;
|
||||
use rustc_attr_parsing::InstructionSetAttr;
|
||||
use rustc_attr_data_structures::InlineAttr;
|
||||
use rustc_attr_data_structures::InstructionSetAttr;
|
||||
#[cfg(feature = "master")]
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
#[cfg(feature = "master")]
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ pub fn get_fn<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, instance: Instance<'tcx>)
|
|||
// This is a monomorphization of a generic function.
|
||||
if !(cx.tcx.sess.opts.share_generics()
|
||||
|| tcx.codegen_fn_attrs(instance_def_id).inline
|
||||
== rustc_attr_parsing::InlineAttr::Never)
|
||||
== rustc_attr_data_structures::InlineAttr::Never)
|
||||
{
|
||||
// When not sharing generics, all instances are in the same
|
||||
// crate and have hidden visibility.
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ extern crate tracing;
|
|||
extern crate rustc_abi;
|
||||
extern crate rustc_apfloat;
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc_attr_parsing;
|
||||
extern crate rustc_attr_data_structures;
|
||||
extern crate rustc_codegen_ssa;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_errors;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ object = { version = "0.36.3", default-features = false, features = ["std", "rea
|
|||
rustc-demangle = "0.1.21"
|
||||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//! Set and unset common attributes on LLVM values.
|
||||
use rustc_attr_parsing::{InlineAttr, InstructionSetAttr, OptimizeAttr};
|
||||
use rustc_attr_data_structures::{InlineAttr, InstructionSetAttr, OptimizeAttr};
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFunctionEntry};
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'t
|
|||
// This is a monomorphization of a generic function.
|
||||
if !(cx.tcx.sess.opts.share_generics()
|
||||
|| tcx.codegen_fn_attrs(instance_def_id).inline
|
||||
== rustc_attr_parsing::InlineAttr::Never)
|
||||
== rustc_attr_data_structures::InlineAttr::Never)
|
||||
{
|
||||
// When not sharing generics, all instances are in the same
|
||||
// crate and have hidden visibility.
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ regex = "1.4"
|
|||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_arena = { path = "../rustc_arena" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ fn exported_symbols_provider_local<'tcx>(
|
|||
|
||||
if !tcx.sess.opts.share_generics() {
|
||||
if tcx.codegen_fn_attrs(mono_item.def_id()).inline
|
||||
== rustc_attr_parsing::InlineAttr::Never
|
||||
== rustc_attr_data_structures::InlineAttr::Never
|
||||
{
|
||||
// this is OK, we explicitly allow sharing inline(never) across crates even
|
||||
// without share-generics.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use itertools::Itertools;
|
|||
use rustc_abi::FIRST_VARIANT;
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, AllocatorKind, global_fn_name};
|
||||
use rustc_attr_parsing::OptimizeAttr;
|
||||
use rustc_attr_data_structures::OptimizeAttr;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
|
||||
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
|
||||
use rustc_data_structures::sync::{IntoDynSyncSend, par_map};
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ use std::str::FromStr;
|
|||
use rustc_abi::ExternAbi;
|
||||
use rustc_ast::expand::autodiff_attrs::{AutoDiffAttrs, DiffActivity, DiffMode};
|
||||
use rustc_ast::{LitKind, MetaItem, MetaItemInner, attr};
|
||||
use rustc_attr_parsing::ReprAttr::ReprAlign;
|
||||
use rustc_attr_parsing::{AttributeKind, InlineAttr, InstructionSetAttr, OptimizeAttr};
|
||||
use rustc_attr_data_structures::ReprAttr::ReprAlign;
|
||||
use rustc_attr_data_structures::{AttributeKind, InlineAttr, InstructionSetAttr, OptimizeAttr};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use rustc_abi::{BackendRepr, Float, Integer, Primitive, RegKind};
|
||||
use rustc_attr_parsing::InstructionSetAttr;
|
||||
use rustc_attr_data_structures::InstructionSetAttr;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::mir::mono::{Linkage, MonoItemData, Visibility};
|
||||
use rustc_middle::mir::{InlineAsmOperand, START_BLOCK};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use rustc_attr_parsing::InstructionSetAttr;
|
||||
use rustc_attr_data_structures::InstructionSetAttr;
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_data_structures::unord::{UnordMap, UnordSet};
|
||||
use rustc_errors::Applicability;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ either = "1"
|
|||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_apfloat = "0.2.0"
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::mem;
|
|||
use std::num::NonZero;
|
||||
use std::ops::Deref;
|
||||
|
||||
use rustc_attr_parsing::{ConstStability, StabilityLevel};
|
||||
use rustc_attr_data_structures as attrs;
|
||||
use rustc_errors::{Diag, ErrorGuaranteed};
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::DefId;
|
||||
|
|
@ -475,7 +475,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
|
|||
/// Check the const stability of the given item (fn or trait).
|
||||
fn check_callee_stability(&mut self, def_id: DefId) {
|
||||
match self.tcx.lookup_const_stability(def_id) {
|
||||
Some(ConstStability { level: StabilityLevel::Stable { .. }, .. }) => {
|
||||
Some(attrs::ConstStability { level: attrs::StabilityLevel::Stable { .. }, .. }) => {
|
||||
// All good.
|
||||
}
|
||||
None => {
|
||||
|
|
@ -491,8 +491,8 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
|
|||
});
|
||||
}
|
||||
}
|
||||
Some(ConstStability {
|
||||
level: StabilityLevel::Unstable { implied_by: implied_feature, issue, .. },
|
||||
Some(attrs::ConstStability {
|
||||
level: attrs::StabilityLevel::Unstable { implied_by: implied_feature, issue, .. },
|
||||
feature,
|
||||
..
|
||||
}) => {
|
||||
|
|
@ -918,8 +918,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
|||
});
|
||||
}
|
||||
}
|
||||
Some(ConstStability {
|
||||
level: StabilityLevel::Unstable { .. },
|
||||
Some(attrs::ConstStability {
|
||||
level: attrs::StabilityLevel::Unstable { .. },
|
||||
feature,
|
||||
..
|
||||
}) => {
|
||||
|
|
@ -930,7 +930,10 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
|||
suggestion: self.crate_inject_span(),
|
||||
});
|
||||
}
|
||||
Some(ConstStability { level: StabilityLevel::Stable { .. }, .. }) => {
|
||||
Some(attrs::ConstStability {
|
||||
level: attrs::StabilityLevel::Stable { .. },
|
||||
..
|
||||
}) => {
|
||||
// All good. Note that a `#[rustc_const_stable]` intrinsic (meaning it
|
||||
// can be *directly* invoked from stable const code) does not always
|
||||
// have the `#[rustc_intrinsic_const_stable_indirect]` attribute (which controls
|
||||
|
|
|
|||
|
|
@ -4,13 +4,12 @@
|
|||
//! has interior mutability or needs to be dropped, as well as the visitor that emits errors when
|
||||
//! it finds operations that are invalid in a certain context.
|
||||
|
||||
use rustc_attr_parsing::{AttributeKind, find_attr};
|
||||
use rustc_errors::DiagCtxtHandle;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::ty::{self, PolyFnSig, TyCtxt};
|
||||
use rustc_middle::{bug, mir};
|
||||
use rustc_span::Symbol;
|
||||
use {rustc_attr_data_structures as attrs, rustc_hir as hir};
|
||||
|
||||
pub use self::qualifs::Qualif;
|
||||
|
||||
|
|
@ -83,7 +82,7 @@ pub fn rustc_allow_const_fn_unstable(
|
|||
) -> bool {
|
||||
let attrs = tcx.hir_attrs(tcx.local_def_id_to_hir_id(def_id));
|
||||
|
||||
find_attr!(attrs, AttributeKind::AllowConstFnUnstable(syms) if syms.contains(&feature_gate))
|
||||
attrs::find_attr!(attrs, attrs::AttributeKind::AllowConstFnUnstable(syms) if syms.contains(&feature_gate))
|
||||
}
|
||||
|
||||
/// Returns `true` if the given `def_id` (trait or function) is "safe to expose on stable".
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ doctest = false
|
|||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_ast_passes = { path = "../rustc_ast_passes" }
|
||||
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use rustc_ast::token::MetaVarKind;
|
|||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::visit::{AssocCtxt, Visitor};
|
||||
use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, Item, NodeId, PatKind};
|
||||
use rustc_attr_parsing::{AttributeKind, Deprecation, Stability, find_attr};
|
||||
use rustc_attr_data_structures::{AttributeKind, Deprecation, Stability, find_attr};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::sync;
|
||||
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, PResult};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use rustc_ast::token::{self, NonterminalKind, Token, TokenKind};
|
|||
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
|
||||
use rustc_ast::{self as ast, DUMMY_NODE_ID, NodeId};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_attr_parsing::{AttributeKind, find_attr};
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||
use rustc_errors::{Applicability, Diag, ErrorGuaranteed};
|
||||
use rustc_feature::Features;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ itertools = "0.12"
|
|||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_arena = { path = "../rustc_arena" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_feature = { path = "../rustc_feature" }
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ use std::cell::LazyCell;
|
|||
use std::ops::ControlFlow;
|
||||
|
||||
use rustc_abi::FieldIdx;
|
||||
use rustc_attr_parsing::AttributeKind;
|
||||
use rustc_attr_parsing::ReprAttr::ReprPacked;
|
||||
use rustc_attr_data_structures::ReprAttr::ReprPacked;
|
||||
use rustc_data_structures::unord::{UnordMap, UnordSet};
|
||||
use rustc_errors::MultiSpan;
|
||||
use rustc_errors::codes::*;
|
||||
|
|
@ -31,7 +30,7 @@ use rustc_trait_selection::traits;
|
|||
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
|
||||
use tracing::{debug, instrument};
|
||||
use ty::TypingMode;
|
||||
use {rustc_attr_parsing as attr, rustc_hir as hir};
|
||||
use {rustc_attr_data_structures as attrs, rustc_hir as hir};
|
||||
|
||||
use super::compare_impl_item::check_type_bounds;
|
||||
use super::*;
|
||||
|
|
@ -1154,7 +1153,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
|||
let repr = def.repr();
|
||||
if repr.packed() {
|
||||
if let Some(reprs) =
|
||||
attr::find_attr!(tcx.get_all_attrs(def.did()), AttributeKind::Repr(r) => r)
|
||||
attrs::find_attr!(tcx.get_all_attrs(def.did()), attrs::AttributeKind::Repr(r) => r)
|
||||
{
|
||||
for (r, _) in reprs {
|
||||
if let ReprPacked(pack) = r
|
||||
|
|
@ -1371,9 +1370,9 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
def.destructor(tcx); // force the destructor to be evaluated
|
||||
|
||||
if def.variants().is_empty() {
|
||||
attr::find_attr!(
|
||||
attrs::find_attr!(
|
||||
tcx.get_all_attrs(def_id),
|
||||
AttributeKind::Repr(rs) => {
|
||||
attrs::AttributeKind::Repr(rs) => {
|
||||
struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
rs.first().unwrap().1,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ edition = "2024"
|
|||
itertools = "0.12"
|
||||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
use std::ops::Deref;
|
||||
|
||||
use rustc_attr_parsing::InlineAttr;
|
||||
use rustc_attr_data_structures::InlineAttr;
|
||||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{Applicability, Diag, struct_span_code_err};
|
||||
use rustc_hir as hir;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use std::path::PathBuf;
|
|||
|
||||
use hir::Expr;
|
||||
use rustc_ast::ast::Mutability;
|
||||
use rustc_attr_parsing::{AttributeKind, find_attr};
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::sorted_map::SortedMap;
|
||||
use rustc_data_structures::unord::UnordSet;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ edition = "2024"
|
|||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use rustc_abi::ExternAbi;
|
||||
use rustc_attr_parsing::{AttributeKind, AttributeParser, ReprAttr};
|
||||
use rustc_attr_data_structures::{AttributeKind, ReprAttr};
|
||||
use rustc_attr_parsing::AttributeParser;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_hir::{AttrArgs, AttrItem, Attribute, GenericParamKind, PatExprKind, PatKind};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use rustc_middle::ty::Ty;
|
|||
use rustc_middle::ty::layout::IntegerExt;
|
||||
use rustc_middle::{bug, ty};
|
||||
use rustc_span::Span;
|
||||
use {rustc_ast as ast, rustc_attr_parsing as attr, rustc_hir as hir};
|
||||
use {rustc_ast as ast, rustc_attr_data_structures as attrs, rustc_hir as hir};
|
||||
|
||||
use crate::LateContext;
|
||||
use crate::context::LintContext;
|
||||
|
|
@ -131,18 +131,18 @@ fn report_bin_hex_error(
|
|||
cx: &LateContext<'_>,
|
||||
hir_id: HirId,
|
||||
span: Span,
|
||||
ty: attr::IntType,
|
||||
ty: attrs::IntType,
|
||||
size: Size,
|
||||
repr_str: String,
|
||||
val: u128,
|
||||
negative: bool,
|
||||
) {
|
||||
let (t, actually) = match ty {
|
||||
attr::IntType::SignedInt(t) => {
|
||||
attrs::IntType::SignedInt(t) => {
|
||||
let actually = if negative { -(size.sign_extend(val)) } else { size.sign_extend(val) };
|
||||
(t.name_str(), actually.to_string())
|
||||
}
|
||||
attr::IntType::UnsignedInt(t) => {
|
||||
attrs::IntType::UnsignedInt(t) => {
|
||||
let actually = size.truncate(val);
|
||||
(t.name_str(), actually.to_string())
|
||||
}
|
||||
|
|
@ -264,7 +264,7 @@ fn lint_int_literal<'tcx>(
|
|||
cx,
|
||||
hir_id,
|
||||
span,
|
||||
attr::IntType::SignedInt(ty::ast_int_ty(t)),
|
||||
attrs::IntType::SignedInt(ty::ast_int_ty(t)),
|
||||
Integer::from_int_ty(cx, t).size(),
|
||||
repr_str,
|
||||
v,
|
||||
|
|
@ -336,7 +336,7 @@ fn lint_uint_literal<'tcx>(
|
|||
cx,
|
||||
hir_id,
|
||||
span,
|
||||
attr::IntType::UnsignedInt(ty::ast_uint_ty(t)),
|
||||
attrs::IntType::UnsignedInt(ty::ast_uint_ty(t)),
|
||||
Integer::from_uint_ty(cx, t).size(),
|
||||
repr_str,
|
||||
lit_val,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ libloading = "0.8.0"
|
|||
odht = { version = "0.3.1", features = ["nightly"] }
|
||||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::any::Any;
|
|||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustc_attr_parsing::Deprecation;
|
||||
use rustc_attr_data_structures::Deprecation;
|
||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ use rustc_span::hygiene::{ExpnIndex, MacroKind, SyntaxContextKey};
|
|||
use rustc_span::{self, ExpnData, ExpnHash, ExpnId, Ident, Span, Symbol};
|
||||
use rustc_target::spec::{PanicStrategy, TargetTuple};
|
||||
use table::TableBuilder;
|
||||
use {rustc_ast as ast, rustc_attr_parsing as attr, rustc_hir as hir};
|
||||
use {rustc_ast as ast, rustc_attr_data_structures as attrs, rustc_hir as hir};
|
||||
|
||||
use crate::creader::CrateMetadataRef;
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ type ExpnHashTable = LazyTable<ExpnIndex, Option<LazyValue<ExpnHash>>>;
|
|||
#[derive(MetadataEncodable, MetadataDecodable)]
|
||||
pub(crate) struct ProcMacroData {
|
||||
proc_macro_decls_static: DefIndex,
|
||||
stability: Option<attr::Stability>,
|
||||
stability: Option<attrs::Stability>,
|
||||
macros: LazyArray<DefIndex>,
|
||||
}
|
||||
|
||||
|
|
@ -422,10 +422,10 @@ define_tables! {
|
|||
safety: Table<DefIndex, hir::Safety>,
|
||||
def_span: Table<DefIndex, LazyValue<Span>>,
|
||||
def_ident_span: Table<DefIndex, LazyValue<Span>>,
|
||||
lookup_stability: Table<DefIndex, LazyValue<attr::Stability>>,
|
||||
lookup_const_stability: Table<DefIndex, LazyValue<attr::ConstStability>>,
|
||||
lookup_default_body_stability: Table<DefIndex, LazyValue<attr::DefaultBodyStability>>,
|
||||
lookup_deprecation_entry: Table<DefIndex, LazyValue<attr::Deprecation>>,
|
||||
lookup_stability: Table<DefIndex, LazyValue<attrs::Stability>>,
|
||||
lookup_const_stability: Table<DefIndex, LazyValue<attrs::ConstStability>>,
|
||||
lookup_default_body_stability: Table<DefIndex, LazyValue<attrs::DefaultBodyStability>>,
|
||||
lookup_deprecation_entry: Table<DefIndex, LazyValue<attrs::Deprecation>>,
|
||||
explicit_predicates_of: Table<DefIndex, LazyValue<ty::GenericPredicates<'static>>>,
|
||||
generics_of: Table<DefIndex, LazyValue<ty::Generics>>,
|
||||
type_of: Table<DefIndex, LazyValue<ty::EarlyBinder<'static, Ty<'static>>>>,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::num::NonZero;
|
|||
|
||||
use rustc_ast::NodeId;
|
||||
use rustc_attr_data_structures::{
|
||||
self as attr, ConstStability, DefaultBodyStability, DeprecatedSince, Deprecation, Stability,
|
||||
self as attrs, ConstStability, DefaultBodyStability, DeprecatedSince, Deprecation, Stability,
|
||||
};
|
||||
use rustc_data_structures::unord::UnordMap;
|
||||
use rustc_errors::{Applicability, Diag, EmissionGuarantee};
|
||||
|
|
@ -411,7 +411,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
|
||||
match stability {
|
||||
Some(Stability {
|
||||
level: attr::StabilityLevel::Unstable { reason, issue, is_soft, implied_by },
|
||||
level: attrs::StabilityLevel::Unstable { reason, issue, is_soft, implied_by },
|
||||
feature,
|
||||
..
|
||||
}) => {
|
||||
|
|
@ -494,7 +494,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
|
||||
match stability {
|
||||
Some(DefaultBodyStability {
|
||||
level: attr::StabilityLevel::Unstable { reason, issue, is_soft, .. },
|
||||
level: attrs::StabilityLevel::Unstable { reason, issue, is_soft, .. },
|
||||
feature,
|
||||
}) => {
|
||||
if span.allows_unstable(feature) {
|
||||
|
|
@ -643,7 +643,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
|
||||
match stability {
|
||||
Some(ConstStability {
|
||||
level: attr::StabilityLevel::Unstable { reason, issue, is_soft, implied_by, .. },
|
||||
level: attrs::StabilityLevel::Unstable { reason, issue, is_soft, implied_by, .. },
|
||||
feature,
|
||||
..
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ itertools = "0.12"
|
|||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_arena = { path = "../rustc_arena" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_const_eval = { path = "../rustc_const_eval" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! Check that a body annotated with `#[rustc_force_inline]` will not fail to inline based on its
|
||||
//! definition alone (irrespective of any specific caller).
|
||||
|
||||
use rustc_attr_parsing::InlineAttr;
|
||||
use rustc_attr_data_structures::InlineAttr;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::mir::{Body, TerminatorKind};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use rustc_attr_parsing::InlineAttr;
|
||||
use rustc_attr_data_structures::InlineAttr;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_middle::mir::visit::Visitor;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::iter;
|
|||
use std::ops::{Range, RangeFrom};
|
||||
|
||||
use rustc_abi::{ExternAbi, FieldIdx};
|
||||
use rustc_attr_parsing::{InlineAttr, OptimizeAttr};
|
||||
use rustc_attr_data_structures::{InlineAttr, OptimizeAttr};
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_index::Idx;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! Validates the MIR to ensure that invariants are upheld.
|
||||
|
||||
use rustc_abi::{ExternAbi, FIRST_VARIANT, Size};
|
||||
use rustc_attr_parsing::InlineAttr;
|
||||
use rustc_attr_data_structures::InlineAttr;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_index::IndexVec;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ edition = "2024"
|
|||
# tidy-alphabetical-start
|
||||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@
|
|||
use std::cell::OnceCell;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use rustc_attr_parsing::InlineAttr;
|
||||
use rustc_attr_data_structures::InlineAttr;
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::sync::{MTLock, par_for_each_in};
|
||||
use rustc_data_structures::unord::{UnordMap, UnordSet};
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ use std::fs::{self, File};
|
|||
use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use rustc_attr_data_structures::InlineAttr;
|
||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::sync;
|
||||
use rustc_data_structures::unord::{UnordMap, UnordSet};
|
||||
|
|
@ -845,8 +846,7 @@ fn mono_item_visibility<'tcx>(
|
|||
return if is_generic
|
||||
&& (always_export_generics
|
||||
|| (can_export_generics
|
||||
&& tcx.codegen_fn_attrs(def_id).inline
|
||||
== rustc_attr_parsing::InlineAttr::Never))
|
||||
&& tcx.codegen_fn_attrs(def_id).inline == InlineAttr::Never))
|
||||
{
|
||||
// If it is an upstream monomorphization and we export generics, we must make
|
||||
// it available to downstream crates.
|
||||
|
|
@ -859,8 +859,7 @@ fn mono_item_visibility<'tcx>(
|
|||
|
||||
if is_generic {
|
||||
if always_export_generics
|
||||
|| (can_export_generics
|
||||
&& tcx.codegen_fn_attrs(def_id).inline == rustc_attr_parsing::InlineAttr::Never)
|
||||
|| (can_export_generics && tcx.codegen_fn_attrs(def_id).inline == InlineAttr::Never)
|
||||
{
|
||||
if tcx.is_unreachable_local_definition(def_id) {
|
||||
// This instance cannot be used from another crate.
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ rustc_abi = { path = "../rustc_abi" }
|
|||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
|
||||
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_expand = { path = "../rustc_expand" }
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use std::collections::hash_map::Entry;
|
|||
|
||||
use rustc_abi::{Align, ExternAbi, Size};
|
||||
use rustc_ast::{AttrStyle, LitKind, MetaItemInner, MetaItemKind, MetaItemLit, ast};
|
||||
use rustc_attr_parsing::{AttributeKind, ReprAttr, find_attr};
|
||||
use rustc_attr_data_structures::{AttributeKind, ReprAttr, find_attr};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{Applicability, DiagCtxtHandle, IntoDiagArg, MultiSpan, StashKey};
|
||||
use rustc_feature::{AttributeDuplicates, AttributeType, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
//! but are not declared in one single location (unlike lang features), which means we need to
|
||||
//! collect them instead.
|
||||
|
||||
use rustc_attr_parsing::{AttributeKind, StabilityLevel, StableSince};
|
||||
use rustc_attr_data_structures::{AttributeKind, StabilityLevel, StableSince};
|
||||
use rustc_hir::Attribute;
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ use std::mem::replace;
|
|||
use std::num::NonZero;
|
||||
|
||||
use rustc_ast_lowering::stability::extern_abi_stability;
|
||||
use rustc_attr_parsing::{
|
||||
self as attr, AttributeKind, ConstStability, DeprecatedSince, PartialConstStability, Stability,
|
||||
StabilityLevel, StableSince, UnstableReason, VERSION_PLACEHOLDER, find_attr,
|
||||
use rustc_attr_data_structures::{
|
||||
self as attrs, AttributeKind, ConstStability, DeprecatedSince, PartialConstStability,
|
||||
Stability, StabilityLevel, StableSince, UnstableReason, VERSION_PLACEHOLDER, find_attr,
|
||||
};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::unord::{ExtendUnord, UnordMap, UnordSet};
|
||||
|
|
@ -121,7 +121,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||
let attrs = self.tcx.hir_attrs(self.tcx.local_def_id_to_hir_id(def_id));
|
||||
debug!("annotate(id = {:?}, attrs = {:?})", def_id, attrs);
|
||||
|
||||
let depr = attr::find_attr!(attrs, AttributeKind::Deprecation{deprecation, span} => (*deprecation, *span));
|
||||
let depr = attrs::find_attr!(attrs, AttributeKind::Deprecation{deprecation, span} => (*deprecation, *span));
|
||||
let const_stability_indirect = find_attr!(attrs, AttributeKind::ConstStabilityIndirect);
|
||||
|
||||
let mut is_deprecated = false;
|
||||
|
|
@ -174,9 +174,9 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||
}
|
||||
|
||||
// # Regular and body stability
|
||||
let stab = attr::find_attr!(attrs, AttributeKind::Stability { stability, span } => (*stability, *span));
|
||||
let stab = attrs::find_attr!(attrs, AttributeKind::Stability { stability, span } => (*stability, *span));
|
||||
let body_stab =
|
||||
attr::find_attr!(attrs, AttributeKind::BodyStability { stability, .. } => *stability);
|
||||
attrs::find_attr!(attrs, AttributeKind::BodyStability { stability, .. } => *stability);
|
||||
|
||||
if let Some((depr, span)) = &depr
|
||||
&& depr.is_since_rustc_version()
|
||||
|
|
@ -206,7 +206,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||
// this is *almost surely* an accident.
|
||||
if let (
|
||||
&Some(DeprecatedSince::RustcVersion(dep_since)),
|
||||
&attr::StabilityLevel::Stable { since: stab_since, .. },
|
||||
&attrs::StabilityLevel::Stable { since: stab_since, .. },
|
||||
) = (&depr.as_ref().map(|(d, _)| d.since), &stab.level)
|
||||
{
|
||||
match stab_since {
|
||||
|
|
@ -263,7 +263,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||
|
||||
// # Const stability
|
||||
|
||||
let const_stab = attr::find_attr!(attrs, AttributeKind::ConstStability { stability, span } => (*stability, *span));
|
||||
let const_stab = attrs::find_attr!(attrs, AttributeKind::ConstStability { stability, span } => (*stability, *span));
|
||||
|
||||
// If the current node is a function with const stability attributes (directly given or
|
||||
// implied), check if the function/method is const or the parent impl block is const.
|
||||
|
|
@ -713,7 +713,7 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index {
|
|||
// by default and are unable to be used.
|
||||
if tcx.sess.opts.unstable_opts.force_unstable_if_unmarked {
|
||||
let stability = Stability {
|
||||
level: attr::StabilityLevel::Unstable {
|
||||
level: attrs::StabilityLevel::Unstable {
|
||||
reason: UnstableReason::Default,
|
||||
issue: NonZero::new(27812),
|
||||
is_soft: false,
|
||||
|
|
@ -796,17 +796,17 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
|
|||
let features = self.tcx.features();
|
||||
if features.staged_api() {
|
||||
let attrs = self.tcx.hir_attrs(item.hir_id());
|
||||
let stab = attr::find_attr!(attrs, AttributeKind::Stability{stability, span} => (*stability, *span));
|
||||
let stab = attrs::find_attr!(attrs, AttributeKind::Stability{stability, span} => (*stability, *span));
|
||||
|
||||
// FIXME(jdonszelmann): make it impossible to miss the or_else in the typesystem
|
||||
let const_stab = attr::find_attr!(attrs, AttributeKind::ConstStability{stability, ..} => *stability);
|
||||
let const_stab = attrs::find_attr!(attrs, AttributeKind::ConstStability{stability, ..} => *stability);
|
||||
|
||||
// If this impl block has an #[unstable] attribute, give an
|
||||
// error if all involved types and traits are stable, because
|
||||
// it will have no effect.
|
||||
// See: https://github.com/rust-lang/rust/issues/55436
|
||||
if let Some((
|
||||
Stability { level: attr::StabilityLevel::Unstable { .. }, .. },
|
||||
Stability { level: attrs::StabilityLevel::Unstable { .. }, .. },
|
||||
span,
|
||||
)) = stab
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ edition = "2024"
|
|||
[dependencies]
|
||||
# tidy-alphabetical-start
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ use errors::{
|
|||
};
|
||||
use rustc_ast::MacroDef;
|
||||
use rustc_ast::visit::{VisitorResult, try_visit};
|
||||
use rustc_attr_parsing::AttributeKind;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_errors::{MultiSpan, listify};
|
||||
|
|
@ -40,7 +39,7 @@ use rustc_session::lint;
|
|||
use rustc_span::hygiene::Transparency;
|
||||
use rustc_span::{Ident, Span, Symbol, sym};
|
||||
use tracing::debug;
|
||||
use {rustc_attr_parsing as attr, rustc_hir as hir};
|
||||
use {rustc_attr_data_structures as attrs, rustc_hir as hir};
|
||||
|
||||
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
||||
|
||||
|
|
@ -497,7 +496,7 @@ impl<'tcx> EmbargoVisitor<'tcx> {
|
|||
let hir_id = self.tcx.local_def_id_to_hir_id(local_def_id);
|
||||
let attrs = self.tcx.hir_attrs(hir_id);
|
||||
|
||||
if attr::find_attr!(attrs, AttributeKind::MacroTransparency(x) => *x)
|
||||
if attrs::find_attr!(attrs, attrs::AttributeKind::MacroTransparency(x) => *x)
|
||||
.unwrap_or(Transparency::fallback(md.macro_rules))
|
||||
!= Transparency::Opaque
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use std::sync::Arc;
|
|||
use rustc_ast::expand::StrippedCfgItem;
|
||||
use rustc_ast::{self as ast, Crate, NodeId, attr};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_attr_parsing::StabilityLevel;
|
||||
use rustc_attr_data_structures::StabilityLevel;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_errors::{Applicability, DiagCtxtHandle, StashKey};
|
||||
use rustc_expand::base::{
|
||||
|
|
|
|||
|
|
@ -4383,7 +4383,7 @@ impl<T> [T] {
|
|||
/// assert_eq!(first_three, &['a', 'b', 'c']);
|
||||
/// ```
|
||||
///
|
||||
/// Splitting off the last two elements of a slice:
|
||||
/// Splitting off a slice starting with the third element:
|
||||
///
|
||||
/// ```
|
||||
/// let mut slice: &[_] = &['a', 'b', 'c', 'd'];
|
||||
|
|
@ -4449,7 +4449,7 @@ impl<T> [T] {
|
|||
/// assert_eq!(first_three, &mut ['a', 'b', 'c']);
|
||||
/// ```
|
||||
///
|
||||
/// Taking the last two elements of a slice:
|
||||
/// Splitting off a slice starting with the third element:
|
||||
///
|
||||
/// ```
|
||||
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ use std::{fmt, iter};
|
|||
|
||||
use arrayvec::ArrayVec;
|
||||
use rustc_abi::{ExternAbi, VariantIdx};
|
||||
use rustc_attr_parsing::{AttributeKind, ConstStability, Deprecation, Stability, StableSince};
|
||||
use rustc_attr_data_structures::{
|
||||
AttributeKind, ConstStability, Deprecation, Stability, StableSince,
|
||||
};
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId};
|
||||
|
|
@ -403,13 +405,13 @@ impl Item {
|
|||
// versions; the paths that are exposed through it are "deprecated" because they
|
||||
// were never supposed to work at all.
|
||||
let stab = self.stability(tcx)?;
|
||||
if let rustc_attr_parsing::StabilityLevel::Stable {
|
||||
if let rustc_attr_data_structures::StabilityLevel::Stable {
|
||||
allowed_through_unstable_modules: Some(note),
|
||||
..
|
||||
} = stab.level
|
||||
{
|
||||
Some(Deprecation {
|
||||
since: rustc_attr_parsing::DeprecatedSince::Unspecified,
|
||||
since: rustc_attr_data_structures::DeprecatedSince::Unspecified,
|
||||
note: Some(note),
|
||||
suggestion: None,
|
||||
})
|
||||
|
|
@ -777,9 +779,9 @@ impl Item {
|
|||
// don't want it it `Item::attrs`.
|
||||
None
|
||||
}
|
||||
rustc_hir::Attribute::Parsed(rustc_attr_parsing::AttributeKind::Repr(
|
||||
..,
|
||||
)) => {
|
||||
rustc_hir::Attribute::Parsed(
|
||||
rustc_attr_data_structures::AttributeKind::Repr(..),
|
||||
) => {
|
||||
// We have separate pretty-printing logic for `#[repr(..)]` attributes.
|
||||
// For example, there are circumstances where `#[repr(transparent)]`
|
||||
// is applied but should not be publicly shown in rustdoc
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::mem;
|
||||
|
||||
use rustc_attr_parsing::StabilityLevel;
|
||||
use rustc_attr_data_structures::StabilityLevel;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use std::slice;
|
|||
|
||||
use itertools::Either;
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_attr_parsing::{ConstStability, StabilityLevel, StableSince};
|
||||
use rustc_attr_data_structures::{ConstStability, StabilityLevel, StableSince};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ use std::{fs, str};
|
|||
|
||||
use askama::Template;
|
||||
use itertools::Either;
|
||||
use rustc_attr_parsing::{
|
||||
use rustc_attr_data_structures::{
|
||||
ConstStability, DeprecatedSince, Deprecation, RustcVersion, StabilityLevel, StableSince,
|
||||
};
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_ast::ast;
|
||||
use rustc_attr_parsing::DeprecatedSince;
|
||||
use rustc_attr_data_structures::{self as attrs, DeprecatedSince};
|
||||
use rustc_hir::def::CtorKind;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_metadata::rendered_const;
|
||||
|
|
@ -153,8 +153,8 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn from_deprecation(deprecation: rustc_attr_parsing::Deprecation) -> Deprecation {
|
||||
let rustc_attr_parsing::Deprecation { since, note, suggestion: _ } = deprecation;
|
||||
pub(crate) fn from_deprecation(deprecation: attrs::Deprecation) -> Deprecation {
|
||||
let attrs::Deprecation { since, note, suggestion: _ } = deprecation;
|
||||
let since = match since {
|
||||
DeprecatedSince::RustcVersion(version) => Some(version.to_string()),
|
||||
DeprecatedSince::Future => Some("TBD".to_owned()),
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ extern crate pulldown_cmark;
|
|||
extern crate rustc_abi;
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc_ast_pretty;
|
||||
extern crate rustc_attr_data_structures;
|
||||
extern crate rustc_attr_parsing;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
//! [`core::error`] module is marked as stable since 1.81.0, so we want to show
|
||||
//! [`core::error::Error`] as stable since 1.81.0 as well.
|
||||
|
||||
use rustc_attr_parsing::{Stability, StabilityLevel};
|
||||
use rustc_attr_data_structures::{Stability, StabilityLevel};
|
||||
use rustc_hir::def_id::CRATE_DEF_ID;
|
||||
|
||||
use crate::clean::{Crate, Item, ItemId, ItemKind};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use clippy_config::Conf;
|
|||
use clippy_utils::diagnostics::span_lint_and_help;
|
||||
use clippy_utils::msrvs::{self, Msrv};
|
||||
use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
|
||||
use rustc_attr_parsing::RustcVersion;
|
||||
use rustc_attr_data_structures::RustcVersion;
|
||||
use rustc_hir::{HirId, Lit};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::impl_lint_pass;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use rustc_attr_parsing::{AttributeKind, ReprAttr, find_attr};
|
||||
use rustc_attr_data_structures::{AttributeKind, ReprAttr, find_attr};
|
||||
use rustc_hir::Attribute;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::Span;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use clippy_utils::source::SpanRangeExt;
|
|||
use clippy_utils::sugg::Sugg;
|
||||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_attr_parsing::RustcVersion;
|
||||
use rustc_attr_data_structures::RustcVersion;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::{FnKind, Visitor, walk_expr};
|
||||
use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, UnOp};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use rustc_attr_parsing::{AttributeKind, ReprAttr, find_attr};
|
||||
use rustc_attr_data_structures::{AttributeKind, ReprAttr, find_attr};
|
||||
use rustc_hir::{HirId, Item, ItemKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use rustc_ast::AttrStyle;
|
||||
use rustc_ast::token::CommentKind;
|
||||
use rustc_attr_parsing::AttributeKind;
|
||||
use rustc_attr_data_structures::AttributeKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::Attribute;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use rustc_attr_parsing::AttributeKind;
|
||||
use rustc_attr_data_structures::AttributeKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Attribute, Item, ItemKind};
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use rustc_ast::{
|
|||
FormatArgPosition, FormatArgPositionKind, FormatArgsPiece, FormatArgumentKind, FormatCount, FormatOptions,
|
||||
FormatPlaceholder, FormatTrait,
|
||||
};
|
||||
use rustc_attr_parsing::RustcVersion;
|
||||
use rustc_attr_data_structures::RustcVersion;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_errors::SuggestionStyle::{CompletelyHidden, ShowCode};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use clippy_config::Conf;
|
|||
use clippy_utils::diagnostics::span_lint;
|
||||
use clippy_utils::is_in_test;
|
||||
use clippy_utils::msrvs::Msrv;
|
||||
use rustc_attr_parsing::{RustcVersion, StabilityLevel, StableSince};
|
||||
use rustc_attr_data_structures::{RustcVersion, StabilityLevel, StableSince};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::{Expr, ExprKind, HirId, QPath};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ extern crate rustc_abi;
|
|||
extern crate rustc_arena;
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc_ast_pretty;
|
||||
extern crate rustc_attr_parsing;
|
||||
extern crate rustc_attr_data_structures;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_errors;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use clippy_config::Conf;
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::is_from_proc_macro;
|
||||
use clippy_utils::msrvs::Msrv;
|
||||
use rustc_attr_parsing::{StabilityLevel, StableSince};
|
||||
use rustc_attr_data_structures::{StabilityLevel, StableSince};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::DefId;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#![allow(clippy::missing_clippy_version_attribute)]
|
||||
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc_attr_data_structures;
|
||||
extern crate rustc_attr_parsing;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_errors;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
|
||||
extern crate rustc_abi;
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc_attr_data_structures;
|
||||
extern crate rustc_attr_parsing;
|
||||
extern crate rustc_const_eval;
|
||||
extern crate rustc_data_structures;
|
||||
|
|
@ -88,7 +89,7 @@ use std::sync::{Mutex, MutexGuard, OnceLock};
|
|||
use itertools::Itertools;
|
||||
use rustc_abi::Integer;
|
||||
use rustc_ast::ast::{self, LitKind, RangeLimits};
|
||||
use rustc_attr_parsing::{AttributeKind, find_attr};
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::packed::Pu128;
|
||||
use rustc_data_structures::unhash::UnhashMap;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use crate::sym;
|
||||
use rustc_ast::Attribute;
|
||||
use rustc_ast::attr::AttributeExt;
|
||||
use rustc_attr_parsing::{RustcVersion, parse_version};
|
||||
use rustc_attr_data_structures::RustcVersion;
|
||||
use rustc_attr_parsing::parse_version;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::Symbol;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
use crate::msrvs::{self, Msrv};
|
||||
use hir::LangItem;
|
||||
use rustc_attr_parsing::{RustcVersion, StableSince};
|
||||
use rustc_attr_data_structures::{RustcVersion, StableSince};
|
||||
use rustc_const_eval::check_consts::ConstCx;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
|
|
@ -404,7 +404,7 @@ fn is_stable_const_fn(cx: &LateContext<'_>, def_id: DefId, msrv: Msrv) -> bool {
|
|||
.and_then(|trait_def_id| cx.tcx.lookup_const_stability(trait_def_id))
|
||||
})
|
||||
.is_none_or(|const_stab| {
|
||||
if let rustc_attr_parsing::StabilityLevel::Stable { since, .. } = const_stab.level {
|
||||
if let rustc_attr_data_structures::StabilityLevel::Stable { since, .. } = const_stab.level {
|
||||
// Checking MSRV is manually necessary because `rustc` has no such concept. This entire
|
||||
// function could be removed if `rustc` provided a MSRV-aware version of `is_stable_const_fn`.
|
||||
// as a part of an unimplemented MSRV check https://github.com/rust-lang/rust/issues/65262.
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ extern crate tracing;
|
|||
extern crate rustc_abi;
|
||||
extern crate rustc_apfloat;
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc_attr_parsing;
|
||||
extern crate rustc_attr_data_structures;
|
||||
extern crate rustc_const_eval;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_errors;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use rand::rngs::StdRng;
|
|||
use rand::{Rng, SeedableRng};
|
||||
use rustc_abi::{Align, ExternAbi, Size};
|
||||
use rustc_apfloat::{Float, FloatConvert};
|
||||
use rustc_attr_parsing::InlineAttr;
|
||||
use rustc_attr_data_structures::InlineAttr;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
#[allow(unused)]
|
||||
use rustc_data_structures::static_assert_size;
|
||||
|
|
|
|||
42
tests/codegen/autodiff/generic.rs
Normal file
42
tests/codegen/autodiff/generic.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
//@ compile-flags: -Zautodiff=Enable -Zautodiff=NoPostopt -C opt-level=3 -Clto=fat
|
||||
//@ no-prefer-dynamic
|
||||
//@ needs-enzyme
|
||||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff;
|
||||
|
||||
#[autodiff(d_square, Reverse, Duplicated, Active)]
|
||||
fn square<T: std::ops::Mul<Output = T> + Copy>(x: &T) -> T {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
// Ensure that `d_square::<f64>` code is generated even if `square::<f64>` was never called
|
||||
//
|
||||
// CHECK: ; generic::square
|
||||
// CHECK-NEXT: ; Function Attrs:
|
||||
// CHECK-NEXT: define internal {{.*}} double
|
||||
// CHECK-NEXT: start:
|
||||
// CHECK-NOT: ret
|
||||
// CHECK: fmul double
|
||||
|
||||
// Ensure that `d_square::<f32>` code is generated
|
||||
//
|
||||
// CHECK: ; generic::square
|
||||
// CHECK-NEXT: ; Function Attrs: {{.*}}
|
||||
// CHECK-NEXT: define internal {{.*}} float
|
||||
// CHECK-NEXT: start:
|
||||
// CHECK-NOT: ret
|
||||
// CHECK: fmul float
|
||||
|
||||
fn main() {
|
||||
let xf32: f32 = std::hint::black_box(3.0);
|
||||
let xf64: f64 = std::hint::black_box(3.0);
|
||||
|
||||
let outputf32 = square::<f32>(&xf32);
|
||||
assert_eq!(9.0, outputf32);
|
||||
|
||||
let mut df_dxf64: f64 = std::hint::black_box(0.0);
|
||||
|
||||
let output_f64 = d_square::<f64>(&xf64, &mut df_dxf64, 1.0);
|
||||
assert_eq!(6.0, df_dxf64);
|
||||
}
|
||||
|
|
@ -31,6 +31,8 @@ pub fn f1(x: &[f64], y: f64) -> f64 {
|
|||
|
||||
// We want to make sure that we can use the macro for functions defined inside of functions
|
||||
|
||||
// Make sure we can handle generics
|
||||
|
||||
::core::panicking::panic("not implemented")
|
||||
}
|
||||
#[rustc_autodiff(Forward, 1, Dual, Const, Dual)]
|
||||
|
|
@ -181,4 +183,16 @@ pub fn f9() {
|
|||
::core::hint::black_box(<f32>::default())
|
||||
}
|
||||
}
|
||||
#[rustc_autodiff]
|
||||
#[inline(never)]
|
||||
pub fn f10<T: std::ops::Mul<Output = T> + Copy>(x: &T) -> T { *x * *x }
|
||||
#[rustc_autodiff(Reverse, 1, Duplicated, Active)]
|
||||
#[inline(never)]
|
||||
pub fn d_square<T: std::ops::Mul<Output = T> +
|
||||
Copy>(x: &T, dx_0: &mut T, dret: T) -> T {
|
||||
unsafe { asm!("NOP", options(pure, nomem)); };
|
||||
::core::hint::black_box(f10::<T>(x));
|
||||
::core::hint::black_box((dx_0, dret));
|
||||
::core::hint::black_box(f10::<T>(x))
|
||||
}
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -63,4 +63,10 @@ pub fn f9() {
|
|||
}
|
||||
}
|
||||
|
||||
// Make sure we can handle generics
|
||||
#[autodiff(d_square, Reverse, Duplicated, Active)]
|
||||
pub fn f10<T: std::ops::Mul<Output = T> + Copy>(x: &T) -> T {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
24
tests/ui/async-await/format-await-send.rs
Normal file
24
tests/ui/async-await/format-await-send.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// regression test for <https://github.com/rust-lang/rust/issues/101650>
|
||||
// assert that Future which has format!() with an async function is Send
|
||||
|
||||
#![allow(unused)]
|
||||
|
||||
//@ check-pass
|
||||
//@ edition: 2018
|
||||
|
||||
use core::future::Future;
|
||||
use core::pin::Pin;
|
||||
|
||||
fn build_string() -> Pin<Box<dyn Future<Output = String> + Send>> {
|
||||
Box::pin(async move {
|
||||
let mut string_builder = String::new();
|
||||
string_builder += &format!("Hello {}", helper().await);
|
||||
string_builder
|
||||
})
|
||||
}
|
||||
|
||||
async fn helper() -> String {
|
||||
"World".to_string()
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue