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 10 pull requests #129359

Merged
merged 27 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
78caecf
Special case DUMMY_SP to emit line 0/column 0 locations on DWARF plat…
khuey Aug 4, 2024
e587855
Use Span::is_dummy().
khuey Aug 4, 2024
5dc4a19
Fix warning.
khuey Aug 4, 2024
1350a65
Remove a Redundant Conditional Check
veera-sivarajan Aug 8, 2024
c8ae02f
CFI: Erase regions when projecting ADT to its transparent non-1zst field
compiler-errors Aug 17, 2024
25964b5
Reword the "unreachable pattern" explanations
Nadrieril Aug 19, 2024
efb28bd
Add a note with a link to explain empty types
Nadrieril Aug 19, 2024
36eced4
Cap the number of patterns pointed to by the lint
Nadrieril Aug 19, 2024
3c735a0
Add a test.
khuey Aug 20, 2024
4e9725c
Add a comment.
khuey Aug 20, 2024
f30392a
Move the "matches no value" note to be a span label
Nadrieril Aug 20, 2024
e424e7f
Avoid extra `cast()`s after `CStr::as_ptr()`
cuviper Aug 20, 2024
0f5c6ea
Make `ArgAbi::make_indirect_force` more specific
beetrees Aug 21, 2024
25ff9b6
Use bool in favor of Option<()> for diagnostics
compiler-errors Aug 21, 2024
0b2525c
Simplify some redundant field names
compiler-errors Aug 21, 2024
9010708
fix comment on PlaceMention semantics
RalfJung Aug 21, 2024
123bb58
Fix stability attribute of `impl !Error for &str`
tbu- Aug 20, 2024
dea325e
Rollup merge of #128627 - khuey:DUMMY_SP-line-no, r=nnethercote
matthiaskrgr Aug 21, 2024
48c9864
Rollup merge of #128843 - veera-sivarajan:small-cleanup, r=davidtwco
matthiaskrgr Aug 21, 2024
7da4b2d
Rollup merge of #129179 - compiler-errors:cfi-erase-transparent, r=da…
matthiaskrgr Aug 21, 2024
9bb17d3
Rollup merge of #129281 - Nadrieril:tweak-unreachable-lint-wording, r…
matthiaskrgr Aug 21, 2024
349f299
Rollup merge of #129312 - tbu-:pr_str_not_impl_error, r=Noratrieb
matthiaskrgr Aug 21, 2024
e961d6b
Rollup merge of #129332 - cuviper:cstr-cast, r=compiler-errors
matthiaskrgr Aug 21, 2024
be80216
Rollup merge of #129339 - beetrees:make-indirect-from-ignore, r=RalfJung
matthiaskrgr Aug 21, 2024
937a18d
Rollup merge of #129344 - compiler-errors:less-option-unit-diagnostic…
matthiaskrgr Aug 21, 2024
4137f3b
Rollup merge of #129345 - compiler-errors:scratch4, r=jieyouxu
matthiaskrgr Aug 21, 2024
9fd2832
Rollup merge of #129355 - RalfJung:PlaceMention, r=compiler-errors
matthiaskrgr Aug 21, 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: 2 additions & 3 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// Multiple different abi names may actually be the same ABI
// If the specified ABIs are not the same name, alert the user that they resolve to the same ABI
let source_map = self.tcx.sess.source_map();
let equivalent = (source_map.span_to_snippet(*prev_sp)
!= source_map.span_to_snippet(*abi_span))
.then_some(());
let equivalent = source_map.span_to_snippet(*prev_sp)
!= source_map.span_to_snippet(*abi_span);

self.dcx().emit_err(AbiSpecifiedMultipleTimes {
abi_span: *abi_span,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub struct AbiSpecifiedMultipleTimes {
#[label]
pub prev_span: Span,
#[note]
pub equivalent: Option<()>,
pub equivalent: bool,
}

#[derive(Diagnostic)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
};
hir::FnHeader {
safety: self.lower_safety(h.safety, default_safety),
asyncness: asyncness,
asyncness,
constness: self.lower_constness(h.constness),
abi: self.lower_extern(h.ext),
}
Expand Down
23 changes: 10 additions & 13 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,8 @@ impl<'a> AstValidator<'a> {
FnHeader { safety: _, coroutine_kind, constness, ext }: FnHeader,
) {
let report_err = |span| {
self.dcx().emit_err(errors::FnQualifierInExtern {
span: span,
block: self.current_extern_span(),
});
self.dcx()
.emit_err(errors::FnQualifierInExtern { span, block: self.current_extern_span() });
};
match coroutine_kind {
Some(knd) => report_err(knd.span()),
Expand Down Expand Up @@ -963,14 +961,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
self_ty,
items,
}) => {
let error =
|annotation_span, annotation, only_trait: bool| errors::InherentImplCannot {
span: self_ty.span,
annotation_span,
annotation,
self_ty: self_ty.span,
only_trait: only_trait.then_some(()),
};
let error = |annotation_span, annotation, only_trait| errors::InherentImplCannot {
span: self_ty.span,
annotation_span,
annotation,
self_ty: self_ty.span,
only_trait,
};

self.with_in_trait_impl(None, |this| {
this.visibility_not_permitted(
Expand Down Expand Up @@ -1195,7 +1192,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
} else if where_clauses.after.has_where_token {
self.dcx().emit_err(errors::WhereClauseAfterTypeAlias {
span: where_clauses.after.span,
help: self.session.is_nightly_build().then_some(()),
help: self.session.is_nightly_build(),
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ pub struct InherentImplCannot<'a> {
#[label(ast_passes_type)]
pub self_ty: Span,
#[note(ast_passes_only_trait)]
pub only_trait: Option<()>,
pub only_trait: bool,
}

#[derive(Diagnostic)]
Expand Down Expand Up @@ -528,7 +528,7 @@ pub struct WhereClauseAfterTypeAlias {
#[primary_span]
pub span: Span,
#[help]
pub help: Option<()>,
pub help: bool,
}

#[derive(Diagnostic)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ pub fn find_deprecation(
sess.dcx().emit_err(
session_diagnostics::DeprecatedItemSuggestion {
span: mi.span,
is_nightly: sess.is_nightly_build().then_some(()),
is_nightly: sess.is_nightly_build(),
details: (),
},
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ pub(crate) struct DeprecatedItemSuggestion {
pub span: Span,

#[help]
pub is_nightly: Option<()>,
pub is_nightly: bool,

#[note]
pub details: (),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn create_wrapper_function(
}
llvm::LLVMRustSetVisibility(callee, llvm::Visibility::Hidden);

let llbb = llvm::LLVMAppendBasicBlockInContext(llcx, llfn, c"entry".as_ptr().cast());
let llbb = llvm::LLVMAppendBasicBlockInContext(llcx, llfn, c"entry".as_ptr());

let llbuilder = llvm::LLVMCreateBuilderInContext(llcx);
llvm::LLVMPositionBuilderAtEnd(llbuilder, llbb);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ pub(crate) fn run_pass_manager(
llvm::LLVMRustAddModuleFlagU32(
module.module_llvm.llmod(),
llvm::LLVMModFlagBehavior::Error,
c"LTOPostLink".as_ptr().cast(),
c"LTOPostLink".as_ptr(),
1,
);
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ unsafe fn embed_bitcode(
let llglobal = llvm::LLVMAddGlobal(
llmod,
common::val_ty(llconst),
c"rustc.embedded.module".as_ptr().cast(),
c"rustc.embedded.module".as_ptr(),
);
llvm::LLVMSetInitializer(llglobal, llconst);

Expand All @@ -1044,7 +1044,7 @@ unsafe fn embed_bitcode(
let llglobal = llvm::LLVMAddGlobal(
llmod,
common::val_ty(llconst),
c"rustc.embedded.cmdline".as_ptr().cast(),
c"rustc.embedded.cmdline".as_ptr(),
);
llvm::LLVMSetInitializer(llglobal, llconst);
let section = if is_apple {
Expand All @@ -1054,7 +1054,7 @@ unsafe fn embed_bitcode(
} else {
c".llvmcmd"
};
llvm::LLVMSetSection(llglobal, section.as_ptr().cast());
llvm::LLVMSetSection(llglobal, section.as_ptr());
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
} else {
// We need custom section flags, so emit module-level inline assembly.
Expand Down Expand Up @@ -1107,7 +1107,7 @@ fn create_msvc_imps(
.collect::<Vec<_>>();

for (imp_name, val) in globals {
let imp = llvm::LLVMAddGlobal(llmod, ptr_ty, imp_name.as_ptr().cast());
let imp = llvm::LLVMAddGlobal(llmod, ptr_ty, imp_name.as_ptr());
llvm::LLVMSetInitializer(imp, val);
llvm::LLVMRustSetLinkage(imp, llvm::Linkage::ExternalLinkage);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ impl<'ll> CodegenCx<'ll, '_> {
let val = llvm::LLVMMetadataAsValue(self.llcx, meta);
llvm::LLVMAddNamedMetadataOperand(
self.llmod,
c"wasm.custom_sections".as_ptr().cast(),
c"wasm.custom_sections".as_ptr(),
val,
);
}
Expand Down
22 changes: 11 additions & 11 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ pub unsafe fn create_module<'ll>(
// If skipping the PLT is enabled, we need to add some module metadata
// to ensure intrinsic calls don't use it.
if !sess.needs_plt() {
let avoid_plt = c"RtLibUseGOT".as_ptr().cast();
let avoid_plt = c"RtLibUseGOT".as_ptr();
unsafe {
llvm::LLVMRustAddModuleFlagU32(llmod, llvm::LLVMModFlagBehavior::Warning, avoid_plt, 1);
}
}

// Enable canonical jump tables if CFI is enabled. (See https://reviews.llvm.org/D65629.)
if sess.is_sanitizer_cfi_canonical_jump_tables_enabled() && sess.is_sanitizer_cfi_enabled() {
let canonical_jump_tables = c"CFI Canonical Jump Tables".as_ptr().cast();
let canonical_jump_tables = c"CFI Canonical Jump Tables".as_ptr();
unsafe {
llvm::LLVMRustAddModuleFlagU32(
llmod,
Expand All @@ -228,7 +228,7 @@ pub unsafe fn create_module<'ll>(

// Enable LTO unit splitting if specified or if CFI is enabled. (See https://reviews.llvm.org/D53891.)
if sess.is_split_lto_unit_enabled() || sess.is_sanitizer_cfi_enabled() {
let enable_split_lto_unit = c"EnableSplitLTOUnit".as_ptr().cast();
let enable_split_lto_unit = c"EnableSplitLTOUnit".as_ptr();
unsafe {
llvm::LLVMRustAddModuleFlagU32(
llmod,
Expand All @@ -241,7 +241,7 @@ pub unsafe fn create_module<'ll>(

// Add "kcfi" module flag if KCFI is enabled. (See https://reviews.llvm.org/D119296.)
if sess.is_sanitizer_kcfi_enabled() {
let kcfi = c"kcfi".as_ptr().cast();
let kcfi = c"kcfi".as_ptr();
unsafe {
llvm::LLVMRustAddModuleFlagU32(llmod, llvm::LLVMModFlagBehavior::Override, kcfi, 1);
}
Expand Down Expand Up @@ -280,26 +280,26 @@ pub unsafe fn create_module<'ll>(
llvm::LLVMRustAddModuleFlagU32(
llmod,
llvm::LLVMModFlagBehavior::Min,
c"branch-target-enforcement".as_ptr().cast(),
c"branch-target-enforcement".as_ptr(),
bti.into(),
);
llvm::LLVMRustAddModuleFlagU32(
llmod,
llvm::LLVMModFlagBehavior::Min,
c"sign-return-address".as_ptr().cast(),
c"sign-return-address".as_ptr(),
pac_ret.is_some().into(),
);
let pac_opts = pac_ret.unwrap_or(PacRet { leaf: false, key: PAuthKey::A });
llvm::LLVMRustAddModuleFlagU32(
llmod,
llvm::LLVMModFlagBehavior::Min,
c"sign-return-address-all".as_ptr().cast(),
c"sign-return-address-all".as_ptr(),
pac_opts.leaf.into(),
);
llvm::LLVMRustAddModuleFlagU32(
llmod,
llvm::LLVMModFlagBehavior::Min,
c"sign-return-address-with-bkey".as_ptr().cast(),
c"sign-return-address-with-bkey".as_ptr(),
u32::from(pac_opts.key == PAuthKey::B),
);
}
Expand All @@ -317,7 +317,7 @@ pub unsafe fn create_module<'ll>(
llvm::LLVMRustAddModuleFlagU32(
llmod,
llvm::LLVMModFlagBehavior::Override,
c"cf-protection-branch".as_ptr().cast(),
c"cf-protection-branch".as_ptr(),
1,
);
}
Expand All @@ -327,7 +327,7 @@ pub unsafe fn create_module<'ll>(
llvm::LLVMRustAddModuleFlagU32(
llmod,
llvm::LLVMModFlagBehavior::Override,
c"cf-protection-return".as_ptr().cast(),
c"cf-protection-return".as_ptr(),
1,
);
}
Expand All @@ -338,7 +338,7 @@ pub unsafe fn create_module<'ll>(
llvm::LLVMRustAddModuleFlagU32(
llmod,
llvm::LLVMModFlagBehavior::Error,
c"Virtual Function Elim".as_ptr().cast(),
c"Virtual Function Elim".as_ptr(),
1,
);
}
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global<'ll>(cx: &CodegenCx<'ll, '
let c_section_var_name = c"__rustc_debug_gdb_scripts_section__";
let section_var_name = c_section_var_name.to_str().unwrap();

let section_var =
unsafe { llvm::LLVMGetNamedGlobal(cx.llmod, c_section_var_name.as_ptr().cast()) };
let section_var = unsafe { llvm::LLVMGetNamedGlobal(cx.llmod, c_section_var_name.as_ptr()) };

section_var.unwrap_or_else(|| {
let mut section_contents = Vec::new();
Expand Down Expand Up @@ -70,7 +69,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global<'ll>(cx: &CodegenCx<'ll, '
let section_var = cx
.define_global(section_var_name, llvm_type)
.unwrap_or_else(|| bug!("symbol `{}` is already defined", section_var_name));
llvm::LLVMSetSection(section_var, c".debug_gdb_scripts".as_ptr().cast());
llvm::LLVMSetSection(section_var, c".debug_gdb_scripts".as_ptr());
llvm::LLVMSetInitializer(section_var, cx.const_bytes(section_contents));
llvm::LLVMSetGlobalConstant(section_var, llvm::True);
llvm::LLVMSetUnnamedAddress(section_var, llvm::UnnamedAddr::Global);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
producer.as_ptr().cast(),
producer.len(),
tcx.sess.opts.optimize != config::OptLevel::No,
c"".as_ptr().cast(),
c"".as_ptr(),
0,
// NB: this doesn't actually have any perceptible effect, it seems. LLVM will instead
// put the path supplied to `MCSplitDwarfFile` into the debug info of the final
Expand Down
18 changes: 14 additions & 4 deletions compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
llvm::LLVMRustAddModuleFlagU32(
self.llmod,
llvm::LLVMModFlagBehavior::Warning,
c"Dwarf Version".as_ptr().cast(),
c"Dwarf Version".as_ptr(),
dwarf_version,
);
} else {
// Indicate that we want CodeView debug information on MSVC
llvm::LLVMRustAddModuleFlagU32(
self.llmod,
llvm::LLVMModFlagBehavior::Warning,
c"CodeView".as_ptr().cast(),
c"CodeView".as_ptr(),
1,
)
}
Expand All @@ -126,7 +126,7 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
llvm::LLVMRustAddModuleFlagU32(
self.llmod,
llvm::LLVMModFlagBehavior::Warning,
c"Debug Info Version".as_ptr().cast(),
c"Debug Info Version".as_ptr(),
llvm::LLVMRustDebugMetadataVersion(),
);
}
Expand Down Expand Up @@ -570,7 +570,17 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
inlined_at: Option<&'ll DILocation>,
span: Span,
) -> &'ll DILocation {
let DebugLoc { line, col, .. } = self.lookup_debug_loc(span.lo());
// When emitting debugging information, DWARF (i.e. everything but MSVC)
// treats line 0 as a magic value meaning that the code could not be
// attributed to any line in the source. That's also exactly what dummy
// spans are. Make that equivalence here, rather than passing dummy spans
// to lookup_debug_loc, which will return line 1 for them.
let (line, col) = if span.is_dummy() && !self.sess().target.is_like_msvc {
(0, 0)
} else {
let DebugLoc { line, col, .. } = self.lookup_debug_loc(span.lo());
(line, col)
};

unsafe { llvm::LLVMRustDIBuilderCreateDebugLocation(line, col, scope, inlined_at) }
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ impl<'a> Linker for L4Bender<'a> {

impl<'a> L4Bender<'a> {
pub fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
L4Bender { cmd, sess: sess, hinted_static: false }
L4Bender { cmd, sess, hinted_static: false }
}

fn hint_static(&mut self) {
Expand All @@ -1520,7 +1520,7 @@ pub struct AixLinker<'a> {

impl<'a> AixLinker<'a> {
pub fn new(cmd: Command, sess: &'a Session) -> AixLinker<'a> {
AixLinker { cmd, sess: sess, hinted_static: None }
AixLinker { cmd, sess, hinted_static: None }
}

fn hint_static(&mut self) {
Expand Down
Loading
Loading