Skip to content

Commit 473e80e

Browse files
committed
Sync from rust 10f4ce3
2 parents c431540 + 92749f0 commit 473e80e

File tree

6 files changed

+25
-44
lines changed

6 files changed

+25
-44
lines changed

example/mini_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ pub mod intrinsics {
567567
pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
568568
pub fn transmute<T, U>(e: T) -> U;
569569
pub fn ctlz_nonzero<T>(x: T) -> T;
570-
pub fn needs_drop<T>() -> bool;
570+
pub fn needs_drop<T: ?::Sized>() -> bool;
571571
pub fn bitreverse<T>(x: T) -> T;
572572
pub fn bswap<T>(x: T) -> T;
573573
pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);

example/mini_core_hello_world.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ struct NoisyDrop {
5555
inner: NoisyDropInner,
5656
}
5757

58+
struct NoisyDropUnsized {
59+
inner: NoisyDropInner,
60+
text: str,
61+
}
62+
5863
struct NoisyDropInner;
5964

6065
impl Drop for NoisyDrop {
@@ -170,7 +175,9 @@ fn main() {
170175
assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8);
171176

172177
assert!(!intrinsics::needs_drop::<u8>());
178+
assert!(!intrinsics::needs_drop::<[u8]>());
173179
assert!(intrinsics::needs_drop::<NoisyDrop>());
180+
assert!(intrinsics::needs_drop::<NoisyDropUnsized>());
174181

175182
Unique {
176183
pointer: NonNull(1 as *mut &str),

src/archive.rs

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,50 +30,19 @@ pub(crate) struct ArArchiveBuilder<'a> {
3030
}
3131

3232
impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
33-
fn new(sess: &'a Session, output: &Path, input: Option<&Path>) -> Self {
34-
let (src_archives, entries) = if let Some(input) = input {
35-
let read_cache = ReadCache::new(File::open(input).unwrap());
36-
let archive = ArchiveFile::parse(&read_cache).unwrap();
37-
let mut entries = Vec::new();
38-
39-
for entry in archive.members() {
40-
let entry = entry.unwrap();
41-
entries.push((
42-
entry.name().to_vec(),
43-
ArchiveEntry::FromArchive { archive_index: 0, file_range: entry.file_range() },
44-
));
45-
}
46-
47-
(vec![read_cache.into_inner()], entries)
48-
} else {
49-
(vec![], Vec::new())
50-
};
51-
33+
fn new(sess: &'a Session, output: &Path) -> Self {
5234
ArArchiveBuilder {
5335
sess,
5436
dst: output.to_path_buf(),
5537
use_gnu_style_archive: sess.target.archive_format == "gnu",
5638
// FIXME fix builtin ranlib on macOS
5739
no_builtin_ranlib: sess.target.is_like_osx,
5840

59-
src_archives,
60-
entries,
41+
src_archives: vec![],
42+
entries: vec![],
6143
}
6244
}
6345

64-
fn src_files(&mut self) -> Vec<String> {
65-
self.entries.iter().map(|(name, _)| String::from_utf8(name.clone()).unwrap()).collect()
66-
}
67-
68-
fn remove_file(&mut self, name: &str) {
69-
let index = self
70-
.entries
71-
.iter()
72-
.position(|(entry_name, _)| entry_name == name.as_bytes())
73-
.expect("Tried to remove file not existing in src archive");
74-
self.entries.remove(index);
75-
}
76-
7746
fn add_file(&mut self, file: &Path) {
7847
self.entries.push((
7948
file.file_name().unwrap().to_str().unwrap().to_string().into_bytes(),
@@ -105,7 +74,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
10574
Ok(())
10675
}
10776

108-
fn build(mut self) {
77+
fn build(mut self) -> bool {
10978
enum BuilderKind {
11079
Bsd(ar::Builder<File>),
11180
Gnu(ar::GnuBuilder<File>),
@@ -221,6 +190,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
221190
)
222191
};
223192

193+
let any_members = !entries.is_empty();
194+
224195
// Add all files
225196
for (entry_name, data) in entries.into_iter() {
226197
let header = ar::Header::new(entry_name, data.len() as u64);
@@ -246,6 +217,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
246217
self.sess.fatal(&format!("Ranlib exited with code {:?}", status.code()));
247218
}
248219
}
220+
221+
any_members
249222
}
250223

251224
fn inject_dll_import_lib(

src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ fn codegen_stmt<'tcx>(
710710
let times = fx
711711
.monomorphize(times)
712712
.eval(fx.tcx, ParamEnv::reveal_all())
713-
.val()
713+
.kind()
714714
.try_to_bits(fx.tcx.data_layout.pointer_size)
715715
.unwrap();
716716
if operand.layout().size.bytes() == 0 {

src/constant.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
4545
ConstantKind::Ty(ct) => ct,
4646
ConstantKind::Val(..) => continue,
4747
};
48-
match const_.val() {
48+
match const_.kind() {
4949
ConstKind::Value(_) => {}
5050
ConstKind::Unevaluated(unevaluated) => {
5151
if let Err(err) =
@@ -126,8 +126,8 @@ pub(crate) fn codegen_constant<'tcx>(
126126
ConstantKind::Ty(ct) => ct,
127127
ConstantKind::Val(val, ty) => return codegen_const_value(fx, val, ty),
128128
};
129-
let const_val = match const_.val() {
130-
ConstKind::Value(const_val) => const_val,
129+
let const_val = match const_.kind() {
130+
ConstKind::Value(valtree) => fx.tcx.valtree_to_const_val((const_.ty(), valtree)),
131131
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
132132
if fx.tcx.is_static(def.did) =>
133133
{
@@ -468,9 +468,10 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
468468
) -> Option<ConstValue<'tcx>> {
469469
match operand {
470470
Operand::Constant(const_) => match const_.literal {
471-
ConstantKind::Ty(const_) => {
472-
fx.monomorphize(const_).eval(fx.tcx, ParamEnv::reveal_all()).val().try_to_value()
473-
}
471+
ConstantKind::Ty(const_) => fx
472+
.monomorphize(const_)
473+
.eval_for_mir(fx.tcx, ParamEnv::reveal_all())
474+
.try_to_value(fx.tcx),
474475
ConstantKind::Val(val, _) => Some(val),
475476
},
476477
// FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored

src/driver/jit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_span::Symbol;
1313

1414
use cranelift_jit::{JITBuilder, JITModule};
1515

16-
// FIXME use std::lazy::SyncOnceCell once it stabilizes
16+
// FIXME use std::sync::OnceLock once it stabilizes
1717
use once_cell::sync::OnceCell;
1818

1919
use crate::{prelude::*, BackendConfig};

0 commit comments

Comments
 (0)