Skip to content

Commit 7c7bb7d

Browse files
committed
Auto merge of rust-lang#132470 - GuillaumeGomez:rollup-1a1mkmp, r=GuillaumeGomez
Rollup of 14 pull requests Successful merges: - rust-lang#131829 (Remove support for `-Zprofile` (gcov-style coverage instrumentation)) - rust-lang#132369 (style-guide: Only use the new binop heuristic for assignments) - rust-lang#132383 (Implement suggestion for never type fallback lints) - rust-lang#132413 (update offset_of! docs to reflect the stabilization of nesting) - rust-lang#132438 (Remove unncessary option for default rust-analyzer setting) - rust-lang#132439 (Add `f16` and `f128` to `invalid_nan_comparison`) - rust-lang#132444 (rustdoc: Directly use rustc_abi instead of reexports) - rust-lang#132445 (Cleanup attributes around unchecked shifts and unchecked negation in const) - rust-lang#132448 (Add missing backtick) - rust-lang#132450 (Show actual MIR when MIR building forgot to terminate block) - rust-lang#132451 (remove some unnecessary rustc_allow_const_fn_unstable) - rust-lang#132455 (make const_alloc_layout feature gate only about functions that are already stable) - rust-lang#132456 (Move remaining inline assembly test files into asm directory) - rust-lang#132459 (feat(byte_sub_ptr): unstably add ptr::byte_sub_ptr) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 705cfe0 + 305ca05 commit 7c7bb7d

File tree

74 files changed

+837
-310
lines changed

Some content is hidden

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

74 files changed

+837
-310
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

-5
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,6 @@ fn probestack_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
232232
return None;
233233
}
234234

235-
// probestack doesn't play nice either with gcov profiling.
236-
if cx.sess().opts.unstable_opts.profile {
237-
return None;
238-
}
239-
240235
let attr_value = match cx.sess().target.stack_probes {
241236
StackProbeType::None => return None,
242237
// Request LLVM to generate the probes inline. If the given LLVM version does not support

compiler/rustc_codegen_llvm/src/back/write.rs

-1
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,6 @@ pub(crate) unsafe fn llvm_optimize(
591591
pgo_use_path.as_ref().map_or(std::ptr::null(), |s| s.as_ptr()),
592592
config.instrument_coverage,
593593
instr_profile_output_path.as_ref().map_or(std::ptr::null(), |s| s.as_ptr()),
594-
config.instrument_gcov,
595594
pgo_sample_use_path.as_ref().map_or(std::ptr::null(), |s| s.as_ptr()),
596595
config.debug_info_for_profiling,
597596
llvm_selfprofiler,

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

-26
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::{iter, ptr};
77
use libc::{c_char, c_longlong, c_uint};
88
use rustc_codegen_ssa::debuginfo::type_names::{VTableNameKind, cpp_like_debuginfo};
99
use rustc_codegen_ssa::traits::*;
10-
use rustc_fs_util::path_to_c_string;
1110
use rustc_hir::def::{CtorKind, DefKind};
1211
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
1312
use rustc_middle::bug;
@@ -979,33 +978,8 @@ pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
979978
debug_name_table_kind,
980979
);
981980

982-
if tcx.sess.opts.unstable_opts.profile {
983-
let default_gcda_path = &output_filenames.with_extension("gcda");
984-
let gcda_path =
985-
tcx.sess.opts.unstable_opts.profile_emit.as_ref().unwrap_or(default_gcda_path);
986-
987-
let gcov_cu_info = [
988-
path_to_mdstring(debug_context.llcontext, &output_filenames.with_extension("gcno")),
989-
path_to_mdstring(debug_context.llcontext, gcda_path),
990-
unit_metadata,
991-
];
992-
let gcov_metadata = llvm::LLVMMDNodeInContext2(
993-
debug_context.llcontext,
994-
gcov_cu_info.as_ptr(),
995-
gcov_cu_info.len(),
996-
);
997-
let val = llvm::LLVMMetadataAsValue(debug_context.llcontext, gcov_metadata);
998-
999-
llvm::LLVMAddNamedMetadataOperand(debug_context.llmod, c"llvm.gcov".as_ptr(), val);
1000-
}
1001-
1002981
return unit_metadata;
1003982
};
1004-
1005-
fn path_to_mdstring<'ll>(llcx: &'ll llvm::Context, path: &Path) -> &'ll llvm::Metadata {
1006-
let path_str = path_to_c_string(path);
1007-
unsafe { llvm::LLVMMDStringInContext2(llcx, path_str.as_ptr(), path_str.as_bytes().len()) }
1008-
}
1009983
}
1010984

1011985
/// Creates a `DW_TAG_member` entry inside the DIE represented by the given `type_di_node`.

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const DW_TAG_arg_variable: c_uint = 0x101;
5555

5656
/// A context object for maintaining all state needed by the debuginfo module.
5757
pub(crate) struct CodegenUnitDebugContext<'ll, 'tcx> {
58-
llcontext: &'ll llvm::Context,
5958
llmod: &'ll llvm::Module,
6059
builder: &'ll mut DIBuilder<'ll>,
6160
created_files: RefCell<UnordMap<Option<(StableSourceFileId, SourceFileHash)>, &'ll DIFile>>,
@@ -78,9 +77,7 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
7877
debug!("CodegenUnitDebugContext::new");
7978
let builder = unsafe { llvm::LLVMRustDIBuilderCreate(llmod) };
8079
// DIBuilder inherits context from the module, so we'd better use the same one
81-
let llcontext = unsafe { llvm::LLVMGetModuleContext(llmod) };
8280
CodegenUnitDebugContext {
83-
llcontext,
8481
llmod,
8582
builder,
8683
created_files: Default::default(),

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,6 @@ unsafe extern "C" {
22692269
PGOUsePath: *const c_char,
22702270
InstrumentCoverage: bool,
22712271
InstrProfileOutput: *const c_char,
2272-
InstrumentGCOV: bool,
22732272
PGOSampleUsePath: *const c_char,
22742273
DebugInfoForProfiling: bool,
22752274
llvm_selfprofiler: *mut c_void,

compiler/rustc_codegen_ssa/src/back/write.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ pub struct ModuleConfig {
9090
pub pgo_sample_use: Option<PathBuf>,
9191
pub debug_info_for_profiling: bool,
9292
pub instrument_coverage: bool,
93-
pub instrument_gcov: bool,
9493

9594
pub sanitizer: SanitizerSet,
9695
pub sanitizer_recover: SanitizerSet,
@@ -123,12 +122,7 @@ pub struct ModuleConfig {
123122
}
124123

125124
impl ModuleConfig {
126-
fn new(
127-
kind: ModuleKind,
128-
tcx: TyCtxt<'_>,
129-
no_builtins: bool,
130-
is_compiler_builtins: bool,
131-
) -> ModuleConfig {
125+
fn new(kind: ModuleKind, tcx: TyCtxt<'_>, no_builtins: bool) -> ModuleConfig {
132126
// If it's a regular module, use `$regular`, otherwise use `$other`.
133127
// `$regular` and `$other` are evaluated lazily.
134128
macro_rules! if_regular {
@@ -189,13 +183,6 @@ impl ModuleConfig {
189183
pgo_sample_use: if_regular!(sess.opts.unstable_opts.profile_sample_use.clone(), None),
190184
debug_info_for_profiling: sess.opts.unstable_opts.debug_info_for_profiling,
191185
instrument_coverage: if_regular!(sess.instrument_coverage(), false),
192-
instrument_gcov: if_regular!(
193-
// compiler_builtins overrides the codegen-units settings,
194-
// which is incompatible with -Zprofile which requires that
195-
// only a single codegen unit is used per crate.
196-
sess.opts.unstable_opts.profile && !is_compiler_builtins,
197-
false
198-
),
199186

200187
sanitizer: if_regular!(sess.opts.unstable_opts.sanitizer, SanitizerSet::empty()),
201188
sanitizer_dataflow_abilist: if_regular!(
@@ -473,16 +460,12 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
473460

474461
let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
475462
let no_builtins = attr::contains_name(crate_attrs, sym::no_builtins);
476-
let is_compiler_builtins = attr::contains_name(crate_attrs, sym::compiler_builtins);
477463

478464
let crate_info = CrateInfo::new(tcx, target_cpu);
479465

480-
let regular_config =
481-
ModuleConfig::new(ModuleKind::Regular, tcx, no_builtins, is_compiler_builtins);
482-
let metadata_config =
483-
ModuleConfig::new(ModuleKind::Metadata, tcx, no_builtins, is_compiler_builtins);
484-
let allocator_config =
485-
ModuleConfig::new(ModuleKind::Allocator, tcx, no_builtins, is_compiler_builtins);
466+
let regular_config = ModuleConfig::new(ModuleKind::Regular, tcx, no_builtins);
467+
let metadata_config = ModuleConfig::new(ModuleKind::Metadata, tcx, no_builtins);
468+
let allocator_config = ModuleConfig::new(ModuleKind::Allocator, tcx, no_builtins);
486469

487470
let (shared_emitter, shared_emitter_main) = SharedEmitter::new();
488471
let (codegen_worker_send, codegen_worker_receive) = channel();

compiler/rustc_hir_typeck/src/errors.rs

+78-5
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,34 @@ pub(crate) struct MissingParenthesesInRange {
169169
pub(crate) enum NeverTypeFallbackFlowingIntoUnsafe {
170170
#[help]
171171
#[diag(hir_typeck_never_type_fallback_flowing_into_unsafe_call)]
172-
Call,
172+
Call {
173+
#[subdiagnostic]
174+
sugg: SuggestAnnotations,
175+
},
173176
#[help]
174177
#[diag(hir_typeck_never_type_fallback_flowing_into_unsafe_method)]
175-
Method,
178+
Method {
179+
#[subdiagnostic]
180+
sugg: SuggestAnnotations,
181+
},
176182
#[help]
177183
#[diag(hir_typeck_never_type_fallback_flowing_into_unsafe_path)]
178-
Path,
184+
Path {
185+
#[subdiagnostic]
186+
sugg: SuggestAnnotations,
187+
},
179188
#[help]
180189
#[diag(hir_typeck_never_type_fallback_flowing_into_unsafe_union_field)]
181-
UnionField,
190+
UnionField {
191+
#[subdiagnostic]
192+
sugg: SuggestAnnotations,
193+
},
182194
#[help]
183195
#[diag(hir_typeck_never_type_fallback_flowing_into_unsafe_deref)]
184-
Deref,
196+
Deref {
197+
#[subdiagnostic]
198+
sugg: SuggestAnnotations,
199+
},
185200
}
186201

187202
#[derive(LintDiagnostic)]
@@ -191,6 +206,64 @@ pub(crate) struct DependencyOnUnitNeverTypeFallback<'tcx> {
191206
#[note]
192207
pub obligation_span: Span,
193208
pub obligation: ty::Predicate<'tcx>,
209+
#[subdiagnostic]
210+
pub sugg: SuggestAnnotations,
211+
}
212+
213+
#[derive(Clone)]
214+
pub(crate) enum SuggestAnnotation {
215+
Unit(Span),
216+
Path(Span),
217+
Local(Span),
218+
Turbo(Span, usize, usize),
219+
}
220+
221+
#[derive(Clone)]
222+
pub(crate) struct SuggestAnnotations {
223+
pub suggestions: Vec<SuggestAnnotation>,
224+
}
225+
impl Subdiagnostic for SuggestAnnotations {
226+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
227+
self,
228+
diag: &mut Diag<'_, G>,
229+
_: &F,
230+
) {
231+
if self.suggestions.is_empty() {
232+
return;
233+
}
234+
235+
let mut suggestions = vec![];
236+
for suggestion in self.suggestions {
237+
match suggestion {
238+
SuggestAnnotation::Unit(span) => {
239+
suggestions.push((span, "()".to_string()));
240+
}
241+
SuggestAnnotation::Path(span) => {
242+
suggestions.push((span.shrink_to_lo(), "<() as ".to_string()));
243+
suggestions.push((span.shrink_to_hi(), ">".to_string()));
244+
}
245+
SuggestAnnotation::Local(span) => {
246+
suggestions.push((span, ": ()".to_string()));
247+
}
248+
SuggestAnnotation::Turbo(span, n_args, idx) => suggestions.push((
249+
span,
250+
format!(
251+
"::<{}>",
252+
(0..n_args)
253+
.map(|i| if i == idx { "()" } else { "_" })
254+
.collect::<Vec<_>>()
255+
.join(", "),
256+
),
257+
)),
258+
}
259+
}
260+
261+
diag.multipart_suggestion_verbose(
262+
"use `()` annotations to avoid fallback changes",
263+
suggestions,
264+
Applicability::MachineApplicable,
265+
);
266+
}
194267
}
195268

196269
#[derive(Subdiagnostic)]

0 commit comments

Comments
 (0)