Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 13 pull requests #132462

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d7e6074
style-guide: Only use the new binop heuristic for assignments
joshtriplett Oct 30, 2024
ce3e14a
Remove support for `-Zprofile` (gcov-style coverage instrumentation)
Zalathar Oct 17, 2024
588c7a9
nit: stop using TypeckRootCtxt
compiler-errors Oct 31, 2024
41966e7
Suggest annotations for never type fallback
compiler-errors Oct 31, 2024
ea4fb7c
Suggest adding self type to method
compiler-errors Oct 31, 2024
c930bba
And locals too
compiler-errors Oct 31, 2024
df6f584
And also suggest for qpaths
compiler-errors Oct 31, 2024
b4248ae
nits
compiler-errors Nov 1, 2024
f3f1593
coverage: Regression test for inlining into an uninstrumented crate
Zalathar Nov 1, 2024
3afbe4f
Add `f16` and `f128` to `invalid_nan_comparison`
tgross35 Nov 1, 2024
b6a49d8
Remove unncessary option for default rust-analyzer setting
chenyukang Nov 1, 2024
5342eb0
Add missing backtick
chengehe Nov 1, 2024
7603385
Show actual MIR when MIR building forgot to terminate block
bjorn3 Oct 7, 2024
506812d
remove some unnecessary rustc_allow_const_fn_unstable
RalfJung Nov 1, 2024
901b340
unchecked_shifts, unchecked_neg are safe-to-const-expose-on-stable, s…
RalfJung Nov 1, 2024
96e7eaf
Move remaining inline assembly test files into asm directory
taiki-e Nov 1, 2024
c9e77e8
make const_alloc_layout feature gate only about functions that are al…
RalfJung Nov 1, 2024
aba2088
feat(byte_sub_ptr): add ptr::byte_sub_ptr
Gankra Mar 3, 2024
c388655
offset_from / sub_ptr docs: emphasize that pointers must be in the sa…
RalfJung Nov 1, 2024
968e7aa
Rollup merge of #131829 - Zalathar:goodbye-zprofile, r=chenyukang
jieyouxu Nov 1, 2024
6f82947
Rollup merge of #132369 - joshtriplett:style-guide-binop-heuristic-as…
jieyouxu Nov 1, 2024
3806a9f
Rollup merge of #132383 - compiler-errors:never-type-fallback-sugg, r…
jieyouxu Nov 1, 2024
9125b51
Rollup merge of #132437 - Zalathar:inline-mixed-regression, r=jieyouxu
jieyouxu Nov 1, 2024
e9fa793
Rollup merge of #132438 - chenyukang:yukang-fix-analyzer_settings, r=…
jieyouxu Nov 1, 2024
52a9a1b
Rollup merge of #132439 - tgross35:f16-f128-nan-lint, r=jieyouxu
jieyouxu Nov 1, 2024
62a8997
Rollup merge of #132445 - RalfJung:const-unchecked-shifts, r=tgross35
jieyouxu Nov 1, 2024
c0765b3
Rollup merge of #132448 - chengehe:master, r=Noratrieb
jieyouxu Nov 1, 2024
dfc74b7
Rollup merge of #132450 - bjorn3:better_mir_errors, r=jieyouxu
jieyouxu Nov 1, 2024
b80eb4b
Rollup merge of #132451 - RalfJung:less-rustc_allow_const_fn_unstable…
jieyouxu Nov 1, 2024
9e0a3a7
Rollup merge of #132455 - RalfJung:const_alloc_layout, r=dtolnay
jieyouxu Nov 1, 2024
5ebccae
Rollup merge of #132456 - taiki-e:test-asm-dir, r=jieyouxu
jieyouxu Nov 1, 2024
824e227
Rollup merge of #132459 - RalfJung:byte_sub_ptr, r=scottmcm
jieyouxu Nov 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,6 @@ fn probestack_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
return None;
}

// probestack doesn't play nice either with gcov profiling.
if cx.sess().opts.unstable_opts.profile {
return None;
}

let attr_value = match cx.sess().target.stack_probes {
StackProbeType::None => return None,
// Request LLVM to generate the probes inline. If the given LLVM version does not support
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@ pub(crate) unsafe fn llvm_optimize(
pgo_use_path.as_ref().map_or(std::ptr::null(), |s| s.as_ptr()),
config.instrument_coverage,
instr_profile_output_path.as_ref().map_or(std::ptr::null(), |s| s.as_ptr()),
config.instrument_gcov,
pgo_sample_use_path.as_ref().map_or(std::ptr::null(), |s| s.as_ptr()),
config.debug_info_for_profiling,
llvm_selfprofiler,
Expand Down
26 changes: 0 additions & 26 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::{iter, ptr};
use libc::{c_char, c_longlong, c_uint};
use rustc_codegen_ssa::debuginfo::type_names::{VTableNameKind, cpp_like_debuginfo};
use rustc_codegen_ssa::traits::*;
use rustc_fs_util::path_to_c_string;
use rustc_hir::def::{CtorKind, DefKind};
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_middle::bug;
Expand Down Expand Up @@ -979,33 +978,8 @@ pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
debug_name_table_kind,
);

if tcx.sess.opts.unstable_opts.profile {
let default_gcda_path = &output_filenames.with_extension("gcda");
let gcda_path =
tcx.sess.opts.unstable_opts.profile_emit.as_ref().unwrap_or(default_gcda_path);

let gcov_cu_info = [
path_to_mdstring(debug_context.llcontext, &output_filenames.with_extension("gcno")),
path_to_mdstring(debug_context.llcontext, gcda_path),
unit_metadata,
];
let gcov_metadata = llvm::LLVMMDNodeInContext2(
debug_context.llcontext,
gcov_cu_info.as_ptr(),
gcov_cu_info.len(),
);
let val = llvm::LLVMMetadataAsValue(debug_context.llcontext, gcov_metadata);

llvm::LLVMAddNamedMetadataOperand(debug_context.llmod, c"llvm.gcov".as_ptr(), val);
}

return unit_metadata;
};

fn path_to_mdstring<'ll>(llcx: &'ll llvm::Context, path: &Path) -> &'ll llvm::Metadata {
let path_str = path_to_c_string(path);
unsafe { llvm::LLVMMDStringInContext2(llcx, path_str.as_ptr(), path_str.as_bytes().len()) }
}
}

/// Creates a `DW_TAG_member` entry inside the DIE represented by the given `type_di_node`.
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const DW_TAG_arg_variable: c_uint = 0x101;

/// A context object for maintaining all state needed by the debuginfo module.
pub(crate) struct CodegenUnitDebugContext<'ll, 'tcx> {
llcontext: &'ll llvm::Context,
llmod: &'ll llvm::Module,
builder: &'ll mut DIBuilder<'ll>,
created_files: RefCell<UnordMap<Option<(StableSourceFileId, SourceFileHash)>, &'ll DIFile>>,
Expand All @@ -78,9 +77,7 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
debug!("CodegenUnitDebugContext::new");
let builder = unsafe { llvm::LLVMRustDIBuilderCreate(llmod) };
// DIBuilder inherits context from the module, so we'd better use the same one
let llcontext = unsafe { llvm::LLVMGetModuleContext(llmod) };
CodegenUnitDebugContext {
llcontext,
llmod,
builder,
created_files: Default::default(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2269,7 +2269,6 @@ unsafe extern "C" {
PGOUsePath: *const c_char,
InstrumentCoverage: bool,
InstrProfileOutput: *const c_char,
InstrumentGCOV: bool,
PGOSampleUsePath: *const c_char,
DebugInfoForProfiling: bool,
llvm_selfprofiler: *mut c_void,
Expand Down
25 changes: 4 additions & 21 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub struct ModuleConfig {
pub pgo_sample_use: Option<PathBuf>,
pub debug_info_for_profiling: bool,
pub instrument_coverage: bool,
pub instrument_gcov: bool,

pub sanitizer: SanitizerSet,
pub sanitizer_recover: SanitizerSet,
Expand Down Expand Up @@ -123,12 +122,7 @@ pub struct ModuleConfig {
}

impl ModuleConfig {
fn new(
kind: ModuleKind,
tcx: TyCtxt<'_>,
no_builtins: bool,
is_compiler_builtins: bool,
) -> ModuleConfig {
fn new(kind: ModuleKind, tcx: TyCtxt<'_>, no_builtins: bool) -> ModuleConfig {
// If it's a regular module, use `$regular`, otherwise use `$other`.
// `$regular` and `$other` are evaluated lazily.
macro_rules! if_regular {
Expand Down Expand Up @@ -189,13 +183,6 @@ impl ModuleConfig {
pgo_sample_use: if_regular!(sess.opts.unstable_opts.profile_sample_use.clone(), None),
debug_info_for_profiling: sess.opts.unstable_opts.debug_info_for_profiling,
instrument_coverage: if_regular!(sess.instrument_coverage(), false),
instrument_gcov: if_regular!(
// compiler_builtins overrides the codegen-units settings,
// which is incompatible with -Zprofile which requires that
// only a single codegen unit is used per crate.
sess.opts.unstable_opts.profile && !is_compiler_builtins,
false
),

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

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

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

let regular_config =
ModuleConfig::new(ModuleKind::Regular, tcx, no_builtins, is_compiler_builtins);
let metadata_config =
ModuleConfig::new(ModuleKind::Metadata, tcx, no_builtins, is_compiler_builtins);
let allocator_config =
ModuleConfig::new(ModuleKind::Allocator, tcx, no_builtins, is_compiler_builtins);
let regular_config = ModuleConfig::new(ModuleKind::Regular, tcx, no_builtins);
let metadata_config = ModuleConfig::new(ModuleKind::Metadata, tcx, no_builtins);
let allocator_config = ModuleConfig::new(ModuleKind::Allocator, tcx, no_builtins);

let (shared_emitter, shared_emitter_main) = SharedEmitter::new();
let (codegen_worker_send, codegen_worker_receive) = channel();
Expand Down
83 changes: 78 additions & 5 deletions compiler/rustc_hir_typeck/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,34 @@ pub(crate) struct MissingParenthesesInRange {
pub(crate) enum NeverTypeFallbackFlowingIntoUnsafe {
#[help]
#[diag(hir_typeck_never_type_fallback_flowing_into_unsafe_call)]
Call,
Call {
#[subdiagnostic]
sugg: SuggestAnnotations,
},
#[help]
#[diag(hir_typeck_never_type_fallback_flowing_into_unsafe_method)]
Method,
Method {
#[subdiagnostic]
sugg: SuggestAnnotations,
},
#[help]
#[diag(hir_typeck_never_type_fallback_flowing_into_unsafe_path)]
Path,
Path {
#[subdiagnostic]
sugg: SuggestAnnotations,
},
#[help]
#[diag(hir_typeck_never_type_fallback_flowing_into_unsafe_union_field)]
UnionField,
UnionField {
#[subdiagnostic]
sugg: SuggestAnnotations,
},
#[help]
#[diag(hir_typeck_never_type_fallback_flowing_into_unsafe_deref)]
Deref,
Deref {
#[subdiagnostic]
sugg: SuggestAnnotations,
},
}

#[derive(LintDiagnostic)]
Expand All @@ -191,6 +206,64 @@ pub(crate) struct DependencyOnUnitNeverTypeFallback<'tcx> {
#[note]
pub obligation_span: Span,
pub obligation: ty::Predicate<'tcx>,
#[subdiagnostic]
pub sugg: SuggestAnnotations,
}

#[derive(Clone)]
pub(crate) enum SuggestAnnotation {
Unit(Span),
Path(Span),
Local(Span),
Turbo(Span, usize, usize),
}

#[derive(Clone)]
pub(crate) struct SuggestAnnotations {
pub suggestions: Vec<SuggestAnnotation>,
}
impl Subdiagnostic for SuggestAnnotations {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_: &F,
) {
if self.suggestions.is_empty() {
return;
}

let mut suggestions = vec![];
for suggestion in self.suggestions {
match suggestion {
SuggestAnnotation::Unit(span) => {
suggestions.push((span, "()".to_string()));
}
SuggestAnnotation::Path(span) => {
suggestions.push((span.shrink_to_lo(), "<() as ".to_string()));
suggestions.push((span.shrink_to_hi(), ">".to_string()));
}
SuggestAnnotation::Local(span) => {
suggestions.push((span, ": ()".to_string()));
}
SuggestAnnotation::Turbo(span, n_args, idx) => suggestions.push((
span,
format!(
"::<{}>",
(0..n_args)
.map(|i| if i == idx { "()" } else { "_" })
.collect::<Vec<_>>()
.join(", "),
),
)),
}
}

diag.multipart_suggestion_verbose(
"use `()` annotations to avoid fallback changes",
suggestions,
Applicability::MachineApplicable,
);
}
}

#[derive(Subdiagnostic)]
Expand Down
Loading
Loading