Auto merge of #72262 - Dylan-DPC:rollup-x56q1jj, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #71625 (Improve the documentation for ManuallyDrop to resolve conflicting usage of terminology)
 - #71919 (Update transitive dependency to work towards removing syn <1.0 dep)
 - #72166 (Simpler slice `Iterator` methods)
 - #72216 (Remove `lang_items\(\).*\.unwrap\(\)`)
 - #72230 (Updated documentation of Prefix::VerbatimDisk)
 - #72234 (Implement Default for proc_macro::TokenStream)
 - #72258 (Fix typo Arbintrary to Arbitrary)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-05-16 14:15:18 +00:00
commit 6163394e1f
16 changed files with 218 additions and 115 deletions

View File

@ -438,7 +438,7 @@ dependencies = [
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
"synstructure 0.12.1",
"synstructure",
]
[[package]]
@ -937,13 +937,13 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"
[[package]]
name = "derive-new"
version = "0.5.6"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ca414e896ae072546f4d789f452daaecf60ddee4c9df5dc6d5936d769e3d87c"
checksum = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
]
[[package]]
@ -1144,14 +1144,14 @@ dependencies = [
[[package]]
name = "failure_derive"
version = "0.1.5"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"synstructure 0.10.2",
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
"synstructure",
]
[[package]]
@ -1404,30 +1404,18 @@ dependencies = [
[[package]]
name = "handlebars"
version = "2.0.1"
version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df044dd42cdb7e32f28557b661406fc0f2494be75199779998810dbc35030e0d"
checksum = "ba758d094d31274eb49d15da6f326b96bf3185239a6359bf684f3d5321148900"
dependencies = [
"hashbrown 0.5.0",
"lazy_static 1.4.0",
"log",
"pest",
"pest_derive",
"quick-error",
"regex",
"serde",
"serde_json",
]
[[package]]
name = "hashbrown"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353"
dependencies = [
"serde",
]
[[package]]
name = "hashbrown"
version = "0.6.2"
@ -2054,9 +2042,9 @@ dependencies = [
[[package]]
name = "mdbook"
version = "0.3.5"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "031bdd9d4893c983e2f69ebc4b59070feee8276a584c4aabdcb351235ea28016"
checksum = "e7ec525f7ebccc2dd935c263717250cd37f9a4b264a77c5dbc950ea2734d8159"
dependencies = [
"ammonia",
"chrono",
@ -2556,15 +2544,15 @@ dependencies = [
[[package]]
name = "pest_generator"
version = "2.1.0"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63120576c4efd69615b5537d3d052257328a4ca82876771d6944424ccfd9f646"
checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
dependencies = [
"pest",
"pest_meta",
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
]
[[package]]
@ -2784,9 +2772,9 @@ checksum = "6ddd112cca70a4d30883b2d21568a1d376ff8be4758649f64f973c6845128ad3"
[[package]]
name = "quick-error"
version = "1.2.2"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]]
name = "quine-mc_cluskey"
@ -3448,7 +3436,7 @@ dependencies = [
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
"synstructure 0.12.1",
"synstructure",
]
[[package]]
@ -4058,7 +4046,7 @@ dependencies = [
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
"synstructure 0.12.1",
"synstructure",
]
[[package]]
@ -4629,13 +4617,13 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.81"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "477b13b646f5b5b56fc95bedfc3b550d12141ce84f466f6c44b9a17589923885"
checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
]
[[package]]
@ -4799,7 +4787,7 @@ dependencies = [
"core",
"dlmalloc",
"fortanix-sgx-abi",
"hashbrown 0.6.2",
"hashbrown",
"hermit-abi",
"libc",
"panic_abort",
@ -4931,18 +4919,6 @@ dependencies = [
"unicode-xid 0.2.0",
]
[[package]]
name = "synstructure"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"unicode-xid 0.1.0",
]
[[package]]
name = "synstructure"
version = "0.12.1"

View File

@ -333,7 +333,7 @@ pub trait Iterator {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn nth(&mut self, mut n: usize) -> Option<Self::Item> {
for x in self {
while let Some(x) = self.next() {
if n == 0 {
return Some(x);
}

View File

@ -7,14 +7,14 @@ use crate::ptr;
///
/// `ManuallyDrop<T>` is subject to the same layout optimizations as `T`.
/// As a consequence, it has *no effect* on the assumptions that the compiler makes
/// about all values being initialized at their type. In particular, initializing
/// a `ManuallyDrop<&mut T>` with [`mem::zeroed`] is undefined behavior.
/// about its contents. For example, initializing a `ManuallyDrop<&mut T>`
/// with [`mem::zeroed`] is undefined behavior.
/// If you need to handle uninitialized data, use [`MaybeUninit<T>`] instead.
///
/// # Examples
///
/// This wrapper helps with explicitly documenting the drop order dependencies between fields of
/// the type:
/// This wrapper can be used to enforce a particular drop order on fields, regardless
/// of how they are defined in the struct:
///
/// ```rust
/// use std::mem::ManuallyDrop;
@ -43,8 +43,18 @@ use crate::ptr;
/// }
/// ```
///
/// However, care should be taken when using this pattern as it can lead to *leak amplification*.
/// In this example, if the `Drop` implementation for `Peach` were to panic, the `banana` field
/// would also be leaked.
///
/// In contrast, the automatically-generated compiler drop implementation would have ensured
/// that all fields are dropped even in the presence of panics. This is especially important when
/// working with [pinned] data, where reusing the memory without calling the destructor could lead
/// to Undefined Behaviour.
///
/// [`mem::zeroed`]: fn.zeroed.html
/// [`MaybeUninit<T>`]: union.MaybeUninit.html
/// [pinned]: ../pin/index.html
#[stable(feature = "manually_drop", since = "1.20.0")]
#[lang = "manually_drop"]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
@ -113,19 +123,28 @@ impl<T> ManuallyDrop<T> {
}
impl<T: ?Sized> ManuallyDrop<T> {
/// Manually drops the contained value.
/// Manually drops the contained value. This is exactly equivalent to calling
/// [`ptr::drop_in_place`] with a pointer to the contained value. As such, unless
/// the contained value is a packed struct, the destructor will be called in-place
/// without moving the value, and thus can be used to safely drop [pinned] data.
///
/// If you have ownership of the value, you can use [`ManuallyDrop::into_inner`] instead.
///
/// # Safety
///
/// This function runs the destructor of the contained value and thus the wrapped value
/// now represents uninitialized data. It is up to the user of this method to ensure the
/// uninitialized data is not actually used.
/// In particular, this function can only be called at most once
/// for a given instance of `ManuallyDrop<T>`.
/// This function runs the destructor of the contained value. Other than changes made by
/// the destructor itself, the memory is left unchanged, and so as far as the compiler is
/// concerned still holds a bit-pattern which is valid for the type `T`.
///
/// However, this "zombie" value should not be exposed to safe code, and this function
/// should not be called more than once. To use a value after it's been dropped, or drop
/// a value multiple times, can cause Undefined Behavior (depending on what `drop` does).
/// This is normally prevented by the type system, but users of `ManuallyDrop` must
/// uphold those guarantees without assistance from the compiler.
///
/// [`ManuallyDrop::into_inner`]: #method.into_inner
/// [`ptr::drop_in_place`]: ../ptr/fn.drop_in_place.html
/// [pinned]: ../pin/index.html
#[stable(feature = "manually_drop", since = "1.20.0")]
#[inline]
pub unsafe fn drop(slot: &mut ManuallyDrop<T>) {

View File

@ -110,11 +110,17 @@ mod mut_ptr;
/// as the compiler doesn't need to prove that it's sound to elide the
/// copy.
///
/// * It can be used to drop [pinned] data when `T` is not `repr(packed)`
/// (pinned data must not be moved before it is dropped).
///
/// Unaligned values cannot be dropped in place, they must be copied to an aligned
/// location first using [`ptr::read_unaligned`].
/// location first using [`ptr::read_unaligned`]. For packed structs, this move is
/// done automatically by the compiler. This means the fields of packed structs
/// are not dropped in-place.
///
/// [`ptr::read`]: ../ptr/fn.read.html
/// [`ptr::read_unaligned`]: ../ptr/fn.read_unaligned.html
/// [pinned]: ../pin/index.html
///
/// # Safety
///

View File

@ -3179,6 +3179,7 @@ macro_rules! is_empty {
$self.ptr.as_ptr() as *const T == $self.end
};
}
// To get rid of some bounds checks (see `position`), we compute the length in a somewhat
// unexpected way. (Tested by `codegen/slice-position-bounds-check`.)
macro_rules! len {
@ -3347,40 +3348,127 @@ macro_rules! iterator {
self.next_back()
}
// We override the default implementation, which uses `try_fold`,
// because this simple implementation generates less LLVM IR and is
// faster to compile.
#[inline]
fn for_each<F>(mut self, mut f: F)
where
Self: Sized,
F: FnMut(Self::Item),
{
while let Some(x) = self.next() {
f(x);
}
}
// We override the default implementation, which uses `try_fold`,
// because this simple implementation generates less LLVM IR and is
// faster to compile.
#[inline]
fn all<F>(&mut self, mut f: F) -> bool
where
Self: Sized,
F: FnMut(Self::Item) -> bool,
{
while let Some(x) = self.next() {
if !f(x) {
return false;
}
}
true
}
// We override the default implementation, which uses `try_fold`,
// because this simple implementation generates less LLVM IR and is
// faster to compile.
#[inline]
fn any<F>(&mut self, mut f: F) -> bool
where
Self: Sized,
F: FnMut(Self::Item) -> bool,
{
while let Some(x) = self.next() {
if f(x) {
return true;
}
}
false
}
// We override the default implementation, which uses `try_fold`,
// because this simple implementation generates less LLVM IR and is
// faster to compile.
#[inline]
fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item>
where
Self: Sized,
P: FnMut(&Self::Item) -> bool,
{
while let Some(x) = self.next() {
if predicate(&x) {
return Some(x);
}
}
None
}
// We override the default implementation, which uses `try_fold`,
// because this simple implementation generates less LLVM IR and is
// faster to compile.
#[inline]
fn find_map<B, F>(&mut self, mut f: F) -> Option<B>
where
Self: Sized,
F: FnMut(Self::Item) -> Option<B>,
{
while let Some(x) = self.next() {
if let Some(y) = f(x) {
return Some(y);
}
}
None
}
// We override the default implementation, which uses `try_fold`,
// because this simple implementation generates less LLVM IR and is
// faster to compile. Also, the `assume` avoids a bounds check.
#[inline]
#[rustc_inherit_overflow_checks]
fn position<P>(&mut self, mut predicate: P) -> Option<usize> where
Self: Sized,
P: FnMut(Self::Item) -> bool,
{
// The addition might panic on overflow.
let n = len!(self);
self.try_fold(0, move |i, x| {
if predicate(x) { Err(i) }
else { Ok(i + 1) }
}).err()
.map(|i| {
let mut i = 0;
while let Some(x) = self.next() {
if predicate(x) {
unsafe { assume(i < n) };
i
})
return Some(i);
}
i += 1;
}
None
}
// We override the default implementation, which uses `try_fold`,
// because this simple implementation generates less LLVM IR and is
// faster to compile. Also, the `assume` avoids a bounds check.
#[inline]
fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: Sized + ExactSizeIterator + DoubleEndedIterator
{
// No need for an overflow check here, because `ExactSizeIterator`
let n = len!(self);
self.try_rfold(n, move |i, x| {
let i = i - 1;
if predicate(x) { Err(i) }
else { Ok(i) }
}).err()
.map(|i| {
let mut i = n;
while let Some(x) = self.next_back() {
i -= 1;
if predicate(x) {
unsafe { assume(i < n) };
i
})
return Some(i);
}
}
None
}
$($extra)*

View File

@ -158,6 +158,13 @@ impl fmt::Debug for TokenStream {
}
}
#[stable(feature = "proc_macro_token_stream_default", since = "1.45.0")]
impl Default for TokenStream {
fn default() -> Self {
TokenStream::new()
}
}
#[unstable(feature = "proc_macro_quote", issue = "54722")]
pub use quote::{quote, quote_span};

View File

@ -64,7 +64,7 @@ impl Trait for Foo {
}
```
The nightly feature [Arbintrary self types][AST] extends the accepted
The nightly feature [Arbitrary self types][AST] extends the accepted
set of receiver types to also include any type that can dereference to
`Self`:

View File

@ -2,6 +2,8 @@ use rustc_middle::traits;
use rustc_middle::ty::adjustment::CustomCoerceUnsized;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_hir::lang_items::CoerceUnsizedTraitLangItem;
pub mod collector;
pub mod partitioning;
@ -10,7 +12,7 @@ pub fn custom_coerce_unsize_info<'tcx>(
source_ty: Ty<'tcx>,
target_ty: Ty<'tcx>,
) -> CustomCoerceUnsized {
let def_id = tcx.lang_items().coerce_unsized_trait().unwrap();
let def_id = tcx.require_lang_item(CoerceUnsizedTraitLangItem, None);
let trait_ref = ty::Binder::bind(ty::TraitRef {
def_id,

View File

@ -141,7 +141,8 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
// code at the moment, because types like `for <'a> fn(&'a ())` do
// not *yet* implement `PartialEq`. So for now we leave this here.
let ty_is_partial_eq: bool = {
let partial_eq_trait_id = self.tcx().require_lang_item(EqTraitLangItem, None);
let partial_eq_trait_id =
self.tcx().require_lang_item(EqTraitLangItem, Some(self.span));
let obligation: PredicateObligation<'_> = predicate_for_trait_def(
self.tcx(),
self.param_env,

View File

@ -4,6 +4,7 @@ use crate::traits::{self, ConstPatternStructural, TraitEngine};
use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
use rustc_hir::lang_items::{StructuralPeqTraitLangItem, StructuralTeqTraitLangItem};
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeFoldable, TypeVisitor};
use rustc_span::Span;
@ -69,7 +70,7 @@ pub fn type_marked_structural(
let mut fulfillment_cx = traits::FulfillmentContext::new();
let cause = ObligationCause::new(span, id, ConstPatternStructural);
// require `#[derive(PartialEq)]`
let structural_peq_def_id = infcx.tcx.lang_items().structural_peq_trait().unwrap();
let structural_peq_def_id = infcx.tcx.require_lang_item(StructuralPeqTraitLangItem, Some(span));
fulfillment_cx.register_bound(
infcx,
ty::ParamEnv::empty(),
@ -80,7 +81,7 @@ pub fn type_marked_structural(
// for now, require `#[derive(Eq)]`. (Doing so is a hack to work around
// the type `for<'a> fn(&'a ())` failing to implement `Eq` itself.)
let cause = ObligationCause::new(span, id, ConstPatternStructural);
let structural_teq_def_id = infcx.tcx.lang_items().structural_teq_trait().unwrap();
let structural_teq_def_id = infcx.tcx.require_lang_item(StructuralTeqTraitLangItem, Some(span));
fulfillment_cx.register_bound(
infcx,
ty::ParamEnv::empty(),

View File

@ -6,7 +6,7 @@ use crate::astconv::AstConv;
use crate::middle::region;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::lang_items;
use rustc_hir::lang_items::{FutureTraitLangItem, GeneratorTraitLangItem};
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::LateBoundRegionConversionTime;
use rustc_infer::infer::{InferOk, InferResult};
@ -245,7 +245,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let trait_ref = projection.to_poly_trait_ref(tcx);
let is_fn = tcx.fn_trait_kind_from_lang_item(trait_ref.def_id()).is_some();
let gen_trait = tcx.require_lang_item(lang_items::GeneratorTraitLangItem, cause_span);
let gen_trait = tcx.require_lang_item(GeneratorTraitLangItem, cause_span);
let is_gen = gen_trait == trait_ref.def_id();
if !is_fn && !is_gen {
debug!("deduce_sig_from_projection: not fn or generator");
@ -678,7 +678,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Check that this is a projection from the `Future` trait.
let trait_ref = predicate.projection_ty.trait_ref(self.tcx);
let future_trait = self.tcx.lang_items().future_trait().unwrap();
let future_trait = self.tcx.require_lang_item(FutureTraitLangItem, Some(cause_span));
if trait_ref.def_id != future_trait {
debug!("deduce_future_output_from_projection: not a future");
return None;

View File

@ -7,7 +7,7 @@ use rustc_trait_selection::traits::{self, ObligationCause};
use rustc_ast::util::parser::PREC_POSTFIX;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::lang_items::DerefTraitLangItem;
use rustc_hir::lang_items::{CloneTraitLangItem, DerefTraitLangItem};
use rustc_hir::{is_range_literal, Node};
use rustc_middle::ty::adjustment::AllowTwoPhase;
use rustc_middle::ty::{self, AssocItem, Ty, TypeAndMut};
@ -456,8 +456,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};
if self.can_coerce(ref_ty, expected) {
let mut sugg_sp = sp;
if let hir::ExprKind::MethodCall(segment, _sp, args) = &expr.kind {
let clone_trait = self.tcx.lang_items().clone_trait().unwrap();
if let hir::ExprKind::MethodCall(ref segment, sp, ref args) = expr.kind {
let clone_trait = self.tcx.require_lang_item(CloneTraitLangItem, Some(sp));
if let ([arg], Some(true), sym::clone) = (
&args[..],
self.tables.borrow().type_dependent_def_id(expr.hir_id).map(|did| {
@ -635,7 +635,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ if sp == expr.span && !is_macro => {
// Check for `Deref` implementations by constructing a predicate to
// prove: `<T as Deref>::Output == U`
let deref_trait = self.tcx.require_lang_item(DerefTraitLangItem, Some(expr.span));
let deref_trait = self.tcx.require_lang_item(DerefTraitLangItem, Some(sp));
let item_def_id = self
.tcx
.associated_items(deref_trait)

View File

@ -100,7 +100,9 @@ use rustc_hir::def::{CtorOf, DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE};
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_hir::lang_items;
use rustc_hir::lang_items::{
FutureTraitLangItem, PinTypeLangItem, SizedTraitLangItem, VaListTypeLangItem,
};
use rustc_hir::{ExprKind, GenericArg, HirIdMap, Item, ItemKind, Node, PatKind, QPath};
use rustc_index::bit_set::BitSet;
use rustc_index::vec::Idx;
@ -1335,10 +1337,8 @@ fn check_fn<'a, 'tcx>(
// C-variadic fns also have a `VaList` input that's not listed in `fn_sig`
// (as it's created inside the body itself, not passed in from outside).
let maybe_va_list = if fn_sig.c_variadic {
let va_list_did = tcx.require_lang_item(
lang_items::VaListTypeLangItem,
Some(body.params.last().unwrap().span),
);
let va_list_did =
tcx.require_lang_item(VaListTypeLangItem, Some(body.params.last().unwrap().span));
let region = tcx.mk_region(ty::ReScope(region::Scope {
id: body.value.hir_id.local_id,
data: region::ScopeData::CallSite,
@ -3296,7 +3296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
code: traits::ObligationCauseCode<'tcx>,
) {
if !ty.references_error() {
let lang_item = self.tcx.require_lang_item(lang_items::SizedTraitLangItem, None);
let lang_item = self.tcx.require_lang_item(SizedTraitLangItem, None);
self.require_type_meets(ty, span, code, lang_item);
}
}
@ -5135,7 +5135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => {}
}
let boxed_found = self.tcx.mk_box(found);
let new_found = self.tcx.mk_lang_item(boxed_found, lang_items::PinTypeLangItem).unwrap();
let new_found = self.tcx.mk_lang_item(boxed_found, PinTypeLangItem).unwrap();
if let (true, Ok(snippet)) = (
self.can_coerce(new_found, expected),
self.sess().source_map().span_to_snippet(expr.span),
@ -5292,7 +5292,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let sp = expr.span;
// Check for `Future` implementations by constructing a predicate to
// prove: `<T as Future>::Output == U`
let future_trait = self.tcx.lang_items().future_trait().unwrap();
let future_trait = self.tcx.require_lang_item(FutureTraitLangItem, Some(sp));
let item_def_id = self
.tcx
.associated_items(future_trait)

View File

@ -4,7 +4,9 @@
use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::lang_items::UnsizeTraitLangItem;
use rustc_hir::lang_items::{
CoerceUnsizedTraitLangItem, DispatchFromDynTraitLangItem, UnsizeTraitLangItem,
};
use rustc_hir::ItemKind;
use rustc_infer::infer;
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
@ -145,11 +147,11 @@ fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'tcx>, impl_did: LocalDefI
fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
debug!("visit_implementation_of_dispatch_from_dyn: impl_did={:?}", impl_did);
let dispatch_from_dyn_trait = tcx.lang_items().dispatch_from_dyn_trait().unwrap();
let impl_hir_id = tcx.hir().as_local_hir_id(impl_did);
let span = tcx.hir().span(impl_hir_id);
let dispatch_from_dyn_trait = tcx.require_lang_item(DispatchFromDynTraitLangItem, Some(span));
let source = tcx.type_of(impl_did);
assert!(!source.has_escaping_bound_vars());
let target = {
@ -314,22 +316,23 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo {
debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did);
let coerce_unsized_trait = tcx.lang_items().coerce_unsized_trait().unwrap();
// this provider should only get invoked for local def-ids
let impl_hir_id = tcx.hir().as_local_hir_id(impl_did.expect_local());
let span = tcx.hir().span(impl_hir_id);
let coerce_unsized_trait = tcx.require_lang_item(CoerceUnsizedTraitLangItem, Some(span));
let unsize_trait = tcx.lang_items().require(UnsizeTraitLangItem).unwrap_or_else(|err| {
tcx.sess.fatal(&format!("`CoerceUnsized` implementation {}", err));
});
// this provider should only get invoked for local def-ids
let impl_hir_id = tcx.hir().as_local_hir_id(impl_did.expect_local());
let source = tcx.type_of(impl_did);
let trait_ref = tcx.impl_trait_ref(impl_did).unwrap();
assert_eq!(trait_ref.def_id, coerce_unsized_trait);
let target = trait_ref.substs.type_at(1);
debug!("visit_implementation_of_coerce_unsized: {:?} -> {:?} (bound)", source, target);
let span = tcx.hir().span(impl_hir_id);
let param_env = tcx.param_env(impl_did);
assert!(!source.has_escaping_bound_vars());

View File

@ -157,10 +157,10 @@ pub enum Prefix<'a> {
#[stable(feature = "rust1", since = "1.0.0")] &'a OsStr,
),
/// Verbatim disk prefix, e.g., `\\?\C:\`.
/// Verbatim disk prefix, e.g., `\\?\C:`.
///
/// Verbatim disk prefixes consist of `\\?\` immediately followed by the
/// drive letter and `:\`.
/// drive letter and `:`.
#[stable(feature = "rust1", since = "1.0.0")]
VerbatimDisk(#[stable(feature = "rust1", since = "1.0.0")] u8),

View File

@ -23,6 +23,6 @@ codespan-reporting = { version = "0.5", optional = true }
rustc-workspace-hack = "1.0.0"
[dependencies.mdbook]
version = "0.3.0"
version = "0.3.7"
default-features = false
features = ["search"]