Skip to content

Commit ab5c841

Browse files
committed
Auto merge of #117180 - matthiaskrgr:rollup-rxhl6ep, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #117111 (Remove support for alias `-Z instrument-coverage`) - #117141 (Require target features to match exactly during inlining) - #117152 (Fix unwrap suggestion for async fn) - #117154 (implement C ABI lowering for CSKY) - #117159 (Work around the fact that `check_mod_type_wf` may spuriously return `ErrorGuaranteed`) - #117163 (compiletest: Display compilation errors in mir-opt tests) - #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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 10 additions & 12 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 17 additions & 22 deletions
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

Lines changed: 0 additions & 10 deletions
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

Lines changed: 1 addition & 0 deletions
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,

0 commit comments

Comments
 (0)