Skip to content

Commit

Permalink
Auto merge of rust-lang#104447 - Mark-Simulacrum:beta-next, r=Mark-Si…
Browse files Browse the repository at this point in the history
…mulacrum

[beta] backport

*  Use nominal_obligations_without_const in wf for FnDef rust-lang#104180
*  Don't silently eat label before block in block-like expr rust-lang#103986
*  Revert "Update CI to use Android NDK r25b" rust-lang#104628
*  rustdoc: Resolve doc links in external traits having local impls rust-lang#104364
*  Use 64 bits for incremental cache in-file positions rust-lang#104164
*  rustdoc: Do not add external traits to the crate in register_res rust-lang#103649
*  Revert "Normalize opaques with escaping bound vars" rust-lang#103509
* Bump to released stable compiler
* [beta] Update cargo rust-lang#104486

r? `@Mark-Simulacrum`
  • Loading branch information
bors committed Nov 20, 2022
2 parents e080cc5 + 2caaf98 commit 0040709
Show file tree
Hide file tree
Showing 34 changed files with 652 additions and 520 deletions.
12 changes: 8 additions & 4 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2456,11 +2456,15 @@ impl<'a> Parser<'a> {
}

pub(crate) fn maybe_recover_unexpected_block_label(&mut self) -> bool {
let Some(label) = self.eat_label().filter(|_| {
self.eat(&token::Colon) && self.token.kind == token::OpenDelim(Delimiter::Brace)
}) else {
// Check for `'a : {`
if !(self.check_lifetime()
&& self.look_ahead(1, |tok| tok.kind == token::Colon)
&& self.look_ahead(2, |tok| tok.kind == token::OpenDelim(Delimiter::Brace)))
{
return false;
};
}
let label = self.eat_label().expect("just checked if a label exists");
self.bump(); // eat `:`
let span = label.ident.span.to(self.prev_token.span);
let mut err = self.struct_span_err(span, "block label not supported here");
err.span_label(span, "not supported here");
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_query_impl/src/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,11 @@ pub type EncodedDepNodeIndex = Vec<(SerializedDepNodeIndex, AbsoluteBytePos)>;
struct SourceFileIndex(u32);

#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Encodable, Decodable)]
pub struct AbsoluteBytePos(u32);
pub struct AbsoluteBytePos(u64);

impl AbsoluteBytePos {
fn new(pos: usize) -> AbsoluteBytePos {
debug_assert!(pos <= u32::MAX as usize);
AbsoluteBytePos(pos as u32)
AbsoluteBytePos(pos.try_into().expect("Incremental cache file size overflowed u64."))
}

fn to_usize(self) -> usize {
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1910,6 +1910,11 @@ impl<'a> Resolver<'a> {
}
}

/// For rustdoc.
pub fn get_partial_res(&self, node_id: NodeId) -> Option<PartialRes> {
self.partial_res_map.get(&node_id).copied()
}

/// Retrieves the span of the given `DefId` if `DefId` is in the local crate.
#[inline]
pub fn opt_span(&self, def_id: DefId) -> Option<Span> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
// This is really important. While we *can* handle this, this has
// severe performance implications for large opaque types with
// late-bound regions. See `issue-88862` benchmark.
ty::Opaque(def_id, substs) => {
ty::Opaque(def_id, substs) if !substs.has_escaping_bound_vars() => {
// Only normalize `impl Trait` outside of type inference, usually in codegen.
match self.param_env.reveal() {
Reveal::UserFacing => ty.super_fold_with(self),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
// This is really important. While we *can* handle this, this has
// severe performance implications for large opaque types with
// late-bound regions. See `issue-88862` benchmark.
ty::Opaque(def_id, substs) => {
ty::Opaque(def_id, substs) if !substs.has_escaping_bound_vars() => {
// Only normalize `impl Trait` outside of type inference, usually in codegen.
match self.param_env.reveal() {
Reveal::UserFacing => ty.try_super_fold_with(self),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ impl<'tcx> WfPredicates<'tcx> {
}

ty::FnDef(did, substs) => {
let obligations = self.nominal_obligations(did, substs);
let obligations = self.nominal_obligations_without_const(did, substs);
self.out.extend(obligations);
}

Expand Down
25 changes: 7 additions & 18 deletions src/bootstrap/cc_detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ fn cc2ar(cc: &Path, target: TargetSelection) -> Option<PathBuf> {
Some(PathBuf::from("ar"))
} else if target.contains("vxworks") {
Some(PathBuf::from("wr-ar"))
} else if target.contains("android") {
Some(cc.parent().unwrap().join(PathBuf::from("llvm-ar")))
} else {
let parent = cc.parent().unwrap();
let file = cc.file_name().unwrap().to_str().unwrap();
Expand Down Expand Up @@ -168,22 +166,13 @@ fn set_compiler(
// compiler already takes into account the triple in question.
t if t.contains("android") => {
if let Some(ndk) = config.and_then(|c| c.ndk.as_ref()) {
let mut triple_iter = target.triple.split("-");
let triple_translated = if let Some(arch) = triple_iter.next() {
let arch_new = match arch {
"arm" | "armv7" | "armv7neon" | "thumbv7" | "thumbv7neon" => "armv7a",
other => other,
};
std::iter::once(arch_new).chain(triple_iter).collect::<Vec<&str>>().join("-")
} else {
target.triple.to_string()
};

// API 19 is the earliest API level supported by NDK r25b but AArch64 and x86_64 support
// begins at API level 21.
let api_level =
if t.contains("aarch64") || t.contains("x86_64") { "21" } else { "19" };
let compiler = format!("{}{}-{}", triple_translated, api_level, compiler.clang());
let target = target
.triple
.replace("armv7neon", "arm")
.replace("armv7", "arm")
.replace("thumbv7neon", "arm")
.replace("thumbv7", "arm");
let compiler = format!("{}-{}", target, compiler.clang());
cfg.compiler(ndk.join("bin").join(compiler));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ci/docker/host-x86_64/arm-android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN sh /scripts/android-base-apt-get.sh

COPY scripts/android-ndk.sh /scripts/
RUN . /scripts/android-ndk.sh && \
download_ndk android-ndk-r25b-linux.zip
download_and_make_toolchain android-ndk-r15c-linux-x86_64.zip arm 14

RUN dpkg --add-architecture i386 && \
apt-get update && \
Expand All @@ -30,7 +30,7 @@ ENV PATH=$PATH:/android/sdk/platform-tools

ENV TARGETS=arm-linux-androideabi

ENV RUST_CONFIGURE_ARGS --arm-linux-androideabi-ndk=/android/ndk/toolchains/llvm/prebuilt/linux-x86_64/
ENV RUST_CONFIGURE_ARGS --arm-linux-androideabi-ndk=/android/ndk/arm-14

ENV SCRIPT python3 ../x.py --stage 2 test --host='' --target $TARGETS

Expand Down
21 changes: 14 additions & 7 deletions src/ci/docker/host-x86_64/dist-android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ RUN sh /scripts/android-base-apt-get.sh
# ndk
COPY scripts/android-ndk.sh /scripts/
RUN . /scripts/android-ndk.sh && \
download_ndk android-ndk-r25b-linux.zip
download_ndk android-ndk-r15c-linux-x86_64.zip && \
make_standalone_toolchain arm 14 && \
make_standalone_toolchain x86 14 && \
make_standalone_toolchain arm 21 && \
make_standalone_toolchain x86 21 && \
make_standalone_toolchain arm64 21 && \
make_standalone_toolchain x86_64 21 && \
remove_ndk

# env
ENV TARGETS=arm-linux-androideabi
Expand All @@ -19,12 +26,12 @@ ENV TARGETS=$TARGETS,x86_64-linux-android
ENV RUST_CONFIGURE_ARGS \
--enable-extended \
--enable-profiler \
--arm-linux-androideabi-ndk=/android/ndk/toolchains/llvm/prebuilt/linux-x86_64/ \
--armv7-linux-androideabi-ndk=/android/ndk/toolchains/llvm/prebuilt/linux-x86_64/ \
--thumbv7neon-linux-androideabi-ndk=/android/ndk/toolchains/llvm/prebuilt/linux-x86_64/ \
--i686-linux-android-ndk=/android/ndk/toolchains/llvm/prebuilt/linux-x86_64/ \
--aarch64-linux-android-ndk=/android/ndk/toolchains/llvm/prebuilt/linux-x86_64/ \
--x86_64-linux-android-ndk=/android/ndk/toolchains/llvm/prebuilt/linux-x86_64/ \
--arm-linux-androideabi-ndk=/android/ndk/arm-14 \
--armv7-linux-androideabi-ndk=/android/ndk/arm-14 \
--thumbv7neon-linux-androideabi-ndk=/android/ndk/arm-14 \
--i686-linux-android-ndk=/android/ndk/x86-14 \
--aarch64-linux-android-ndk=/android/ndk/arm64-21 \
--x86_64-linux-android-ndk=/android/ndk/x86_64-21 \
--disable-docs

ENV SCRIPT python3 ../x.py dist --host='' --target $TARGETS
Expand Down
22 changes: 20 additions & 2 deletions src/ci/docker/scripts/android-ndk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,28 @@ set -ex
URL=https://dl.google.com/android/repository

download_ndk() {
mkdir /android/
cd /android
mkdir -p /android/ndk
cd /android/ndk
curl -fO $URL/$1
unzip -q $1
rm $1
mv android-ndk-* ndk
}

make_standalone_toolchain() {
# See https://developer.android.com/ndk/guides/standalone_toolchain.htm
python3 /android/ndk/ndk/build/tools/make_standalone_toolchain.py \
--install-dir /android/ndk/$1-$2 \
--arch $1 \
--api $2
}

remove_ndk() {
rm -rf /android/ndk/ndk
}

download_and_make_toolchain() {
download_ndk $1 && \
make_standalone_toolchain $2 $3 && \
remove_ndk
}
4 changes: 0 additions & 4 deletions src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::clean::{
PathSegment, Primitive, PrimitiveType, Type, TypeBinding, Visibility,
};
use crate::core::DocContext;
use crate::formats::item_type::ItemType;
use crate::visit_lib::LibEmbargoVisitor;

use rustc_ast as ast;
Expand Down Expand Up @@ -504,9 +503,6 @@ pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
return did;
}
inline::record_extern_fqn(cx, did, kind);
if let ItemType::Trait = kind {
inline::record_extern_trait(cx, did);
}
did
}

Expand Down
9 changes: 8 additions & 1 deletion src/librustdoc/passes/collect_intra_doc_links/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,14 @@ impl Visitor<'_> for EarlyDocLinkResolver<'_, '_> {
self.parent_scope.module = old_module;
} else {
match &item.kind {
ItemKind::Impl(box ast::Impl { of_trait: Some(..), .. }) => {
ItemKind::Impl(box ast::Impl { of_trait: Some(trait_ref), .. }) => {
if let Some(partial_res) = self.resolver.get_partial_res(trait_ref.ref_id)
&& let Some(res) = partial_res.full_res()
&& let Some(trait_def_id) = res.opt_def_id()
&& !trait_def_id.is_local()
&& self.visited_mods.insert(trait_def_id) {
self.resolve_doc_links_extern_impl(trait_def_id, false);
}
self.all_trait_impls.push(self.resolver.local_def_id(item.id).to_def_id());
}
ItemKind::MacroDef(macro_def) if macro_def.macro_rules => {
Expand Down
Loading

0 comments on commit 0040709

Please sign in to comment.