Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6163394

Browse files
committedMay 16, 2020
Auto merge of rust-lang#72262 - Dylan-DPC:rollup-x56q1jj, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - rust-lang#71625 (Improve the documentation for ManuallyDrop to resolve conflicting usage of terminology) - rust-lang#71919 (Update transitive dependency to work towards removing syn <1.0 dep) - rust-lang#72166 (Simpler slice `Iterator` methods) - rust-lang#72216 (Remove `lang_items\(\).*\.unwrap\(\)`) - rust-lang#72230 (Updated documentation of Prefix::VerbatimDisk) - rust-lang#72234 (Implement Default for proc_macro::TokenStream) - rust-lang#72258 (Fix typo Arbintrary to Arbitrary) Failed merges: r? @ghost
2 parents 31add7e + e43dd47 commit 6163394

File tree

16 files changed

+218
-115
lines changed

16 files changed

+218
-115
lines changed
 

‎Cargo.lock

Lines changed: 31 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ dependencies = [
438438
"proc-macro2 1.0.3",
439439
"quote 1.0.2",
440440
"syn 1.0.11",
441-
"synstructure 0.12.1",
441+
"synstructure",
442442
]
443443

444444
[[package]]
@@ -937,13 +937,13 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"
937937

938938
[[package]]
939939
name = "derive-new"
940-
version = "0.5.6"
940+
version = "0.5.8"
941941
source = "registry+https://github.com/rust-lang/crates.io-index"
942-
checksum = "6ca414e896ae072546f4d789f452daaecf60ddee4c9df5dc6d5936d769e3d87c"
942+
checksum = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9"
943943
dependencies = [
944-
"proc-macro2 0.4.30",
945-
"quote 0.6.12",
946-
"syn 0.15.35",
944+
"proc-macro2 1.0.3",
945+
"quote 1.0.2",
946+
"syn 1.0.11",
947947
]
948948

949949
[[package]]
@@ -1144,14 +1144,14 @@ dependencies = [
11441144

11451145
[[package]]
11461146
name = "failure_derive"
1147-
version = "0.1.5"
1147+
version = "0.1.8"
11481148
source = "registry+https://github.com/rust-lang/crates.io-index"
1149-
checksum = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
1149+
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
11501150
dependencies = [
1151-
"proc-macro2 0.4.30",
1152-
"quote 0.6.12",
1153-
"syn 0.15.35",
1154-
"synstructure 0.10.2",
1151+
"proc-macro2 1.0.3",
1152+
"quote 1.0.2",
1153+
"syn 1.0.11",
1154+
"synstructure",
11551155
]
11561156

11571157
[[package]]
@@ -1404,30 +1404,18 @@ dependencies = [
14041404

14051405
[[package]]
14061406
name = "handlebars"
1407-
version = "2.0.1"
1407+
version = "3.0.1"
14081408
source = "registry+https://github.com/rust-lang/crates.io-index"
1409-
checksum = "df044dd42cdb7e32f28557b661406fc0f2494be75199779998810dbc35030e0d"
1409+
checksum = "ba758d094d31274eb49d15da6f326b96bf3185239a6359bf684f3d5321148900"
14101410
dependencies = [
1411-
"hashbrown 0.5.0",
1412-
"lazy_static 1.4.0",
14131411
"log",
14141412
"pest",
14151413
"pest_derive",
14161414
"quick-error",
1417-
"regex",
14181415
"serde",
14191416
"serde_json",
14201417
]
14211418

1422-
[[package]]
1423-
name = "hashbrown"
1424-
version = "0.5.0"
1425-
source = "registry+https://github.com/rust-lang/crates.io-index"
1426-
checksum = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353"
1427-
dependencies = [
1428-
"serde",
1429-
]
1430-
14311419
[[package]]
14321420
name = "hashbrown"
14331421
version = "0.6.2"
@@ -2054,9 +2042,9 @@ dependencies = [
20542042

20552043
[[package]]
20562044
name = "mdbook"
2057-
version = "0.3.5"
2045+
version = "0.3.7"
20582046
source = "registry+https://github.com/rust-lang/crates.io-index"
2059-
checksum = "031bdd9d4893c983e2f69ebc4b59070feee8276a584c4aabdcb351235ea28016"
2047+
checksum = "e7ec525f7ebccc2dd935c263717250cd37f9a4b264a77c5dbc950ea2734d8159"
20602048
dependencies = [
20612049
"ammonia",
20622050
"chrono",
@@ -2556,15 +2544,15 @@ dependencies = [
25562544

25572545
[[package]]
25582546
name = "pest_generator"
2559-
version = "2.1.0"
2547+
version = "2.1.3"
25602548
source = "registry+https://github.com/rust-lang/crates.io-index"
2561-
checksum = "63120576c4efd69615b5537d3d052257328a4ca82876771d6944424ccfd9f646"
2549+
checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
25622550
dependencies = [
25632551
"pest",
25642552
"pest_meta",
2565-
"proc-macro2 0.4.30",
2566-
"quote 0.6.12",
2567-
"syn 0.15.35",
2553+
"proc-macro2 1.0.3",
2554+
"quote 1.0.2",
2555+
"syn 1.0.11",
25682556
]
25692557

25702558
[[package]]
@@ -2784,9 +2772,9 @@ checksum = "6ddd112cca70a4d30883b2d21568a1d376ff8be4758649f64f973c6845128ad3"
27842772

27852773
[[package]]
27862774
name = "quick-error"
2787-
version = "1.2.2"
2775+
version = "1.2.3"
27882776
source = "registry+https://github.com/rust-lang/crates.io-index"
2789-
checksum = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
2777+
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
27902778

27912779
[[package]]
27922780
name = "quine-mc_cluskey"
@@ -3448,7 +3436,7 @@ dependencies = [
34483436
"proc-macro2 1.0.3",
34493437
"quote 1.0.2",
34503438
"syn 1.0.11",
3451-
"synstructure 0.12.1",
3439+
"synstructure",
34523440
]
34533441

34543442
[[package]]
@@ -4058,7 +4046,7 @@ dependencies = [
40584046
"proc-macro2 1.0.3",
40594047
"quote 1.0.2",
40604048
"syn 1.0.11",
4061-
"synstructure 0.12.1",
4049+
"synstructure",
40624050
]
40634051

40644052
[[package]]
@@ -4629,13 +4617,13 @@ dependencies = [
46294617

46304618
[[package]]
46314619
name = "serde_derive"
4632-
version = "1.0.81"
4620+
version = "1.0.106"
46334621
source = "registry+https://github.com/rust-lang/crates.io-index"
4634-
checksum = "477b13b646f5b5b56fc95bedfc3b550d12141ce84f466f6c44b9a17589923885"
4622+
checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c"
46354623
dependencies = [
4636-
"proc-macro2 0.4.30",
4637-
"quote 0.6.12",
4638-
"syn 0.15.35",
4624+
"proc-macro2 1.0.3",
4625+
"quote 1.0.2",
4626+
"syn 1.0.11",
46394627
]
46404628

46414629
[[package]]
@@ -4799,7 +4787,7 @@ dependencies = [
47994787
"core",
48004788
"dlmalloc",
48014789
"fortanix-sgx-abi",
4802-
"hashbrown 0.6.2",
4790+
"hashbrown",
48034791
"hermit-abi",
48044792
"libc",
48054793
"panic_abort",
@@ -4931,18 +4919,6 @@ dependencies = [
49314919
"unicode-xid 0.2.0",
49324920
]
49334921

4934-
[[package]]
4935-
name = "synstructure"
4936-
version = "0.10.2"
4937-
source = "registry+https://github.com/rust-lang/crates.io-index"
4938-
checksum = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f"
4939-
dependencies = [
4940-
"proc-macro2 0.4.30",
4941-
"quote 0.6.12",
4942-
"syn 0.15.35",
4943-
"unicode-xid 0.1.0",
4944-
]
4945-
49464922
[[package]]
49474923
name = "synstructure"
49484924
version = "0.12.1"

‎src/libcore/iter/traits/iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ pub trait Iterator {
333333
#[inline]
334334
#[stable(feature = "rust1", since = "1.0.0")]
335335
fn nth(&mut self, mut n: usize) -> Option<Self::Item> {
336-
for x in self {
336+
while let Some(x) = self.next() {
337337
if n == 0 {
338338
return Some(x);
339339
}

‎src/libcore/mem/manually_drop.rs

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ use crate::ptr;
77
///
88
/// `ManuallyDrop<T>` is subject to the same layout optimizations as `T`.
99
/// As a consequence, it has *no effect* on the assumptions that the compiler makes
10-
/// about all values being initialized at their type. In particular, initializing
11-
/// a `ManuallyDrop<&mut T>` with [`mem::zeroed`] is undefined behavior.
10+
/// about its contents. For example, initializing a `ManuallyDrop<&mut T>`
11+
/// with [`mem::zeroed`] is undefined behavior.
1212
/// If you need to handle uninitialized data, use [`MaybeUninit<T>`] instead.
1313
///
1414
/// # Examples
1515
///
16-
/// This wrapper helps with explicitly documenting the drop order dependencies between fields of
17-
/// the type:
16+
/// This wrapper can be used to enforce a particular drop order on fields, regardless
17+
/// of how they are defined in the struct:
1818
///
1919
/// ```rust
2020
/// use std::mem::ManuallyDrop;
@@ -43,8 +43,18 @@ use crate::ptr;
4343
/// }
4444
/// ```
4545
///
46+
/// However, care should be taken when using this pattern as it can lead to *leak amplification*.
47+
/// In this example, if the `Drop` implementation for `Peach` were to panic, the `banana` field
48+
/// would also be leaked.
49+
///
50+
/// In contrast, the automatically-generated compiler drop implementation would have ensured
51+
/// that all fields are dropped even in the presence of panics. This is especially important when
52+
/// working with [pinned] data, where reusing the memory without calling the destructor could lead
53+
/// to Undefined Behaviour.
54+
///
4655
/// [`mem::zeroed`]: fn.zeroed.html
4756
/// [`MaybeUninit<T>`]: union.MaybeUninit.html
57+
/// [pinned]: ../pin/index.html
4858
#[stable(feature = "manually_drop", since = "1.20.0")]
4959
#[lang = "manually_drop"]
5060
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -113,19 +123,28 @@ impl<T> ManuallyDrop<T> {
113123
}
114124

115125
impl<T: ?Sized> ManuallyDrop<T> {
116-
/// Manually drops the contained value.
126+
/// Manually drops the contained value. This is exactly equivalent to calling
127+
/// [`ptr::drop_in_place`] with a pointer to the contained value. As such, unless
128+
/// the contained value is a packed struct, the destructor will be called in-place
129+
/// without moving the value, and thus can be used to safely drop [pinned] data.
117130
///
118131
/// If you have ownership of the value, you can use [`ManuallyDrop::into_inner`] instead.
119132
///
120133
/// # Safety
121134
///
122-
/// This function runs the destructor of the contained value and thus the wrapped value
123-
/// now represents uninitialized data. It is up to the user of this method to ensure the
124-
/// uninitialized data is not actually used.
125-
/// In particular, this function can only be called at most once
126-
/// for a given instance of `ManuallyDrop<T>`.
135+
/// This function runs the destructor of the contained value. Other than changes made by
136+
/// the destructor itself, the memory is left unchanged, and so as far as the compiler is
137+
/// concerned still holds a bit-pattern which is valid for the type `T`.
138+
///
139+
/// However, this "zombie" value should not be exposed to safe code, and this function
140+
/// should not be called more than once. To use a value after it's been dropped, or drop
141+
/// a value multiple times, can cause Undefined Behavior (depending on what `drop` does).
142+
/// This is normally prevented by the type system, but users of `ManuallyDrop` must
143+
/// uphold those guarantees without assistance from the compiler.
127144
///
128145
/// [`ManuallyDrop::into_inner`]: #method.into_inner
146+
/// [`ptr::drop_in_place`]: ../ptr/fn.drop_in_place.html
147+
/// [pinned]: ../pin/index.html
129148
#[stable(feature = "manually_drop", since = "1.20.0")]
130149
#[inline]
131150
pub unsafe fn drop(slot: &mut ManuallyDrop<T>) {

‎src/libcore/ptr/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,17 @@ mod mut_ptr;
110110
/// as the compiler doesn't need to prove that it's sound to elide the
111111
/// copy.
112112
///
113+
/// * It can be used to drop [pinned] data when `T` is not `repr(packed)`
114+
/// (pinned data must not be moved before it is dropped).
115+
///
113116
/// Unaligned values cannot be dropped in place, they must be copied to an aligned
114-
/// location first using [`ptr::read_unaligned`].
117+
/// location first using [`ptr::read_unaligned`]. For packed structs, this move is
118+
/// done automatically by the compiler. This means the fields of packed structs
119+
/// are not dropped in-place.
115120
///
116121
/// [`ptr::read`]: ../ptr/fn.read.html
117122
/// [`ptr::read_unaligned`]: ../ptr/fn.read_unaligned.html
123+
/// [pinned]: ../pin/index.html
118124
///
119125
/// # Safety
120126
///

‎src/libcore/slice/mod.rs

Lines changed: 105 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,6 +3179,7 @@ macro_rules! is_empty {
31793179
$self.ptr.as_ptr() as *const T == $self.end
31803180
};
31813181
}
3182+
31823183
// To get rid of some bounds checks (see `position`), we compute the length in a somewhat
31833184
// unexpected way. (Tested by `codegen/slice-position-bounds-check`.)
31843185
macro_rules! len {
@@ -3347,40 +3348,127 @@ macro_rules! iterator {
33473348
self.next_back()
33483349
}
33493350

3351+
// We override the default implementation, which uses `try_fold`,
3352+
// because this simple implementation generates less LLVM IR and is
3353+
// faster to compile.
3354+
#[inline]
3355+
fn for_each<F>(mut self, mut f: F)
3356+
where
3357+
Self: Sized,
3358+
F: FnMut(Self::Item),
3359+
{
3360+
while let Some(x) = self.next() {
3361+
f(x);
3362+
}
3363+
}
3364+
3365+
// We override the default implementation, which uses `try_fold`,
3366+
// because this simple implementation generates less LLVM IR and is
3367+
// faster to compile.
3368+
#[inline]
3369+
fn all<F>(&mut self, mut f: F) -> bool
3370+
where
3371+
Self: Sized,
3372+
F: FnMut(Self::Item) -> bool,
3373+
{
3374+
while let Some(x) = self.next() {
3375+
if !f(x) {
3376+
return false;
3377+
}
3378+
}
3379+
true
3380+
}
3381+
3382+
// We override the default implementation, which uses `try_fold`,
3383+
// because this simple implementation generates less LLVM IR and is
3384+
// faster to compile.
3385+
#[inline]
3386+
fn any<F>(&mut self, mut f: F) -> bool
3387+
where
3388+
Self: Sized,
3389+
F: FnMut(Self::Item) -> bool,
3390+
{
3391+
while let Some(x) = self.next() {
3392+
if f(x) {
3393+
return true;
3394+
}
3395+
}
3396+
false
3397+
}
3398+
3399+
// We override the default implementation, which uses `try_fold`,
3400+
// because this simple implementation generates less LLVM IR and is
3401+
// faster to compile.
3402+
#[inline]
3403+
fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item>
3404+
where
3405+
Self: Sized,
3406+
P: FnMut(&Self::Item) -> bool,
3407+
{
3408+
while let Some(x) = self.next() {
3409+
if predicate(&x) {
3410+
return Some(x);
3411+
}
3412+
}
3413+
None
3414+
}
3415+
3416+
// We override the default implementation, which uses `try_fold`,
3417+
// because this simple implementation generates less LLVM IR and is
3418+
// faster to compile.
3419+
#[inline]
3420+
fn find_map<B, F>(&mut self, mut f: F) -> Option<B>
3421+
where
3422+
Self: Sized,
3423+
F: FnMut(Self::Item) -> Option<B>,
3424+
{
3425+
while let Some(x) = self.next() {
3426+
if let Some(y) = f(x) {
3427+
return Some(y);
3428+
}
3429+
}
3430+
None
3431+
}
3432+
3433+
// We override the default implementation, which uses `try_fold`,
3434+
// because this simple implementation generates less LLVM IR and is
3435+
// faster to compile. Also, the `assume` avoids a bounds check.
33503436
#[inline]
33513437
#[rustc_inherit_overflow_checks]
33523438
fn position<P>(&mut self, mut predicate: P) -> Option<usize> where
33533439
Self: Sized,
33543440
P: FnMut(Self::Item) -> bool,
33553441
{
3356-
// The addition might panic on overflow.
33573442
let n = len!(self);
3358-
self.try_fold(0, move |i, x| {
3359-
if predicate(x) { Err(i) }
3360-
else { Ok(i + 1) }
3361-
}).err()
3362-
.map(|i| {
3443+
let mut i = 0;
3444+
while let Some(x) = self.next() {
3445+
if predicate(x) {
33633446
unsafe { assume(i < n) };
3364-
i
3365-
})
3447+
return Some(i);
3448+
}
3449+
i += 1;
3450+
}
3451+
None
33663452
}
33673453

3454+
// We override the default implementation, which uses `try_fold`,
3455+
// because this simple implementation generates less LLVM IR and is
3456+
// faster to compile. Also, the `assume` avoids a bounds check.
33683457
#[inline]
33693458
fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where
33703459
P: FnMut(Self::Item) -> bool,
33713460
Self: Sized + ExactSizeIterator + DoubleEndedIterator
33723461
{
3373-
// No need for an overflow check here, because `ExactSizeIterator`
33743462
let n = len!(self);
3375-
self.try_rfold(n, move |i, x| {
3376-
let i = i - 1;
3377-
if predicate(x) { Err(i) }
3378-
else { Ok(i) }
3379-
}).err()
3380-
.map(|i| {
3463+
let mut i = n;
3464+
while let Some(x) = self.next_back() {
3465+
i -= 1;
3466+
if predicate(x) {
33813467
unsafe { assume(i < n) };
3382-
i
3383-
})
3468+
return Some(i);
3469+
}
3470+
}
3471+
None
33843472
}
33853473

33863474
$($extra)*

‎src/libproc_macro/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ impl fmt::Debug for TokenStream {
158158
}
159159
}
160160

161+
#[stable(feature = "proc_macro_token_stream_default", since = "1.45.0")]
162+
impl Default for TokenStream {
163+
fn default() -> Self {
164+
TokenStream::new()
165+
}
166+
}
167+
161168
#[unstable(feature = "proc_macro_quote", issue = "54722")]
162169
pub use quote::{quote, quote_span};
163170

‎src/librustc_error_codes/error_codes/E0307.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Trait for Foo {
6464
}
6565
```
6666

67-
The nightly feature [Arbintrary self types][AST] extends the accepted
67+
The nightly feature [Arbitrary self types][AST] extends the accepted
6868
set of receiver types to also include any type that can dereference to
6969
`Self`:
7070

‎src/librustc_mir/monomorphize/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use rustc_middle::traits;
22
use rustc_middle::ty::adjustment::CustomCoerceUnsized;
33
use rustc_middle::ty::{self, Ty, TyCtxt};
44

5+
use rustc_hir::lang_items::CoerceUnsizedTraitLangItem;
6+
57
pub mod collector;
68
pub mod partitioning;
79

@@ -10,7 +12,7 @@ pub fn custom_coerce_unsize_info<'tcx>(
1012
source_ty: Ty<'tcx>,
1113
target_ty: Ty<'tcx>,
1214
) -> CustomCoerceUnsized {
13-
let def_id = tcx.lang_items().coerce_unsized_trait().unwrap();
15+
let def_id = tcx.require_lang_item(CoerceUnsizedTraitLangItem, None);
1416

1517
let trait_ref = ty::Binder::bind(ty::TraitRef {
1618
def_id,

‎src/librustc_mir_build/hair/pattern/const_to_pat.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
141141
// code at the moment, because types like `for <'a> fn(&'a ())` do
142142
// not *yet* implement `PartialEq`. So for now we leave this here.
143143
let ty_is_partial_eq: bool = {
144-
let partial_eq_trait_id = self.tcx().require_lang_item(EqTraitLangItem, None);
144+
let partial_eq_trait_id =
145+
self.tcx().require_lang_item(EqTraitLangItem, Some(self.span));
145146
let obligation: PredicateObligation<'_> = predicate_for_trait_def(
146147
self.tcx(),
147148
self.param_env,

‎src/librustc_trait_selection/traits/structural_match.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::traits::{self, ConstPatternStructural, TraitEngine};
44

55
use rustc_data_structures::fx::FxHashSet;
66
use rustc_hir as hir;
7+
use rustc_hir::lang_items::{StructuralPeqTraitLangItem, StructuralTeqTraitLangItem};
78
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeFoldable, TypeVisitor};
89
use rustc_span::Span;
910

@@ -69,7 +70,7 @@ pub fn type_marked_structural(
6970
let mut fulfillment_cx = traits::FulfillmentContext::new();
7071
let cause = ObligationCause::new(span, id, ConstPatternStructural);
7172
// require `#[derive(PartialEq)]`
72-
let structural_peq_def_id = infcx.tcx.lang_items().structural_peq_trait().unwrap();
73+
let structural_peq_def_id = infcx.tcx.require_lang_item(StructuralPeqTraitLangItem, Some(span));
7374
fulfillment_cx.register_bound(
7475
infcx,
7576
ty::ParamEnv::empty(),
@@ -80,7 +81,7 @@ pub fn type_marked_structural(
8081
// for now, require `#[derive(Eq)]`. (Doing so is a hack to work around
8182
// the type `for<'a> fn(&'a ())` failing to implement `Eq` itself.)
8283
let cause = ObligationCause::new(span, id, ConstPatternStructural);
83-
let structural_teq_def_id = infcx.tcx.lang_items().structural_teq_trait().unwrap();
84+
let structural_teq_def_id = infcx.tcx.require_lang_item(StructuralTeqTraitLangItem, Some(span));
8485
fulfillment_cx.register_bound(
8586
infcx,
8687
ty::ParamEnv::empty(),

‎src/librustc_typeck/check/closure.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::astconv::AstConv;
66
use crate::middle::region;
77
use rustc_hir as hir;
88
use rustc_hir::def_id::DefId;
9-
use rustc_hir::lang_items;
9+
use rustc_hir::lang_items::{FutureTraitLangItem, GeneratorTraitLangItem};
1010
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
1111
use rustc_infer::infer::LateBoundRegionConversionTime;
1212
use rustc_infer::infer::{InferOk, InferResult};
@@ -245,7 +245,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
245245
let trait_ref = projection.to_poly_trait_ref(tcx);
246246

247247
let is_fn = tcx.fn_trait_kind_from_lang_item(trait_ref.def_id()).is_some();
248-
let gen_trait = tcx.require_lang_item(lang_items::GeneratorTraitLangItem, cause_span);
248+
let gen_trait = tcx.require_lang_item(GeneratorTraitLangItem, cause_span);
249249
let is_gen = gen_trait == trait_ref.def_id();
250250
if !is_fn && !is_gen {
251251
debug!("deduce_sig_from_projection: not fn or generator");
@@ -678,7 +678,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
678678

679679
// Check that this is a projection from the `Future` trait.
680680
let trait_ref = predicate.projection_ty.trait_ref(self.tcx);
681-
let future_trait = self.tcx.lang_items().future_trait().unwrap();
681+
let future_trait = self.tcx.require_lang_item(FutureTraitLangItem, Some(cause_span));
682682
if trait_ref.def_id != future_trait {
683683
debug!("deduce_future_output_from_projection: not a future");
684684
return None;

‎src/librustc_typeck/check/demand.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_trait_selection::traits::{self, ObligationCause};
77
use rustc_ast::util::parser::PREC_POSTFIX;
88
use rustc_errors::{Applicability, DiagnosticBuilder};
99
use rustc_hir as hir;
10-
use rustc_hir::lang_items::DerefTraitLangItem;
10+
use rustc_hir::lang_items::{CloneTraitLangItem, DerefTraitLangItem};
1111
use rustc_hir::{is_range_literal, Node};
1212
use rustc_middle::ty::adjustment::AllowTwoPhase;
1313
use rustc_middle::ty::{self, AssocItem, Ty, TypeAndMut};
@@ -456,8 +456,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
456456
};
457457
if self.can_coerce(ref_ty, expected) {
458458
let mut sugg_sp = sp;
459-
if let hir::ExprKind::MethodCall(segment, _sp, args) = &expr.kind {
460-
let clone_trait = self.tcx.lang_items().clone_trait().unwrap();
459+
if let hir::ExprKind::MethodCall(ref segment, sp, ref args) = expr.kind {
460+
let clone_trait = self.tcx.require_lang_item(CloneTraitLangItem, Some(sp));
461461
if let ([arg], Some(true), sym::clone) = (
462462
&args[..],
463463
self.tables.borrow().type_dependent_def_id(expr.hir_id).map(|did| {
@@ -635,7 +635,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
635635
_ if sp == expr.span && !is_macro => {
636636
// Check for `Deref` implementations by constructing a predicate to
637637
// prove: `<T as Deref>::Output == U`
638-
let deref_trait = self.tcx.require_lang_item(DerefTraitLangItem, Some(expr.span));
638+
let deref_trait = self.tcx.require_lang_item(DerefTraitLangItem, Some(sp));
639639
let item_def_id = self
640640
.tcx
641641
.associated_items(deref_trait)

‎src/librustc_typeck/check/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ use rustc_hir::def::{CtorOf, DefKind, Res};
100100
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE};
101101
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
102102
use rustc_hir::itemlikevisit::ItemLikeVisitor;
103-
use rustc_hir::lang_items;
103+
use rustc_hir::lang_items::{
104+
FutureTraitLangItem, PinTypeLangItem, SizedTraitLangItem, VaListTypeLangItem,
105+
};
104106
use rustc_hir::{ExprKind, GenericArg, HirIdMap, Item, ItemKind, Node, PatKind, QPath};
105107
use rustc_index::bit_set::BitSet;
106108
use rustc_index::vec::Idx;
@@ -1335,10 +1337,8 @@ fn check_fn<'a, 'tcx>(
13351337
// C-variadic fns also have a `VaList` input that's not listed in `fn_sig`
13361338
// (as it's created inside the body itself, not passed in from outside).
13371339
let maybe_va_list = if fn_sig.c_variadic {
1338-
let va_list_did = tcx.require_lang_item(
1339-
lang_items::VaListTypeLangItem,
1340-
Some(body.params.last().unwrap().span),
1341-
);
1340+
let va_list_did =
1341+
tcx.require_lang_item(VaListTypeLangItem, Some(body.params.last().unwrap().span));
13421342
let region = tcx.mk_region(ty::ReScope(region::Scope {
13431343
id: body.value.hir_id.local_id,
13441344
data: region::ScopeData::CallSite,
@@ -3296,7 +3296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
32963296
code: traits::ObligationCauseCode<'tcx>,
32973297
) {
32983298
if !ty.references_error() {
3299-
let lang_item = self.tcx.require_lang_item(lang_items::SizedTraitLangItem, None);
3299+
let lang_item = self.tcx.require_lang_item(SizedTraitLangItem, None);
33003300
self.require_type_meets(ty, span, code, lang_item);
33013301
}
33023302
}
@@ -5135,7 +5135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
51355135
_ => {}
51365136
}
51375137
let boxed_found = self.tcx.mk_box(found);
5138-
let new_found = self.tcx.mk_lang_item(boxed_found, lang_items::PinTypeLangItem).unwrap();
5138+
let new_found = self.tcx.mk_lang_item(boxed_found, PinTypeLangItem).unwrap();
51395139
if let (true, Ok(snippet)) = (
51405140
self.can_coerce(new_found, expected),
51415141
self.sess().source_map().span_to_snippet(expr.span),
@@ -5292,7 +5292,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
52925292
let sp = expr.span;
52935293
// Check for `Future` implementations by constructing a predicate to
52945294
// prove: `<T as Future>::Output == U`
5295-
let future_trait = self.tcx.lang_items().future_trait().unwrap();
5295+
let future_trait = self.tcx.require_lang_item(FutureTraitLangItem, Some(sp));
52965296
let item_def_id = self
52975297
.tcx
52985298
.associated_items(future_trait)

‎src/librustc_typeck/coherence/builtin.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
use rustc_errors::struct_span_err;
55
use rustc_hir as hir;
66
use rustc_hir::def_id::{DefId, LocalDefId};
7-
use rustc_hir::lang_items::UnsizeTraitLangItem;
7+
use rustc_hir::lang_items::{
8+
CoerceUnsizedTraitLangItem, DispatchFromDynTraitLangItem, UnsizeTraitLangItem,
9+
};
810
use rustc_hir::ItemKind;
911
use rustc_infer::infer;
1012
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
@@ -145,11 +147,11 @@ fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'tcx>, impl_did: LocalDefI
145147
fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
146148
debug!("visit_implementation_of_dispatch_from_dyn: impl_did={:?}", impl_did);
147149

148-
let dispatch_from_dyn_trait = tcx.lang_items().dispatch_from_dyn_trait().unwrap();
149-
150150
let impl_hir_id = tcx.hir().as_local_hir_id(impl_did);
151151
let span = tcx.hir().span(impl_hir_id);
152152

153+
let dispatch_from_dyn_trait = tcx.require_lang_item(DispatchFromDynTraitLangItem, Some(span));
154+
153155
let source = tcx.type_of(impl_did);
154156
assert!(!source.has_escaping_bound_vars());
155157
let target = {
@@ -314,22 +316,23 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
314316

315317
pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo {
316318
debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did);
317-
let coerce_unsized_trait = tcx.lang_items().coerce_unsized_trait().unwrap();
319+
320+
// this provider should only get invoked for local def-ids
321+
let impl_hir_id = tcx.hir().as_local_hir_id(impl_did.expect_local());
322+
let span = tcx.hir().span(impl_hir_id);
323+
324+
let coerce_unsized_trait = tcx.require_lang_item(CoerceUnsizedTraitLangItem, Some(span));
318325

319326
let unsize_trait = tcx.lang_items().require(UnsizeTraitLangItem).unwrap_or_else(|err| {
320327
tcx.sess.fatal(&format!("`CoerceUnsized` implementation {}", err));
321328
});
322329

323-
// this provider should only get invoked for local def-ids
324-
let impl_hir_id = tcx.hir().as_local_hir_id(impl_did.expect_local());
325-
326330
let source = tcx.type_of(impl_did);
327331
let trait_ref = tcx.impl_trait_ref(impl_did).unwrap();
328332
assert_eq!(trait_ref.def_id, coerce_unsized_trait);
329333
let target = trait_ref.substs.type_at(1);
330334
debug!("visit_implementation_of_coerce_unsized: {:?} -> {:?} (bound)", source, target);
331335

332-
let span = tcx.hir().span(impl_hir_id);
333336
let param_env = tcx.param_env(impl_did);
334337
assert!(!source.has_escaping_bound_vars());
335338

‎src/libstd/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ pub enum Prefix<'a> {
157157
#[stable(feature = "rust1", since = "1.0.0")] &'a OsStr,
158158
),
159159

160-
/// Verbatim disk prefix, e.g., `\\?\C:\`.
160+
/// Verbatim disk prefix, e.g., `\\?\C:`.
161161
///
162162
/// Verbatim disk prefixes consist of `\\?\` immediately followed by the
163-
/// drive letter and `:\`.
163+
/// drive letter and `:`.
164164
#[stable(feature = "rust1", since = "1.0.0")]
165165
VerbatimDisk(#[stable(feature = "rust1", since = "1.0.0")] u8),
166166

‎src/tools/rustbook/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ codespan-reporting = { version = "0.5", optional = true }
2323
rustc-workspace-hack = "1.0.0"
2424

2525
[dependencies.mdbook]
26-
version = "0.3.0"
26+
version = "0.3.7"
2727
default-features = false
2828
features = ["search"]

0 commit comments

Comments
 (0)
This repository has been archived.