Auto merge of #41987 - Mark-Simulacrum:rollup, r=Mark-Simulacrum

Rollup of 7 pull requests

- Successful merges: #41612, #41826, #41939, #41946, #41950, #41975, #41979
- Failed merges:
This commit is contained in:
bors 2017-05-14 03:00:34 +00:00
commit 94497b73a7
25 changed files with 196 additions and 81 deletions

34
src/Cargo.lock generated
View File

@ -27,7 +27,7 @@ version = "0.0.0"
dependencies = [
"build_helper 0.1.0",
"core 0.0.0",
"gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.0.0",
]
@ -73,9 +73,9 @@ name = "bootstrap"
version = "0.0.0"
dependencies = [
"build_helper 0.1.0",
"cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"cmake 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -119,10 +119,10 @@ dependencies = [
[[package]]
name = "cmake"
version = "0.1.22"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -140,7 +140,7 @@ version = "0.0.0"
dependencies = [
"build_helper 0.1.0",
"core 0.0.0",
"gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -194,7 +194,7 @@ name = "flate"
version = "0.0.0"
dependencies = [
"build_helper 0.1.0",
"gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -203,7 +203,7 @@ version = "0.0.0"
[[package]]
name = "gcc"
version = "0.3.45"
version = "0.3.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -473,7 +473,7 @@ version = "0.0.0"
dependencies = [
"alloc_system 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"cmake 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@ -606,7 +606,7 @@ name = "rustc_llvm"
version = "0.0.0"
dependencies = [
"build_helper 0.1.0",
"gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_bitflags 0.0.0",
]
@ -616,7 +616,7 @@ version = "0.0.0"
dependencies = [
"alloc_system 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"cmake 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@ -660,7 +660,7 @@ version = "0.0.0"
dependencies = [
"alloc_system 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"cmake 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@ -754,7 +754,7 @@ version = "0.0.0"
dependencies = [
"alloc_system 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"cmake 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@ -782,7 +782,7 @@ dependencies = [
"arena 0.0.0",
"build_helper 0.1.0",
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
@ -831,7 +831,7 @@ dependencies = [
"collections 0.0.0",
"compiler_builtins 0.0.0",
"core 0.0.0",
"gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.0.0",
"panic_abort 0.0.0",
"panic_unwind 0.0.0",
@ -997,12 +997,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f67931368edf3a9a51d29886d245f1c3db2f1ef0dcc9e35ff70341b78c10d23"
"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
"checksum clap 2.22.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e17a4a72ffea176f77d6e2db609c6c919ef221f23862c9915e687fb54d833485"
"checksum cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "d18d68987ed4c516dcc3e7913659bfa4076f5182eea4a7e0038bb060953e76ac"
"checksum cmake 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "92278eb79412c8f75cfc89e707a1bb3a6490b68f7f2e78d15c774f30fe701122"
"checksum diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0a515461b6c8c08419850ced27bc29e86166dcdcde8fbe76f8b1f0589bb49472"
"checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90"
"checksum env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e3856f1697098606fc6cb97a93de88ca3f3bc35bb878c725920e6e82ecf05e83"
"checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922"
"checksum gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)" = "40899336fb50db0c78710f53e87afc54d8c7266fb76262fecc78ca1a7f09deae"
"checksum gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)" = "181e3cebba1d663bd92eb90e2da787e10597e027eb00de8d742b260a7850948f"
"checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685"
"checksum handlebars 0.25.2 (registry+https://github.com/rust-lang/crates.io-index)" = "663e1728d8037fb0d4e13bcd1b1909fb5d913690a9929eb385922df157c2ff8f"
"checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c"

View File

@ -30,11 +30,11 @@ test = false
[dependencies]
build_helper = { path = "../build_helper" }
cmake = "0.1.17"
cmake = "0.1.23"
filetime = "0.1"
num_cpus = "1.0"
toml = "0.1"
getopts = "0.2"
rustc-serialize = "0.3"
gcc = "0.3.38"
gcc = "0.3.46"
libc = "0.2"

View File

@ -108,6 +108,7 @@ pub fn llvm(build: &Build, target: &str) {
cfg.define("LLVM_USE_CRT_DEBUG", "MT");
cfg.define("LLVM_USE_CRT_RELEASE", "MT");
cfg.define("LLVM_USE_CRT_RELWITHDEBINFO", "MT");
cfg.static_crt(true);
}
if target.starts_with("i686") {

View File

@ -235,6 +235,42 @@ pub trait Drop {
/// }
/// ```
///
/// Here is an example of the same `Point` struct implementing the `Add` trait
/// using generics.
///
/// ```
/// use std::ops::Add;
///
/// #[derive(Debug)]
/// struct Point<T> {
/// x: T,
/// y: T,
/// }
///
/// // Notice that the implementation uses the `Output` associated type
/// impl<T: Add<Output=T>> Add for Point<T> {
/// type Output = Point<T>;
///
/// fn add(self, other: Point<T>) -> Point<T> {
/// Point {
/// x: self.x + other.x,
/// y: self.y + other.y,
/// }
/// }
/// }
///
/// impl<T: PartialEq> PartialEq for Point<T> {
/// fn eq(&self, other: &Self) -> bool {
/// self.x == other.x && self.y == other.y
/// }
/// }
///
/// fn main() {
/// assert_eq!(Point { x: 1, y: 0 } + Point { x: 2, y: 3 },
/// Point { x: 3, y: 3 });
/// }
/// ```
///
/// Note that `RHS = Self` by default, but this is not mandatory. For example,
/// [std::time::SystemTime] implements `Add<Duration>`, which permits
/// operations of the form `SystemTime = SystemTime + Duration`.

View File

@ -1222,27 +1222,26 @@ fn foo() {
"##,
E0435: r##"
A non-constant value was used to initialise a constant.
A non-constant value was used in a constant expression.
Erroneous code example:
```compile_fail,E0435
let foo = 42u32;
const FOO : u32 = foo; // error: attempt to use a non-constant value in a
// constant
let foo = 42;
let a: [u8; foo]; // error: attempt to use a non-constant value in a constant
```
To fix this error, please replace the value with a constant. Example:
```
const FOO : u32 = 42u32; // ok!
let a: [u8; 42]; // ok!
```
Or:
```
const OTHER_FOO : u32 = 42u32;
const FOO : u32 = OTHER_FOO; // ok!
const FOO: usize = 42;
let a: [u8; FOO]; // ok!
```
"##,
@ -1560,7 +1559,7 @@ register_diagnostics! {
// E0157, unused error code
// E0257,
// E0258,
E0402, // cannot use an outer type parameter in this context
// E0402, // cannot use an outer type parameter in this context
// E0406, merged into 420
// E0410, merged into 408
// E0413, merged into 530

View File

@ -127,8 +127,6 @@ impl Ord for BindingError {
enum ResolutionError<'a> {
/// error E0401: can't use type parameters from outer function
TypeParametersFromOuterFunction,
/// error E0402: cannot use an outer type parameter in this context
OuterTypeParameterContext,
/// error E0403: the name is already used for a type parameter in this type parameter list
NameAlreadyUsedInTypeParameterList(Name, &'a Span),
/// error E0407: method is not a member of trait
@ -187,12 +185,6 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
err.span_label(span, "use of type variable from outer function");
err
}
ResolutionError::OuterTypeParameterContext => {
struct_span_err!(resolver.session,
span,
E0402,
"cannot use an outer type parameter in this context")
}
ResolutionError::NameAlreadyUsedInTypeParameterList(name, first_use_span) => {
let mut err = struct_span_err!(resolver.session,
span,
@ -1671,16 +1663,16 @@ impl<'a> Resolver<'a> {
this.check_proc_macro_attrs(&trait_item.attrs);
match trait_item.node {
TraitItemKind::Const(_, ref default) => {
TraitItemKind::Const(ref ty, ref default) => {
this.visit_ty(ty);
// Only impose the restrictions of
// ConstRibKind if there's an actual constant
// ConstRibKind for an actual constant
// expression in a provided default.
if default.is_some() {
if let Some(ref expr) = *default{
this.with_constant_rib(|this| {
visit::walk_trait_item(this, trait_item)
this.visit_expr(expr);
});
} else {
visit::walk_trait_item(this, trait_item)
}
}
TraitItemKind::Method(ref sig, _) => {
@ -1709,9 +1701,13 @@ impl<'a> Resolver<'a> {
});
}
ItemKind::Const(..) | ItemKind::Static(..) => {
self.with_constant_rib(|this| {
visit::walk_item(this, item);
ItemKind::Static(ref ty, _, ref expr) |
ItemKind::Const(ref ty, ref expr) => {
self.with_item_rib(|this| {
this.visit_ty(ty);
this.with_constant_rib(|this| {
this.visit_expr(expr);
});
});
}
@ -1782,13 +1778,21 @@ impl<'a> Resolver<'a> {
self.label_ribs.pop();
}
fn with_item_rib<F>(&mut self, f: F)
where F: FnOnce(&mut Resolver)
{
self.ribs[ValueNS].push(Rib::new(ItemRibKind));
self.ribs[TypeNS].push(Rib::new(ItemRibKind));
f(self);
self.ribs[TypeNS].pop();
self.ribs[ValueNS].pop();
}
fn with_constant_rib<F>(&mut self, f: F)
where F: FnOnce(&mut Resolver)
{
self.ribs[ValueNS].push(Rib::new(ConstantItemRibKind));
self.ribs[TypeNS].push(Rib::new(ConstantItemRibKind));
f(self);
self.ribs[TypeNS].pop();
self.ribs[ValueNS].pop();
}
@ -2755,7 +2759,8 @@ impl<'a> Resolver<'a> {
for rib in ribs {
match rib.kind {
NormalRibKind | MethodRibKind(_) | ClosureRibKind(..) |
ModuleRibKind(..) | MacroDefinition(..) | ForwardTyParamBanRibKind => {
ModuleRibKind(..) | MacroDefinition(..) | ForwardTyParamBanRibKind |
ConstantItemRibKind => {
// Nothing to do. Continue.
}
ItemRibKind => {
@ -2767,14 +2772,6 @@ impl<'a> Resolver<'a> {
}
return Def::Err;
}
ConstantItemRibKind => {
// see #9186
if record_used {
resolve_error(self, span,
ResolutionError::OuterTypeParameterContext);
}
return Def::Err;
}
}
}
}

View File

@ -13,6 +13,7 @@ use std::io::prelude::*;
use std::io;
use std::path::Path;
use std::str;
use html::markdown::{Markdown, RenderType};
#[derive(Clone)]
pub struct ExternalHtml{
@ -28,17 +29,26 @@ pub struct ExternalHtml{
}
impl ExternalHtml {
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String])
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String],
md_before_content: &[String], md_after_content: &[String], render: RenderType)
-> Option<ExternalHtml> {
load_external_files(in_header)
.and_then(|ih|
load_external_files(before_content)
.map(|bc| (ih, bc))
)
.and_then(|(ih, bc)|
load_external_files(md_before_content)
.map(|m_bc| (ih, format!("{}{}", bc, Markdown(&m_bc, render))))
)
.and_then(|(ih, bc)|
load_external_files(after_content)
.map(|ac| (ih, bc, ac))
)
.and_then(|(ih, bc, ac)|
load_external_files(md_after_content)
.map(|m_ac| (ih, bc, format!("{}{}", ac, Markdown(&m_ac, render))))
)
.map(|(ih, bc, ac)|
ExternalHtml {
in_header: ih,

View File

@ -943,9 +943,9 @@
if (hasClass(main, 'content')) {
removeClass(main, 'hidden');
}
var search = document.getElementById('search');
if (hasClass(main, 'content')) {
addClass(main, 'hidden');
var search_c = document.getElementById('search');
if (hasClass(search_c, 'content')) {
addClass(search_c, 'hidden');
}
}
// Revert to the previous title manually since the History
@ -959,7 +959,11 @@
// perform the search. This will empty the bar if there's
// nothing there, which lets you really go back to a
// previous state with nothing in the bar.
document.getElementsByClassName('search-input')[0].value = params.search;
if (params.search) {
document.getElementsByClassName('search-input')[0].value = params.search;
} else {
document.getElementsByClassName('search-input')[0].value = '';
}
// Some browsers fire 'onpopstate' for every page load
// (Chrome), while others fire the event only when actually
// popping a state (Firefox), which is why search() is

View File

@ -160,6 +160,14 @@ pub fn opts() -> Vec<RustcOptGroup> {
"files to include inline between the content and </body> of a rendered \
Markdown file or generated documentation",
"FILES")),
unstable(optmulti("", "markdown-before-content",
"files to include inline between <body> and the content of a rendered \
Markdown file or generated documentation",
"FILES")),
unstable(optmulti("", "markdown-after-content",
"files to include inline between the content and </body> of a rendered \
Markdown file or generated documentation",
"FILES")),
stable(optopt("", "markdown-playground-url",
"URL to send code snippets to", "URL")),
stable(optflag("", "markdown-no-toc", "don't include table of contents")),
@ -275,7 +283,10 @@ pub fn main_args(args: &[String]) -> isize {
let external_html = match ExternalHtml::load(
&matches.opt_strs("html-in-header"),
&matches.opt_strs("html-before-content"),
&matches.opt_strs("html-after-content")) {
&matches.opt_strs("html-after-content"),
&matches.opt_strs("markdown-before-content"),
&matches.opt_strs("markdown-after-content"),
render_type) {
Some(eh) => eh,
None => return 3,
};

View File

@ -754,9 +754,7 @@ impl<'a> StringReader<'a> {
// integer literal followed by field/method access or a range pattern
// (`0..2` and `12.foo()`)
if self.ch_is('.') && !self.nextch_is('.') &&
!self.nextch()
.unwrap_or('\0')
.is_xid_start() {
!ident_start(self.nextch()) {
// might have stuff after the ., and if it does, it needs to start
// with a number
self.bump();

@ -1 +1 @@
Subproject commit cf85b5a8da7853c4de5cc57766da8b7988c06461
Subproject commit 1ef3b9128e1baaed61b42d5b0de79dee100acf17

View File

@ -1,4 +1,4 @@
# If this file is modified, then llvm will be (optionally) cleaned and then rebuilt.
# The actual contents of this file do not matter, but to trigger a change on the
# build bots then the contents should be changed so git updates the mtime.
2017-05-06
2017-05-13

View File

@ -10,6 +10,6 @@
fn main () {
let foo = 42u32;
const FOO : u32 = foo; //~ ERROR E0435
let _: [u8; foo]; //~ ERROR E0435
//~| NOTE non-constant used with constant
}

View File

@ -26,7 +26,7 @@ impl Foo for Def {
pub fn test<A: Foo, B: Foo>() {
let _array = [4; <A as Foo>::Y];
//~^ ERROR cannot use an outer type parameter in this context [E0402]
//~^ ERROR the trait bound `A: Foo` is not satisfied [E0277]
}
fn main() {

View File

@ -26,7 +26,7 @@ impl Foo for Def {
pub fn test<A: Foo, B: Foo>() {
let _array: [u32; <A as Foo>::Y];
//~^ ERROR cannot use an outer type parameter in this context [E0402]
//~^ ERROR the trait bound `A: Foo` is not satisfied [E0277]
}
fn main() {

View File

@ -14,7 +14,7 @@ enum Bar<T> { What } //~ ERROR parameter `T` is never used
fn foo<T>() {
static a: Bar<T> = Bar::What;
//~^ ERROR cannot use an outer type parameter in this context
//~^ ERROR can't use type parameters from outer function; try using a local type parameter instead
}
fn main() {

View File

@ -11,5 +11,5 @@
fn main() {
let foo = 42u32;
const FOO : u32 = foo;
//~^ ERROR attempt to use a non-constant value in a constant
//~^ ERROR can't capture dynamic environment
}

View File

@ -12,7 +12,7 @@ fn main() {
let foo = 100;
static y: isize = foo + 1;
//~^ ERROR attempt to use a non-constant value in a constant
//~^ ERROR can't capture dynamic environment
println!("{}", y);
}

View File

@ -10,7 +10,7 @@
fn f(x:isize) {
static child: isize = x + 1;
//~^ ERROR attempt to use a non-constant value in a constant
//~^ ERROR can't capture dynamic environment
}
fn main() {}

View File

@ -16,7 +16,7 @@ trait PTrait {
impl PTrait for P {
fn getChildOption(&self) -> Option<Box<P>> {
static childVal: Box<P> = self.child.get();
//~^ ERROR attempt to use a non-constant value in a constant
//~^ ERROR can't capture dynamic environment
panic!();
}
}

View File

@ -0,0 +1,28 @@
// 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.
trait Dim {
fn dim() -> usize;
}
enum Dim3 {}
impl Dim for Dim3 {
fn dim() -> usize {
3
}
}
fn main() {
let array: [usize; Dim3::dim()]
//~^ ERROR calls in constants are limited to constant functions
= [0; Dim3::dim()];
//~^ ERROR calls in constants are limited to constant functions
}

View File

@ -22,12 +22,7 @@ impl Dim for Dim3 {
pub struct Vector<T, D: Dim> {
entries: [T; D::dim()]
//~^ ERROR cannot use an outer type parameter in this context
//~^ ERROR no associated item named `dim` found for type `D` in the current scope
}
fn main() {
let array: [usize; Dim3::dim()]
//~^ ERROR calls in constants are limited to constant functions
= [0; Dim3::dim()];
//~^ ERROR calls in constants are limited to constant functions
}
fn main() {}

View File

@ -0,0 +1,13 @@
// 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.
fn main() {
let a = 42._; //~ ERROR unexpected token: `_`
}

View File

@ -37,6 +37,10 @@ fn sub<A: Foo, B: Foo>() -> i32 {
A::X - B::X
}
trait Bar: Foo {
const Y: i32 = Self::X;
}
fn main() {
assert_eq!(11, Abc::X);
assert_eq!(97, Def::X);

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.
trait Tr : Sized {
fn _method_on_numbers(self) {}
}
impl Tr for i32 {}
fn main() {
42._method_on_numbers();
}