Skip to content

Commit ab5c841

Browse files
committed
Auto merge of rust-lang#117180 - matthiaskrgr:rollup-rxhl6ep, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#117111 (Remove support for alias `-Z instrument-coverage`) - rust-lang#117141 (Require target features to match exactly during inlining) - rust-lang#117152 (Fix unwrap suggestion for async fn) - rust-lang#117154 (implement C ABI lowering for CSKY) - rust-lang#117159 (Work around the fact that `check_mod_type_wf` may spuriously return `ErrorGuaranteed`) - rust-lang#117163 (compiletest: Display compilation errors in mir-opt tests) - rust-lang#117173 (Make `Iterator` a lang item) r? `@ghost` `@rustbot` modify labels: rollup
2 parents cf226e9 + b0521fe commit ab5c841

File tree

95 files changed

+834
-372
lines changed

Some content is hidden

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

95 files changed

+834
-372
lines changed

compiler/rustc_hir/src/lang_items.rs

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ language_item_table! {
210210

211211
FnOnceOutput, sym::fn_once_output, fn_once_output, Target::AssocTy, GenericRequirement::None;
212212

213+
Iterator, sym::iterator, iterator_trait, Target::Trait, GenericRequirement::Exact(0);
213214
Future, sym::future_trait, future_trait, Target::Trait, GenericRequirement::Exact(0);
214215
CoroutineState, sym::coroutine_state, gen_state, Target::Enum, GenericRequirement::None;
215216
Coroutine, sym::coroutine, gen_trait, Target::Trait, GenericRequirement::Minimum(1);

compiler/rustc_hir_analysis/src/check/check.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
128128

129129
let param_env = tcx.param_env(item_def_id);
130130
for field in &def.non_enum_variant().fields {
131-
let field_ty = tcx.normalize_erasing_regions(param_env, field.ty(tcx, args));
131+
let Ok(field_ty) = tcx.try_normalize_erasing_regions(param_env, field.ty(tcx, args))
132+
else {
133+
tcx.sess.delay_span_bug(span, "could not normalize field type");
134+
continue;
135+
};
132136

133137
if !allowed_union_field(field_ty, tcx, param_env) {
134138
let (field_span, ty_span) = match tcx.hir().get_if_local(field.did) {

compiler/rustc_hir_analysis/src/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,19 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
202202
})?;
203203
}
204204

205-
tcx.sess.time("wf_checking", || {
205+
let errs = tcx.sess.time("wf_checking", || {
206206
tcx.hir().try_par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module))
207-
})?;
207+
});
208208

209209
// NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync.
210210
tcx.sess.time("item_types_checking", || {
211211
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
212212
});
213213

214+
// HACK: `check_mod_type_wf` may spuriously emit errors due to `delay_span_bug`, even if those errors
215+
// only actually get emitted in `check_mod_item_types`.
216+
errs?;
217+
214218
if tcx.features().rustc_attrs {
215219
tcx.sess.track_errors(|| collect::test_opaque_hidden_types(tcx))?;
216220
}

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -1747,19 +1747,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17471747
expected: Ty<'tcx>,
17481748
found: Ty<'tcx>,
17491749
) -> bool {
1750-
let ty::Adt(adt, args) = found.kind() else { return false };
1750+
let ty::Adt(adt, args) = found.kind() else {
1751+
return false;
1752+
};
17511753
let ret_ty_matches = |diagnostic_item| {
1752-
if let Some(ret_ty) = self
1753-
.ret_coercion
1754-
.as_ref()
1755-
.map(|c| self.resolve_vars_if_possible(c.borrow().expected_ty()))
1756-
&& let ty::Adt(kind, _) = ret_ty.kind()
1757-
&& self.tcx.get_diagnostic_item(diagnostic_item) == Some(kind.did())
1758-
{
1759-
true
1760-
} else {
1761-
false
1762-
}
1754+
let Some(sig) = self.body_fn_sig() else {
1755+
return false;
1756+
};
1757+
let ty::Adt(kind, _) = sig.output().kind() else {
1758+
return false;
1759+
};
1760+
self.tcx.is_diagnostic_item(diagnostic_item, kind.did())
17631761
};
17641762

17651763
// don't suggest anything like `Ok(ok_val).unwrap()` , `Some(some_val).unwrap()`,

compiler/rustc_interface/src/passes.rs

+5
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,11 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
856856
// This check has to be run after all lints are done processing. We don't
857857
// define a lint filter, as all lint checks should have finished at this point.
858858
sess.time("check_lint_expectations", || tcx.ensure().check_expectations(None));
859+
860+
// This query is only invoked normally if a diagnostic is emitted that needs any
861+
// diagnostic item. If the crate compiles without checking any diagnostic items,
862+
// we will fail to emit overlap diagnostics. Thus we invoke it here unconditionally.
863+
let _ = tcx.all_diagnostic_items(());
859864
});
860865

861866
if sess.opts.unstable_opts.print_vtable_sizes {

compiler/rustc_interface/src/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,6 @@ fn test_unstable_options_tracking_hash() {
789789
tracked!(inline_mir, Some(true));
790790
tracked!(inline_mir_hint_threshold, Some(123));
791791
tracked!(inline_mir_threshold, Some(123));
792-
tracked!(instrument_coverage, Some(InstrumentCoverage::All));
793792
tracked!(instrument_mcount, true);
794793
tracked!(instrument_xray, Some(InstrumentXRay::default()));
795794
tracked!(link_directives, false);

compiler/rustc_mir_transform/src/inline.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,8 @@ impl<'tcx> Inliner<'tcx> {
438438
return Err("incompatible instruction set");
439439
}
440440

441-
for feature in &callee_attrs.target_features {
442-
if !self.codegen_fn_attrs.target_features.contains(feature) {
443-
return Err("incompatible target feature");
444-
}
441+
if callee_attrs.target_features != self.codegen_fn_attrs.target_features {
442+
return Err("incompatible target features");
445443
}
446444

447445
Ok(())

compiler/rustc_session/src/config.rs

+17-22
Original file line numberDiff line numberDiff line change
@@ -2739,29 +2739,24 @@ pub fn build_session_options(
27392739
_ => {}
27402740
}
27412741

2742-
// Handle both `-Z instrument-coverage` and `-C instrument-coverage`; the latter takes
2743-
// precedence.
2744-
match (cg.instrument_coverage, unstable_opts.instrument_coverage) {
2745-
(Some(ic_c), Some(ic_z)) if ic_c != ic_z => {
2746-
handler.early_error(
2747-
"incompatible values passed for `-C instrument-coverage` \
2748-
and `-Z instrument-coverage`",
2749-
);
2750-
}
2751-
(Some(InstrumentCoverage::Off | InstrumentCoverage::All), _) => {}
2752-
(Some(_), _) if !unstable_opts.unstable_options => {
2753-
handler.early_error(
2754-
"`-C instrument-coverage=branch` and `-C instrument-coverage=except-*` \
2755-
require `-Z unstable-options`",
2756-
);
2757-
}
2758-
(None, None) => {}
2759-
(None, ic) => {
2760-
handler
2761-
.early_warn("`-Z instrument-coverage` is deprecated; use `-C instrument-coverage`");
2762-
cg.instrument_coverage = ic;
2742+
// Check for unstable values of `-C instrument-coverage`.
2743+
// This is what prevents them from being used on stable compilers.
2744+
match cg.instrument_coverage {
2745+
// Stable values:
2746+
Some(InstrumentCoverage::All | InstrumentCoverage::Off) | None => {}
2747+
// Unstable values:
2748+
Some(
2749+
InstrumentCoverage::Branch
2750+
| InstrumentCoverage::ExceptUnusedFunctions
2751+
| InstrumentCoverage::ExceptUnusedGenerics,
2752+
) => {
2753+
if !unstable_opts.unstable_options {
2754+
handler.early_error(
2755+
"`-C instrument-coverage=branch` and `-C instrument-coverage=except-*` \
2756+
require `-Z unstable-options`",
2757+
);
2758+
}
27632759
}
2764-
_ => {}
27652760
}
27662761

27672762
if cg.instrument_coverage.is_some() && cg.instrument_coverage != Some(InstrumentCoverage::Off) {

compiler/rustc_session/src/options.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1593,16 +1593,6 @@ options! {
15931593
"a default MIR inlining threshold (default: 50)"),
15941594
input_stats: bool = (false, parse_bool, [UNTRACKED],
15951595
"gather statistics about the input (default: no)"),
1596-
#[rustc_lint_opt_deny_field_access("use `Session::instrument_coverage` instead of this field")]
1597-
instrument_coverage: Option<InstrumentCoverage> = (None, parse_instrument_coverage, [TRACKED],
1598-
"instrument the generated code to support LLVM source-based code coverage \
1599-
reports (note, the compiler build config must include `profiler = true`); \
1600-
implies `-C symbol-mangling-version=v0`. Optional values are:
1601-
`=all` (implicit value)
1602-
`=branch`
1603-
`=except-unused-generics`
1604-
`=except-unused-functions`
1605-
`=off` (default)"),
16061596
instrument_mcount: bool = (false, parse_bool, [TRACKED],
16071597
"insert function instrument code for mcount-based tracing (default: no)"),
16081598
instrument_xray: Option<InstrumentXRay> = (None, parse_instrument_xray, [TRACKED],

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ symbols! {
910910
iter,
911911
iter_mut,
912912
iter_repeat,
913+
iterator,
913914
iterator_collect_fn,
914915
kcfi,
915916
keyword,

compiler/rustc_target/src/abi/call/csky.rs

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,39 @@
1-
// See https://github.com/llvm/llvm-project/blob/d85b94bf0080dcd780656c0f5e6342800720eba9/llvm/lib/Target/CSKY/CSKYCallingConv.td
2-
use crate::abi::call::{ArgAbi, FnAbi};
1+
// Reference: CSKY ABI Manual
2+
// https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1695027452256/T-HEAD_800_Series_ABI_Standards_Manual.pdf
3+
//
4+
// Reference: Clang CSKY lowering code
5+
// https://github.com/llvm/llvm-project/blob/4a074f32a6914f2a8d7215d78758c24942dddc3d/clang/lib/CodeGen/Targets/CSKY.cpp#L76-L162
36

4-
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
5-
if ret.layout.is_aggregate() || ret.layout.size.bits() > 64 {
6-
ret.make_indirect();
7+
use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
8+
9+
fn classify_ret<Ty>(arg: &mut ArgAbi<'_, Ty>) {
10+
// For return type, aggregate which <= 2*XLen will be returned in registers.
11+
// Otherwise, aggregate will be returned indirectly.
12+
if arg.layout.is_aggregate() {
13+
let total = arg.layout.size;
14+
if total.bits() > 64 {
15+
arg.make_indirect();
16+
} else if total.bits() > 32 {
17+
arg.cast_to(Uniform { unit: Reg::i32(), total });
18+
} else {
19+
arg.cast_to(Reg::i32());
20+
}
721
} else {
8-
ret.extend_integer_width_to(32);
22+
arg.extend_integer_width_to(32);
923
}
1024
}
1125

1226
fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
13-
if arg.layout.is_aggregate() || arg.layout.size.bits() > 64 {
14-
arg.make_indirect();
27+
// For argument type, the first 4*XLen parts of aggregate will be passed
28+
// in registers, and the rest will be passed in stack.
29+
// So we can coerce to integers directly and let backend handle it correctly.
30+
if arg.layout.is_aggregate() {
31+
let total = arg.layout.size;
32+
if total.bits() > 32 {
33+
arg.cast_to(Uniform { unit: Reg::i32(), total });
34+
} else {
35+
arg.cast_to(Reg::i32());
36+
}
1537
} else {
1638
arg.extend_integer_width_to(32);
1739
}

library/core/src/iter/traits/iterator.rs

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {}
6969
message = "`{Self}` is not an iterator"
7070
)]
7171
#[doc(notable_trait)]
72+
#[cfg_attr(not(bootstrap), lang = "iterator")]
7273
#[rustc_diagnostic_item = "Iterator"]
7374
#[must_use = "iterators are lazy and do nothing unless consumed"]
7475
pub trait Iterator {

src/doc/rustc/src/platform-support/csky-unknown-linux-gnuabiv2.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ target | std | host | notes
1010
`csky-unknown-linux-gnuabiv2hf` | ✓ | | C-SKY abiv2 Linux, hardfloat (little endian)
1111

1212
Reference:
13-
https://c-sky.github.io/
1413

15-
https://gitlab.com/c-sky/
14+
- [CSKY ABI Manual](https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1695027452256/T-HEAD_800_Series_ABI_Standards_Manual.pdf)
15+
- [csky-linux-gnuabiv2-toolchain](https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource/1356021/1619528643136/csky-linux-gnuabiv2-tools-x86_64-glibc-linux-4.9.56-20210423.tar.gz)
16+
- [csky-linux-gnuabiv2-qemu](https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1689324918932/xuantie-qemu-x86_64-Ubuntu-18.04-20230714-0202.tar.gz)
17+
18+
other links:
19+
20+
- https://c-sky.github.io/
21+
- https://gitlab.com/c-sky/
1622

1723
## Target maintainers
1824

src/tools/clippy/tests/ui/crashes/ice-6252.stderr

+12-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ help: you might be missing a type parameter
2424
LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
2525
| +++++
2626

27-
error: aborting due to 2 previous errors
27+
error[E0046]: not all trait items implemented, missing: `VAL`
28+
--> $DIR/ice-6252.rs:11:1
29+
|
30+
LL | const VAL: T;
31+
| ------------ `VAL` from trait
32+
...
33+
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation
35+
36+
error: aborting due to 3 previous errors
2837

29-
For more information about this error, try `rustc --explain E0412`.
38+
Some errors have detailed explanations: E0046, E0412.
39+
For more information about an error, try `rustc --explain E0046`.

src/tools/compiletest/src/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3999,10 +3999,10 @@ impl<'test> TestCx<'test> {
39993999
let passes = std::mem::take(&mut test_info.passes);
40004000

40014001
let proc_res = self.compile_test_with_passes(should_run, Emit::Mir, passes);
4002-
self.check_mir_dump(test_info);
40034002
if !proc_res.status.success() {
40044003
self.fatal_proc_rec("compilation failed!", &proc_res);
40054004
}
4005+
self.check_mir_dump(test_info);
40064006

40074007
if let WillExecute::Yes = should_run {
40084008
let proc_res = self.exec_compiled_test();

tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff

-21
This file was deleted.

tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff

-21
This file was deleted.

tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff

-21
This file was deleted.

tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff

-21
This file was deleted.

tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff

-22
This file was deleted.

0 commit comments

Comments
 (0)