Skip to content

Commit 7daf890

Browse files
committed
Merge branch 'master' into wasi
2 parents 744442d + 1489095 commit 7daf890

File tree

152 files changed

+3827
-3054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+3827
-3054
lines changed

Cargo.lock

Lines changed: 1895 additions & 1896 deletions
Large diffs are not rendered by default.

src/doc/rustc-ux-guidelines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ for details on how to format and write long error codes.
7070
[librustc_privacy](https://github.com/rust-lang/rust/blob/master/src/librustc_privacy/error_codes.rs),
7171
[librustc_resolve](https://github.com/rust-lang/rust/blob/master/src/librustc_resolve/error_codes.rs),
7272
[librustc_codegen_llvm](https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/error_codes.rs),
73-
[librustc_plugin](https://github.com/rust-lang/rust/blob/master/src/librustc_plugin/error_codes.rs),
73+
[librustc_plugin_impl](https://github.com/rust-lang/rust/blob/master/src/librustc_plugin/error_codes.rs),
7474
[librustc_typeck](https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/error_codes.rs).
7575
* Explanations have full markdown support. Use it, especially to highlight
7676
code with backticks.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# `or_patterns`
2+
3+
The tracking issue for this feature is: [#54883]
4+
5+
[#54883]: https://github.com/rust-lang/rust/issues/54883
6+
7+
------------------------
8+
9+
The `or_pattern` language feature allows `|` to be arbitrarily nested within
10+
a pattern, for example, `Some(A(0) | B(1 | 2))` becomes a valid pattern.
11+
12+
## Examples
13+
14+
```rust,ignore
15+
#![feature(or_patterns)]
16+
17+
pub enum Foo {
18+
Bar,
19+
Baz,
20+
Quux,
21+
}
22+
23+
pub fn example(maybe_foo: Option<Foo>) {
24+
match maybe_foo {
25+
Some(Foo::Bar | Foo::Baz) => {
26+
println!("The value contained `Bar` or `Baz`");
27+
}
28+
Some(_) => {
29+
println!("The value did not contain `Bar` or `Baz`");
30+
}
31+
None => {
32+
println!("The value was `None`");
33+
}
34+
}
35+
}
36+
```

src/doc/unstable-book/src/language-features/plugin.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extend the compiler's behavior with new syntax extensions, lint checks, etc.
1818
A plugin is a dynamic library crate with a designated *registrar* function that
1919
registers extensions with `rustc`. Other crates can load these extensions using
2020
the crate attribute `#![plugin(...)]`. See the
21-
`rustc_plugin` documentation for more about the
21+
`rustc_driver::plugin` documentation for more about the
2222
mechanics of defining and loading a plugin.
2323

2424
If present, arguments passed as `#![plugin(foo(... args ...))]` are not
@@ -54,13 +54,13 @@ that implements Roman numeral integer literals.
5454
extern crate syntax;
5555
extern crate syntax_pos;
5656
extern crate rustc;
57-
extern crate rustc_plugin;
57+
extern crate rustc_driver;
5858
5959
use syntax::parse::token::{self, Token};
6060
use syntax::tokenstream::TokenTree;
6161
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
6262
use syntax_pos::Span;
63-
use rustc_plugin::Registry;
63+
use rustc_driver::plugin::Registry;
6464
6565
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
6666
-> Box<dyn MacResult + 'static> {
@@ -180,11 +180,11 @@ extern crate syntax;
180180
// Load rustc as a plugin to get macros
181181
#[macro_use]
182182
extern crate rustc;
183-
extern crate rustc_plugin;
183+
extern crate rustc_driver;
184184
185185
use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
186186
EarlyLintPassObject, LintArray};
187-
use rustc_plugin::Registry;
187+
use rustc_driver::plugin::Registry;
188188
use syntax::ast;
189189
190190
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");

src/liballoc/collections/vec_deque.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,31 @@ impl<T> VecDeque<T> {
11991199
}
12001200
}
12011201

1202+
/// Removes the last element from the `VecDeque` and returns it, or `None` if
1203+
/// it is empty.
1204+
///
1205+
/// # Examples
1206+
///
1207+
/// ```
1208+
/// use std::collections::VecDeque;
1209+
///
1210+
/// let mut buf = VecDeque::new();
1211+
/// assert_eq!(buf.pop_back(), None);
1212+
/// buf.push_back(1);
1213+
/// buf.push_back(3);
1214+
/// assert_eq!(buf.pop_back(), Some(3));
1215+
/// ```
1216+
#[stable(feature = "rust1", since = "1.0.0")]
1217+
pub fn pop_back(&mut self) -> Option<T> {
1218+
if self.is_empty() {
1219+
None
1220+
} else {
1221+
self.head = self.wrap_sub(self.head, 1);
1222+
let head = self.head;
1223+
unsafe { Some(self.buffer_read(head)) }
1224+
}
1225+
}
1226+
12021227
/// Prepends an element to the `VecDeque`.
12031228
///
12041229
/// # Examples
@@ -1243,38 +1268,13 @@ impl<T> VecDeque<T> {
12431268
unsafe { self.buffer_write(head, value) }
12441269
}
12451270

1246-
/// Removes the last element from the `VecDeque` and returns it, or `None` if
1247-
/// it is empty.
1248-
///
1249-
/// # Examples
1250-
///
1251-
/// ```
1252-
/// use std::collections::VecDeque;
1253-
///
1254-
/// let mut buf = VecDeque::new();
1255-
/// assert_eq!(buf.pop_back(), None);
1256-
/// buf.push_back(1);
1257-
/// buf.push_back(3);
1258-
/// assert_eq!(buf.pop_back(), Some(3));
1259-
/// ```
1260-
#[stable(feature = "rust1", since = "1.0.0")]
1261-
pub fn pop_back(&mut self) -> Option<T> {
1262-
if self.is_empty() {
1263-
None
1264-
} else {
1265-
self.head = self.wrap_sub(self.head, 1);
1266-
let head = self.head;
1267-
unsafe { Some(self.buffer_read(head)) }
1268-
}
1269-
}
1270-
12711271
#[inline]
12721272
fn is_contiguous(&self) -> bool {
12731273
self.tail <= self.head
12741274
}
12751275

1276-
/// Removes an element from anywhere in the `VecDeque` and returns it, replacing it with the
1277-
/// last element.
1276+
/// Removes an element from anywhere in the `VecDeque` and returns it,
1277+
/// replacing it with the first element.
12781278
///
12791279
/// This does not preserve ordering, but is O(1).
12801280
///
@@ -1288,28 +1288,28 @@ impl<T> VecDeque<T> {
12881288
/// use std::collections::VecDeque;
12891289
///
12901290
/// let mut buf = VecDeque::new();
1291-
/// assert_eq!(buf.swap_remove_back(0), None);
1291+
/// assert_eq!(buf.swap_remove_front(0), None);
12921292
/// buf.push_back(1);
12931293
/// buf.push_back(2);
12941294
/// buf.push_back(3);
12951295
/// assert_eq!(buf, [1, 2, 3]);
12961296
///
1297-
/// assert_eq!(buf.swap_remove_back(0), Some(1));
1298-
/// assert_eq!(buf, [3, 2]);
1297+
/// assert_eq!(buf.swap_remove_front(2), Some(3));
1298+
/// assert_eq!(buf, [2, 1]);
12991299
/// ```
13001300
#[stable(feature = "deque_extras_15", since = "1.5.0")]
1301-
pub fn swap_remove_back(&mut self, index: usize) -> Option<T> {
1301+
pub fn swap_remove_front(&mut self, index: usize) -> Option<T> {
13021302
let length = self.len();
1303-
if length > 0 && index < length - 1 {
1304-
self.swap(index, length - 1);
1303+
if length > 0 && index < length && index != 0 {
1304+
self.swap(index, 0);
13051305
} else if index >= length {
13061306
return None;
13071307
}
1308-
self.pop_back()
1308+
self.pop_front()
13091309
}
13101310

1311-
/// Removes an element from anywhere in the `VecDeque` and returns it,
1312-
/// replacing it with the first element.
1311+
/// Removes an element from anywhere in the `VecDeque` and returns it, replacing it with the
1312+
/// last element.
13131313
///
13141314
/// This does not preserve ordering, but is O(1).
13151315
///
@@ -1323,24 +1323,24 @@ impl<T> VecDeque<T> {
13231323
/// use std::collections::VecDeque;
13241324
///
13251325
/// let mut buf = VecDeque::new();
1326-
/// assert_eq!(buf.swap_remove_front(0), None);
1326+
/// assert_eq!(buf.swap_remove_back(0), None);
13271327
/// buf.push_back(1);
13281328
/// buf.push_back(2);
13291329
/// buf.push_back(3);
13301330
/// assert_eq!(buf, [1, 2, 3]);
13311331
///
1332-
/// assert_eq!(buf.swap_remove_front(2), Some(3));
1333-
/// assert_eq!(buf, [2, 1]);
1332+
/// assert_eq!(buf.swap_remove_back(0), Some(1));
1333+
/// assert_eq!(buf, [3, 2]);
13341334
/// ```
13351335
#[stable(feature = "deque_extras_15", since = "1.5.0")]
1336-
pub fn swap_remove_front(&mut self, index: usize) -> Option<T> {
1336+
pub fn swap_remove_back(&mut self, index: usize) -> Option<T> {
13371337
let length = self.len();
1338-
if length > 0 && index < length && index != 0 {
1339-
self.swap(index, 0);
1338+
if length > 0 && index < length - 1 {
1339+
self.swap(index, length - 1);
13401340
} else if index >= length {
13411341
return None;
13421342
}
1343-
self.pop_front()
1343+
self.pop_back()
13441344
}
13451345

13461346
/// Inserts an element at `index` within the `VecDeque`, shifting all elements with indices

src/liballoc/sync.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
107107
/// // a, b, and foo are all Arcs that point to the same memory location
108108
/// ```
109109
///
110-
/// The [`Arc::clone(&from)`] syntax is the most idiomatic because it conveys more explicitly
111-
/// the meaning of the code. In the example above, this syntax makes it easier to see that
112-
/// this code is creating a new reference rather than copying the whole content of foo.
113-
///
114110
/// ## `Deref` behavior
115111
///
116112
/// `Arc<T>` automatically dereferences to `T` (via the [`Deref`][deref] trait),

src/libproc_macro/bridge/client.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,14 @@ pub enum ProcMacro {
468468
}
469469

470470
impl ProcMacro {
471+
pub fn name(&self) -> &'static str {
472+
match self {
473+
ProcMacro::CustomDerive { trait_name, .. } => trait_name,
474+
ProcMacro::Attr { name, .. } => name,
475+
ProcMacro::Bang { name, ..} => name
476+
}
477+
}
478+
471479
pub const fn custom_derive(
472480
trait_name: &'static str,
473481
attributes: &'static [&'static str],

src/librustc/cfg/construct.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
140140
self.add_ast_node(pat.hir_id.local_id, &[pats_exit])
141141
}
142142

143+
PatKind::Or(ref pats) => {
144+
let branches: Vec<_> = pats.iter().map(|p| self.pat(p, pred)).collect();
145+
self.add_ast_node(pat.hir_id.local_id, &branches)
146+
}
147+
143148
PatKind::Slice(ref pre, ref vec, ref post) => {
144149
let pre_exit = self.pats_all(pre.iter(), pred);
145150
let vec_exit = self.pats_all(vec.iter(), pre_exit);

src/librustc/hir/def_id.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::ty::{self, TyCtxt};
2-
use crate::hir::map::definitions::FIRST_FREE_DEF_INDEX;
32
use rustc_data_structures::indexed_vec::Idx;
43
use std::fmt;
54
use std::u32;
@@ -102,31 +101,6 @@ newtype_index! {
102101
}
103102
}
104103

105-
impl DefIndex {
106-
// Proc macros from a proc-macro crate have a kind of virtual DefIndex. This
107-
// function maps the index of the macro within the crate (which is also the
108-
// index of the macro in the CrateMetadata::proc_macros array) to the
109-
// corresponding DefIndex.
110-
pub fn from_proc_macro_index(proc_macro_index: usize) -> DefIndex {
111-
// DefIndex for proc macros start from FIRST_FREE_DEF_INDEX,
112-
// because the first FIRST_FREE_DEF_INDEX indexes are reserved
113-
// for internal use.
114-
let def_index = DefIndex::from(
115-
proc_macro_index.checked_add(FIRST_FREE_DEF_INDEX)
116-
.expect("integer overflow adding `proc_macro_index`"));
117-
assert!(def_index != CRATE_DEF_INDEX);
118-
def_index
119-
}
120-
121-
// This function is the reverse of from_proc_macro_index() above.
122-
pub fn to_proc_macro_index(self: DefIndex) -> usize {
123-
self.index().checked_sub(FIRST_FREE_DEF_INDEX)
124-
.unwrap_or_else(|| {
125-
bug!("using local index {:?} as proc-macro index", self)
126-
})
127-
}
128-
}
129-
130104
impl rustc_serialize::UseSpecializedEncodable for DefIndex {}
131105
impl rustc_serialize::UseSpecializedDecodable for DefIndex {}
132106

src/librustc/hir/intravisit.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime
433433
LifetimeName::Static |
434434
LifetimeName::Error |
435435
LifetimeName::Implicit |
436+
LifetimeName::ImplicitObjectLifetimeDefault |
436437
LifetimeName::Underscore => {}
437438
}
438439
}
@@ -709,6 +710,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
709710
visitor.visit_pat(&field.pat)
710711
}
711712
}
713+
PatKind::Or(ref pats) => walk_list!(visitor, visit_pat, pats),
712714
PatKind::Tuple(ref tuple_elements, _) => {
713715
walk_list!(visitor, visit_pat, tuple_elements);
714716
}

0 commit comments

Comments
 (0)