Skip to content

Commit 40fda7b

Browse files
committed
Auto merge of rust-lang#107318 - matthiaskrgr:rollup-776kd81, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#97373 (impl DispatchFromDyn for Cell and UnsafeCell) - rust-lang#106625 (Remove backwards compat for LLVM 12 coverage format) - rust-lang#106779 (Avoid __cxa_thread_atexit_impl on Emscripten) - rust-lang#106811 (Append .dwp to the binary filename instead of replacing the existing extension.) - rust-lang#106836 (Remove optimistic spinning from `mpsc::SyncSender`) - rust-lang#106946 (implement Hash for proc_macro::LineColumn) - rust-lang#107074 (remove unnecessary check for opaque types) - rust-lang#107287 (Improve fn pointer notes) - rust-lang#107304 (Use `can_eq` to compare types for default assoc type error) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e187f88 + 3aeafca commit 40fda7b

28 files changed

+942
-732
lines changed

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

+17-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::common::CodegenCx;
22
use crate::coverageinfo;
3-
use crate::errors::InstrumentCoverageRequiresLLVM12;
43
use crate::llvm;
54

65
use llvm::coverageinfo::CounterMappingRegion;
@@ -19,8 +18,8 @@ use std::ffi::CString;
1918

2019
/// Generates and exports the Coverage Map.
2120
///
22-
/// Rust Coverage Map generation supports LLVM Coverage Mapping Format versions
23-
/// 5 (LLVM 12, only) and 6 (zero-based encoded as 4 and 5, respectively), as defined at
21+
/// Rust Coverage Map generation supports LLVM Coverage Mapping Format version
22+
/// 6 (zero-based encoded as 5), as defined at
2423
/// [LLVM Code Coverage Mapping Format](https://github.com/rust-lang/llvm-project/blob/rustc/13.0-2021-09-30/llvm/docs/CoverageMappingFormat.rst#llvm-code-coverage-mapping-format).
2524
/// These versions are supported by the LLVM coverage tools (`llvm-profdata` and `llvm-cov`)
2625
/// bundled with Rust's fork of LLVM.
@@ -33,13 +32,10 @@ use std::ffi::CString;
3332
pub fn finalize(cx: &CodegenCx<'_, '_>) {
3433
let tcx = cx.tcx;
3534

36-
// Ensure the installed version of LLVM supports at least Coverage Map
37-
// Version 5 (encoded as a zero-based value: 4), which was introduced with
38-
// LLVM 12.
35+
// Ensure the installed version of LLVM supports Coverage Map Version 6
36+
// (encoded as a zero-based value: 5), which was introduced with LLVM 13.
3937
let version = coverageinfo::mapping_version();
40-
if version < 4 {
41-
tcx.sess.emit_fatal(InstrumentCoverageRequiresLLVM12);
42-
}
38+
assert_eq!(version, 5, "The `CoverageMappingVersion` exposed by `llvm-wrapper` is out of sync");
4339

4440
debug!("Generating coverage map for CodegenUnit: `{}`", cx.codegen_unit.name());
4541

@@ -61,7 +57,7 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) {
6157
return;
6258
}
6359

64-
let mut mapgen = CoverageMapGenerator::new(tcx, version);
60+
let mut mapgen = CoverageMapGenerator::new(tcx);
6561

6662
// Encode coverage mappings and generate function records
6763
let mut function_data = Vec::new();
@@ -124,25 +120,18 @@ struct CoverageMapGenerator {
124120
}
125121

126122
impl CoverageMapGenerator {
127-
fn new(tcx: TyCtxt<'_>, version: u32) -> Self {
123+
fn new(tcx: TyCtxt<'_>) -> Self {
128124
let mut filenames = FxIndexSet::default();
129-
if version >= 5 {
130-
// LLVM Coverage Mapping Format version 6 (zero-based encoded as 5)
131-
// requires setting the first filename to the compilation directory.
132-
// Since rustc generates coverage maps with relative paths, the
133-
// compilation directory can be combined with the relative paths
134-
// to get absolute paths, if needed.
135-
let working_dir = tcx
136-
.sess
137-
.opts
138-
.working_dir
139-
.remapped_path_if_available()
140-
.to_string_lossy()
141-
.to_string();
142-
let c_filename =
143-
CString::new(working_dir).expect("null error converting filename to C string");
144-
filenames.insert(c_filename);
145-
}
125+
// LLVM Coverage Mapping Format version 6 (zero-based encoded as 5)
126+
// requires setting the first filename to the compilation directory.
127+
// Since rustc generates coverage maps with relative paths, the
128+
// compilation directory can be combined with the relative paths
129+
// to get absolute paths, if needed.
130+
let working_dir =
131+
tcx.sess.opts.working_dir.remapped_path_if_available().to_string_lossy().to_string();
132+
let c_filename =
133+
CString::new(working_dir).expect("null error converting filename to C string");
134+
filenames.insert(c_filename);
146135
Self { filenames }
147136
}
148137

compiler/rustc_codegen_llvm/src/errors.rs

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ pub(crate) struct ErrorCreatingImportLibrary<'a> {
3939
pub error: String,
4040
}
4141

42-
#[derive(Diagnostic)]
43-
#[diag(codegen_llvm_instrument_coverage_requires_llvm_12)]
44-
pub(crate) struct InstrumentCoverageRequiresLLVM12;
45-
4642
#[derive(Diagnostic)]
4743
#[diag(codegen_llvm_symbol_already_defined)]
4844
pub(crate) struct SymbolAlreadyDefined<'a> {

compiler/rustc_codegen_ssa/src/back/link.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ fn link_dwarf_object<'a>(
599599
cg_results: &CodegenResults,
600600
executable_out_filename: &Path,
601601
) {
602-
let dwp_out_filename = executable_out_filename.with_extension("dwp");
602+
let mut dwp_out_filename = executable_out_filename.to_path_buf().into_os_string();
603+
dwp_out_filename.push(".dwp");
603604
debug!(?dwp_out_filename, ?executable_out_filename);
604605

605606
#[derive(Default)]

compiler/rustc_const_eval/src/transform/validate.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_middle::mir::{
1313
ProjectionElem, RetagKind, RuntimePhase, Rvalue, SourceScope, Statement, StatementKind,
1414
Terminator, TerminatorKind, UnOp, START_BLOCK,
1515
};
16-
use rustc_middle::ty::{self, InstanceDef, ParamEnv, Ty, TyCtxt, TypeVisitable};
16+
use rustc_middle::ty::{self, InstanceDef, ParamEnv, Ty, TyCtxt};
1717
use rustc_mir_dataflow::impls::MaybeStorageLive;
1818
use rustc_mir_dataflow::storage::always_storage_live_locals;
1919
use rustc_mir_dataflow::{Analysis, ResultsCursor};
@@ -230,11 +230,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
230230
// Equal types, all is good.
231231
return true;
232232
}
233-
// Normalization reveals opaque types, but we may be validating MIR while computing
234-
// said opaque types, causing cycles.
235-
if (src, dest).has_opaque_types() {
236-
return true;
237-
}
238233

239234
crate::util::is_subtype(self.tcx, self.param_env, src, dest)
240235
}

compiler/rustc_error_messages/locales/en-US/codegen_llvm.ftl

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ codegen_llvm_unknown_ctarget_feature_prefix =
1111
codegen_llvm_error_creating_import_library =
1212
Error creating import library for {$lib_name}: {$error}
1313
14-
codegen_llvm_instrument_coverage_requires_llvm_12 =
15-
rustc option `-C instrument-coverage` requires LLVM 12 or higher.
16-
1714
codegen_llvm_symbol_already_defined =
1815
symbol `{$symbol_name}` is already defined
1916

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ use std::path::PathBuf;
7979
use std::{cmp, fmt, iter};
8080

8181
mod note;
82+
mod note_and_explain;
8283
mod suggest;
8384

8485
pub(crate) mod need_type_info;
@@ -1846,7 +1847,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
18461847
}
18471848

18481849
self.check_and_note_conflicting_crates(diag, terr);
1849-
self.tcx.note_and_explain_type_err(diag, terr, cause, span, cause.body_id.to_def_id());
1850+
1851+
self.note_and_explain_type_err(diag, terr, cause, span, cause.body_id.to_def_id());
18501852

18511853
if let Some(ValuePairs::PolyTraitRefs(exp_found)) = values
18521854
&& let ty::Closure(def_id, _) = exp_found.expected.skip_binder().self_ty().kind()

0 commit comments

Comments
 (0)