Skip to content

Commit 2719969

Browse files
committed
Auto merge of #151070 - JonathanBrouwer:rollup-hfZvtaP, r=JonathanBrouwer
Rollup of 13 pull requests Successful merges: - #150586 (rustdoc: Fix intra-doc link bugs involving type aliases and associated items) - #150677 (Improve std::path::Path::join documentation) - #150723 (std: move `errno` and related functions into `sys::io`) - #150737 (diagnostics: make implicit Sized bounds explicit in E0277) - #150771 (Remove legacy homu `try` and `auto` branch mentions) - #150915 (Regression test for type params on eii) - #150962 (Remove `FeedConstTy` and provide ty when lowering const arg) - #151017 (Port the rustc dump attributes to the attribute parser) - #151019 (Make `Type::of` support unsized types) - #151034 (std: Change UEFI env vars to volatile storage) - #151052 (ui: add regression test for macro resolution ICE (issue #150711)) - #151053 (Reduce flakyness for `tests/rustdoc-gui/notable-trait.goml`) - #151055 (Emit error instead of delayed bug when meeting mismatch type for const array) r? @ghost
2 parents 2850ca8 + 945e6cd commit 2719969

File tree

109 files changed

+1979
-1349
lines changed

Some content is hidden

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

109 files changed

+1979
-1349
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ name: CI
1111
on:
1212
push:
1313
branches:
14-
- auto
15-
- try
16-
- try-perf
17-
- automation/bors/try
1814
- automation/bors/auto
15+
- automation/bors/try
16+
- try-perf
1917
pull_request:
2018
branches:
2119
- "**"
@@ -33,9 +31,10 @@ defaults:
3331

3432
concurrency:
3533
# For a given workflow, if we push to the same branch, cancel all previous builds on that branch.
36-
# We add an exception for try builds (try branch) and unrolled rollup builds (try-perf), which
37-
# are all triggered on the same branch, but which should be able to run concurrently.
38-
group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try') && github.sha) || github.ref }}
34+
# We add an exception for try builds (automation/bors/try branch) and unrolled rollup builds
35+
# (try-perf), which are all triggered on the same branch, but which should be able to run
36+
# concurrently.
37+
group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try') && github.sha) || github.ref }}
3938
cancel-in-progress: true
4039
env:
4140
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
@@ -57,7 +56,7 @@ jobs:
5756
- name: Test citool
5857
# Only test citool on the auto branch, to reduce latency of the calculate matrix job
5958
# on PR/try builds.
60-
if: ${{ github.ref == 'refs/heads/auto' || github.ref == 'refs/heads/automation/bors/auto' }}
59+
if: ${{ github.ref == 'refs/heads/automation/bors/auto' }}
6160
run: |
6261
cd src/ci/citool
6362
CARGO_INCREMENTAL=0 cargo test
@@ -80,7 +79,7 @@ jobs:
8079
# access the environment.
8180
#
8281
# We only enable the environment for the rust-lang/rust repository, so that CI works on forks.
83-
environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/auto' || github.ref == 'refs/heads/automation/bors/auto')) && 'bors') || '' }}
82+
environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/automation/bors/auto')) && 'bors') || '' }}
8483
env:
8584
CI_JOB_NAME: ${{ matrix.name }}
8685
CI_JOB_DOC_URL: ${{ matrix.doc_url }}
@@ -314,7 +313,7 @@ jobs:
314313
needs: [ calculate_matrix, job ]
315314
# !cancelled() executes the job regardless of whether the previous jobs passed or failed
316315
if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }}
317-
environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/auto' || github.ref == 'refs/heads/automation/bors/auto')) && 'bors') || '' }}
316+
environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/automation/bors/auto')) && 'bors') || '' }}
318317
steps:
319318
- name: checkout the source code
320319
uses: actions/checkout@v5

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pub(crate) mod pin_v2;
5757
pub(crate) mod proc_macro_attrs;
5858
pub(crate) mod prototype;
5959
pub(crate) mod repr;
60+
pub(crate) mod rustc_dump;
6061
pub(crate) mod rustc_internal;
6162
pub(crate) mod semantics;
6263
pub(crate) mod stability;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
use rustc_hir::Target;
2+
use rustc_hir::attrs::AttributeKind;
3+
use rustc_span::{Span, Symbol, sym};
4+
5+
use crate::attributes::prelude::Allow;
6+
use crate::attributes::{NoArgsAttributeParser, OnDuplicate};
7+
use crate::context::Stage;
8+
use crate::target_checking::AllowedTargets;
9+
10+
pub(crate) struct RustcDumpUserArgs;
11+
12+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpUserArgs {
13+
const PATH: &[Symbol] = &[sym::rustc_dump_user_args];
14+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
15+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
16+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpUserArgs;
17+
}
18+
19+
pub(crate) struct RustcDumpDefParents;
20+
21+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpDefParents {
22+
const PATH: &[Symbol] = &[sym::rustc_dump_def_parents];
23+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
24+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
25+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpDefParents;
26+
}
27+
28+
pub(crate) struct RustcDumpItemBounds;
29+
30+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpItemBounds {
31+
const PATH: &[Symbol] = &[sym::rustc_dump_item_bounds];
32+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
33+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::AssocTy)]);
34+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpItemBounds;
35+
}
36+
37+
pub(crate) struct RustcDumpPredicates;
38+
39+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpPredicates {
40+
const PATH: &[Symbol] = &[sym::rustc_dump_predicates];
41+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
42+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
43+
Allow(Target::Struct),
44+
Allow(Target::Enum),
45+
Allow(Target::Union),
46+
Allow(Target::Trait),
47+
Allow(Target::AssocTy),
48+
]);
49+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpPredicates;
50+
}
51+
52+
pub(crate) struct RustcDumpVtable;
53+
54+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpVtable {
55+
const PATH: &[Symbol] = &[sym::rustc_dump_vtable];
56+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
57+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
58+
Allow(Target::Impl { of_trait: true }),
59+
Allow(Target::TyAlias),
60+
]);
61+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcDumpVtable;
62+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ use crate::attributes::proc_macro_attrs::{
6363
};
6464
use crate::attributes::prototype::CustomMirParser;
6565
use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser};
66+
use crate::attributes::rustc_dump::{
67+
RustcDumpDefParents, RustcDumpItemBounds, RustcDumpPredicates, RustcDumpUserArgs,
68+
RustcDumpVtable,
69+
};
6670
use crate::attributes::rustc_internal::{
6771
RustcHasIncoherentInherentImplsParser, RustcLayoutScalarValidRangeEndParser,
6872
RustcLayoutScalarValidRangeStartParser, RustcLegacyConstGenericsParser,
@@ -267,6 +271,11 @@ attribute_parsers!(
267271
Single<WithoutArgs<ProcMacroParser>>,
268272
Single<WithoutArgs<PubTransparentParser>>,
269273
Single<WithoutArgs<RustcCoherenceIsCoreParser>>,
274+
Single<WithoutArgs<RustcDumpDefParents>>,
275+
Single<WithoutArgs<RustcDumpItemBounds>>,
276+
Single<WithoutArgs<RustcDumpPredicates>>,
277+
Single<WithoutArgs<RustcDumpUserArgs>>,
278+
Single<WithoutArgs<RustcDumpVtable>>,
270279
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
271280
Single<WithoutArgs<RustcLintDiagnosticsParser>>,
272281
Single<WithoutArgs<RustcLintOptTyParser>>,

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,21 @@ pub enum AttributeKind {
906906
/// Represents `#[rustc_coherence_is_core]`
907907
RustcCoherenceIsCore(Span),
908908

909+
/// Represents `#[rustc_dump_def_parents]`
910+
RustcDumpDefParents,
911+
912+
/// Represents `#[rustc_dump_item_bounds]`
913+
RustcDumpItemBounds,
914+
915+
/// Represents `#[rustc_dump_predicates]`
916+
RustcDumpPredicates,
917+
918+
/// Represents `#[rustc_dump_user_args]`
919+
RustcDumpUserArgs,
920+
921+
/// Represents `#[rustc_dump_vtable]`
922+
RustcDumpVtable(Span),
923+
909924
/// Represents `#[rustc_has_incoherent_inherent_impls]`
910925
RustcHasIncoherentInherentImpls,
911926

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ impl AttributeKind {
9797
Repr { .. } => No,
9898
RustcBuiltinMacro { .. } => Yes,
9999
RustcCoherenceIsCore(..) => No,
100+
RustcDumpDefParents => No,
101+
RustcDumpItemBounds => No,
102+
RustcDumpPredicates => No,
103+
RustcDumpUserArgs => No,
104+
RustcDumpVtable(..) => No,
100105
RustcHasIncoherentInherentImpls => Yes,
101106
RustcLayoutScalarValidRangeEnd(..) => Yes,
102107
RustcLayoutScalarValidRangeStart(..) => Yes,

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ hir_analysis_duplicate_precise_capture = cannot capture parameter `{$name}` twic
166166
.label = parameter captured again here
167167
168168
hir_analysis_eii_with_generics =
169-
#[{$eii_name}] cannot have generic parameters other than lifetimes
169+
`{$impl_name}` cannot have generic parameters other than lifetimes
170170
.label = required by this attribute
171+
.help = `#[{$eii_name}]` marks the implementation of an "externally implementable item"
171172
172173
hir_analysis_empty_specialization = specialization impl does not specialize any associated items
173174
.note = impl is a specialization of this impl

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,12 +974,19 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
974974
(0, _) => ("const", "consts", None),
975975
_ => ("type or const", "types or consts", None),
976976
};
977+
let name =
978+
if find_attr!(tcx.get_all_attrs(def_id), AttributeKind::EiiForeignItem) {
979+
"externally implementable items"
980+
} else {
981+
"foreign items"
982+
};
983+
977984
let span = tcx.def_span(def_id);
978985
struct_span_code_err!(
979986
tcx.dcx(),
980987
span,
981988
E0044,
982-
"foreign items may not have {kinds} parameters",
989+
"{name} may not have {kinds} parameters",
983990
)
984991
.with_span_label(span, format!("can't have {kinds} parameters"))
985992
.with_help(

compiler/rustc_hir_analysis/src/check/compare_eii.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ use std::iter;
88

99
use rustc_data_structures::fx::FxIndexSet;
1010
use rustc_errors::{Applicability, E0806, struct_span_code_err};
11+
use rustc_hir::attrs::{AttributeKind, EiiImplResolution};
1112
use rustc_hir::def_id::{DefId, LocalDefId};
12-
use rustc_hir::{self as hir, FnSig, HirId, ItemKind};
13+
use rustc_hir::{self as hir, FnSig, HirId, ItemKind, find_attr};
1314
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
1415
use rustc_infer::traits::{ObligationCause, ObligationCauseCode};
1516
use rustc_middle::ty::error::{ExpectedFound, TypeError};
@@ -169,11 +170,23 @@ fn check_no_generics<'tcx>(
169170
eii_attr_span: Span,
170171
) -> Result<(), ErrorGuaranteed> {
171172
let generics = tcx.generics_of(external_impl);
172-
if generics.own_requires_monomorphization() {
173+
if generics.own_requires_monomorphization()
174+
// When an EII implementation is automatically generated by the `#[eii]` macro,
175+
// it will directly refer to the foreign item, not through a macro.
176+
// We don't want to emit this error if it's an implementation that's generated by the `#[eii]` macro,
177+
// since in that case it looks like a duplicate error: the declaration of the EII already can't contain generics.
178+
// So, we check here if at least one of the eii impls has ImplResolution::Macro, which indicates it's
179+
// not generated as part of the declaration.
180+
&& find_attr!(
181+
tcx.get_all_attrs(external_impl),
182+
AttributeKind::EiiImpls(impls) if impls.iter().any(|i| matches!(i.resolution, EiiImplResolution::Macro(_)))
183+
)
184+
{
173185
tcx.dcx().emit_err(EiiWithGenerics {
174186
span: tcx.def_span(external_impl),
175187
attr: eii_attr_span,
176188
eii_name,
189+
impl_name: tcx.item_name(external_impl),
177190
});
178191
}
179192

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ use rustc_trait_selection::traits::{
4747
use tracing::{debug, instrument};
4848

4949
use crate::errors;
50-
use crate::hir_ty_lowering::{
51-
FeedConstTy, HirTyLowerer, InherentAssocCandidate, RegionInferReason,
52-
};
50+
use crate::hir_ty_lowering::{HirTyLowerer, InherentAssocCandidate, RegionInferReason};
5351

5452
pub(crate) mod dump;
5553
mod generics_of;
@@ -1499,7 +1497,7 @@ fn const_param_default<'tcx>(
14991497

15001498
let ct = icx
15011499
.lowerer()
1502-
.lower_const_arg(default_ct, FeedConstTy::with_type_of(tcx, def_id, identity_args));
1500+
.lower_const_arg(default_ct, tcx.type_of(def_id).instantiate(tcx, identity_args));
15031501
ty::EarlyBinder::bind(ct)
15041502
}
15051503

@@ -1557,7 +1555,7 @@ fn const_of_item<'tcx>(
15571555
let identity_args = ty::GenericArgs::identity_for_item(tcx, def_id);
15581556
let ct = icx
15591557
.lowerer()
1560-
.lower_const_arg(ct_arg, FeedConstTy::with_type_of(tcx, def_id.to_def_id(), identity_args));
1558+
.lower_const_arg(ct_arg, tcx.type_of(def_id.to_def_id()).instantiate(tcx, identity_args));
15611559
if let Err(e) = icx.check_tainted_by_errors()
15621560
&& !ct.references_error()
15631561
{

0 commit comments

Comments
 (0)