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 9 pull requests #104215

Merged
merged 56 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c87567c
Add context to compiler error message
Oct 20, 2022
6cb6564
Update tests to match error message changes
Oct 20, 2022
c33ee13
Remove linuxkernel targets
alex Nov 5, 2022
de0ab1c
Merge apple_base and apple_sdk_base into one module
BlackHoleFox Oct 23, 2022
ae948c6
Cleanup Apple target specifications
BlackHoleFox Oct 23, 2022
16edaa5
Limit efiapi calling convention to supported arches
nicholasbishop Nov 5, 2022
a7a40dd
Simplify some `Autoderef::new` calls
oli-obk Nov 8, 2022
1d93b35
Remove overloaded_span argument from `new`, where it is usually redun…
oli-obk Nov 8, 2022
b745a29
Remove an unused span
oli-obk Nov 8, 2022
ef40824
Update books
ehuss Nov 8, 2022
ba359d8
Add support for custom MIR parsing
JakobDegen Aug 3, 2022
a68ec22
Fix `rustdoc --version` when used with download-rustc
jyn514 Nov 9, 2022
575f609
Port unknown feature diagnostic to the new framework
SLASHLogin Aug 25, 2022
a54c800
Formatting
SLASHLogin Aug 25, 2022
1c4bd83
locales formatting
SLASHLogin Aug 25, 2022
21b0426
Trailing whitespaces
SLASHLogin Aug 25, 2022
b164790
Change String in structs to &'a str
SLASHLogin Aug 25, 2022
69d412a
Missing lifetime parameter and formatting
SLASHLogin Aug 25, 2022
05ae7ec
Import `error creating import library`
SLASHLogin Aug 25, 2022
4c625dc
Port Instrument coverage requires llvm 12 to the new struct
SLASHLogin Aug 25, 2022
9f0c165
Port `symbol_already_defined` error
SLASHLogin Aug 25, 2022
ec1e101
Fix diag() and formatting
SLASHLogin Aug 25, 2022
59b8aed
Port branch protection on aarch64
SLASHLogin Aug 25, 2022
f031823
Formatting
SLASHLogin Aug 25, 2022
39d363f
Port layout size overflow
SLASHLogin Aug 26, 2022
5d79d3c
Port InvalidMinimumAlignment
SLASHLogin Aug 26, 2022
60ee496
Port LinkageConstOrMutType error
SLASHLogin Aug 26, 2022
02403ee
Reuse SymbolAlreadyDefined
SLASHLogin Aug 26, 2022
978b5f7
Port SanitizerMemtagRequiresMte
SLASHLogin Aug 26, 2022
d32caf9
Port ArchiveBuildFailure
SLASHLogin Aug 26, 2022
ddbb650
Import ErrorWritingDEFFile
SLASHLogin Aug 26, 2022
81f7a8d
Port ErrorCallingDllTool
SLASHLogin Aug 26, 2022
c01546f
Port `DlltoolFailImportLibrary` and implement `IntoDiagnosticArg` for…
SLASHLogin Aug 26, 2022
33ef16f
Port `UnknownArchiveKind`
SLASHLogin Aug 26, 2022
185ef7b
Port `MissingFeatures` and `TargetFeatureDisableOrEnable`
SLASHLogin Aug 26, 2022
1c7a801
Fix CI
SLASHLogin Aug 27, 2022
e9a5329
Correct tests to match errors
SLASHLogin Aug 30, 2022
67394e7
Flatten diagnostic structs
SLASHLogin Oct 30, 2022
3728e95
Port diagnostics created by `Handler`
SLASHLogin Oct 30, 2022
9a15458
Simplify existing Diagnostic implementations
SLASHLogin Oct 30, 2022
b4820a3
Delay diagnostic translation in `rustc_codegen_ssa`
SLASHLogin Nov 2, 2022
3b949eb
Add `replace_args` method for `rustc_errors::diagnostic::Diagnostic`
SLASHLogin Nov 3, 2022
0381e51
Formatting
SLASHLogin Nov 3, 2022
a8a8055
Use `LayoutError`'s implementation of `IntoDiagnostic`
SLASHLogin Nov 4, 2022
0baac88
Update compiler/rustc_codegen_llvm/src/back/archive.rs
SLASHLogin Nov 8, 2022
39895b0
Add constructor for `Diagnostic` that takes `Vec<(DiagnosticMessage, …
SLASHLogin Nov 9, 2022
caada74
Add missing `emitted_at` to the `Diagnostic`
SLASHLogin Nov 9, 2022
2206267
Rollup merge of #101005 - SLASHLogin:rustc_codegen_llvm_diagnostics, …
Manishearth Nov 9, 2022
46bc12c
Rollup merge of #103307 - b4den:master, r=estebank
Manishearth Nov 9, 2022
3f11d39
Rollup merge of #103464 - JakobDegen:mir-parsing, r=oli-obk
Manishearth Nov 9, 2022
017c9aa
Rollup merge of #103929 - BlackHoleFox:apple-targets-cleanup, r=petro…
Manishearth Nov 9, 2022
67c0bff
Rollup merge of #104015 - alex:remove-kernel, r=oli-obk
Manishearth Nov 9, 2022
bfd637a
Rollup merge of #104020 - nicholasbishop:bishop-limit-efiapi, r=nagisa
Manishearth Nov 9, 2022
a709cc1
Rollup merge of #104156 - oli-obk:autoderef, r=estebank
Manishearth Nov 9, 2022
656f56c
Rollup merge of #104171 - ehuss:update-books, r=ehuss
Manishearth Nov 9, 2022
70c04a2
Rollup merge of #104184 - jyn514:rustdoc-version, r=davidtwco
Manishearth Nov 9, 2022
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
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}

let mut err = self.temporary_value_borrowed_for_too_long(proper_span);
err.span_label(proper_span, "creates a temporary which is freed while still in use");
err.span_label(proper_span, "creates a temporary value which is freed while still in use");
err.span_label(drop_span, "temporary value is freed at the end of this statement");

match explanation {
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern crate tracing;

use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::graph::dominators::Dominators;
use rustc_data_structures::vec_map::VecMap;
use rustc_errors::{Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
Expand Down Expand Up @@ -129,6 +130,19 @@ fn mir_borrowck<'tcx>(
) -> &'tcx BorrowCheckResult<'tcx> {
let (input_body, promoted) = tcx.mir_promoted(def);
debug!("run query mir_borrowck: {}", tcx.def_path_str(def.did.to_def_id()));

if input_body.borrow().should_skip() {
debug!("Skipping borrowck because of injected body");
// Let's make up a borrowck result! Fun times!
let result = BorrowCheckResult {
concrete_opaque_types: VecMap::new(),
closure_requirements: None,
used_mut_upvars: SmallVec::new(),
tainted_by_errors: None,
};
return tcx.arena.alloc(result);
}

let hir_owner = tcx.hir().local_def_id_to_hir_id(def.did).owner;

let infcx =
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl DebugContext {

let producer = format!(
"cg_clif (rustc {}, cranelift {})",
rustc_interface::util::version_str().unwrap_or("unknown version"),
rustc_interface::util::rustc_version_str().unwrap_or("unknown version"),
cranelift_codegen::VERSION,
);
let comp_dir = tcx
Expand Down
18 changes: 10 additions & 8 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtec
use smallvec::SmallVec;

use crate::attributes;
use crate::errors::{MissingFeatures, SanitizerMemtagRequiresMte, TargetFeatureDisableOrEnable};
use crate::llvm::AttributePlace::Function;
use crate::llvm::{self, AllocKindFlags, Attribute, AttributeKind, AttributePlace, MemoryEffects};
use crate::llvm_util;
Expand Down Expand Up @@ -82,7 +83,7 @@ pub fn sanitize_attrs<'ll>(
let mte_feature =
features.iter().map(|s| &s[..]).rfind(|n| ["+mte", "-mte"].contains(&&n[..]));
if let None | Some("-mte") = mte_feature {
cx.tcx.sess.err("`-Zsanitizer=memtag` requires `-Ctarget-feature=+mte`");
cx.tcx.sess.emit_err(SanitizerMemtagRequiresMte);
}

attrs.push(llvm::AttributeKind::SanitizeMemTag.create_attr(cx.llcx));
Expand Down Expand Up @@ -393,13 +394,14 @@ pub fn from_fn_attrs<'ll, 'tcx>(
.get_attrs(instance.def_id(), sym::target_feature)
.next()
.map_or_else(|| cx.tcx.def_span(instance.def_id()), |a| a.span);
let msg = format!(
"the target features {} must all be either enabled or disabled together",
f.join(", ")
);
let mut err = cx.tcx.sess.struct_span_err(span, &msg);
err.help("add the missing features in a `target_feature` attribute");
err.emit();
cx.tcx
.sess
.create_err(TargetFeatureDisableOrEnable {
features: f,
span: Some(span),
missing_features: Some(MissingFeatures),
})
.emit();
return;
}

Expand Down
35 changes: 20 additions & 15 deletions compiler/rustc_codegen_llvm/src/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ use std::str;
use object::read::macho::FatArch;

use crate::common;
use crate::errors::{
ArchiveBuildFailure, DlltoolFailImportLibrary, ErrorCallingDllTool, ErrorCreatingImportLibrary,
ErrorWritingDEFFile, UnknownArchiveKind,
};
use crate::llvm::archive_ro::{ArchiveRO, Child};
use crate::llvm::{self, ArchiveKind, LLVMMachineType, LLVMRustCOFFShortExport};
use rustc_codegen_ssa::back::archive::{ArchiveBuilder, ArchiveBuilderBuilder};
Expand Down Expand Up @@ -147,7 +151,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
fn build(mut self: Box<Self>, output: &Path) -> bool {
match self.build_with_llvm(output) {
Ok(any_members) => any_members,
Err(e) => self.sess.fatal(&format!("failed to build archive: {}", e)),
Err(e) => self.sess.emit_fatal(ArchiveBuildFailure { error: e }),
}
}
}
Expand Down Expand Up @@ -217,7 +221,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
match std::fs::write(&def_file_path, def_file_content) {
Ok(_) => {}
Err(e) => {
sess.fatal(&format!("Error writing .DEF file: {}", e));
sess.emit_fatal(ErrorWritingDEFFile { error: e });
}
};

Expand All @@ -239,13 +243,14 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {

match result {
Err(e) => {
sess.fatal(&format!("Error calling dlltool: {}", e));
sess.emit_fatal(ErrorCallingDllTool { error: e });
}
Ok(output) if !output.status.success() => {
sess.emit_fatal(DlltoolFailImportLibrary {
stdout: String::from_utf8_lossy(&output.stdout),
stderr: String::from_utf8_lossy(&output.stderr),
})
}
Ok(output) if !output.status.success() => sess.fatal(&format!(
"Dlltool could not create import library: {}\n{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
)),
_ => {}
}
} else {
Expand Down Expand Up @@ -293,11 +298,10 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
};

if result == crate::llvm::LLVMRustResult::Failure {
sess.fatal(&format!(
"Error creating import library for {}: {}",
sess.emit_fatal(ErrorCreatingImportLibrary {
lib_name,
llvm::last_error().unwrap_or("unknown LLVM error".to_string())
));
error: llvm::last_error().unwrap_or("unknown LLVM error".to_string()),
});
}
};

Expand All @@ -308,9 +312,10 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
impl<'a> LlvmArchiveBuilder<'a> {
fn build_with_llvm(&mut self, output: &Path) -> io::Result<bool> {
let kind = &*self.sess.target.archive_format;
let kind = kind.parse::<ArchiveKind>().map_err(|_| kind).unwrap_or_else(|kind| {
self.sess.fatal(&format!("Don't know how to build archive of type: {}", kind))
});
let kind = kind
.parse::<ArchiveKind>()
.map_err(|_| kind)
.unwrap_or_else(|kind| self.sess.emit_fatal(UnknownArchiveKind { kind }));

let mut additions = mem::take(&mut self.additions);
let mut strings = Vec::new();
Expand Down
9 changes: 2 additions & 7 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::back::write::{self, save_temp_bitcode, DiagnosticHandlers};
use crate::errors::DynamicLinkingWithLTO;
use crate::llvm::{self, build_string};
use crate::{LlvmCodegenBackend, ModuleLlvm};
use object::read::archive::ArchiveFile;
Expand Down Expand Up @@ -90,13 +91,7 @@ fn prepare_lto(
}

if cgcx.opts.cg.prefer_dynamic && !cgcx.opts.unstable_opts.dylib_lto {
diag_handler
.struct_err("cannot prefer dynamic linking when performing LTO")
.note(
"only 'staticlib', 'bin', and 'cdylib' outputs are \
supported with LTO",
)
.emit();
diag_handler.emit_err(DynamicLinkingWithLTO);
return Err(FatalError);
}

Expand Down
16 changes: 7 additions & 9 deletions compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::base;
use crate::common::{self, CodegenCx};
use crate::debuginfo;
use crate::errors::{InvalidMinimumAlignment, LinkageConstOrMutType, SymbolAlreadyDefined};
use crate::llvm::{self, True};
use crate::llvm_util;
use crate::type_::Type;
Expand Down Expand Up @@ -146,7 +147,7 @@ fn set_global_alignment<'ll>(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align:
match Align::from_bits(min) {
Ok(min) => align = align.max(min),
Err(err) => {
cx.sess().err(&format!("invalid minimum global alignment: {}", err));
cx.sess().emit_err(InvalidMinimumAlignment { err });
}
}
}
Expand Down Expand Up @@ -174,10 +175,7 @@ fn check_and_apply_linkage<'ll, 'tcx>(
let llty2 = if let ty::RawPtr(ref mt) = ty.kind() {
cx.layout_of(mt.ty).llvm_type(cx)
} else {
cx.sess().span_fatal(
cx.tcx.def_span(def_id),
"must have type `*const T` or `*mut T` due to `#[linkage]` attribute",
)
cx.sess().emit_fatal(LinkageConstOrMutType { span: cx.tcx.def_span(def_id) })
};
unsafe {
// Declare a symbol `foo` with the desired linkage.
Expand All @@ -193,10 +191,10 @@ fn check_and_apply_linkage<'ll, 'tcx>(
let mut real_name = "_rust_extern_with_linkage_".to_string();
real_name.push_str(sym);
let g2 = cx.define_global(&real_name, llty).unwrap_or_else(|| {
cx.sess().span_fatal(
cx.tcx.def_span(def_id),
&format!("symbol `{}` is already defined", &sym),
)
cx.sess().emit_fatal(SymbolAlreadyDefined {
span: cx.tcx.def_span(def_id),
symbol_name: sym,
})
});
llvm::LLVMRustSetLinkage(g2, llvm::Linkage::InternalLinkage);
llvm::LLVMSetInitializer(g2, g1);
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::back::write::to_llvm_code_model;
use crate::callee::get_fn;
use crate::coverageinfo;
use crate::debuginfo;
use crate::errors::BranchProtectionRequiresAArch64;
use crate::llvm;
use crate::llvm_util;
use crate::type_::Type;
Expand All @@ -26,6 +27,7 @@ use rustc_session::config::{BranchProtection, CFGuard, CFProtection};
use rustc_session::config::{CrateType, DebugInfo, PAuthKey, PacRet};
use rustc_session::Session;
use rustc_span::source_map::Span;
use rustc_span::source_map::Spanned;
use rustc_target::abi::{
call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx,
};
Expand Down Expand Up @@ -275,7 +277,7 @@ pub unsafe fn create_module<'ll>(

if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
if sess.target.arch != "aarch64" {
sess.err("-Zbranch-protection is only supported on aarch64");
sess.emit_err(BranchProtectionRequiresAArch64);
} else {
llvm::LLVMRustAddModuleFlag(
llmod,
Expand Down Expand Up @@ -951,7 +953,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
#[inline]
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
if let LayoutError::SizeOverflow(_) = err {
self.sess().span_fatal(span, &err.to_string())
self.sess().emit_fatal(Spanned { span, node: err })
} else {
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
}
Expand All @@ -969,7 +971,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
fn_abi_request: FnAbiRequest<'tcx>,
) -> ! {
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
self.sess().span_fatal(span, &err.to_string())
self.sess().emit_fatal(Spanned { span, node: err })
} else {
match fn_abi_request {
FnAbiRequest::OfFnPtr { sig, extra_args } => {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::common::CodegenCx;
use crate::coverageinfo;
use crate::errors::InstrumentCoverageRequiresLLVM12;
use crate::llvm;

use llvm::coverageinfo::CounterMappingRegion;
Expand Down Expand Up @@ -37,7 +38,7 @@ pub fn finalize<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) {
// LLVM 12.
let version = coverageinfo::mapping_version();
if version < 4 {
tcx.sess.fatal("rustc option `-C instrument-coverage` requires LLVM 12 or higher.");
tcx.sess.emit_fatal(InstrumentCoverageRequiresLLVM12);
}

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