Skip to content

Commit bea0372

Browse files
committed
Auto merge of #63752 - Centril:rollup-nlxwety, r=Centril
Rollup of 4 pull requests Successful merges: - #62497 (Fix double resolving custom libdir) - #63209 (Stabilize `async_await` in Rust 1.39.0) - #63746 (Cherry-pick src/test changes with Centril's changes) - #63750 (rustc_metadata: replace LazySeq<T> with Lazy<[T]>.) Failed merges: r? @ghost
2 parents 5a56e05 + e3e8b7f commit bea0372

File tree

218 files changed

+801
-1139
lines changed

Some content is hidden

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

218 files changed

+801
-1139
lines changed

src/bootstrap/builder.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -618,13 +618,7 @@ impl<'a> Builder<'a> {
618618
}
619619

620620
fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
621-
let compiler = self.compiler;
622-
let config = &builder.build.config;
623-
let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() {
624-
builder.build.config.libdir_relative().unwrap()
625-
} else {
626-
Path::new("lib")
627-
};
621+
let lib = builder.sysroot_libdir_relative(self.compiler);
628622
let sysroot = builder
629623
.sysroot(self.compiler)
630624
.join(lib)
@@ -678,6 +672,18 @@ impl<'a> Builder<'a> {
678672
}
679673
}
680674

675+
/// Returns the compiler's relative libdir where the standard library and other artifacts are
676+
/// found for a compiler's sysroot.
677+
///
678+
/// For example this returns `lib` on Unix and Windows.
679+
pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path {
680+
match self.config.libdir_relative() {
681+
Some(relative_libdir) if compiler.stage >= 1
682+
=> relative_libdir,
683+
_ => Path::new("lib")
684+
}
685+
}
686+
681687
/// Adds the compiler's directory of dynamic libraries to `cmd`'s dynamic
682688
/// library lookup path.
683689
pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command) {

src/bootstrap/dist.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ impl Step for Rustc {
469469
fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
470470
let host = compiler.host;
471471
let src = builder.sysroot(compiler);
472-
let libdir = builder.rustc_libdir(compiler);
473472

474473
// Copy rustc/rustdoc binaries
475474
t!(fs::create_dir_all(image.join("bin")));
@@ -481,20 +480,26 @@ impl Step for Rustc {
481480

482481
// Copy runtime DLLs needed by the compiler
483482
if libdir_relative.to_str() != Some("bin") {
483+
let libdir = builder.rustc_libdir(compiler);
484484
for entry in builder.read_dir(&libdir) {
485485
let name = entry.file_name();
486486
if let Some(s) = name.to_str() {
487487
if is_dylib(s) {
488-
builder.install(&entry.path(), &image.join(&libdir_relative), 0o644);
488+
// Don't use custom libdir here because ^lib/ will be resolved again
489+
// with installer
490+
builder.install(&entry.path(), &image.join("lib"), 0o644);
489491
}
490492
}
491493
}
492494
}
493495

494496
// Copy over the codegen backends
495497
let backends_src = builder.sysroot_codegen_backends(compiler);
496-
let backends_rel = backends_src.strip_prefix(&src).unwrap();
497-
let backends_dst = image.join(&backends_rel);
498+
let backends_rel = backends_src.strip_prefix(&src).unwrap()
499+
.strip_prefix(builder.sysroot_libdir_relative(compiler)).unwrap();
500+
// Don't use custom libdir here because ^lib/ will be resolved again with installer
501+
let backends_dst = image.join("lib").join(&backends_rel);
502+
498503
t!(fs::create_dir_all(&backends_dst));
499504
builder.cp_r(&backends_src, &backends_dst);
500505

src/librustc/error_codes.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,6 @@ generator can be constructed.
20882088
Erroneous code example:
20892089
20902090
```edition2018,compile-fail,E0698
2091-
#![feature(async_await)]
20922091
async fn bar<T>() -> () {}
20932092
20942093
async fn foo() {
@@ -2101,7 +2100,6 @@ To fix this you must bind `T` to a concrete type such as `String`
21012100
so that a generator can then be constructed:
21022101
21032102
```edition2018
2104-
#![feature(async_await)]
21052103
async fn bar<T>() -> () {}
21062104
21072105
async fn foo() {

src/librustc_metadata/cstore.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ pub struct CrateMetadata {
6868
pub alloc_decoding_state: AllocDecodingState,
6969

7070
// NOTE(eddyb) we pass `'static` to a `'tcx` parameter because this
71-
// lifetime is only used behind `Lazy` / `LazySeq`, and therefore
72-
// acts like an universal (`for<'tcx>`), that is paired up with
73-
// whichever `TyCtxt` is being used to decode those values.
71+
// lifetime is only used behind `Lazy`, and therefore acts like an
72+
// universal (`for<'tcx>`), that is paired up with whichever `TyCtxt`
73+
// is being used to decode those values.
7474
pub root: schema::CrateRoot<'static>,
7575

7676
/// For each definition in this crate, we encode a key. When the
@@ -80,7 +80,7 @@ pub struct CrateMetadata {
8080
/// compilation support.
8181
pub def_path_table: Lrc<DefPathTable>,
8282

83-
pub trait_impls: FxHashMap<(u32, DefIndex), schema::LazySeq<DefIndex>>,
83+
pub trait_impls: FxHashMap<(u32, DefIndex), schema::Lazy<[DefIndex]>>,
8484

8585
pub dep_kind: Lock<DepKind>,
8686
pub source: CrateSource,

src/librustc_metadata/decoder.rs

+19-16
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ impl<'a, 'tcx, T: Decodable> Lazy<T> {
134134
}
135135
}
136136

137-
impl<'a: 'x, 'tcx: 'x, 'x, T: Decodable> LazySeq<T> {
137+
impl<'a: 'x, 'tcx: 'x, 'x, T: Decodable> Lazy<[T]> {
138138
pub fn decode<M: Metadata<'a, 'tcx>>(
139139
self,
140140
meta: M,
141141
) -> impl ExactSizeIterator<Item = T> + Captures<'a> + Captures<'tcx> + 'x {
142142
let mut dcx = meta.decoder(self.position);
143143
dcx.lazy_state = LazyState::NodeStart(self.position);
144-
(0..self.len).map(move |_| T::decode(&mut dcx).unwrap())
144+
(0..self.meta).map(move |_| T::decode(&mut dcx).unwrap())
145145
}
146146
}
147147

@@ -154,18 +154,22 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
154154
self.cdata.expect("missing CrateMetadata in DecodeContext")
155155
}
156156

157-
fn read_lazy_distance(&mut self, min_size: usize) -> Result<usize, <Self as Decoder>::Error> {
157+
fn read_lazy_with_meta<T: ?Sized + LazyMeta>(
158+
&mut self,
159+
meta: T::Meta,
160+
) -> Result<Lazy<T>, <Self as Decoder>::Error> {
161+
let min_size = T::min_size(meta);
158162
let distance = self.read_usize()?;
159163
let position = match self.lazy_state {
160-
LazyState::NoNode => bug!("read_lazy_distance: outside of a metadata node"),
164+
LazyState::NoNode => bug!("read_lazy_with_meta: outside of a metadata node"),
161165
LazyState::NodeStart(start) => {
162166
assert!(distance + min_size <= start);
163167
start - distance - min_size
164168
}
165169
LazyState::Previous(last_min_end) => last_min_end + distance,
166170
};
167171
self.lazy_state = LazyState::Previous(position + min_size);
168-
Ok(position)
172+
Ok(Lazy::from_position_and_meta(position, meta))
169173
}
170174
}
171175

@@ -230,19 +234,18 @@ impl<'a, 'tcx> TyDecoder<'tcx> for DecodeContext<'a, 'tcx> {
230234

231235
impl<'a, 'tcx, T> SpecializedDecoder<Lazy<T>> for DecodeContext<'a, 'tcx> {
232236
fn specialized_decode(&mut self) -> Result<Lazy<T>, Self::Error> {
233-
Ok(Lazy::with_position(self.read_lazy_distance(Lazy::<T>::min_size())?))
237+
self.read_lazy_with_meta(())
234238
}
235239
}
236240

237-
impl<'a, 'tcx, T> SpecializedDecoder<LazySeq<T>> for DecodeContext<'a, 'tcx> {
238-
fn specialized_decode(&mut self) -> Result<LazySeq<T>, Self::Error> {
241+
impl<'a, 'tcx, T> SpecializedDecoder<Lazy<[T]>> for DecodeContext<'a, 'tcx> {
242+
fn specialized_decode(&mut self) -> Result<Lazy<[T]>, Self::Error> {
239243
let len = self.read_usize()?;
240-
let position = if len == 0 {
241-
0
244+
if len == 0 {
245+
Ok(Lazy::empty())
242246
} else {
243-
self.read_lazy_distance(LazySeq::<T>::min_size(len))?
244-
};
245-
Ok(LazySeq::with_position_and_length(position, len))
247+
self.read_lazy_with_meta(len)
248+
}
246249
}
247250
}
248251

@@ -378,7 +381,7 @@ impl<'tcx> MetadataBlob {
378381
}
379382

380383
pub fn get_rustc_version(&self) -> String {
381-
Lazy::with_position(METADATA_HEADER.len() + 4).decode(self)
384+
Lazy::<String>::from_position(METADATA_HEADER.len() + 4).decode(self)
382385
}
383386

384387
pub fn get_root(&self) -> CrateRoot<'tcx> {
@@ -387,7 +390,7 @@ impl<'tcx> MetadataBlob {
387390
let pos = (((slice[offset + 0] as u32) << 24) | ((slice[offset + 1] as u32) << 16) |
388391
((slice[offset + 2] as u32) << 8) |
389392
((slice[offset + 3] as u32) << 0)) as usize;
390-
Lazy::with_position(pos).decode(self)
393+
Lazy::<CrateRoot<'tcx>>::from_position(pos).decode(self)
391394
}
392395

393396
pub fn list_crate_metadata(&self,
@@ -1140,7 +1143,7 @@ impl<'a, 'tcx> CrateMetadata {
11401143
EntryKind::Fn(data) |
11411144
EntryKind::ForeignFn(data) => data.decode(self).arg_names,
11421145
EntryKind::Method(data) => data.decode(self).fn_data.arg_names,
1143-
_ => LazySeq::empty(),
1146+
_ => Lazy::empty(),
11441147
};
11451148
arg_names.decode(self).collect()
11461149
}

0 commit comments

Comments
 (0)