Skip to content

Commit 0376d43

Browse files
committed
Auto merge of #152904 - JonathanBrouwer:rollup-8vFeFeZ, r=JonathanBrouwer
Rollup of 11 pull requests Successful merges: - #152759 (Simpler `find_attr!()`) - #152057 (bootstrap: respect POSIX jobserver) - #152818 (DOC: do not link to "nightly" in Iterator::by_ref() docstring) - #152840 (Add bootstrap snapshot tests for {`install`, `install src`}) - #152844 (Rename `DepGraphQuery` to `RetainedDepGraph`) - #152846 (Clarify some variable names in the query proc-macro) - #152858 (Fix typo in doc for core::mem::type_info::Struct) - #152861 (resolve: do not suggest `_` for unresolved imports) - #152873 (std::ops::ControlFlow - use "a" before `Result`) - #152877 (std::ops::ControlFlow - use normal comment for internal methods) - #152883 (Deny final not followed by item)
2 parents 59fd4ef + a196a00 commit 0376d43

163 files changed

Lines changed: 1226 additions & 905 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
264264
.flatten()
265265
})
266266
.flatten(),
267-
None => self
268-
.tcx
269-
.get_all_attrs(*def_id)
270-
.iter()
271-
.find(|base_attr| (addition_info.equals)(base_attr)),
267+
None =>
268+
{
269+
#[allow(deprecated)]
270+
self.tcx
271+
.get_all_attrs(*def_id)
272+
.iter()
273+
.find(|base_attr| (addition_info.equals)(base_attr))
274+
}
272275
};
273276

274277
if let Some(original_attr) = original_attr {

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_ast_pretty::pprust::expr_to_string;
77
use rustc_data_structures::stack::ensure_sufficient_stack;
88
use rustc_errors::msg;
99
use rustc_hir as hir;
10-
use rustc_hir::attrs::AttributeKind;
1110
use rustc_hir::def::{DefKind, Res};
1211
use rustc_hir::definitions::DefPathData;
1312
use rustc_hir::{HirId, Target, find_attr};
@@ -805,7 +804,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
805804
) {
806805
if self.tcx.features().async_fn_track_caller()
807806
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
808-
&& find_attr!(*attrs, AttributeKind::TrackCaller(_))
807+
&& find_attr!(*attrs, TrackCaller(_))
809808
{
810809
let unstable_span = self.mark_span_with_reason(
811810
DesugaringKind::Async,
@@ -1072,8 +1071,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10721071
let (binder_clause, generic_params) = self.lower_closure_binder(binder);
10731072

10741073
let (body_id, closure_kind) = self.with_new_scopes(fn_decl_span, move |this| {
1075-
1076-
let mut coroutine_kind = find_attr!(attrs, AttributeKind::Coroutine(_) => hir::CoroutineKind::Coroutine(Movability::Movable));
1074+
let mut coroutine_kind = find_attr!(attrs, Coroutine(_) => hir::CoroutineKind::Coroutine(Movability::Movable));
10771075

10781076
// FIXME(contracts): Support contracts on closures?
10791077
let body_id = this.lower_fn_body(decl, None, |this| {

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
243243
vis_span,
244244
span: self.lower_span(i.span),
245245
has_delayed_lints: !self.delayed_lints.is_empty(),
246-
eii: find_attr!(attrs, AttributeKind::EiiImpls(..) | AttributeKind::EiiDeclaration(..)),
246+
eii: find_attr!(attrs, EiiImpls(..) | EiiDeclaration(..)),
247247
};
248248
self.arena.alloc(item)
249249
}
@@ -707,10 +707,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
707707
vis_span,
708708
span: this.lower_span(use_tree.span),
709709
has_delayed_lints: !this.delayed_lints.is_empty(),
710-
eii: find_attr!(
711-
attrs,
712-
AttributeKind::EiiImpls(..) | AttributeKind::EiiDeclaration(..)
713-
),
710+
eii: find_attr!(attrs, EiiImpls(..) | EiiDeclaration(..)),
714711
};
715712
hir::OwnerNode::Item(this.arena.alloc(item))
716713
});
@@ -1415,9 +1412,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14151412
// create a fake body so that the entire rest of the compiler doesn't have to deal with
14161413
// this as a special case.
14171414
return self.lower_fn_body(decl, contract, |this| {
1418-
if find_attr!(attrs, AttributeKind::RustcIntrinsic)
1419-
|| this.tcx.is_sdylib_interface_build()
1420-
{
1415+
if find_attr!(attrs, RustcIntrinsic) || this.tcx.is_sdylib_interface_build() {
14211416
let span = this.lower_span(span);
14221417
let empty_block = hir::Block {
14231418
hir_id: this.next_id(),
@@ -1695,7 +1690,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
16951690
let safety = self.lower_safety(h.safety, default_safety);
16961691

16971692
// Treat safe `#[target_feature]` functions as unsafe, but also remember that we did so.
1698-
let safety = if find_attr!(attrs, AttributeKind::TargetFeature { was_forced: false, .. })
1693+
let safety = if find_attr!(attrs, TargetFeature { was_forced: false, .. })
16991694
&& safety.is_safe()
17001695
&& !self.tcx.sess.target.is_like_wasm
17011696
{

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
4747
use rustc_data_structures::sync::spawn;
4848
use rustc_data_structures::tagged_ptr::TaggedRef;
4949
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle};
50-
use rustc_hir::attrs::AttributeKind;
5150
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5251
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
5352
use rustc_hir::definitions::{DefPathData, DisambiguatorState};
@@ -255,10 +254,10 @@ impl ResolverAstLowering {
255254
return None;
256255
}
257256

257+
// we can use parsed attrs here since for other crates they're already available
258258
find_attr!(
259-
// we can use parsed attrs here since for other crates they're already available
260-
tcx.get_all_attrs(def_id),
261-
AttributeKind::RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes
259+
tcx, def_id,
260+
RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes
262261
)
263262
.map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect())
264263
}

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,6 @@ impl<S: Stage> CombineAttributeParser<S> for RustcMirParser {
854854
.collect()
855855
}
856856
}
857-
858857
pub(crate) struct RustcNonConstTraitMethodParser;
859858

860859
impl<S: Stage> NoArgsAttributeParser<S> for RustcNonConstTraitMethodParser {
@@ -1252,24 +1251,6 @@ impl<S: Stage> SingleAttributeParser<S> for RustcDefPath {
12521251
}
12531252
}
12541253

1255-
pub(crate) struct RustcIntrinsicParser;
1256-
1257-
impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicParser {
1258-
const PATH: &[Symbol] = &[sym::rustc_intrinsic];
1259-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
1260-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
1261-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsic;
1262-
}
1263-
1264-
pub(crate) struct RustcIntrinsicConstStableIndirectParser;
1265-
1266-
impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicConstStableIndirectParser {
1267-
const PATH: &'static [Symbol] = &[sym::rustc_intrinsic_const_stable_indirect];
1268-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
1269-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
1270-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsicConstStableIndirect;
1271-
}
1272-
12731254
pub(crate) struct RustcStrictCoherenceParser;
12741255

12751256
impl<S: Stage> NoArgsAttributeParser<S> for RustcStrictCoherenceParser {
@@ -1343,3 +1324,21 @@ impl<S: Stage> SingleAttributeParser<S> for RustcDocPrimitiveParser {
13431324
Some(AttributeKind::RustcDocPrimitive(cx.attr_span, value_str))
13441325
}
13451326
}
1327+
1328+
pub(crate) struct RustcIntrinsicParser;
1329+
1330+
impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicParser {
1331+
const PATH: &[Symbol] = &[sym::rustc_intrinsic];
1332+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
1333+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
1334+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsic;
1335+
}
1336+
1337+
pub(crate) struct RustcIntrinsicConstStableIndirectParser;
1338+
1339+
impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicConstStableIndirectParser {
1340+
const PATH: &'static [Symbol] = &[sym::rustc_intrinsic_const_stable_indirect];
1341+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
1342+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
1343+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsicConstStableIndirect;
1344+
}

compiler/rustc_borrowck/src/nll.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::str::FromStr;
77

88
use polonius_engine::{Algorithm, AllFacts, Output};
99
use rustc_data_structures::frozen::Frozen;
10-
use rustc_hir::attrs::AttributeKind;
1110
use rustc_hir::find_attr;
1211
use rustc_index::IndexSlice;
1312
use rustc_middle::mir::pretty::PrettyPrintMirOptions;
@@ -296,7 +295,7 @@ pub(super) fn dump_annotation<'tcx, 'infcx>(
296295
) {
297296
let tcx = infcx.tcx;
298297
let base_def_id = tcx.typeck_root_def_id(body.source.def_id());
299-
if !find_attr!(tcx.get_all_attrs(base_def_id), AttributeKind::RustcRegions) {
298+
if !find_attr!(tcx, base_def_id, RustcRegions) {
300299
return;
301300
}
302301

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
460460
{
461461
to_add.push(create_alloc_family_attr(cx.llcx));
462462
if let Some(instance) = instance
463-
&& let Some(name) = find_attr!(tcx.get_all_attrs(instance.def_id()), rustc_hir::attrs::AttributeKind::RustcAllocatorZeroedVariant {name} => name)
463+
&& let Some(name) =
464+
find_attr!(tcx, instance.def_id(), RustcAllocatorZeroedVariant {name} => name)
464465
{
465466
to_add.push(llvm::CreateAttrStringValue(
466467
cx.llcx,

compiler/rustc_codegen_ssa/src/assert_module_sources.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::fmt;
2828

2929
use rustc_data_structures::unord::{UnordMap, UnordSet};
3030
use rustc_errors::{DiagArgValue, IntoDiagArg};
31-
use rustc_hir::attrs::{AttributeKind, CguFields, CguKind};
31+
use rustc_hir::attrs::{CguFields, CguKind};
3232
use rustc_hir::def_id::LOCAL_CRATE;
3333
use rustc_hir::{self as hir, find_attr};
3434
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
@@ -89,7 +89,7 @@ struct AssertModuleSource<'tcx> {
8989
impl<'tcx> AssertModuleSource<'tcx> {
9090
fn check_attrs(&mut self, attrs: &[hir::Attribute]) {
9191
for &(span, cgu_fields) in find_attr!(attrs,
92-
AttributeKind::RustcCguTestAttr(e) => e)
92+
RustcCguTestAttr(e) => e)
9393
.into_iter()
9494
.flatten()
9595
{

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use rustc_errors::{
1818
Level, MultiSpan, Style, Suggestions, catch_fatal_errors,
1919
};
2020
use rustc_fs_util::link_or_copy;
21-
use rustc_hir::attrs::AttributeKind;
2221
use rustc_hir::find_attr;
2322
use rustc_incremental::{
2423
copy_cgu_workproduct_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
@@ -454,8 +453,7 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
454453
) -> OngoingCodegen<B> {
455454
let (coordinator_send, coordinator_receive) = channel();
456455

457-
let crate_attrs = tcx.hir_attrs(rustc_hir::CRATE_HIR_ID);
458-
let no_builtins = find_attr!(crate_attrs, AttributeKind::NoBuiltins);
456+
let no_builtins = find_attr!(tcx, crate, NoBuiltins);
459457

460458
let crate_info = CrateInfo::new(tcx, target_cpu);
461459

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
1313
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
1414
use rustc_data_structures::sync::{IntoDynSyncSend, par_map};
1515
use rustc_data_structures::unord::UnordMap;
16-
use rustc_hir::attrs::{AttributeKind, DebuggerVisualizerType, OptimizeAttr};
17-
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE};
16+
use rustc_hir::attrs::{DebuggerVisualizerType, OptimizeAttr};
17+
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
1818
use rustc_hir::lang_items::LangItem;
1919
use rustc_hir::{ItemId, Target, find_attr};
2020
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
@@ -894,7 +894,7 @@ impl CrateInfo {
894894
let linked_symbols =
895895
crate_types.iter().map(|&c| (c, crate::back::linker::linked_symbols(tcx, c))).collect();
896896
let local_crate_name = tcx.crate_name(LOCAL_CRATE);
897-
let windows_subsystem = find_attr!(tcx.get_all_attrs(CRATE_DEF_ID), AttributeKind::WindowsSubsystem(kind, _) => *kind);
897+
let windows_subsystem = find_attr!(tcx, crate, WindowsSubsystem(kind, _) => *kind);
898898

899899
// This list is used when generating the command line to pass through to
900900
// system linker. The linker expects undefined symbols on the left of the

0 commit comments

Comments
 (0)