Skip to content

Commit ac47dba

Browse files
committed
Auto merge of rust-lang#126824 - GuillaumeGomez:rollup-sybv8o7, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - rust-lang#126555 (Add `f16` inline ASM support for 32-bit ARM) - rust-lang#126686 (Add `#[rustc_dump_{predicates,item_bounds}]`) - rust-lang#126723 (Fix `...` in multline code-skips in suggestions) - rust-lang#126731 (Bootstrap command refactoring: refactor `BootstrapCommand` (step 1)) - rust-lang#126823 (Migrate `run-make/inline-always-many-cgu` to `rmake.rs`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d03d6c0 + d265538 commit ac47dba

Some content is hidden

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

45 files changed

+723
-424
lines changed

compiler/rustc_codegen_llvm/src/asm.rs

+39
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,19 @@ fn llvm_fixup_input<'ll, 'tcx>(
10371037
value
10381038
}
10391039
}
1040+
(
1041+
InlineAsmRegClass::Arm(
1042+
ArmInlineAsmRegClass::dreg
1043+
| ArmInlineAsmRegClass::dreg_low8
1044+
| ArmInlineAsmRegClass::dreg_low16
1045+
| ArmInlineAsmRegClass::qreg
1046+
| ArmInlineAsmRegClass::qreg_low4
1047+
| ArmInlineAsmRegClass::qreg_low8,
1048+
),
1049+
Abi::Vector { element, count: count @ (4 | 8) },
1050+
) if element.primitive() == Primitive::Float(Float::F16) => {
1051+
bx.bitcast(value, bx.type_vector(bx.type_i16(), count))
1052+
}
10401053
(InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg), Abi::Scalar(s)) => {
10411054
match s.primitive() {
10421055
// MIPS only supports register-length arithmetics.
@@ -1158,6 +1171,19 @@ fn llvm_fixup_output<'ll, 'tcx>(
11581171
value
11591172
}
11601173
}
1174+
(
1175+
InlineAsmRegClass::Arm(
1176+
ArmInlineAsmRegClass::dreg
1177+
| ArmInlineAsmRegClass::dreg_low8
1178+
| ArmInlineAsmRegClass::dreg_low16
1179+
| ArmInlineAsmRegClass::qreg
1180+
| ArmInlineAsmRegClass::qreg_low4
1181+
| ArmInlineAsmRegClass::qreg_low8,
1182+
),
1183+
Abi::Vector { element, count: count @ (4 | 8) },
1184+
) if element.primitive() == Primitive::Float(Float::F16) => {
1185+
bx.bitcast(value, bx.type_vector(bx.type_f16(), count))
1186+
}
11611187
(InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg), Abi::Scalar(s)) => {
11621188
match s.primitive() {
11631189
// MIPS only supports register-length arithmetics.
@@ -1270,6 +1296,19 @@ fn llvm_fixup_output_type<'ll, 'tcx>(
12701296
layout.llvm_type(cx)
12711297
}
12721298
}
1299+
(
1300+
InlineAsmRegClass::Arm(
1301+
ArmInlineAsmRegClass::dreg
1302+
| ArmInlineAsmRegClass::dreg_low8
1303+
| ArmInlineAsmRegClass::dreg_low16
1304+
| ArmInlineAsmRegClass::qreg
1305+
| ArmInlineAsmRegClass::qreg_low4
1306+
| ArmInlineAsmRegClass::qreg_low8,
1307+
),
1308+
Abi::Vector { element, count: count @ (4 | 8) },
1309+
) if element.primitive() == Primitive::Float(Float::F16) => {
1310+
cx.type_vector(cx.type_i16(), count)
1311+
}
12731312
(InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg), Abi::Scalar(s)) => {
12741313
match s.primitive() {
12751314
// MIPS only supports register-length arithmetics.

compiler/rustc_errors/src/emitter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,7 @@ impl HumanEmitter {
19051905
//
19061906
// LL | this line was highlighted
19071907
// LL | this line is just for context
1908-
// ...
1908+
// ...
19091909
// LL | this line is just for context
19101910
// LL | this line was highlighted
19111911
_ => {
@@ -1926,7 +1926,7 @@ impl HumanEmitter {
19261926
)
19271927
}
19281928

1929-
buffer.puts(row_num, max_line_num_len - 1, "...", Style::LineNumber);
1929+
buffer.puts(row_num, 0, "...", Style::LineNumber);
19301930
row_num += 1;
19311931

19321932
if let Some((p, l)) = last_line {

compiler/rustc_feature/src/builtin_attrs.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,14 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
10881088
ErrorFollowing, EncodeCrossCrate::No,
10891089
"the `#[custom_mir]` attribute is just used for the Rust test suite",
10901090
),
1091+
rustc_attr!(
1092+
TEST, rustc_dump_item_bounds, Normal, template!(Word),
1093+
WarnFollowing, EncodeCrossCrate::No
1094+
),
1095+
rustc_attr!(
1096+
TEST, rustc_dump_predicates, Normal, template!(Word),
1097+
WarnFollowing, EncodeCrossCrate::No
1098+
),
10911099
rustc_attr!(
10921100
TEST, rustc_object_lifetime_default, Normal, template!(Word),
10931101
WarnFollowing, EncodeCrossCrate::No

compiler/rustc_hir_analysis/messages.ftl

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ hir_analysis_ty_param_some = type parameter `{$param}` must be used as the type
510510
.note = implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
511511
.only_note = only traits defined in the current crate can be implemented for a type parameter
512512
513-
hir_analysis_type_of = {$type_of}
513+
hir_analysis_type_of = {$ty}
514514
515515
hir_analysis_typeof_reserved_keyword_used =
516516
`typeof` is a reserved keyword but unimplemented
@@ -566,7 +566,7 @@ hir_analysis_value_of_associated_struct_already_specified =
566566
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like {$conventions}
567567
.label = C-variadic function must have a compatible calling convention
568568
569-
hir_analysis_variances_of = {$variances_of}
569+
hir_analysis_variances_of = {$variances}
570570
571571
hir_analysis_where_clause_on_main = `main` function is not allowed to have a `where` clause
572572
.label = `main` cannot have a `where` clause

compiler/rustc_hir_analysis/src/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ use std::ops::Bound;
4545
use crate::check::intrinsic::intrinsic_operation_unsafety;
4646
use crate::errors;
4747
use crate::hir_ty_lowering::{HirTyLowerer, RegionInferReason};
48-
pub use type_of::test_opaque_hidden_types;
4948

49+
pub(crate) mod dump;
5050
mod generics_of;
5151
mod item_bounds;
5252
mod predicates_of;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
use rustc_hir::def::DefKind;
2+
use rustc_hir::def_id::CRATE_DEF_ID;
3+
use rustc_middle::ty::TyCtxt;
4+
use rustc_span::sym;
5+
6+
pub(crate) fn opaque_hidden_types(tcx: TyCtxt<'_>) {
7+
if !tcx.has_attr(CRATE_DEF_ID, sym::rustc_hidden_type_of_opaques) {
8+
return;
9+
}
10+
11+
for id in tcx.hir().items() {
12+
let DefKind::OpaqueTy = tcx.def_kind(id.owner_id) else { continue };
13+
14+
let ty = tcx.type_of(id.owner_id).instantiate_identity();
15+
16+
tcx.dcx().emit_err(crate::errors::TypeOf { span: tcx.def_span(id.owner_id), ty });
17+
}
18+
}
19+
20+
pub(crate) fn predicates_and_item_bounds(tcx: TyCtxt<'_>) {
21+
for id in tcx.hir_crate_items(()).owners() {
22+
if tcx.has_attr(id, sym::rustc_dump_predicates) {
23+
let preds = tcx.predicates_of(id).instantiate_identity(tcx).predicates;
24+
let span = tcx.def_span(id);
25+
26+
let mut diag = tcx.dcx().struct_span_err(span, sym::rustc_dump_predicates.as_str());
27+
for pred in preds {
28+
diag.note(format!("{pred:?}"));
29+
}
30+
diag.emit();
31+
}
32+
if tcx.has_attr(id, sym::rustc_dump_item_bounds) {
33+
let bounds = tcx.item_bounds(id).instantiate_identity();
34+
let span = tcx.def_span(id);
35+
36+
let mut diag = tcx.dcx().struct_span_err(span, sym::rustc_dump_item_bounds.as_str());
37+
for bound in bounds {
38+
diag.note(format!("{bound:?}"));
39+
}
40+
diag.emit();
41+
}
42+
}
43+
}

compiler/rustc_hir_analysis/src/collect/type_of.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::errors::TypeofReservedKeywordUsed;
1515

1616
use super::bad_placeholder;
1717
use super::ItemCtxt;
18-
pub use opaque::test_opaque_hidden_types;
1918

2019
mod opaque;
2120

compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs

+3-17
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
11
use rustc_errors::StashKey;
22
use rustc_hir::def::DefKind;
3-
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
3+
use rustc_hir::def_id::LocalDefId;
44
use rustc_hir::intravisit::{self, Visitor};
55
use rustc_hir::{self as hir, def, Expr, ImplItem, Item, Node, TraitItem};
66
use rustc_middle::bug;
77
use rustc_middle::hir::nested_filter;
88
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
9-
use rustc_span::{sym, ErrorGuaranteed, DUMMY_SP};
9+
use rustc_span::DUMMY_SP;
1010

11-
use crate::errors::{TaitForwardCompat, TaitForwardCompat2, TypeOf, UnconstrainedOpaqueType};
12-
13-
pub fn test_opaque_hidden_types(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
14-
let mut res = Ok(());
15-
if tcx.has_attr(CRATE_DEF_ID, sym::rustc_hidden_type_of_opaques) {
16-
for id in tcx.hir().items() {
17-
if matches!(tcx.def_kind(id.owner_id), DefKind::OpaqueTy) {
18-
let type_of = tcx.type_of(id.owner_id).instantiate_identity();
19-
20-
res = Err(tcx.dcx().emit_err(TypeOf { span: tcx.def_span(id.owner_id), type_of }));
21-
}
22-
}
23-
}
24-
res
25-
}
11+
use crate::errors::{TaitForwardCompat, TaitForwardCompat2, UnconstrainedOpaqueType};
2612

2713
/// Checks "defining uses" of opaque `impl Trait` in associated types.
2814
/// These can only be defined by associated items of the same trait.

compiler/rustc_hir_analysis/src/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -682,15 +682,15 @@ pub(crate) enum CannotCaptureLateBound {
682682
pub(crate) struct VariancesOf {
683683
#[primary_span]
684684
pub span: Span,
685-
pub variances_of: String,
685+
pub variances: String,
686686
}
687687

688688
#[derive(Diagnostic)]
689689
#[diag(hir_analysis_type_of)]
690690
pub(crate) struct TypeOf<'tcx> {
691691
#[primary_span]
692692
pub span: Span,
693-
pub type_of: Ty<'tcx>,
693+
pub ty: Ty<'tcx>,
694694
}
695695

696696
#[derive(Diagnostic)]

compiler/rustc_hir_analysis/src/lib.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ pub fn provide(providers: &mut Providers) {
151151
pub fn check_crate(tcx: TyCtxt<'_>) {
152152
let _prof_timer = tcx.sess.timer("type_check_crate");
153153

154-
if tcx.features().rustc_attrs {
155-
let _ = tcx.sess.time("outlives_testing", || outlives::test::test_inferred_outlives(tcx));
156-
}
157-
158154
tcx.sess.time("coherence_checking", || {
159155
tcx.hir().par_for_each_module(|module| {
160156
let _ = tcx.ensure().check_mod_type_wf(module);
@@ -169,11 +165,10 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
169165
});
170166

171167
if tcx.features().rustc_attrs {
172-
let _ = tcx.sess.time("variance_testing", || variance::test::test_variance(tcx));
173-
}
174-
175-
if tcx.features().rustc_attrs {
176-
let _ = collect::test_opaque_hidden_types(tcx);
168+
tcx.sess.time("outlives_dumping", || outlives::dump::inferred_outlives(tcx));
169+
tcx.sess.time("variance_dumping", || variance::dump::variances(tcx));
170+
collect::dump::opaque_hidden_types(tcx);
171+
collect::dump::predicates_and_item_bounds(tcx);
177172
}
178173

179174
// Make sure we evaluate all static and (non-associated) const items, even if unused.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use rustc_middle::bug;
2+
use rustc_middle::ty::{self, TyCtxt};
3+
use rustc_span::sym;
4+
5+
pub(crate) fn inferred_outlives(tcx: TyCtxt<'_>) {
6+
for id in tcx.hir().items() {
7+
if !tcx.has_attr(id.owner_id, sym::rustc_outlives) {
8+
continue;
9+
}
10+
11+
let preds = tcx.inferred_outlives_of(id.owner_id);
12+
let mut preds: Vec<_> = preds
13+
.iter()
14+
.map(|(pred, _)| match pred.kind().skip_binder() {
15+
ty::ClauseKind::RegionOutlives(p) => p.to_string(),
16+
ty::ClauseKind::TypeOutlives(p) => p.to_string(),
17+
err => bug!("unexpected clause {:?}", err),
18+
})
19+
.collect();
20+
preds.sort();
21+
22+
let span = tcx.def_span(id.owner_id);
23+
let mut err = tcx.dcx().struct_span_err(span, sym::rustc_outlives.as_str());
24+
for pred in preds {
25+
err.note(pred);
26+
}
27+
err.emit();
28+
}
29+
}

compiler/rustc_hir_analysis/src/outlives/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ use rustc_middle::ty::GenericArgKind;
55
use rustc_middle::ty::{self, CratePredicatesMap, TyCtxt, Upcast};
66
use rustc_span::Span;
77

8+
pub(crate) mod dump;
89
mod explicit;
910
mod implicit_infer;
10-
/// Code to write unit test for outlives.
11-
pub mod test;
1211
mod utils;
1312

1413
pub fn provide(providers: &mut Providers) {

compiler/rustc_hir_analysis/src/outlives/test.rs

-31
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use rustc_hir::def::DefKind;
2+
use rustc_hir::def_id::CRATE_DEF_ID;
3+
use rustc_middle::ty::TyCtxt;
4+
use rustc_span::symbol::sym;
5+
6+
pub(crate) fn variances(tcx: TyCtxt<'_>) {
7+
if tcx.has_attr(CRATE_DEF_ID, sym::rustc_variance_of_opaques) {
8+
for id in tcx.hir().items() {
9+
let DefKind::OpaqueTy = tcx.def_kind(id.owner_id) else { continue };
10+
11+
let variances = tcx.variances_of(id.owner_id);
12+
13+
tcx.dcx().emit_err(crate::errors::VariancesOf {
14+
span: tcx.def_span(id.owner_id),
15+
variances: format!("{variances:?}"),
16+
});
17+
}
18+
}
19+
20+
for id in tcx.hir().items() {
21+
if !tcx.has_attr(id.owner_id, sym::rustc_variance) {
22+
continue;
23+
}
24+
25+
let variances = tcx.variances_of(id.owner_id);
26+
27+
tcx.dcx().emit_err(crate::errors::VariancesOf {
28+
span: tcx.def_span(id.owner_id),
29+
variances: format!("{variances:?}"),
30+
});
31+
}
32+
}

compiler/rustc_hir_analysis/src/variance/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ mod constraints;
2222
/// Code to solve constraints and write out the results.
2323
mod solve;
2424

25-
/// Code to write unit tests of variance.
26-
pub mod test;
25+
pub(crate) mod dump;
2726

2827
/// Code for transforming variances.
2928
mod xform;

0 commit comments

Comments
 (0)