diff --git a/src/Cargo.lock b/src/Cargo.lock index 3dd8231a49f69..776a268aa8de1 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -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" diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 1088067c2de57..cc560e0172e3a 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -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" diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 67edd70a1565a..6cb1d1fc4bf05 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -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") { diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 391b606f613f2..6942f5fb67b60 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -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 { +/// x: T, +/// y: T, +/// } +/// +/// // Notice that the implementation uses the `Output` associated type +/// impl> Add for Point { +/// type Output = Point; +/// +/// fn add(self, other: Point) -> Point { +/// Point { +/// x: self.x + other.x, +/// y: self.y + other.y, +/// } +/// } +/// } +/// +/// impl PartialEq for Point { +/// 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`, which permits /// operations of the form `SystemTime = SystemTime + Duration`. diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 2c2babf0a6653..368fb7a88685b 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -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 diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index c4512cb38c4e2..774e84de36638 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -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(&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(&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; - } } } } diff --git a/src/librustdoc/externalfiles.rs b/src/librustdoc/externalfiles.rs index d78f00497ca55..111ae4ede277a 100644 --- a/src/librustdoc/externalfiles.rs +++ b/src/librustdoc/externalfiles.rs @@ -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 { 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, diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index fbc7615588eed..c115a6ccba609 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -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 diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index d89fa547a89cd..bbaa7bc2fb65e 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -160,6 +160,14 @@ pub fn opts() -> Vec { "files to include inline between the content and of a rendered \ Markdown file or generated documentation", "FILES")), + unstable(optmulti("", "markdown-before-content", + "files to include inline between 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 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, }; diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index ded1f0b599a61..a83b19c7334e7 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -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(); diff --git a/src/llvm b/src/llvm index cf85b5a8da785..1ef3b9128e1ba 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit cf85b5a8da7853c4de5cc57766da8b7988c06461 +Subproject commit 1ef3b9128e1baaed61b42d5b0de79dee100acf17 diff --git a/src/rustllvm/llvm-rebuild-trigger b/src/rustllvm/llvm-rebuild-trigger index d73d1c25e5bdb..70663f30e8f9e 100644 --- a/src/rustllvm/llvm-rebuild-trigger +++ b/src/rustllvm/llvm-rebuild-trigger @@ -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 diff --git a/src/test/compile-fail/E0435.rs b/src/test/compile-fail/E0435.rs index f687633d34d86..b15bf44fbd063 100644 --- a/src/test/compile-fail/E0435.rs +++ b/src/test/compile-fail/E0435.rs @@ -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 } diff --git a/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs b/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs index 7fd9605ef2cdc..e284a61eb2daa 100644 --- a/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs +++ b/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs @@ -26,7 +26,7 @@ impl Foo for Def { pub fn test() { let _array = [4; ::Y]; - //~^ ERROR cannot use an outer type parameter in this context [E0402] + //~^ ERROR the trait bound `A: Foo` is not satisfied [E0277] } fn main() { diff --git a/src/test/compile-fail/associated-const-type-parameter-arrays.rs b/src/test/compile-fail/associated-const-type-parameter-arrays.rs index 71c7a3965ec3c..848ea65a9cfd1 100644 --- a/src/test/compile-fail/associated-const-type-parameter-arrays.rs +++ b/src/test/compile-fail/associated-const-type-parameter-arrays.rs @@ -26,7 +26,7 @@ impl Foo for Def { pub fn test() { let _array: [u32; ::Y]; - //~^ ERROR cannot use an outer type parameter in this context [E0402] + //~^ ERROR the trait bound `A: Foo` is not satisfied [E0277] } fn main() { diff --git a/src/test/compile-fail/inner-static-type-parameter.rs b/src/test/compile-fail/inner-static-type-parameter.rs index a6a3319845836..6fb497092d217 100644 --- a/src/test/compile-fail/inner-static-type-parameter.rs +++ b/src/test/compile-fail/inner-static-type-parameter.rs @@ -14,7 +14,7 @@ enum Bar { What } //~ ERROR parameter `T` is never used fn foo() { static a: Bar = 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() { diff --git a/src/test/compile-fail/issue-27433.rs b/src/test/compile-fail/issue-27433.rs index 78d96398b9587..782b205743871 100644 --- a/src/test/compile-fail/issue-27433.rs +++ b/src/test/compile-fail/issue-27433.rs @@ -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 } diff --git a/src/test/compile-fail/issue-3521-2.rs b/src/test/compile-fail/issue-3521-2.rs index 6cd2c02c417ea..1742cb4fb7214 100644 --- a/src/test/compile-fail/issue-3521-2.rs +++ b/src/test/compile-fail/issue-3521-2.rs @@ -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); } diff --git a/src/test/compile-fail/issue-3668-2.rs b/src/test/compile-fail/issue-3668-2.rs index 16fb2f68133f2..fe46877e8d340 100644 --- a/src/test/compile-fail/issue-3668-2.rs +++ b/src/test/compile-fail/issue-3668-2.rs @@ -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() {} diff --git a/src/test/compile-fail/issue-3668.rs b/src/test/compile-fail/issue-3668.rs index 9c31dc1e38ef8..00f64414a9e72 100644 --- a/src/test/compile-fail/issue-3668.rs +++ b/src/test/compile-fail/issue-3668.rs @@ -16,7 +16,7 @@ trait PTrait { impl PTrait for P { fn getChildOption(&self) -> Option> { static childVal: Box

= self.child.get(); - //~^ ERROR attempt to use a non-constant value in a constant + //~^ ERROR can't capture dynamic environment panic!(); } } diff --git a/src/test/compile-fail/issue-39559-2.rs b/src/test/compile-fail/issue-39559-2.rs new file mode 100644 index 0000000000000..aa0750230649d --- /dev/null +++ b/src/test/compile-fail/issue-39559-2.rs @@ -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 or the MIT license +// , 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 +} diff --git a/src/test/compile-fail/issue-39559.rs b/src/test/compile-fail/issue-39559.rs index b7f767f109c0c..871ecf269ceec 100644 --- a/src/test/compile-fail/issue-39559.rs +++ b/src/test/compile-fail/issue-39559.rs @@ -22,12 +22,7 @@ impl Dim for Dim3 { pub struct Vector { 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() {} diff --git a/src/test/parse-fail/underscore-suffix-for-float.rs b/src/test/parse-fail/underscore-suffix-for-float.rs new file mode 100644 index 0000000000000..df7d9aa374dce --- /dev/null +++ b/src/test/parse-fail/underscore-suffix-for-float.rs @@ -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 or the MIT license +// , 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: `_` +} diff --git a/src/test/run-pass/associated-const-type-parameters.rs b/src/test/run-pass/associated-const-type-parameters.rs index b276589f0c47b..df2083530646e 100644 --- a/src/test/run-pass/associated-const-type-parameters.rs +++ b/src/test/run-pass/associated-const-type-parameters.rs @@ -37,6 +37,10 @@ fn sub() -> 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); diff --git a/src/test/run-pass/underscore-method-after-integer.rs b/src/test/run-pass/underscore-method-after-integer.rs new file mode 100644 index 0000000000000..af91256421101 --- /dev/null +++ b/src/test/run-pass/underscore-method-after-integer.rs @@ -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 or the MIT license +// , 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(); +}