Skip to content

Commit 06cafcb

Browse files
committed
Auto merge of rust-lang#152274 - JonathanBrouwer:rollup-5GoDGKf, r=JonathanBrouwer
Rollup of 4 pull requests Successful merges: - rust-lang#146900 (Add avr_target_feature) - rust-lang#150949 (Port symbol mangler attrs) - rust-lang#152252 (Convert diagnostic style checks) - rust-lang#152265 (Use `.map.collect` to aggregate in `.to_ty` of tuples)
2 parents 56aaf58 + 5e476ba commit 06cafcb

File tree

55 files changed

+262
-405
lines changed

Some content is hidden

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

55 files changed

+262
-405
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,11 +656,7 @@ impl Pat {
656656
// A tuple pattern `(P0, .., Pn)` can be reparsed as `(T0, .., Tn)`
657657
// assuming `T0` to `Tn` are all syntactically valid as types.
658658
PatKind::Tuple(pats) => {
659-
let mut tys = ThinVec::with_capacity(pats.len());
660-
// FIXME(#48994) - could just be collected into an Option<Vec>
661-
for pat in pats {
662-
tys.push(pat.to_ty()?);
663-
}
659+
let tys = pats.iter().map(|pat| pat.to_ty()).collect::<Option<ThinVec<_>>>()?;
664660
TyKind::Tup(tys)
665661
}
666662
_ => return None,

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,3 +760,53 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcEffectiveVisibilityParser {
760760
]);
761761
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcEffectiveVisibility;
762762
}
763+
764+
pub(crate) struct RustcSymbolName;
765+
766+
impl<S: Stage> SingleAttributeParser<S> for RustcSymbolName {
767+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
768+
Allow(Target::Fn),
769+
Allow(Target::Method(MethodKind::TraitImpl)),
770+
Allow(Target::Method(MethodKind::Inherent)),
771+
Allow(Target::Method(MethodKind::Trait { body: true })),
772+
Allow(Target::ForeignFn),
773+
Allow(Target::ForeignStatic),
774+
Allow(Target::Impl { of_trait: false }),
775+
]);
776+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
777+
const PATH: &[Symbol] = &[sym::rustc_symbol_name];
778+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
779+
const TEMPLATE: AttributeTemplate = template!(Word);
780+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
781+
if let Err(span) = args.no_args() {
782+
cx.expected_no_args(span);
783+
return None;
784+
}
785+
Some(AttributeKind::RustcSymbolName(cx.attr_span))
786+
}
787+
}
788+
789+
pub(crate) struct RustcDefPath;
790+
791+
impl<S: Stage> SingleAttributeParser<S> for RustcDefPath {
792+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
793+
Allow(Target::Fn),
794+
Allow(Target::Method(MethodKind::TraitImpl)),
795+
Allow(Target::Method(MethodKind::Inherent)),
796+
Allow(Target::Method(MethodKind::Trait { body: true })),
797+
Allow(Target::ForeignFn),
798+
Allow(Target::ForeignStatic),
799+
Allow(Target::Impl { of_trait: false }),
800+
]);
801+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
802+
const PATH: &[Symbol] = &[sym::rustc_def_path];
803+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
804+
const TEMPLATE: AttributeTemplate = template!(Word);
805+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
806+
if let Err(span) = args.no_args() {
807+
cx.expected_no_args(span);
808+
return None;
809+
}
810+
Some(AttributeKind::RustcDefPath(cx.attr_span))
811+
}
812+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ attribute_parsers!(
194194
Single<RustcAbiParser>,
195195
Single<RustcAllocatorZeroedVariantParser>,
196196
Single<RustcBuiltinMacroParser>,
197+
Single<RustcDefPath>,
197198
Single<RustcForceInlineParser>,
198199
Single<RustcIfThisChangedParser>,
199200
Single<RustcLayoutScalarValidRangeEndParser>,
@@ -204,6 +205,7 @@ attribute_parsers!(
204205
Single<RustcObjectLifetimeDefaultParser>,
205206
Single<RustcScalableVectorParser>,
206207
Single<RustcSimdMonomorphizeLaneLimitParser>,
208+
Single<RustcSymbolName>,
207209
Single<SanitizeParser>,
208210
Single<ShouldPanicParser>,
209211
Single<SkipDuringMethodDispatchParser>,

compiler/rustc_codegen_llvm/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,5 @@ pub(crate) struct FixedX18InvalidArch<'a> {
214214
}
215215

216216
#[derive(Diagnostic)]
217-
#[diag("`-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later.")]
217+
#[diag("`-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later")]
218218
pub(crate) struct SanitizerKcfiArityRequiresLLVM2100;

compiler/rustc_codegen_ssa/src/errors.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub(crate) struct MissingQueryDepGraph {
5959

6060
#[derive(Diagnostic)]
6161
#[diag(
62-
"found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case)."
62+
"found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case)"
6363
)]
6464
pub(crate) struct MalformedCguName {
6565
#[primary_span]
@@ -562,12 +562,12 @@ pub(crate) struct SelfContainedLinkerMissing;
562562

563563
#[derive(Diagnostic)]
564564
#[diag(
565-
"please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option."
565+
"please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option"
566566
)]
567567
pub(crate) struct CheckInstalledVisualStudio;
568568

569569
#[derive(Diagnostic)]
570-
#[diag("VS Code is a different product, and is not sufficient.")]
570+
#[diag("VS Code is a different product, and is not sufficient")]
571571
pub(crate) struct InsufficientVSCodeProduct;
572572

573573
#[derive(Diagnostic)]
@@ -610,13 +610,13 @@ pub(crate) struct LinkerFileStem;
610610

611611
#[derive(Diagnostic)]
612612
#[diag(
613-
"link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms."
613+
"link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms"
614614
)]
615615
pub(crate) struct StaticLibraryNativeArtifacts;
616616

617617
#[derive(Diagnostic)]
618618
#[diag(
619-
"native artifacts to link against have been written to {$path}. The order and any duplication can be significant on some platforms."
619+
"native artifacts to link against have been written to {$path}. The order and any duplication can be significant on some platforms"
620620
)]
621621
pub(crate) struct StaticLibraryNativeArtifactsToFile<'a> {
622622
pub path: &'a Path,

compiler/rustc_const_eval/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ pub(crate) struct UnallowedHeapAllocations {
309309
pub span: Span,
310310
pub kind: ConstContext,
311311
#[note(
312-
"The runtime heap is not yet available at compile-time, so no runtime heap allocations can be created."
312+
"the runtime heap is not yet available at compile-time, so no runtime heap allocations can be created"
313313
)]
314314
pub teach: bool,
315315
}
@@ -347,7 +347,7 @@ pub(crate) struct InteriorMutableBorrowEscaping {
347347
#[diag("constant evaluation is taking a long time")]
348348
#[note(
349349
"this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
350-
If your compilation actually takes a long time, you can safely allow the lint."
350+
If your compilation actually takes a long time, you can safely allow the lint"
351351
)]
352352
pub struct LongRunning {
353353
#[help("the constant being evaluated")]

compiler/rustc_driver_impl/src/session_diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub(crate) struct RlinkCorruptFile<'a> {
5151
}
5252

5353
#[derive(Diagnostic)]
54-
#[diag("the compiler unexpectedly panicked. this is a bug.")]
54+
#[diag("the compiler unexpectedly panicked. This is a bug")]
5555
pub(crate) struct Ice;
5656

5757
#[derive(Diagnostic)]

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ declare_features! (
373373
(unstable, async_for_loop, "1.77.0", Some(118898)),
374374
/// Allows `async` trait bound modifier.
375375
(unstable, async_trait_bounds, "1.85.0", Some(62290)),
376+
/// Target features on avr.
377+
(unstable, avr_target_feature, "CURRENT_RUSTC_VERSION", Some(146889)),
376378
/// Allows using Intel AVX10 target features and intrinsics
377379
(unstable, avx10_target_feature, "1.88.0", Some(138843)),
378380
/// Target features on bpf.

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,9 @@ pub enum AttributeKind {
10811081
/// Represents `#[rustc_deallocator]`
10821082
RustcDeallocator,
10831083

1084+
/// Represents `#[rustc_def_path]`
1085+
RustcDefPath(Span),
1086+
10841087
/// Represents `#[rustc_deny_explicit_impl]`.
10851088
RustcDenyExplicitImpl(Span),
10861089

@@ -1218,6 +1221,9 @@ pub enum AttributeKind {
12181221
/// Represents `#[rustc_std_internal_symbol]`.
12191222
RustcStdInternalSymbol(Span),
12201223

1224+
/// Represents `#[rustc_symbol_name]`
1225+
RustcSymbolName(Span),
1226+
12211227
/// Represents `#[rustc_then_this_would_need]`
12221228
RustcThenThisWouldNeed(Span, ThinVec<Ident>),
12231229

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ impl AttributeKind {
105105
RustcConstStability { .. } => Yes,
106106
RustcConstStabilityIndirect => No,
107107
RustcDeallocator => No,
108+
RustcDefPath(..) => No,
108109
RustcDenyExplicitImpl(..) => No,
109110
RustcDummy => No,
110111
RustcDumpDefParents => No,
@@ -149,6 +150,7 @@ impl AttributeKind {
149150
RustcSkipDuringMethodDispatch { .. } => No,
150151
RustcSpecializationTrait(..) => No,
151152
RustcStdInternalSymbol(..) => No,
153+
RustcSymbolName(..) => Yes,
152154
RustcThenThisWouldNeed(..) => No,
153155
RustcUnsafeSpecializationMarker(..) => No,
154156
RustcVariance => No,

0 commit comments

Comments
 (0)