Skip to content

Commit 686f9ce

Browse files
committed
Auto merge of #150115 - JonathanBrouwer:rollup-3gqipmq, r=JonathanBrouwer
Rollup of 4 pull requests Successful merges: - #149922 (Tidying up tests/ui/issues 14 tests [5/N]) - #150095 (Port `#[rustc_no_implicit_autorefs]`, `#[rustc_lint_opt_ty]`, and `#[rustc_lint_query_instability]` attributes to be parsed) - #150099 ([rustdoc] Fix invalid handling of field followed by negated macro call) - #150113 (Update tracking issue for PinCoerceUnsized) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f794a08 + 4ea2467 commit 686f9ce

Some content is hidden

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

44 files changed

+235
-156
lines changed

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcNeverReturnsNullPointerParser {
2727
]);
2828
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNeverReturnsNullPointer;
2929
}
30+
pub(crate) struct RustcNoImplicitAutorefsParser;
31+
32+
impl<S: Stage> NoArgsAttributeParser<S> for RustcNoImplicitAutorefsParser {
33+
const PATH: &[Symbol] = &[sym::rustc_no_implicit_autorefs];
34+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
35+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
36+
Allow(Target::Fn),
37+
Allow(Target::Method(MethodKind::Inherent)),
38+
Allow(Target::Method(MethodKind::Trait { body: false })),
39+
Allow(Target::Method(MethodKind::Trait { body: true })),
40+
Allow(Target::Method(MethodKind::TraitImpl)),
41+
]);
42+
43+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNoImplicitAutorefs;
44+
}
3045

3146
pub(crate) struct RustcLayoutScalarValidRangeStartParser;
3247

@@ -102,6 +117,30 @@ impl<S: Stage> SingleAttributeParser<S> for RustcLegacyConstGenericsParser {
102117
}
103118
}
104119

120+
pub(crate) struct RustcLintOptTyParser;
121+
122+
impl<S: Stage> NoArgsAttributeParser<S> for RustcLintOptTyParser {
123+
const PATH: &[Symbol] = &[sym::rustc_lint_opt_ty];
124+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
125+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]);
126+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintOptTy;
127+
}
128+
129+
pub(crate) struct RustcLintQueryInstabilityParser;
130+
131+
impl<S: Stage> NoArgsAttributeParser<S> for RustcLintQueryInstabilityParser {
132+
const PATH: &[Symbol] = &[sym::rustc_lint_query_instability];
133+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
134+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
135+
Allow(Target::Fn),
136+
Allow(Target::Method(MethodKind::Inherent)),
137+
Allow(Target::Method(MethodKind::Trait { body: false })),
138+
Allow(Target::Method(MethodKind::Trait { body: true })),
139+
Allow(Target::Method(MethodKind::TraitImpl)),
140+
]);
141+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintQueryInstability;
142+
}
143+
105144
pub(crate) struct RustcObjectLifetimeDefaultParser;
106145

107146
impl<S: Stage> SingleAttributeParser<S> for RustcObjectLifetimeDefaultParser {

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ use crate::attributes::prototype::CustomMirParser;
6161
use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser};
6262
use crate::attributes::rustc_internal::{
6363
RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser,
64-
RustcLegacyConstGenericsParser, RustcMainParser, RustcNeverReturnsNullPointerParser,
64+
RustcLegacyConstGenericsParser, RustcLintOptTyParser, RustcLintQueryInstabilityParser,
65+
RustcMainParser, RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser,
6566
RustcObjectLifetimeDefaultParser, RustcScalableVectorParser,
6667
RustcSimdMonomorphizeLaneLimitParser,
6768
};
@@ -255,8 +256,11 @@ attribute_parsers!(
255256
Single<WithoutArgs<ProcMacroParser>>,
256257
Single<WithoutArgs<PubTransparentParser>>,
257258
Single<WithoutArgs<RustcCoherenceIsCoreParser>>,
259+
Single<WithoutArgs<RustcLintOptTyParser>>,
260+
Single<WithoutArgs<RustcLintQueryInstabilityParser>>,
258261
Single<WithoutArgs<RustcMainParser>>,
259262
Single<WithoutArgs<RustcNeverReturnsNullPointerParser>>,
263+
Single<WithoutArgs<RustcNoImplicitAutorefsParser>>,
260264
Single<WithoutArgs<RustcPassIndirectlyInNonRusticAbisParser>>,
261265
Single<WithoutArgs<RustcShouldNotBeCalledOnConstItems>>,
262266
Single<WithoutArgs<SpecializationTraitParser>>,

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,12 +931,21 @@ pub enum AttributeKind {
931931
/// Represents `#[rustc_legacy_const_generics]`
932932
RustcLegacyConstGenerics { fn_indexes: ThinVec<(usize, Span)>, attr_span: Span },
933933

934+
/// Represents `#[rustc_lint_opt_ty]`
935+
RustcLintOptTy,
936+
937+
/// Represents `#[rustc_lint_query_instability]`
938+
RustcLintQueryInstability,
939+
934940
/// Represents `#[rustc_main]`.
935941
RustcMain,
936942

937943
/// Represents `#[rustc_never_returns_null_ptr]`
938944
RustcNeverReturnsNullPointer,
939945

946+
/// Represents `#[rustc_no_implicit_autorefs]`
947+
RustcNoImplicitAutorefs,
948+
940949
/// Represents `#[rustc_object_lifetime_default]`.
941950
RustcObjectLifetimeDefault,
942951

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ impl AttributeKind {
9494
RustcLayoutScalarValidRangeEnd(..) => Yes,
9595
RustcLayoutScalarValidRangeStart(..) => Yes,
9696
RustcLegacyConstGenerics { .. } => Yes,
97+
RustcLintOptTy => Yes,
98+
RustcLintQueryInstability => Yes,
9799
RustcMain => No,
98100
RustcNeverReturnsNullPointer => Yes,
101+
RustcNoImplicitAutorefs => Yes,
99102
RustcObjectLifetimeDefault => No,
100103
RustcPassIndirectlyInNonRusticAbis(..) => No,
101104
RustcScalableVector { .. } => Yes,

compiler/rustc_lint/src/autorefs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use rustc_ast::{BorrowKind, UnOp};
2-
use rustc_hir::{Expr, ExprKind, Mutability};
2+
use rustc_hir::attrs::AttributeKind;
3+
use rustc_hir::{Expr, ExprKind, Mutability, find_attr};
34
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, OverloadedDeref};
45
use rustc_session::{declare_lint, declare_lint_pass};
5-
use rustc_span::sym;
66

77
use crate::lints::{
88
ImplicitUnsafeAutorefsDiag, ImplicitUnsafeAutorefsMethodNote, ImplicitUnsafeAutorefsOrigin,
@@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitAutorefs {
106106
ExprKind::MethodCall(..) => cx.typeck_results().type_dependent_def_id(expr.hir_id),
107107
_ => None,
108108
}
109-
&& method_did.map(|did| cx.tcx.has_attr(did, sym::rustc_no_implicit_autorefs)).unwrap_or(true)
109+
&& method_did.map(|did| find_attr!(cx.tcx.get_all_attrs(did), AttributeKind::RustcNoImplicitAutorefs)).unwrap_or(true)
110110
{
111111
cx.emit_span_lint(
112112
DANGEROUS_IMPLICIT_AUTOREFS,

compiler/rustc_lint/src/internal.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! Some lints that are only useful in the compiler or crates that use compiler internals, such as
22
//! Clippy.
33
4+
use rustc_hir::attrs::AttributeKind;
45
use rustc_hir::def::Res;
56
use rustc_hir::def_id::DefId;
6-
use rustc_hir::{Expr, ExprKind, HirId};
7+
use rustc_hir::{Expr, ExprKind, HirId, find_attr};
78
use rustc_middle::ty::{self, GenericArgsRef, PredicatePolarity, Ty};
89
use rustc_session::{declare_lint_pass, declare_tool_lint};
910
use rustc_span::hygiene::{ExpnKind, MacroKind};
@@ -90,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for QueryStability {
9091
ty::Instance::try_resolve(cx.tcx, cx.typing_env(), callee_def_id, generic_args)
9192
{
9293
let def_id = instance.def_id();
93-
if cx.tcx.has_attr(def_id, sym::rustc_lint_query_instability) {
94+
if find_attr!(cx.tcx.get_all_attrs(def_id), AttributeKind::RustcLintQueryInstability) {
9495
cx.emit_span_lint(
9596
POTENTIAL_QUERY_INSTABILITY,
9697
span,
@@ -150,7 +151,10 @@ fn has_unstable_into_iter_predicate<'tcx>(
150151
};
151152
// Does the input type's `IntoIterator` implementation have the
152153
// `rustc_lint_query_instability` attribute on its `into_iter` method?
153-
if cx.tcx.has_attr(instance.def_id(), sym::rustc_lint_query_instability) {
154+
if find_attr!(
155+
cx.tcx.get_all_attrs(instance.def_id()),
156+
AttributeKind::RustcLintQueryInstability
157+
) {
154158
return true;
155159
}
156160
}
@@ -658,7 +662,7 @@ impl LateLintPass<'_> for BadOptAccess {
658662
let Some(adt_def) = cx.typeck_results().expr_ty(base).ty_adt_def() else { return };
659663
// Skip types without `#[rustc_lint_opt_ty]` - only so that the rest of the lint can be
660664
// avoided.
661-
if !cx.tcx.has_attr(adt_def.did(), sym::rustc_lint_opt_ty) {
665+
if !find_attr!(cx.tcx.get_all_attrs(adt_def.did()), AttributeKind::RustcLintOptTy) {
662666
return;
663667
}
664668

compiler/rustc_passes/messages.ftl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,6 @@ passes_rustc_lint_opt_deny_field_access =
477477
`#[rustc_lint_opt_deny_field_access]` should be applied to a field
478478
.label = not a field
479479
480-
passes_rustc_lint_opt_ty =
481-
`#[rustc_lint_opt_ty]` should be applied to a struct
482-
.label = not a struct
483-
484480
passes_rustc_pub_transparent =
485481
attribute should be applied to `#[repr(transparent)]` types
486482
.label = not a `#[repr(transparent)]` type

compiler/rustc_passes/src/check_attr.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
255255
| AttributeKind::MacroUse { .. }
256256
| AttributeKind::MacroEscape( .. )
257257
| AttributeKind::NoLink
258+
| AttributeKind::RustcNoImplicitAutorefs
258259
| AttributeKind::RustcLayoutScalarValidRangeStart(..)
259260
| AttributeKind::RustcLayoutScalarValidRangeEnd(..)
261+
| AttributeKind::RustcLintOptTy
262+
| AttributeKind::RustcLintQueryInstability
260263
| AttributeKind::RustcNeverReturnsNullPointer
261264
| AttributeKind::RustcScalableVector { .. }
262265
| AttributeKind::RustcSimdMonomorphizeLaneLimit(..)
@@ -305,19 +308,12 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
305308
self.check_diagnostic_on_const(attr.span(), hir_id, target, item)
306309
}
307310
[sym::thread_local, ..] => self.check_thread_local(attr, span, target),
308-
[sym::rustc_no_implicit_autorefs, ..] => {
309-
self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target)
310-
}
311-
[sym::rustc_lint_query_instability, ..] => {
312-
self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target)
313-
}
314311
[sym::rustc_lint_untracked_query_information, ..] => {
315312
self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target)
316313
}
317314
[sym::rustc_lint_diagnostics, ..] => {
318315
self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target)
319316
}
320-
[sym::rustc_lint_opt_ty, ..] => self.check_rustc_lint_opt_ty(attr, span, target),
321317
[sym::rustc_lint_opt_deny_field_access, ..] => {
322318
self.check_rustc_lint_opt_deny_field_access(attr, span, target)
323319
}
@@ -1255,16 +1251,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
12551251
}
12561252
}
12571253

1258-
/// Checks that the `#[rustc_lint_opt_ty]` attribute is only applied to a struct.
1259-
fn check_rustc_lint_opt_ty(&self, attr: &Attribute, span: Span, target: Target) {
1260-
match target {
1261-
Target::Struct => {}
1262-
_ => {
1263-
self.dcx().emit_err(errors::RustcLintOptTy { attr_span: attr.span(), span });
1264-
}
1265-
}
1266-
}
1267-
12681254
/// Checks that the `#[rustc_lint_opt_deny_field_access]` attribute is only applied to a field.
12691255
fn check_rustc_lint_opt_deny_field_access(&self, attr: &Attribute, span: Span, target: Target) {
12701256
match target {

compiler/rustc_passes/src/errors.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,6 @@ pub(crate) struct UnusedMultiple {
412412
pub name: Symbol,
413413
}
414414

415-
#[derive(Diagnostic)]
416-
#[diag(passes_rustc_lint_opt_ty)]
417-
pub(crate) struct RustcLintOptTy {
418-
#[primary_span]
419-
pub attr_span: Span,
420-
#[label]
421-
pub span: Span,
422-
}
423-
424415
#[derive(Diagnostic)]
425416
#[diag(passes_rustc_lint_opt_deny_field_access)]
426417
pub(crate) struct RustcLintOptDenyFieldAccess {

library/alloc/src/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2253,7 +2253,7 @@ impl<Args: Tuple, F: AsyncFn<Args> + ?Sized, A: Allocator> AsyncFn<Args> for Box
22532253
#[unstable(feature = "coerce_unsized", issue = "18598")]
22542254
impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> for Box<T, A> {}
22552255

2256-
#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")]
2256+
#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")]
22572257
unsafe impl<T: ?Sized, A: Allocator> PinCoerceUnsized for Box<T, A> {}
22582258

22592259
// It is quite crucial that we only allow the `Global` allocator here.

0 commit comments

Comments
 (0)