Skip to content

Commit 4931e09

Browse files
committed
Auto merge of #151087 - GuillaumeGomez:rollup-vIdiReJ, r=GuillaumeGomez
Rollup of 13 pull requests Successful merges: - #150587 (triagebot: add A-rustdoc-js autolabel) - #150677 (Improve std::path::Path::join documentation) - #150737 (diagnostics: make implicit Sized bounds explicit in E0277) - #150771 (Remove legacy homu `try` and `auto` branch mentions) - #150840 (Make `--print=check-cfg` output compatible `--check-cfg` arguments) - #150915 (Regression test for type params on eii) - #151017 (Port the rustc dump attributes to the attribute parser) - #151019 (Make `Type::of` support unsized types) - #151031 (Support arrays in type reflection) - #151043 (armv7-unknown-linux-uclibceabihf.md: Fix bootstrap.toml syntax) - #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 fcac501 + 3adbd3a commit 4931e09

File tree

52 files changed

+728
-175
lines changed

Some content is hidden

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

52 files changed

+728
-175
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_const_eval/src/const_eval/type_info.rs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_hir::LangItem;
33
use rustc_middle::mir::interpret::CtfeProvenance;
44
use rustc_middle::span_bug;
55
use rustc_middle::ty::layout::TyAndLayout;
6-
use rustc_middle::ty::{self, ScalarInt, Ty};
6+
use rustc_middle::ty::{self, Const, ScalarInt, Ty};
77
use rustc_span::{Symbol, sym};
88

99
use crate::const_eval::CompileTimeMachine;
@@ -56,14 +56,21 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
5656
self.write_tuple_fields(tuple_place, fields, ty)?;
5757
variant
5858
}
59+
ty::Array(ty, len) => {
60+
let (variant, variant_place) = downcast(sym::Array)?;
61+
let array_place = self.project_field(&variant_place, FieldIdx::ZERO)?;
62+
63+
self.write_array_type_info(array_place, *ty, *len)?;
64+
65+
variant
66+
}
5967
// For now just merge all primitives into one `Leaf` variant with no data
6068
ty::Uint(_) | ty::Int(_) | ty::Float(_) | ty::Char | ty::Bool => {
6169
downcast(sym::Leaf)?.0
6270
}
6371
ty::Adt(_, _)
6472
| ty::Foreign(_)
6573
| ty::Str
66-
| ty::Array(_, _)
6774
| ty::Pat(_, _)
6875
| ty::Slice(_)
6976
| ty::RawPtr(..)
@@ -172,4 +179,28 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
172179
}
173180
interp_ok(())
174181
}
182+
183+
pub(crate) fn write_array_type_info(
184+
&mut self,
185+
place: impl Writeable<'tcx, CtfeProvenance>,
186+
ty: Ty<'tcx>,
187+
len: Const<'tcx>,
188+
) -> InterpResult<'tcx> {
189+
// Iterate over all fields of `type_info::Array`.
190+
for (field_idx, field) in
191+
place.layout().ty.ty_adt_def().unwrap().non_enum_variant().fields.iter_enumerated()
192+
{
193+
let field_place = self.project_field(&place, field_idx)?;
194+
195+
match field.name {
196+
// Write the `TypeId` of the array's elements to the `element_ty` field.
197+
sym::element_ty => self.write_type_id(ty, &field_place)?,
198+
// Write the length of the array to the `len` field.
199+
sym::len => self.write_scalar(len.to_leaf(), &field_place)?,
200+
other => span_bug!(self.tcx.def_span(field.did), "unimplemented field {other}"),
201+
}
202+
}
203+
204+
interp_ok(())
205+
}
175206
}

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -765,30 +765,35 @@ fn print_crate_info(
765765
for (name, expected_values) in &sess.psess.check_config.expecteds {
766766
use crate::config::ExpectedValues;
767767
match expected_values {
768-
ExpectedValues::Any => check_cfgs.push(format!("{name}=any()")),
768+
ExpectedValues::Any => {
769+
check_cfgs.push(format!("cfg({name}, values(any()))"))
770+
}
769771
ExpectedValues::Some(values) => {
770-
if !values.is_empty() {
771-
check_cfgs.extend(values.iter().map(|value| {
772+
let mut values: Vec<_> = values
773+
.iter()
774+
.map(|value| {
772775
if let Some(value) = value {
773-
format!("{name}=\"{value}\"")
776+
format!("\"{value}\"")
774777
} else {
775-
name.to_string()
778+
"none()".to_string()
776779
}
777-
}))
778-
} else {
779-
check_cfgs.push(format!("{name}="))
780-
}
780+
})
781+
.collect();
782+
783+
values.sort_unstable();
784+
785+
let values = values.join(", ");
786+
787+
check_cfgs.push(format!("cfg({name}, values({values}))"))
781788
}
782789
}
783790
}
784791

785792
check_cfgs.sort_unstable();
786-
if !sess.psess.check_config.exhaustive_names {
787-
if !sess.psess.check_config.exhaustive_values {
788-
println_info!("any()=any()");
789-
} else {
790-
println_info!("any()");
791-
}
793+
if !sess.psess.check_config.exhaustive_names
794+
&& sess.psess.check_config.exhaustive_values
795+
{
796+
println_info!("cfg(any())");
792797
}
793798
for check_cfg in check_cfgs {
794799
println_info!("{check_cfg}");

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(

0 commit comments

Comments
 (0)