Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #75609

Merged
merged 26 commits into from
Aug 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2303939
Don't visit foreign function bodies when lowering ast to hir
ayazhafiz Jul 10, 2020
ab4275c
fixup! Don't visit foreign function bodies when lowering ast to hir
ayazhafiz Jul 10, 2020
68aca3b
fixup! fixup! Don't visit foreign function bodies when lowering ast t…
ayazhafiz Jul 15, 2020
0c64d32
fixup! Don't visit foreign function bodies when lowering ast to hir
ayazhafiz Jul 15, 2020
d442bf7
fixup! Don't visit foreign function bodies when lowering ast to hir
ayazhafiz Jul 16, 2020
50ead68
Add regression test for issue-66768
JohnTitor Aug 5, 2020
0d0546a
Add #[track_caller] to `Session::delay_span_bug`
Aaron1011 Aug 6, 2020
3c2eb18
Use intra-doc links
denisvasilik Aug 11, 2020
c492341
Revert broken link
denisvasilik Aug 11, 2020
4c5896f
Remove intra-doc link as it resolves without reference link
denisvasilik Aug 12, 2020
7aac3e0
pin docs: add some forward references
RalfJung Aug 13, 2020
8de63eb
Bump minor version of emsdk to 1.38.47
tmiasko Aug 15, 2020
0a96e08
Switch to intra-doc links in /sys/windows/ext/{ffi,fs,process}.rs
nixphix Aug 16, 2020
8b86b28
Use LocalDefId instead of HirId for reachable_set elements.
eddyb Jul 14, 2020
5d44d54
rustc_typeck: construct {Closure,Generator}Substs more directly.
eddyb Jul 13, 2020
e1cd185
move DelaySpanBugEmitted to ty::context
mark-i-m Jul 16, 2020
8eba138
Rollup merge of #74204 - ayazhafiz:i/74120, r=eddyb
tmandry Aug 16, 2020
c518347
Rollup merge of #74314 - eddyb:closure-substs-direct, r=nikomatsakis
tmandry Aug 16, 2020
3ef2244
Rollup merge of #74346 - eddyb:reachable-defs, r=nikomatsakis
tmandry Aug 16, 2020
54c7434
Rollup merge of #74399 - mark-i-m:ty-err-4, r=eddyb
tmandry Aug 16, 2020
76b2fce
Rollup merge of #75177 - JohnTitor:broken-mir-test, r=eddyb
tmandry Aug 16, 2020
8a33c98
Rollup merge of #75223 - Aaron1011:feature/session-track-caller, r=eddyb
tmandry Aug 16, 2020
18e3799
Rollup merge of #75423 - denisvasilik:intra-doc-links-core-hint, r=dt…
tmandry Aug 16, 2020
8ba56af
Rollup merge of #75485 - RalfJung:pin, r=nagisa
tmandry Aug 16, 2020
b32df43
Rollup merge of #75569 - tmiasko:emscripten, r=tlively
tmandry Aug 16, 2020
e46b1ef
Rollup merge of #75596 - nixphix:docs/windows-ext, r=jyn514
tmandry Aug 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions library/core/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use crate::intrinsics;
/// Otherwise, consider using the [`unreachable!`] macro, which does not allow
/// optimizations but will panic when executed.
///
/// [`unreachable!`]: ../macro.unreachable.html
///
/// # Example
///
Expand Down Expand Up @@ -61,7 +60,7 @@ pub const unsafe fn unreachable_unchecked() -> ! {
/// **Note**: On platforms that do not support receiving spin-loop hints this function does not
/// do anything at all.
///
/// [`core::sync::atomic::spin_loop_hint`]: ../sync/atomic/fn.spin_loop_hint.html
/// [`core::sync::atomic::spin_loop_hint`]: crate::sync::atomic::spin_loop_hint
#[inline]
#[unstable(feature = "renamed_spin_loop", issue = "55002")]
pub fn spin_loop() {
Expand Down
13 changes: 10 additions & 3 deletions library/core/src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
//! as moving an object with pointers to itself will invalidate them, which could cause undefined
//! behavior.
//!
//! A [`Pin<P>`] ensures that the pointee of any pointer type `P` has a stable location in memory,
//! meaning it cannot be moved elsewhere and its memory cannot be deallocated
//! until it gets dropped. We say that the pointee is "pinned".
//! At a high level, a [`Pin<P>`] ensures that the pointee of any pointer type
//! `P` has a stable location in memory, meaning it cannot be moved elsewhere
//! and its memory cannot be deallocated until it gets dropped. We say that the
//! pointee is "pinned". Things get more subtle when discussing types that
//! combine pinned with non-pinned data; [see below](#projections-and-structural-pinning)
//! for more details.
//!
//! By default, all types in Rust are movable. Rust allows passing all types by-value,
//! and common smart-pointer types such as [`Box<T>`] and `&mut T` allow replacing and
Expand Down Expand Up @@ -61,6 +64,10 @@
//!
//! # Example: self-referential struct
//!
//! Before we go into more details to explain the guarantees and choices
//! associated with `Pin<T>`, we discuss some examples for how it might be used.
//! Feel free to [skip to where the theoretical discussion continues](#drop-guarantee).
//!
//! ```rust
//! use std::pin::Pin;
//! use std::marker::PhantomPinned;
Expand Down
27 changes: 6 additions & 21 deletions library/std/src/sys/windows/ext/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
//! [`OsString`] is the Rust wrapper for owned strings in the
//! preferred representation of the operating system. On Windows,
//! this struct gets augmented with an implementation of the
//! [`OsStringExt`] trait, which has a [`from_wide`] method. This
//! [`OsStringExt`] trait, which has a [`OsStringExt::from_wide`] method. This
//! lets you create an [`OsString`] from a `&[u16]` slice; presumably
//! you get such a slice out of a `WCHAR` Windows API.
//!
//! Similarly, [`OsStr`] is the Rust wrapper for borrowed strings from
//! preferred representation of the operating system. On Windows, the
//! [`OsStrExt`] trait provides the [`encode_wide`] method, which
//! [`OsStrExt`] trait provides the [`OsStrExt::encode_wide`] method, which
//! outputs an [`EncodeWide`] iterator. You can [`collect`] this
//! iterator, for example, to obtain a `Vec<u16>`; you can later get a
//! pointer to this vector's contents and feed it to Windows APIs.
Expand All @@ -47,15 +47,8 @@
//! ill-formed UTF-16.
//!
//! [ill-formed-utf-16]: https://simonsapin.github.io/wtf-8/#ill-formed-utf-16
//! [`OsString`]: ../../../ffi/struct.OsString.html
//! [`OsStr`]: ../../../ffi/struct.OsStr.html
//! [`OsStringExt`]: trait.OsStringExt.html
//! [`OsStrExt`]: trait.OsStrExt.html
//! [`EncodeWide`]: struct.EncodeWide.html
//! [`from_wide`]: trait.OsStringExt.html#tymethod.from_wide
//! [`encode_wide`]: trait.OsStrExt.html#tymethod.encode_wide
//! [`collect`]: ../../../iter/trait.Iterator.html#method.collect
//! [U+FFFD]: ../../../char/constant.REPLACEMENT_CHARACTER.html
//! [`collect`]: crate::iter::Iterator::collect
//! [U+FFFD]: crate::char::REPLACEMENT_CHARACTER

#![stable(feature = "rust1", since = "1.0.0")]

Expand All @@ -68,14 +61,12 @@ use crate::sys_common::{AsInner, FromInner};
pub use crate::sys_common::wtf8::EncodeWide;

/// Windows-specific extensions to [`OsString`].
///
/// [`OsString`]: ../../../../std/ffi/struct.OsString.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStringExt {
/// Creates an `OsString` from a potentially ill-formed UTF-16 slice of
/// 16-bit code units.
///
/// This is lossless: calling [`encode_wide`] on the resulting string
/// This is lossless: calling [`OsStrExt::encode_wide`] on the resulting string
/// will always return the original code units.
///
/// # Examples
Expand All @@ -89,8 +80,6 @@ pub trait OsStringExt {
///
/// let string = OsString::from_wide(&source[..]);
/// ```
///
/// [`encode_wide`]: ./trait.OsStrExt.html#tymethod.encode_wide
#[stable(feature = "rust1", since = "1.0.0")]
fn from_wide(wide: &[u16]) -> Self;
}
Expand All @@ -103,14 +92,12 @@ impl OsStringExt for OsString {
}

/// Windows-specific extensions to [`OsStr`].
///
/// [`OsStr`]: ../../../../std/ffi/struct.OsStr.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStrExt {
/// Re-encodes an `OsStr` as a wide character sequence, i.e., potentially
/// ill-formed UTF-16.
///
/// This is lossless: calling [`OsString::from_wide`] and then
/// This is lossless: calling [`OsStringExt::from_wide`] and then
/// `encode_wide` on the result will yield the original code units.
/// Note that the encoding does not add a final null terminator.
///
Expand All @@ -128,8 +115,6 @@ pub trait OsStrExt {
/// let result: Vec<u16> = string.encode_wide().collect();
/// assert_eq!(&source[..], &result[..]);
/// ```
///
/// [`OsString::from_wide`]: ./trait.OsStringExt.html#tymethod.from_wide
#[stable(feature = "rust1", since = "1.0.0")]
fn encode_wide(&self) -> EncodeWide<'_>;
}
Expand Down
11 changes: 2 additions & 9 deletions library/std/src/sys/windows/ext/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use crate::path::Path;
use crate::sys;
use crate::sys_common::{AsInner, AsInnerMut};

/// Windows-specific extensions to [`File`].
///
/// [`File`]: ../../../fs/struct.File.html
/// Windows-specific extensions to [`fs::File`].
#[stable(feature = "file_offset", since = "1.15.0")]
pub trait FileExt {
/// Seeks to a given position and reads a number of bytes.
Expand Down Expand Up @@ -94,8 +92,6 @@ impl FileExt for fs::File {
}

/// Windows-specific extensions to [`fs::OpenOptions`].
///
/// [`fs::OpenOptions`]: ../../../../std/fs/struct.OpenOptions.html
#[stable(feature = "open_options_ext", since = "1.10.0")]
pub trait OpenOptionsExt {
/// Overrides the `dwDesiredAccess` argument to the call to [`CreateFile`]
Expand Down Expand Up @@ -295,7 +291,6 @@ impl OpenOptionsExt for OpenOptions {
/// The data members that this trait exposes correspond to the members
/// of the [`BY_HANDLE_FILE_INFORMATION`] structure.
///
/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
/// [`BY_HANDLE_FILE_INFORMATION`]:
/// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/ns-fileapi-by_handle_file_information
#[stable(feature = "metadata_ext", since = "1.1.0")]
Expand Down Expand Up @@ -499,11 +494,9 @@ impl MetadataExt for Metadata {
}
}

/// Windows-specific extensions to [`FileType`].
/// Windows-specific extensions to [`fs::FileType`].
///
/// On Windows, a symbolic link knows whether it is a file or directory.
///
/// [`FileType`]: ../../../../std/fs/struct.FileType.html
#[unstable(feature = "windows_file_type_ext", issue = "none")]
pub trait FileTypeExt {
/// Returns `true` if this file type is a symbolic link that is also a directory.
Expand Down
4 changes: 0 additions & 4 deletions library/std/src/sys/windows/ext/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ impl IntoRawHandle for process::ChildStderr {
}

/// Windows-specific extensions to [`process::ExitStatus`].
///
/// [`process::ExitStatus`]: ../../../../std/process/struct.ExitStatus.html
#[stable(feature = "exit_status_from", since = "1.12.0")]
pub trait ExitStatusExt {
/// Creates a new `ExitStatus` from the raw underlying `u32` return value of
Expand All @@ -91,8 +89,6 @@ impl ExitStatusExt for process::ExitStatus {
}

/// Windows-specific extensions to the [`process::Command`] builder.
///
/// [`process::Command`]: ../../../../std/process/struct.Command.html
#[stable(feature = "windows_process_extensions", since = "1.16.0")]
pub trait CommandExt {
/// Sets the [process creation flags][1] to be passed to `CreateProcess`.
Expand Down
4 changes: 2 additions & 2 deletions src/ci/docker/scripts/emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ exit 1

git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable
cd /emsdk-portable
hide_output ./emsdk install 1.38.46-upstream
./emsdk activate 1.38.46-upstream
hide_output ./emsdk install 1.38.47-upstream
./emsdk activate 1.38.47-upstream
14 changes: 13 additions & 1 deletion src/librustc_ast_lowering/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::Arena;
use rustc_ast::ast::*;
use rustc_ast::node_id::NodeMap;
use rustc_ast::ptr::P;
use rustc_ast::visit::{self, AssocCtxt, Visitor};
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::struct_span_err;
use rustc_hir as hir;
Expand Down Expand Up @@ -75,6 +75,18 @@ impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> {
}
}

fn visit_fn(&mut self, fk: FnKind<'a>, sp: Span, _: NodeId) {
match fk {
FnKind::Fn(FnCtxt::Foreign, _, sig, _, _) => {
self.visit_fn_header(&sig.header);
visit::walk_fn_decl(self, &sig.decl);
// Don't visit the foreign function body even if it has one, since lowering the
// body would have no meaning and will have already been caught as a parse error.
}
_ => visit::walk_fn(self, fk, sp),
}
}

fn visit_assoc_item(&mut self, item: &'a AssocItem, ctxt: AssocCtxt) {
self.lctx.with_hir_id_owner(item.id, |lctx| match ctxt {
AssocCtxt::Trait => {
Expand Down
8 changes: 3 additions & 5 deletions src/librustc_codegen_ssa/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
let mut reachable_non_generics: DefIdMap<_> = tcx
.reachable_set(LOCAL_CRATE)
.iter()
.filter_map(|&hir_id| {
.filter_map(|&def_id| {
// We want to ignore some FFI functions that are not exposed from
// this crate. Reachable FFI functions can be lumped into two
// categories:
Expand All @@ -75,9 +75,8 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
//
// As a result, if this id is an FFI item (foreign item) then we only
// let it through if it's included statically.
match tcx.hir().get(hir_id) {
match tcx.hir().get(tcx.hir().local_def_id_to_hir_id(def_id)) {
Node::ForeignItem(..) => {
let def_id = tcx.hir().local_def_id(hir_id);
tcx.is_statically_included_foreign_item(def_id).then_some(def_id)
}

Expand All @@ -87,7 +86,6 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
..
})
| Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }) => {
let def_id = tcx.hir().local_def_id(hir_id);
let generics = tcx.generics_of(def_id);
if !generics.requires_monomorphization(tcx)
// Functions marked with #[inline] are codegened with "internal"
Expand Down Expand Up @@ -361,7 +359,7 @@ fn upstream_drop_glue_for_provider<'tcx>(

fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
if let Some(def_id) = def_id.as_local() {
!tcx.reachable_set(LOCAL_CRATE).contains(&tcx.hir().local_def_id_to_hir_id(def_id))
!tcx.reachable_set(LOCAL_CRATE).contains(&def_id)
} else {
bug!("is_unreachable_local_definition called with non-local DefId: {:?}", def_id)
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_middle/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,8 @@ rustc_queries! {
}

Other {
query reachable_set(_: CrateNum) -> &'tcx HirIdSet {
query reachable_set(_: CrateNum) -> FxHashSet<LocalDefId> {
storage(ArenaCacheSelector<'tcx>)
desc { "reachability" }
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/consts/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub enum ConstKind<'tcx> {

/// A placeholder for a const which could not be computed; this is
/// propagated to avoid useless error messages.
Error(ty::sty::DelaySpanBugEmitted),
Error(ty::DelaySpanBugEmitted),
}

#[cfg(target_arch = "x86_64")]
Expand Down
13 changes: 8 additions & 5 deletions src/librustc_middle/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ use std::mem;
use std::ops::{Bound, Deref};
use std::sync::Arc;

/// A type that is not publicly constructable. This prevents people from making `TyKind::Error`
/// except through `tcx.err*()`, which are in this module.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[derive(TyEncodable, TyDecodable, HashStable)]
pub struct DelaySpanBugEmitted(());

type InternedSet<'tcx, T> = ShardedHashMap<Interned<'tcx, T>, ()>;

pub struct CtxtInterners<'tcx> {
Expand Down Expand Up @@ -1171,18 +1177,15 @@ impl<'tcx> TyCtxt<'tcx> {
#[track_caller]
pub fn ty_error_with_message<S: Into<MultiSpan>>(self, span: S, msg: &str) -> Ty<'tcx> {
self.sess.delay_span_bug(span, msg);
self.mk_ty(Error(super::sty::DelaySpanBugEmitted(())))
self.mk_ty(Error(DelaySpanBugEmitted(())))
}

/// Like `err` but for constants.
#[track_caller]
pub fn const_error(self, ty: Ty<'tcx>) -> &'tcx Const<'tcx> {
self.sess
.delay_span_bug(DUMMY_SP, "ty::ConstKind::Error constructed but no error reported.");
self.mk_const(ty::Const {
val: ty::ConstKind::Error(super::sty::DelaySpanBugEmitted(())),
ty,
})
self.mk_const(ty::Const { val: ty::ConstKind::Error(DelaySpanBugEmitted(())), ty })
}

pub fn consider_optimizing<T: Fn() -> String>(&self, msg: T) -> bool {
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_middle/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub use self::sty::{Binder, BoundTy, BoundTyKind, BoundVar, DebruijnIndex, INNER
pub use self::sty::{BoundRegion, EarlyBoundRegion, FreeRegion, Region};
pub use self::sty::{CanonicalPolyFnSig, FnSig, GenSig, PolyFnSig, PolyGenSig};
pub use self::sty::{ClosureSubsts, GeneratorSubsts, TypeAndMut, UpvarSubsts};
pub use self::sty::{ClosureSubstsParts, GeneratorSubstsParts};
pub use self::sty::{ConstVid, FloatVid, IntVid, RegionVid, TyVid};
pub use self::sty::{ExistentialPredicate, InferTy, ParamConst, ParamTy, ProjectionTy};
pub use self::sty::{ExistentialProjection, PolyExistentialProjection};
Expand All @@ -72,8 +73,8 @@ pub use self::binding::BindingMode::*;

pub use self::context::{tls, FreeRegionInfo, TyCtxt};
pub use self::context::{
CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, ResolvedOpaqueTy,
UserType, UserTypeAnnotationIndex,
CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations,
DelaySpanBugEmitted, ResolvedOpaqueTy, UserType, UserTypeAnnotationIndex,
};
pub use self::context::{
CtxtInterners, GeneratorInteriorTypeCause, GlobalCtxt, Lift, TypeckResults,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId};
use rustc_hir::lang_items::{LangItem, LanguageItems};
use rustc_hir::{Crate, HirIdSet, ItemLocalId, TraitCandidate};
use rustc_hir::{Crate, ItemLocalId, TraitCandidate};
use rustc_index::{bit_set::FiniteBitSet, vec::IndexVec};
use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
use rustc_session::utils::NativeLibKind;
Expand Down
Loading