Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #42739

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 8 additions & 9 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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") {
Expand Down
26 changes: 13 additions & 13 deletions src/doc/grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/doc/unstable-book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/doc/unstable-book/src/library-features/collections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# `collections`

This feature is internal to the Rust compiler and is not intended for general use.

------------------------
12 changes: 12 additions & 0 deletions src/libcollections/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 changes: 72 additions & 0 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 4 additions & 1 deletion src/libcore/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
35 changes: 20 additions & 15 deletions src/librustc_const_eval/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![],
}
Expand Down
1 change: 1 addition & 0 deletions src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
38 changes: 38 additions & 0 deletions src/test/compile-fail/issue-11740.rs
Original file line number Diff line number Diff line change
@@ -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") };
}
19 changes: 19 additions & 0 deletions src/test/compile-fail/issue-19601.rs
Original file line number Diff line number Diff line change
@@ -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
}
23 changes: 23 additions & 0 deletions src/test/compile-fail/issue-22603.rs
Original file line number Diff line number Diff line change
@@ -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"));
}
17 changes: 17 additions & 0 deletions src/test/compile-fail/issue-22789.rs
Original file line number Diff line number Diff line change
@@ -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,));
}
27 changes: 27 additions & 0 deletions src/test/compile-fail/issue-26614.rs
Original file line number Diff line number Diff line change
@@ -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;
}
Loading