Skip to content

Commit 247a018

Browse files
committed
Auto merge of #42738 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 7 pull requests - Successful merges: #42695, #42714, #42720, #42723, #42730, #42731, #42734 - Failed merges: #42722
2 parents 28cc0c5 + 3bed3bd commit 247a018

File tree

20 files changed

+323
-39
lines changed

20 files changed

+323
-39
lines changed

src/Cargo.lock

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/dist.rs

+1
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ pub fn rust_src(build: &Build) {
550550
"src/liballoc_jemalloc",
551551
"src/liballoc_system",
552552
"src/libbacktrace",
553+
"src/libcollections",
553554
"src/libcompiler_builtins",
554555
"src/libcore",
555556
"src/liblibc",

src/bootstrap/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ pub fn std(build: &Build, stage: u32, target: &str) {
254254
// for which docs must be built.
255255
if !build.config.compiler_docs {
256256
cargo.arg("--no-deps");
257-
for krate in &["alloc", "core", "std", "std_unicode"] {
257+
for krate in &["alloc", "collections", "core", "std", "std_unicode"] {
258258
cargo.arg("-p").arg(krate);
259259
// Create all crate output directories first to make sure rustdoc uses
260260
// relative links.

src/bootstrap/flags.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,18 @@ Arguments:
242242
let cwd = t!(env::current_dir());
243243
let paths = matches.free[1..].iter().map(|p| cwd.join(p)).collect::<Vec<_>>();
244244

245+
let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| {
246+
if fs::metadata("config.toml").is_ok() {
247+
Some(PathBuf::from("config.toml"))
248+
} else {
249+
None
250+
}
251+
});
245252

246253
// All subcommands can have an optional "Available paths" section
247254
if matches.opt_present("verbose") {
248255
let flags = Flags::parse(&["build".to_string()]);
249-
let mut config = Config::default();
256+
let mut config = Config::parse(&flags.build, cfg_file.clone());
250257
config.build = flags.build.clone();
251258
let mut build = Build::new(flags, config);
252259
metadata::build(&mut build);
@@ -307,14 +314,6 @@ Arguments:
307314
};
308315

309316

310-
let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| {
311-
if fs::metadata("config.toml").is_ok() {
312-
Some(PathBuf::from("config.toml"))
313-
} else {
314-
None
315-
}
316-
});
317-
318317
let mut stage = matches.opt_str("stage").map(|j| j.parse().unwrap());
319318

320319
if matches.opt_present("incremental") {

src/doc/grammar.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,19 @@ token : simple_token | ident | literal | symbol | whitespace token ;
154154

155155
<p id="keyword-table-marker"></p>
156156

157-
| | | | | |
158-
|----------|----------|----------|----------|---------|
159-
| abstract | alignof | as | become | box |
160-
| break | const | continue | crate | do |
161-
| else | enum | extern | false | final |
162-
| fn | for | if | impl | in |
163-
| let | loop | macro | match | mod |
164-
| move | mut | offsetof | override | priv |
165-
| proc | pub | pure | ref | return |
166-
| Self | self | sizeof | static | struct |
167-
| super | trait | true | type | typeof |
168-
| unsafe | unsized | use | virtual | where |
169-
| while | yield | | | |
157+
| | | | | |
158+
|----------|----------|----------|----------|----------|
159+
| _ | abstract | alignof | as | become |
160+
| box | break | const | continue | crate |
161+
| do | else | enum | extern | false |
162+
| final | fn | for | if | impl |
163+
| in | let | loop | macro | match |
164+
| mod | move | mut | offsetof | override |
165+
| priv | proc | pub | pure | ref |
166+
| return | Self | self | sizeof | static |
167+
| struct | super | trait | true | type |
168+
| typeof | unsafe | unsized | use | virtual |
169+
| where | while | yield | | |
170170

171171

172172
Each of these keywords has special meaning in its grammar, and all of them are

src/doc/unstable-book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
- [char_escape_debug](library-features/char-escape-debug.md)
109109
- [coerce_unsized](library-features/coerce-unsized.md)
110110
- [collection_placement](library-features/collection-placement.md)
111+
- [collections](library-features/collections.md)
111112
- [collections_range](library-features/collections-range.md)
112113
- [command_envs](library-features/command-envs.md)
113114
- [compiler_builtins_lib](library-features/compiler-builtins-lib.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# `collections`
2+
3+
This feature is internal to the Rust compiler and is not intended for general use.
4+
5+
------------------------

src/libcollections/Cargo.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
authors = ["The Rust Project Developers"]
3+
name = "collections"
4+
version = "0.0.0"
5+
6+
[lib]
7+
name = "collections"
8+
path = "lib.rs"
9+
10+
[dependencies]
11+
alloc = { path = "../liballoc" }
12+
core = { path = "../libcore" }

src/libcollections/lib.rs

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name = "collections"]
12+
#![crate_type = "rlib"]
13+
#![allow(unused_attributes)]
14+
#![unstable(feature = "collections",
15+
reason = "this library is unlikely to be stabilized in its current \
16+
form or name",
17+
issue = "27783")]
18+
#![rustc_deprecated(since = "1.20.0",
19+
reason = "collections moved to `alloc`")]
20+
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
21+
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
22+
html_root_url = "https://doc.rust-lang.org/nightly/",
23+
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
24+
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
25+
#![no_std]
26+
#![needs_allocator]
27+
#![deny(warnings)]
28+
29+
#![feature(alloc)]
30+
#![feature(collections_range)]
31+
#![feature(macro_reexport)]
32+
#![feature(needs_allocator)]
33+
#![feature(staged_api)]
34+
35+
//! Collection types
36+
//!
37+
//! See [`std::collections`](../std/collections/index.html) for a detailed
38+
//! discussion of collections in Rust.
39+
40+
#[macro_reexport(vec, format)]
41+
extern crate alloc;
42+
43+
pub use alloc::Bound;
44+
45+
pub use alloc::binary_heap;
46+
pub use alloc::borrow;
47+
pub use alloc::fmt;
48+
pub use alloc::linked_list;
49+
pub use alloc::range;
50+
pub use alloc::slice;
51+
pub use alloc::str;
52+
pub use alloc::string;
53+
pub use alloc::vec;
54+
pub use alloc::vec_deque;
55+
56+
pub use alloc::btree_map;
57+
pub use alloc::btree_set;
58+
59+
#[doc(no_inline)]
60+
pub use alloc::binary_heap::BinaryHeap;
61+
#[doc(no_inline)]
62+
pub use alloc::btree_map::BTreeMap;
63+
#[doc(no_inline)]
64+
pub use alloc::btree_set::BTreeSet;
65+
#[doc(no_inline)]
66+
pub use alloc::linked_list::LinkedList;
67+
#[doc(no_inline)]
68+
pub use alloc::vec_deque::VecDeque;
69+
#[doc(no_inline)]
70+
pub use alloc::string::String;
71+
#[doc(no_inline)]
72+
pub use alloc::vec::Vec;

src/libcore/str/pattern.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,10 @@ impl<'a, 'b> StrSearcher<'a, 'b> {
618618
}
619619

620620
unsafe impl<'a, 'b> Searcher<'a> for StrSearcher<'a, 'b> {
621-
fn haystack(&self) -> &'a str { self.haystack }
621+
#[inline]
622+
fn haystack(&self) -> &'a str {
623+
self.haystack
624+
}
622625

623626
#[inline]
624627
fn next(&mut self) -> SearchStep {

src/librustc_const_eval/_match.rs

+20-15
Original file line numberDiff line numberDiff line change
@@ -774,21 +774,26 @@ fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>,
774774
},
775775
ty::TyRef(_, ref ty_and_mut) => vec![ty_and_mut.ty],
776776
ty::TyAdt(adt, substs) => {
777-
adt.variants[ctor.variant_index_for_adt(adt)].fields.iter().map(|field| {
778-
let is_visible = adt.is_enum()
779-
|| field.vis.is_accessible_from(cx.module, cx.tcx);
780-
if is_visible {
781-
field.ty(cx.tcx, substs)
782-
} else {
783-
// Treat all non-visible fields as nil. They
784-
// can't appear in any other pattern from
785-
// this match (because they are private),
786-
// so their type does not matter - but
787-
// we don't want to know they are
788-
// uninhabited.
789-
cx.tcx.mk_nil()
790-
}
791-
}).collect()
777+
if adt.is_box() {
778+
// Use T as the sub pattern type of Box<T>.
779+
vec![substs[0].as_type().unwrap()]
780+
} else {
781+
adt.variants[ctor.variant_index_for_adt(adt)].fields.iter().map(|field| {
782+
let is_visible = adt.is_enum()
783+
|| field.vis.is_accessible_from(cx.module, cx.tcx);
784+
if is_visible {
785+
field.ty(cx.tcx, substs)
786+
} else {
787+
// Treat all non-visible fields as nil. They
788+
// can't appear in any other pattern from
789+
// this match (because they are private),
790+
// so their type does not matter - but
791+
// we don't want to know they are
792+
// uninhabited.
793+
cx.tcx.mk_nil()
794+
}
795+
}).collect()
796+
}
792797
}
793798
_ => vec![],
794799
}

src/libstd/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ alloc_jemalloc = { path = "../liballoc_jemalloc", optional = true }
1515
alloc_system = { path = "../liballoc_system" }
1616
panic_unwind = { path = "../libpanic_unwind", optional = true }
1717
panic_abort = { path = "../libpanic_abort" }
18+
collections = { path = "../libcollections" }
1819
core = { path = "../libcore" }
1920
libc = { path = "../rustc/libc_shim" }
2021
rand = { path = "../librand" }

src/test/compile-fail/issue-11740.rs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
#![allow(warnings)]
13+
14+
struct Attr {
15+
name: String,
16+
value: String,
17+
}
18+
19+
struct Element {
20+
attrs: Vec<Box<Attr>>,
21+
}
22+
23+
impl Element {
24+
pub unsafe fn get_attr<'a>(&'a self, name: &str) {
25+
self.attrs
26+
.iter()
27+
.find(|attr| {
28+
let attr: &&Box<Attr> = std::mem::transmute(attr);
29+
true
30+
});
31+
}
32+
}
33+
34+
#[rustc_error]
35+
fn main() { //~ ERROR compilation successful
36+
let element = Element { attrs: Vec::new() };
37+
let _ = unsafe { element.get_attr("foo") };
38+
}

src/test/compile-fail/issue-19601.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
#![allow(warnings)]
13+
14+
trait A<T> {}
15+
struct B<T> where B<T>: A<B<T>> { t: T }
16+
17+
#[rustc_error]
18+
fn main() { //~ ERROR compilation successful
19+
}

src/test/compile-fail/issue-22603.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(unboxed_closures, fn_traits, rustc_attrs)]
12+
13+
struct Foo;
14+
15+
impl<A> FnOnce<(A,)> for Foo {
16+
type Output = ();
17+
extern "rust-call" fn call_once(self, (_,): (A,)) {
18+
}
19+
}
20+
#[rustc_error]
21+
fn main() { //~ ERROR compilation successful
22+
println!("{:?}", Foo("bar"));
23+
}

src/test/compile-fail/issue-22789.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(unboxed_closures, fn_traits, rustc_attrs)]
12+
13+
#[rustc_error]
14+
fn main() { //~ ERROR compilation successful
15+
let k = |x: i32| { x + 1 };
16+
Fn::call(&k, (0,));
17+
}

src/test/compile-fail/issue-26614.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
#![allow(warnings)]
13+
14+
trait Mirror {
15+
type It;
16+
}
17+
18+
impl<T> Mirror for T {
19+
type It = Self;
20+
}
21+
22+
23+
#[rustc_error]
24+
fn main() { //~ ERROR compilation successful
25+
let c: <u32 as Mirror>::It = 5;
26+
const CCCC: <u32 as Mirror>::It = 5;
27+
}

0 commit comments

Comments
 (0)