Sync from rust 10f4ce324b
This commit is contained in:
commit
473e80eb28
6 changed files with 25 additions and 44 deletions
|
|
@ -567,7 +567,7 @@ pub mod intrinsics {
|
|||
pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
|
||||
pub fn transmute<T, U>(e: T) -> U;
|
||||
pub fn ctlz_nonzero<T>(x: T) -> T;
|
||||
pub fn needs_drop<T>() -> bool;
|
||||
pub fn needs_drop<T: ?::Sized>() -> bool;
|
||||
pub fn bitreverse<T>(x: T) -> T;
|
||||
pub fn bswap<T>(x: T) -> T;
|
||||
pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,11 @@ struct NoisyDrop {
|
|||
inner: NoisyDropInner,
|
||||
}
|
||||
|
||||
struct NoisyDropUnsized {
|
||||
inner: NoisyDropInner,
|
||||
text: str,
|
||||
}
|
||||
|
||||
struct NoisyDropInner;
|
||||
|
||||
impl Drop for NoisyDrop {
|
||||
|
|
@ -170,7 +175,9 @@ fn main() {
|
|||
assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8);
|
||||
|
||||
assert!(!intrinsics::needs_drop::<u8>());
|
||||
assert!(!intrinsics::needs_drop::<[u8]>());
|
||||
assert!(intrinsics::needs_drop::<NoisyDrop>());
|
||||
assert!(intrinsics::needs_drop::<NoisyDropUnsized>());
|
||||
|
||||
Unique {
|
||||
pointer: NonNull(1 as *mut &str),
|
||||
|
|
|
|||
|
|
@ -30,25 +30,7 @@ pub(crate) struct ArArchiveBuilder<'a> {
|
|||
}
|
||||
|
||||
impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
||||
fn new(sess: &'a Session, output: &Path, input: Option<&Path>) -> Self {
|
||||
let (src_archives, entries) = if let Some(input) = input {
|
||||
let read_cache = ReadCache::new(File::open(input).unwrap());
|
||||
let archive = ArchiveFile::parse(&read_cache).unwrap();
|
||||
let mut entries = Vec::new();
|
||||
|
||||
for entry in archive.members() {
|
||||
let entry = entry.unwrap();
|
||||
entries.push((
|
||||
entry.name().to_vec(),
|
||||
ArchiveEntry::FromArchive { archive_index: 0, file_range: entry.file_range() },
|
||||
));
|
||||
}
|
||||
|
||||
(vec![read_cache.into_inner()], entries)
|
||||
} else {
|
||||
(vec![], Vec::new())
|
||||
};
|
||||
|
||||
fn new(sess: &'a Session, output: &Path) -> Self {
|
||||
ArArchiveBuilder {
|
||||
sess,
|
||||
dst: output.to_path_buf(),
|
||||
|
|
@ -56,24 +38,11 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
|||
// FIXME fix builtin ranlib on macOS
|
||||
no_builtin_ranlib: sess.target.is_like_osx,
|
||||
|
||||
src_archives,
|
||||
entries,
|
||||
src_archives: vec![],
|
||||
entries: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
fn src_files(&mut self) -> Vec<String> {
|
||||
self.entries.iter().map(|(name, _)| String::from_utf8(name.clone()).unwrap()).collect()
|
||||
}
|
||||
|
||||
fn remove_file(&mut self, name: &str) {
|
||||
let index = self
|
||||
.entries
|
||||
.iter()
|
||||
.position(|(entry_name, _)| entry_name == name.as_bytes())
|
||||
.expect("Tried to remove file not existing in src archive");
|
||||
self.entries.remove(index);
|
||||
}
|
||||
|
||||
fn add_file(&mut self, file: &Path) {
|
||||
self.entries.push((
|
||||
file.file_name().unwrap().to_str().unwrap().to_string().into_bytes(),
|
||||
|
|
@ -105,7 +74,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn build(mut self) {
|
||||
fn build(mut self) -> bool {
|
||||
enum BuilderKind {
|
||||
Bsd(ar::Builder<File>),
|
||||
Gnu(ar::GnuBuilder<File>),
|
||||
|
|
@ -221,6 +190,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
|||
)
|
||||
};
|
||||
|
||||
let any_members = !entries.is_empty();
|
||||
|
||||
// Add all files
|
||||
for (entry_name, data) in entries.into_iter() {
|
||||
let header = ar::Header::new(entry_name, data.len() as u64);
|
||||
|
|
@ -246,6 +217,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
|||
self.sess.fatal(&format!("Ranlib exited with code {:?}", status.code()));
|
||||
}
|
||||
}
|
||||
|
||||
any_members
|
||||
}
|
||||
|
||||
fn inject_dll_import_lib(
|
||||
|
|
|
|||
|
|
@ -710,7 +710,7 @@ fn codegen_stmt<'tcx>(
|
|||
let times = fx
|
||||
.monomorphize(times)
|
||||
.eval(fx.tcx, ParamEnv::reveal_all())
|
||||
.val()
|
||||
.kind()
|
||||
.try_to_bits(fx.tcx.data_layout.pointer_size)
|
||||
.unwrap();
|
||||
if operand.layout().size.bytes() == 0 {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
|
|||
ConstantKind::Ty(ct) => ct,
|
||||
ConstantKind::Val(..) => continue,
|
||||
};
|
||||
match const_.val() {
|
||||
match const_.kind() {
|
||||
ConstKind::Value(_) => {}
|
||||
ConstKind::Unevaluated(unevaluated) => {
|
||||
if let Err(err) =
|
||||
|
|
@ -126,8 +126,8 @@ pub(crate) fn codegen_constant<'tcx>(
|
|||
ConstantKind::Ty(ct) => ct,
|
||||
ConstantKind::Val(val, ty) => return codegen_const_value(fx, val, ty),
|
||||
};
|
||||
let const_val = match const_.val() {
|
||||
ConstKind::Value(const_val) => const_val,
|
||||
let const_val = match const_.kind() {
|
||||
ConstKind::Value(valtree) => fx.tcx.valtree_to_const_val((const_.ty(), valtree)),
|
||||
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
|
||||
if fx.tcx.is_static(def.did) =>
|
||||
{
|
||||
|
|
@ -468,9 +468,10 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
|
|||
) -> Option<ConstValue<'tcx>> {
|
||||
match operand {
|
||||
Operand::Constant(const_) => match const_.literal {
|
||||
ConstantKind::Ty(const_) => {
|
||||
fx.monomorphize(const_).eval(fx.tcx, ParamEnv::reveal_all()).val().try_to_value()
|
||||
}
|
||||
ConstantKind::Ty(const_) => fx
|
||||
.monomorphize(const_)
|
||||
.eval_for_mir(fx.tcx, ParamEnv::reveal_all())
|
||||
.try_to_value(fx.tcx),
|
||||
ConstantKind::Val(val, _) => Some(val),
|
||||
},
|
||||
// FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use rustc_span::Symbol;
|
|||
|
||||
use cranelift_jit::{JITBuilder, JITModule};
|
||||
|
||||
// FIXME use std::lazy::SyncOnceCell once it stabilizes
|
||||
// FIXME use std::sync::OnceLock once it stabilizes
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
use crate::{prelude::*, BackendConfig};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue