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
This commit is contained in:
bors 2017-06-18 17:29:58 +00:00
commit 247a0184ff
20 changed files with 323 additions and 39 deletions

9
src/Cargo.lock generated
View File

@ -251,6 +251,14 @@ dependencies = [
"gcc 0.3.50 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "collections"
version = "0.0.0"
dependencies = [
"alloc 0.0.0",
"core 0.0.0",
]
[[package]]
name = "compiler_builtins"
version = "0.0.0"
@ -1586,6 +1594,7 @@ dependencies = [
"alloc_jemalloc 0.0.0",
"alloc_system 0.0.0",
"build_helper 0.1.0",
"collections 0.0.0",
"compiler_builtins 0.0.0",
"core 0.0.0",
"gcc 0.3.50 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -550,6 +550,7 @@ pub fn rust_src(build: &Build) {
"src/liballoc_jemalloc",
"src/liballoc_system",
"src/libbacktrace",
"src/libcollections",
"src/libcompiler_builtins",
"src/libcore",
"src/liblibc",

View File

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

View File

@ -242,11 +242,18 @@ Arguments:
let cwd = t!(env::current_dir());
let paths = matches.free[1..].iter().map(|p| cwd.join(p)).collect::<Vec<_>>();
let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| {
if fs::metadata("config.toml").is_ok() {
Some(PathBuf::from("config.toml"))
} else {
None
}
});
// All subcommands can have an optional "Available paths" section
if matches.opt_present("verbose") {
let flags = Flags::parse(&["build".to_string()]);
let mut config = Config::default();
let mut config = Config::parse(&flags.build, cfg_file.clone());
config.build = flags.build.clone();
let mut build = Build::new(flags, config);
metadata::build(&mut build);
@ -307,14 +314,6 @@ Arguments:
};
let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| {
if fs::metadata("config.toml").is_ok() {
Some(PathBuf::from("config.toml"))
} else {
None
}
});
let mut stage = matches.opt_str("stage").map(|j| j.parse().unwrap());
if matches.opt_present("incremental") {

View File

@ -154,19 +154,19 @@ token : simple_token | ident | literal | symbol | whitespace token ;
<p id="keyword-table-marker"></p>
| | | | | |
|----------|----------|----------|----------|---------|
| abstract | alignof | as | become | box |
| break | const | continue | crate | do |
| else | enum | extern | false | final |
| fn | for | if | impl | in |
| let | loop | macro | match | mod |
| move | mut | offsetof | override | priv |
| proc | pub | pure | ref | return |
| Self | self | sizeof | static | struct |
| super | trait | true | type | typeof |
| unsafe | unsized | use | virtual | where |
| while | yield | | | |
| | | | | |
|----------|----------|----------|----------|----------|
| _ | abstract | alignof | as | become |
| box | break | const | continue | crate |
| do | else | enum | extern | false |
| final | fn | for | if | impl |
| in | let | loop | macro | match |
| mod | move | mut | offsetof | override |
| priv | proc | pub | pure | ref |
| return | Self | self | sizeof | static |
| struct | super | trait | true | type |
| typeof | unsafe | unsized | use | virtual |
| where | while | yield | | |
Each of these keywords has special meaning in its grammar, and all of them are

View File

@ -108,6 +108,7 @@
- [char_escape_debug](library-features/char-escape-debug.md)
- [coerce_unsized](library-features/coerce-unsized.md)
- [collection_placement](library-features/collection-placement.md)
- [collections](library-features/collections.md)
- [collections_range](library-features/collections-range.md)
- [command_envs](library-features/command-envs.md)
- [compiler_builtins_lib](library-features/compiler-builtins-lib.md)

View File

@ -0,0 +1,5 @@
# `collections`
This feature is internal to the Rust compiler and is not intended for general use.
------------------------

View File

@ -0,0 +1,12 @@
[package]
authors = ["The Rust Project Developers"]
name = "collections"
version = "0.0.0"
[lib]
name = "collections"
path = "lib.rs"
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }

72
src/libcollections/lib.rs Normal file
View File

@ -0,0 +1,72 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![crate_name = "collections"]
#![crate_type = "rlib"]
#![allow(unused_attributes)]
#![unstable(feature = "collections",
reason = "this library is unlikely to be stabilized in its current \
form or name",
issue = "27783")]
#![rustc_deprecated(since = "1.20.0",
reason = "collections moved to `alloc`")]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
#![no_std]
#![needs_allocator]
#![deny(warnings)]
#![feature(alloc)]
#![feature(collections_range)]
#![feature(macro_reexport)]
#![feature(needs_allocator)]
#![feature(staged_api)]
//! Collection types
//!
//! See [`std::collections`](../std/collections/index.html) for a detailed
//! discussion of collections in Rust.
#[macro_reexport(vec, format)]
extern crate alloc;
pub use alloc::Bound;
pub use alloc::binary_heap;
pub use alloc::borrow;
pub use alloc::fmt;
pub use alloc::linked_list;
pub use alloc::range;
pub use alloc::slice;
pub use alloc::str;
pub use alloc::string;
pub use alloc::vec;
pub use alloc::vec_deque;
pub use alloc::btree_map;
pub use alloc::btree_set;
#[doc(no_inline)]
pub use alloc::binary_heap::BinaryHeap;
#[doc(no_inline)]
pub use alloc::btree_map::BTreeMap;
#[doc(no_inline)]
pub use alloc::btree_set::BTreeSet;
#[doc(no_inline)]
pub use alloc::linked_list::LinkedList;
#[doc(no_inline)]
pub use alloc::vec_deque::VecDeque;
#[doc(no_inline)]
pub use alloc::string::String;
#[doc(no_inline)]
pub use alloc::vec::Vec;

View File

@ -618,7 +618,10 @@ impl<'a, 'b> StrSearcher<'a, 'b> {
}
unsafe impl<'a, 'b> Searcher<'a> for StrSearcher<'a, 'b> {
fn haystack(&self) -> &'a str { self.haystack }
#[inline]
fn haystack(&self) -> &'a str {
self.haystack
}
#[inline]
fn next(&mut self) -> SearchStep {

View File

@ -774,21 +774,26 @@ fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>,
},
ty::TyRef(_, ref ty_and_mut) => vec![ty_and_mut.ty],
ty::TyAdt(adt, substs) => {
adt.variants[ctor.variant_index_for_adt(adt)].fields.iter().map(|field| {
let is_visible = adt.is_enum()
|| field.vis.is_accessible_from(cx.module, cx.tcx);
if is_visible {
field.ty(cx.tcx, substs)
} else {
// Treat all non-visible fields as nil. They
// can't appear in any other pattern from
// this match (because they are private),
// so their type does not matter - but
// we don't want to know they are
// uninhabited.
cx.tcx.mk_nil()
}
}).collect()
if adt.is_box() {
// Use T as the sub pattern type of Box<T>.
vec![substs[0].as_type().unwrap()]
} else {
adt.variants[ctor.variant_index_for_adt(adt)].fields.iter().map(|field| {
let is_visible = adt.is_enum()
|| field.vis.is_accessible_from(cx.module, cx.tcx);
if is_visible {
field.ty(cx.tcx, substs)
} else {
// Treat all non-visible fields as nil. They
// can't appear in any other pattern from
// this match (because they are private),
// so their type does not matter - but
// we don't want to know they are
// uninhabited.
cx.tcx.mk_nil()
}
}).collect()
}
}
_ => vec![],
}

View File

@ -15,6 +15,7 @@ alloc_jemalloc = { path = "../liballoc_jemalloc", optional = true }
alloc_system = { path = "../liballoc_system" }
panic_unwind = { path = "../libpanic_unwind", optional = true }
panic_abort = { path = "../libpanic_abort" }
collections = { path = "../libcollections" }
core = { path = "../libcore" }
libc = { path = "../rustc/libc_shim" }
rand = { path = "../librand" }

View File

@ -0,0 +1,38 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_attrs)]
#![allow(warnings)]
struct Attr {
name: String,
value: String,
}
struct Element {
attrs: Vec<Box<Attr>>,
}
impl Element {
pub unsafe fn get_attr<'a>(&'a self, name: &str) {
self.attrs
.iter()
.find(|attr| {
let attr: &&Box<Attr> = std::mem::transmute(attr);
true
});
}
}
#[rustc_error]
fn main() { //~ ERROR compilation successful
let element = Element { attrs: Vec::new() };
let _ = unsafe { element.get_attr("foo") };
}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,27 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_attrs)]
#![allow(warnings)]
trait Mirror {
type It;
}
impl<T> Mirror for T {
type It = Self;
}
#[rustc_error]
fn main() { //~ ERROR compilation successful
let c: <u32 as Mirror>::It = 5;
const CCCC: <u32 as Mirror>::It = 5;
}

View File

@ -0,0 +1,31 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
#![feature(box_patterns)]
#[derive(Debug, PartialEq)]
enum Test {
Foo(usize),
Bar(isize),
}
fn main() {
let a = box Test::Foo(10);
let b = box Test::Bar(-20);
match (a, b) {
(_, box Test::Foo(_)) => unreachable!(),
(box Test::Foo(x), b) => {
assert_eq!(x, 10);
assert_eq!(b, box Test::Bar(-20));
},
_ => unreachable!(),
}
}

View File

@ -14,6 +14,10 @@ fn plus_one(x: i32) -> i32 {
x + 1;
}
fn foo() -> Result<u8, u64> {
Ok(1);
}
fn main() {
let x = plus_one(5);
println!("X = {}", x);

View File

@ -15,5 +15,22 @@ help: consider removing this semicolon:
14 | x + 1;
| ^
error[E0308]: mismatched types
--> $DIR/coercion-missing-tail-expected-type.rs:17:29
|
17 | fn foo() -> Result<u8, u64> {
| _____________________________^
18 | | Ok(1);
19 | | }
| |_^ expected enum `std::result::Result`, found ()
|
= note: expected type `std::result::Result<u8, u64>`
found type `()`
help: consider removing this semicolon:
--> $DIR/coercion-missing-tail-expected-type.rs:18:10
|
18 | Ok(1);
| ^
error: aborting due to previous error(s)