Skip to content

Commit

Permalink
Auto merge of rust-lang#63752 - Centril:rollup-nlxwety, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 4 pull requests

Successful merges:

 - rust-lang#62497 (Fix double resolving custom libdir)
 - rust-lang#63209 (Stabilize `async_await` in Rust 1.39.0)
 - rust-lang#63746 (Cherry-pick src/test changes with Centril's changes)
 - rust-lang#63750 (rustc_metadata: replace LazySeq<T> with Lazy<[T]>.)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Aug 20, 2019
2 parents 5a56e05 + e3e8b7f commit bea0372
Show file tree
Hide file tree
Showing 218 changed files with 801 additions and 1,139 deletions.
20 changes: 13 additions & 7 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,7 @@ impl<'a> Builder<'a> {
}

fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
let compiler = self.compiler;
let config = &builder.build.config;
let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() {
builder.build.config.libdir_relative().unwrap()
} else {
Path::new("lib")
};
let lib = builder.sysroot_libdir_relative(self.compiler);
let sysroot = builder
.sysroot(self.compiler)
.join(lib)
Expand Down Expand Up @@ -678,6 +672,18 @@ impl<'a> Builder<'a> {
}
}

/// Returns the compiler's relative libdir where the standard library and other artifacts are
/// found for a compiler's sysroot.
///
/// For example this returns `lib` on Unix and Windows.
pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path {
match self.config.libdir_relative() {
Some(relative_libdir) if compiler.stage >= 1
=> relative_libdir,
_ => Path::new("lib")
}
}

/// Adds the compiler's directory of dynamic libraries to `cmd`'s dynamic
/// library lookup path.
pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command) {
Expand Down
13 changes: 9 additions & 4 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ impl Step for Rustc {
fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
let host = compiler.host;
let src = builder.sysroot(compiler);
let libdir = builder.rustc_libdir(compiler);

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

// Copy runtime DLLs needed by the compiler
if libdir_relative.to_str() != Some("bin") {
let libdir = builder.rustc_libdir(compiler);
for entry in builder.read_dir(&libdir) {
let name = entry.file_name();
if let Some(s) = name.to_str() {
if is_dylib(s) {
builder.install(&entry.path(), &image.join(&libdir_relative), 0o644);
// Don't use custom libdir here because ^lib/ will be resolved again
// with installer
builder.install(&entry.path(), &image.join("lib"), 0o644);
}
}
}
}

// Copy over the codegen backends
let backends_src = builder.sysroot_codegen_backends(compiler);
let backends_rel = backends_src.strip_prefix(&src).unwrap();
let backends_dst = image.join(&backends_rel);
let backends_rel = backends_src.strip_prefix(&src).unwrap()
.strip_prefix(builder.sysroot_libdir_relative(compiler)).unwrap();
// Don't use custom libdir here because ^lib/ will be resolved again with installer
let backends_dst = image.join("lib").join(&backends_rel);

t!(fs::create_dir_all(&backends_dst));
builder.cp_r(&backends_src, &backends_dst);

Expand Down
2 changes: 0 additions & 2 deletions src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2088,7 +2088,6 @@ generator can be constructed.
Erroneous code example:
```edition2018,compile-fail,E0698
#![feature(async_await)]
async fn bar<T>() -> () {}
async fn foo() {
Expand All @@ -2101,7 +2100,6 @@ To fix this you must bind `T` to a concrete type such as `String`
so that a generator can then be constructed:
```edition2018
#![feature(async_await)]
async fn bar<T>() -> () {}
async fn foo() {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_metadata/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ pub struct CrateMetadata {
pub alloc_decoding_state: AllocDecodingState,

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

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

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

pub dep_kind: Lock<DepKind>,
pub source: CrateSource,
Expand Down
35 changes: 19 additions & 16 deletions src/librustc_metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ impl<'a, 'tcx, T: Decodable> Lazy<T> {
}
}

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

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

fn read_lazy_distance(&mut self, min_size: usize) -> Result<usize, <Self as Decoder>::Error> {
fn read_lazy_with_meta<T: ?Sized + LazyMeta>(
&mut self,
meta: T::Meta,
) -> Result<Lazy<T>, <Self as Decoder>::Error> {
let min_size = T::min_size(meta);
let distance = self.read_usize()?;
let position = match self.lazy_state {
LazyState::NoNode => bug!("read_lazy_distance: outside of a metadata node"),
LazyState::NoNode => bug!("read_lazy_with_meta: outside of a metadata node"),
LazyState::NodeStart(start) => {
assert!(distance + min_size <= start);
start - distance - min_size
}
LazyState::Previous(last_min_end) => last_min_end + distance,
};
self.lazy_state = LazyState::Previous(position + min_size);
Ok(position)
Ok(Lazy::from_position_and_meta(position, meta))
}
}

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

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

impl<'a, 'tcx, T> SpecializedDecoder<LazySeq<T>> for DecodeContext<'a, 'tcx> {
fn specialized_decode(&mut self) -> Result<LazySeq<T>, Self::Error> {
impl<'a, 'tcx, T> SpecializedDecoder<Lazy<[T]>> for DecodeContext<'a, 'tcx> {
fn specialized_decode(&mut self) -> Result<Lazy<[T]>, Self::Error> {
let len = self.read_usize()?;
let position = if len == 0 {
0
if len == 0 {
Ok(Lazy::empty())
} else {
self.read_lazy_distance(LazySeq::<T>::min_size(len))?
};
Ok(LazySeq::with_position_and_length(position, len))
self.read_lazy_with_meta(len)
}
}
}

Expand Down Expand Up @@ -378,7 +381,7 @@ impl<'tcx> MetadataBlob {
}

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

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

pub fn list_crate_metadata(&self,
Expand Down Expand Up @@ -1140,7 +1143,7 @@ impl<'a, 'tcx> CrateMetadata {
EntryKind::Fn(data) |
EntryKind::ForeignFn(data) => data.decode(self).arg_names,
EntryKind::Method(data) => data.decode(self).fn_data.arg_names,
_ => LazySeq::empty(),
_ => Lazy::empty(),
};
arg_names.decode(self).collect()
}
Expand Down
Loading

0 comments on commit bea0372

Please sign in to comment.