Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a4fb414

Browse files
committed
Auto merge of rust-lang#2898 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 2e17ac8 + 4014b17 commit a4fb414

File tree

187 files changed

+2152
-1232
lines changed

Some content is hidden

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

187 files changed

+2152
-1232
lines changed

RELEASES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ and related tools.
14811481
[is_power_of_two_usize]: https://doc.rust-lang.org/stable/core/num/struct.NonZeroUsize.html#method.is_power_of_two
14821482
[stdarch/1266]: https://github.com/rust-lang/stdarch/pull/1266
14831483

1484-
Version 1.58.1 (2022-01-19)
1484+
Version 1.58.1 (2022-01-20)
14851485
===========================
14861486

14871487
* Fix race condition in `std::fs::remove_dir_all` ([CVE-2022-21658])

compiler/rustc_builtin_macros/src/deriving/bounds.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,26 @@ pub fn expand_deriving_copy(
2727

2828
trait_def.expand(cx, mitem, item, push);
2929
}
30+
31+
pub fn expand_deriving_const_param_ty(
32+
cx: &mut ExtCtxt<'_>,
33+
span: Span,
34+
mitem: &MetaItem,
35+
item: &Annotatable,
36+
push: &mut dyn FnMut(Annotatable),
37+
is_const: bool,
38+
) {
39+
let trait_def = TraitDef {
40+
span,
41+
path: path_std!(marker::ConstParamTy),
42+
skip_path_as_bound: false,
43+
needs_copy_as_bound_if_packed: false,
44+
additional_bounds: Vec::new(),
45+
supports_unions: false,
46+
methods: Vec::new(),
47+
associated_types: Vec::new(),
48+
is_const,
49+
};
50+
51+
trait_def.expand(cx, mitem, item, push);
52+
}

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
115115
register_derive! {
116116
Clone: clone::expand_deriving_clone,
117117
Copy: bounds::expand_deriving_copy,
118+
ConstParamTy: bounds::expand_deriving_const_param_ty,
118119
Debug: debug::expand_deriving_debug,
119120
Default: default::expand_deriving_default,
120121
Eq: eq::expand_deriving_eq,

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -966,11 +966,7 @@ fn codegen_panic_inner<'tcx>(
966966
args: &[Value],
967967
span: Span,
968968
) {
969-
let def_id = fx
970-
.tcx
971-
.lang_items()
972-
.require(lang_item)
973-
.unwrap_or_else(|e| fx.tcx.sess.span_fatal(span, e.to_string()));
969+
let def_id = fx.tcx.require_lang_item(lang_item, Some(span));
974970

975971
let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx);
976972
let symbol_name = fx.tcx.symbol_name(instance).name;

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use std::fs::File;
2525
use std::io;
2626
use std::iter;
2727
use std::path::Path;
28-
use std::ptr;
2928
use std::slice;
3029
use std::sync::Arc;
3130

@@ -709,17 +708,6 @@ pub unsafe fn optimize_thin_module(
709708
let llmod = module.module_llvm.llmod();
710709
save_temp_bitcode(cgcx, &module, "thin-lto-input");
711710

712-
// Before we do much else find the "main" `DICompileUnit` that we'll be
713-
// using below. If we find more than one though then rustc has changed
714-
// in a way we're not ready for, so generate an ICE by returning
715-
// an error.
716-
let mut cu1 = ptr::null_mut();
717-
let mut cu2 = ptr::null_mut();
718-
llvm::LLVMRustThinLTOGetDICompileUnit(llmod, &mut cu1, &mut cu2);
719-
if !cu2.is_null() {
720-
return Err(write::llvm_err(&diag_handler, LlvmError::MultipleSourceDiCompileUnit));
721-
}
722-
723711
// Up next comes the per-module local analyses that we do for Thin LTO.
724712
// Each of these functions is basically copied from the LLVM
725713
// implementation and then tailored to suit this implementation. Ideally
@@ -766,43 +754,6 @@ pub unsafe fn optimize_thin_module(
766754
save_temp_bitcode(cgcx, &module, "thin-lto-after-import");
767755
}
768756

769-
// Ok now this is a bit unfortunate. This is also something you won't
770-
// find upstream in LLVM's ThinLTO passes! This is a hack for now to
771-
// work around bugs in LLVM.
772-
//
773-
// First discovered in #45511 it was found that as part of ThinLTO
774-
// importing passes LLVM will import `DICompileUnit` metadata
775-
// information across modules. This means that we'll be working with one
776-
// LLVM module that has multiple `DICompileUnit` instances in it (a
777-
// bunch of `llvm.dbg.cu` members). Unfortunately there's a number of
778-
// bugs in LLVM's backend which generates invalid DWARF in a situation
779-
// like this:
780-
//
781-
// https://bugs.llvm.org/show_bug.cgi?id=35212
782-
// https://bugs.llvm.org/show_bug.cgi?id=35562
783-
//
784-
// While the first bug there is fixed the second ended up causing #46346
785-
// which was basically a resurgence of #45511 after LLVM's bug 35212 was
786-
// fixed.
787-
//
788-
// This function below is a huge hack around this problem. The function
789-
// below is defined in `PassWrapper.cpp` and will basically "merge"
790-
// all `DICompileUnit` instances in a module. Basically it'll take all
791-
// the objects, rewrite all pointers of `DISubprogram` to point to the
792-
// first `DICompileUnit`, and then delete all the other units.
793-
//
794-
// This is probably mangling to the debug info slightly (but hopefully
795-
// not too much) but for now at least gets LLVM to emit valid DWARF (or
796-
// so it appears). Hopefully we can remove this once upstream bugs are
797-
// fixed in LLVM.
798-
{
799-
let _timer = cgcx
800-
.prof
801-
.generic_activity_with_arg("LLVM_thin_lto_patch_debuginfo", thin_module.name());
802-
llvm::LLVMRustThinLTOPatchDICompileUnit(llmod, cu1);
803-
save_temp_bitcode(cgcx, &module, "thin-lto-after-patch");
804-
}
805-
806757
// Alright now that we've done everything related to the ThinLTO
807758
// analysis it's time to run some optimizations! Here we use the same
808759
// `run_pass_manager` as the "fat" LTO above except that we tell it to

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,12 +2484,6 @@ extern "C" {
24842484
len: usize,
24852485
out_len: &mut usize,
24862486
) -> *const u8;
2487-
pub fn LLVMRustThinLTOGetDICompileUnit(
2488-
M: &Module,
2489-
CU1: &mut *mut c_void,
2490-
CU2: &mut *mut c_void,
2491-
);
2492-
pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
24932487

24942488
pub fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>;
24952489
pub fn LLVMRustLinkerAdd(

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use snap::write::FrameEncoder;
1414

1515
use object::elf::NT_GNU_PROPERTY_TYPE_0;
1616
use rustc_data_structures::memmap::Mmap;
17-
use rustc_data_structures::owned_slice::try_slice_owned;
18-
use rustc_data_structures::sync::MetadataRef;
17+
use rustc_data_structures::owned_slice::{try_slice_owned, OwnedSlice};
1918
use rustc_metadata::fs::METADATA_FILENAME;
2019
use rustc_metadata::EncodedMetadata;
2120
use rustc_session::cstore::MetadataLoader;
@@ -39,7 +38,7 @@ pub struct DefaultMetadataLoader;
3938
fn load_metadata_with(
4039
path: &Path,
4140
f: impl for<'a> FnOnce(&'a [u8]) -> Result<&'a [u8], String>,
42-
) -> Result<MetadataRef, String> {
41+
) -> Result<OwnedSlice, String> {
4342
let file =
4443
File::open(path).map_err(|e| format!("failed to open file '{}': {}", path.display(), e))?;
4544

@@ -49,7 +48,7 @@ fn load_metadata_with(
4948
}
5049

5150
impl MetadataLoader for DefaultMetadataLoader {
52-
fn get_rlib_metadata(&self, _target: &Target, path: &Path) -> Result<MetadataRef, String> {
51+
fn get_rlib_metadata(&self, _target: &Target, path: &Path) -> Result<OwnedSlice, String> {
5352
load_metadata_with(path, |data| {
5453
let archive = object::read::archive::ArchiveFile::parse(&*data)
5554
.map_err(|e| format!("failed to parse rlib '{}': {}", path.display(), e))?;
@@ -69,7 +68,7 @@ impl MetadataLoader for DefaultMetadataLoader {
6968
})
7069
}
7170

72-
fn get_dylib_metadata(&self, _target: &Target, path: &Path) -> Result<MetadataRef, String> {
71+
fn get_dylib_metadata(&self, _target: &Target, path: &Path) -> Result<OwnedSlice, String> {
7372
load_metadata_with(path, |data| search_for_section(path, data, ".rustc"))
7473
}
7574
}

compiler/rustc_codegen_ssa/src/traits/backend.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
use std::any::Any;
2+
13
use super::write::WriteBackendMethods;
24
use super::CodegenObject;
35
use crate::back::write::TargetMachineFactoryFn;
46
use crate::{CodegenResults, ModuleCodegen};
57

68
use rustc_ast::expand::allocator::AllocatorKind;
79
use rustc_data_structures::fx::FxHashMap;
10+
use rustc_data_structures::sync::{DynSend, DynSync};
811
use rustc_errors::ErrorGuaranteed;
912
use rustc_metadata::EncodedMetadata;
1013
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
@@ -20,11 +23,6 @@ use rustc_span::symbol::Symbol;
2023
use rustc_target::abi::call::FnAbi;
2124
use rustc_target::spec::Target;
2225

23-
pub use rustc_data_structures::sync::MetadataRef;
24-
25-
use rustc_data_structures::sync::{DynSend, DynSync};
26-
use std::any::Any;
27-
2826
pub trait BackendTypes {
2927
type Value: CodegenObject;
3028
type Function: CodegenObject;

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use std::fmt;
33

44
use rustc_errors::Diagnostic;
55
use rustc_middle::mir::AssertKind;
6-
use rustc_middle::ty::{layout::LayoutError, query::TyCtxtAt, ConstInt};
6+
use rustc_middle::query::TyCtxtAt;
7+
use rustc_middle::ty::{layout::LayoutError, ConstInt};
78
use rustc_span::{Span, Symbol};
89

910
use super::InterpCx;
@@ -169,14 +170,14 @@ impl<'tcx> ConstEvalErr<'tcx> {
169170
// See <https://github.com/rust-lang/rust/pull/63152>.
170171
let mut err = struct_error(tcx, &self.error.to_string());
171172
self.decorate(&mut err, decorate);
172-
ErrorHandled::Reported(err.emit())
173+
ErrorHandled::Reported(err.emit().into())
173174
}
174175
_ => {
175176
// Report as hard error.
176177
let mut err = struct_error(tcx, message);
177178
err.span_label(self.span, self.error.to_string());
178179
self.decorate(&mut err, decorate);
179-
ErrorHandled::Reported(err.emit())
180+
ErrorHandled::Reported(err.emit().into())
180181
}
181182
}
182183
}

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
382382
rustc_span::DUMMY_SP,
383383
"This is likely a const item that is missing from its impl",
384384
);
385-
throw_inval!(AlreadyReported(guar));
385+
throw_inval!(AlreadyReported(guar.into()));
386386
} else {
387387
// `find_mir_or_eval_fn` checks that this is a const fn before even calling us,
388388
// so this should be unreachable.

0 commit comments

Comments
 (0)