From e91b625e86794462c54c3f1bfaeebb2acb709bf9 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Wed, 20 Jul 2016 16:43:53 -0400 Subject: [PATCH 01/37] Fix typo (privledge->privilege) --- src/libstd/env.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 95aa6468dd9..2c0de960561 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -526,7 +526,7 @@ pub fn temp_dir() -> PathBuf { /// Ok("/home/alex/bar") /// ``` /// -/// This sort of behavior has been known to [lead to privledge escalation] when +/// This sort of behavior has been known to [lead to privilege escalation] when /// used incorrectly, for example. /// /// [lead to privledge escalation]: http://securityvulns.com/Wdocument183.html From 1403df72c82d3c3c2c19369c5f4bb34b3e095604 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Fri, 5 Aug 2016 16:57:19 -0300 Subject: [PATCH 02/37] Implement From for Cell, RefCell and UnsafeCell --- src/libcore/cell.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 06af200e478..eb694319f42 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -146,6 +146,7 @@ use clone::Clone; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; +use convert::From; use default::Default; use marker::{Copy, Send, Sync, Sized, Unsize}; use ops::{Deref, DerefMut, Drop, FnOnce, CoerceUnsized}; @@ -326,6 +327,13 @@ impl Ord for Cell { } } +#[stable(feature = "cell_from", since = "1.12.0")] +impl From for Cell { + fn from(t: T) -> Cell { + Cell::new(t) + } +} + /// A mutable memory location with dynamically checked borrow rules /// /// See the [module-level documentation](index.html) for more. @@ -635,6 +643,13 @@ impl Ord for RefCell { } } +#[stable(feature = "cell_from", since = "1.12.0")] +impl From for RefCell { + fn from(t: T) -> RefCell { + RefCell::new(t) + } +} + struct BorrowRef<'b> { borrow: &'b Cell, } @@ -957,3 +972,10 @@ impl Default for UnsafeCell { UnsafeCell::new(Default::default()) } } + +#[stable(feature = "cell_from", since = "1.12.0")] +impl From for UnsafeCell { + fn from(t: T) -> UnsafeCell { + UnsafeCell::new(t) + } +} From 9d6fa40ba181cbb50ff06978f2b7b2905854bed5 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 8 Aug 2016 18:33:16 -0400 Subject: [PATCH 03/37] Add regression test for #22894. --- src/test/run-pass/issue-22894.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/test/run-pass/issue-22894.rs diff --git a/src/test/run-pass/issue-22894.rs b/src/test/run-pass/issue-22894.rs new file mode 100644 index 00000000000..8acd88deef2 --- /dev/null +++ b/src/test/run-pass/issue-22894.rs @@ -0,0 +1,13 @@ +// Copyright 2016 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. + +#[allow(dead_code)] +static X: &'static str = &*""; +fn main() {} From 1a6fac7ed24b52571ea4b20b440b0acb6e0d8992 Mon Sep 17 00:00:00 2001 From: ShyamSundarB Date: Mon, 8 Aug 2016 00:12:53 +0530 Subject: [PATCH 04/37] E0248 Change in issue format E0248 Change in issue format E0267 UT New Format E0268 UT New Format E0267 & E0268 New Error Format --- src/librustc_passes/loops.rs | 8 ++++++-- src/librustc_typeck/astconv.rs | 8 +++++--- src/test/compile-fail/E0248.rs | 2 +- src/test/compile-fail/E0267.rs | 1 + src/test/compile-fail/E0268.rs | 1 + 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index 4e251793f69..eab16bd5bd1 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -77,10 +77,14 @@ impl<'a> CheckLoopVisitor<'a> { match self.cx { Loop => {} Closure => { - span_err!(self.sess, span, E0267, "`{}` inside of a closure", name); + struct_span_err!(self.sess, span, E0267, "`{}` inside of a closure", name) + .span_label(span, &format!("cannot break inside of a closure")) + .emit(); } Normal => { - span_err!(self.sess, span, E0268, "`{}` outside of loop", name); + struct_span_err!(self.sess, span, E0268, "`{}` outside of loop", name) + .span_label(span, &format!("cannot break outside of a loop")) + .emit(); } } } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 50ffa52e88b..deba31db5df 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1582,9 +1582,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { return self.tcx().types.err; } _ => { - span_err!(tcx.sess, span, E0248, - "found value `{}` used as a type", - tcx.item_path_str(def.def_id())); + struct_span_err!(tcx.sess, span, E0248, + "found value `{}` used as a type", + tcx.item_path_str(def.def_id())) + .span_label(span, &format!("value used as a type")) + .emit(); return self.tcx().types.err; } } diff --git a/src/test/compile-fail/E0248.rs b/src/test/compile-fail/E0248.rs index fdfd41a456b..25568a323e1 100644 --- a/src/test/compile-fail/E0248.rs +++ b/src/test/compile-fail/E0248.rs @@ -13,6 +13,6 @@ enum Foo { } fn do_something(x: Foo::Bar) { } //~ ERROR E0248 - + //~| NOTE value used as a type fn main() { } diff --git a/src/test/compile-fail/E0267.rs b/src/test/compile-fail/E0267.rs index 6287256e866..b58fbce8bc6 100644 --- a/src/test/compile-fail/E0267.rs +++ b/src/test/compile-fail/E0267.rs @@ -10,4 +10,5 @@ fn main() { let w = || { break; }; //~ ERROR E0267 + //~| NOTE cannot break inside of a closure } diff --git a/src/test/compile-fail/E0268.rs b/src/test/compile-fail/E0268.rs index 41e88e2f492..3313e07667a 100644 --- a/src/test/compile-fail/E0268.rs +++ b/src/test/compile-fail/E0268.rs @@ -10,4 +10,5 @@ fn main() { break; //~ ERROR E0268 + //~| NOTE cannot break outside of a loop } From 5c2c19aa89d5c855ac34a8978612fbd4f038872c Mon Sep 17 00:00:00 2001 From: Luke Hinds Date: Tue, 9 Aug 2016 22:31:57 +0100 Subject: [PATCH 05/37] Update error message for E0253 #35512 Fixes #35512. Part of #35233. --- src/librustc_resolve/resolve_imports.rs | 4 +++- src/test/compile-fail/E0253.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 6986f99926e..1e40aa7d187 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -505,7 +505,9 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { } Success(binding) if !binding.is_importable() => { let msg = format!("`{}` is not directly importable", target); - span_err!(self.session, directive.span, E0253, "{}", &msg); + struct_span_err!(self.session, directive.span, E0253, "{}", &msg) + .span_label(directive.span, &format!("cannot be imported directly")) + .emit(); // Do not import this illegal binding. Import a dummy binding and pretend // everything is fine self.import_dummy_binding(module, directive); diff --git a/src/test/compile-fail/E0253.rs b/src/test/compile-fail/E0253.rs index 28fcf4452b3..6093f7a81fe 100644 --- a/src/test/compile-fail/E0253.rs +++ b/src/test/compile-fail/E0253.rs @@ -14,6 +14,8 @@ mod foo { } } -use foo::MyTrait::do_something; //~ ERROR E0253 +use foo::MyTrait::do_something; + //~^ ERROR E0253 + //~|NOTE not directly importable fn main() {} From 5dac93d59cc2c4c805db91dfcb14fd5017d1a0b1 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Sat, 6 Aug 2016 21:13:25 +0200 Subject: [PATCH 06/37] [emscripten] Disable jemalloc for emscripten --- src/bootstrap/sanity.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index 09f96782e71..d6ac3ef6c9c 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -98,7 +98,8 @@ pub fn check(build: &mut Build) { if target.contains("rumprun") || target.contains("bitrig") || target.contains("openbsd") || - target.contains("msvc") { + target.contains("msvc") || + target.contains("emscripten") { build.config.use_jemalloc = false; } From ad91873cb6ca0824e395cc8e9bb452fed986fde3 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Tue, 9 Aug 2016 01:39:37 +0200 Subject: [PATCH 07/37] [emscripten] Ignore tests Most of these rely on spawning processes, which is not possible in Emscripten. --- src/test/run-pass-fulldeps/linkage-visibility.rs | 1 + src/test/run-pass-fulldeps/logging-enabled.rs | 1 + src/test/run-pass-fulldeps/logging-separate-lines.rs | 1 + src/test/run-pass/backtrace-debuginfo.rs | 1 + src/test/run-pass/backtrace.rs | 1 + src/test/run-pass/command-before-exec.rs | 1 + src/test/run-pass/command-exec.rs | 1 + src/test/run-pass/drop-flag-sanity-check.rs | 1 + src/test/run-pass/drop-trait-enum.rs | 2 ++ src/test/run-pass/env-args-reverse-iterator.rs | 2 ++ src/test/run-pass/env-home-dir.rs | 1 + src/test/run-pass/exec-env.rs | 2 +- src/test/run-pass/hashmap-memory.rs | 2 ++ src/test/run-pass/issue-10626.rs | 1 + src/test/run-pass/issue-12133-3.rs | 1 + src/test/run-pass/issue-13304.rs | 1 + src/test/run-pass/issue-14456.rs | 1 + src/test/run-pass/issue-14940.rs | 1 + src/test/run-pass/issue-16272.rs | 1 + src/test/run-pass/issue-20091.rs | 1 + src/test/run-pass/issue-2190-1.rs | 1 + src/test/run-pass/issue-24313.rs | 2 ++ src/test/run-pass/issue-28950.rs | 1 + src/test/run-pass/issue-29485.rs | 1 + src/test/run-pass/issue-30490.rs | 2 ++ src/test/run-pass/issue-33770.rs | 2 ++ src/test/run-pass/linkage1.rs | 1 + src/test/run-pass/multi-panic.rs | 2 ++ src/test/run-pass/no-stdio.rs | 2 ++ src/test/run-pass/panic-handler-chain.rs | 3 +++ src/test/run-pass/process-exit.rs | 2 ++ src/test/run-pass/process-remove-from-env.rs | 1 + src/test/run-pass/process-spawn-with-unicode-params.rs | 1 + src/test/run-pass/running-with-no-runtime.rs | 2 ++ src/test/run-pass/segfault-no-out-of-stack.rs | 2 ++ src/test/run-pass/signal-exit-status.rs | 1 + src/test/run-pass/sigpipe-should-be-ignored.rs | 1 + src/test/run-pass/sleep.rs | 2 ++ src/test/run-pass/wait-forked-but-failed-child.rs | 1 + 39 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/test/run-pass-fulldeps/linkage-visibility.rs b/src/test/run-pass-fulldeps/linkage-visibility.rs index e6eaefb0490..f884bb2098e 100644 --- a/src/test/run-pass-fulldeps/linkage-visibility.rs +++ b/src/test/run-pass-fulldeps/linkage-visibility.rs @@ -12,6 +12,7 @@ // ignore-android: FIXME(#10356) // ignore-windows: std::dynamic_lib does not work on Windows well // ignore-musl +// ignore-emscripten no dynamic linking extern crate linkage_visibility as foo; diff --git a/src/test/run-pass-fulldeps/logging-enabled.rs b/src/test/run-pass-fulldeps/logging-enabled.rs index 2975835a271..26261348020 100644 --- a/src/test/run-pass-fulldeps/logging-enabled.rs +++ b/src/test/run-pass-fulldeps/logging-enabled.rs @@ -9,6 +9,7 @@ // except according to those terms. // exec-env:RUST_LOG=logging_enabled=info +// ignore-emscripten: FIXME(#31622) #![feature(rustc_private)] diff --git a/src/test/run-pass-fulldeps/logging-separate-lines.rs b/src/test/run-pass-fulldeps/logging-separate-lines.rs index 09759326afd..183a522bba7 100644 --- a/src/test/run-pass-fulldeps/logging-separate-lines.rs +++ b/src/test/run-pass-fulldeps/logging-separate-lines.rs @@ -11,6 +11,7 @@ // ignore-windows // exec-env:RUST_LOG=debug // compile-flags:-C debug-assertions=y +// ignore-emscripten: FIXME(#31622) #![feature(rustc_private)] diff --git a/src/test/run-pass/backtrace-debuginfo.rs b/src/test/run-pass/backtrace-debuginfo.rs index f42a6ab162b..838005cbc91 100644 --- a/src/test/run-pass/backtrace-debuginfo.rs +++ b/src/test/run-pass/backtrace-debuginfo.rs @@ -17,6 +17,7 @@ // compile-flags:-g -Cllvm-args=-enable-tail-merge=0 // ignore-pretty as this critically relies on line numbers +// ignore-emscripten spawning processes is not supported use std::io; use std::io::prelude::*; diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs index f1ce17c0736..f26706d1754 100644 --- a/src/test/run-pass/backtrace.rs +++ b/src/test/run-pass/backtrace.rs @@ -10,6 +10,7 @@ // no-pretty-expanded FIXME #15189 // ignore-android FIXME #17520 +// ignore-emscripten spawning processes is not supported // compile-flags:-g use std::env; diff --git a/src/test/run-pass/command-before-exec.rs b/src/test/run-pass/command-before-exec.rs index 72f952fb6c0..5b83ce48e5d 100644 --- a/src/test/run-pass/command-before-exec.rs +++ b/src/test/run-pass/command-before-exec.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-windows - this is a unix-specific test +// ignore-emscripten #![feature(process_exec, libc)] diff --git a/src/test/run-pass/command-exec.rs b/src/test/run-pass/command-exec.rs index 039245bfd08..130526e72b1 100644 --- a/src/test/run-pass/command-exec.rs +++ b/src/test/run-pass/command-exec.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-windows - this is a unix-specific test +// ignore-emscripten // ignore-pretty #![feature(process_exec)] diff --git a/src/test/run-pass/drop-flag-sanity-check.rs b/src/test/run-pass/drop-flag-sanity-check.rs index f9e1b651a49..a8014768d78 100644 --- a/src/test/run-pass/drop-flag-sanity-check.rs +++ b/src/test/run-pass/drop-flag-sanity-check.rs @@ -9,6 +9,7 @@ // except according to those terms. // compile-flags: -Z force-dropflag-checks=on +// ignore-emscripten // Quick-and-dirty test to ensure -Z force-dropflag-checks=on works as // expected. Note that the inlined drop-flag is slated for removal diff --git a/src/test/run-pass/drop-trait-enum.rs b/src/test/run-pass/drop-trait-enum.rs index ce675547a68..912cb4c5e87 100644 --- a/src/test/run-pass/drop-trait-enum.rs +++ b/src/test/run-pass/drop-trait-enum.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten no threads support + #![allow(unknown_features)] #![feature(box_syntax)] diff --git a/src/test/run-pass/env-args-reverse-iterator.rs b/src/test/run-pass/env-args-reverse-iterator.rs index d22fa6494f0..89af1db7c78 100644 --- a/src/test/run-pass/env-args-reverse-iterator.rs +++ b/src/test/run-pass/env-args-reverse-iterator.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + use std::env::args; use std::process::Command; diff --git a/src/test/run-pass/env-home-dir.rs b/src/test/run-pass/env-home-dir.rs index 2110f0b3bf9..bcb0c62d9fe 100644 --- a/src/test/run-pass/env-home-dir.rs +++ b/src/test/run-pass/env-home-dir.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten #![feature(path)] diff --git a/src/test/run-pass/exec-env.rs b/src/test/run-pass/exec-env.rs index d17056e6d79..a96d189afaa 100644 --- a/src/test/run-pass/exec-env.rs +++ b/src/test/run-pass/exec-env.rs @@ -9,7 +9,7 @@ // except according to those terms. // exec-env:TEST_EXEC_ENV=22 - +// ignore-emscripten FIXME: issue #31622 use std::env; diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 3f6f1aa6b5f..8efc4cb1b17 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten No support for threads + #![allow(unknown_features)] #![feature(std_misc)] diff --git a/src/test/run-pass/issue-10626.rs b/src/test/run-pass/issue-10626.rs index c81e16ebb7c..b350bd1a4cc 100644 --- a/src/test/run-pass/issue-10626.rs +++ b/src/test/run-pass/issue-10626.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten // Make sure that if a process doesn't have its stdio/stderr descriptors set up // that we don't die in a large ball of fire diff --git a/src/test/run-pass/issue-12133-3.rs b/src/test/run-pass/issue-12133-3.rs index 66201ff901f..8f455c2fe4e 100644 --- a/src/test/run-pass/issue-12133-3.rs +++ b/src/test/run-pass/issue-12133-3.rs @@ -12,6 +12,7 @@ // aux-build:issue-12133-dylib.rs // aux-build:issue-12133-dylib2.rs // ignore-musl +// ignore-emscripten no dylib support // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/issue-13304.rs b/src/test/run-pass/issue-13304.rs index c260aa95b57..e1c2c5684fb 100644 --- a/src/test/run-pass/issue-13304.rs +++ b/src/test/run-pass/issue-13304.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-aarch64 +// ignore-emscripten #![feature(io, process_capture)] use std::env; diff --git a/src/test/run-pass/issue-14456.rs b/src/test/run-pass/issue-14456.rs index 7e24c8f73ab..513ab91489c 100644 --- a/src/test/run-pass/issue-14456.rs +++ b/src/test/run-pass/issue-14456.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten #![feature(io, process_capture)] diff --git a/src/test/run-pass/issue-14940.rs b/src/test/run-pass/issue-14940.rs index ba6815d5b7c..ffe6b646794 100644 --- a/src/test/run-pass/issue-14940.rs +++ b/src/test/run-pass/issue-14940.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten use std::env; use std::process::Command; diff --git a/src/test/run-pass/issue-16272.rs b/src/test/run-pass/issue-16272.rs index 9562d113ada..d4f3d15b320 100644 --- a/src/test/run-pass/issue-16272.rs +++ b/src/test/run-pass/issue-16272.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-aarch64 +// ignore-emscripten use std::process::Command; use std::env; diff --git a/src/test/run-pass/issue-20091.rs b/src/test/run-pass/issue-20091.rs index 1fe44348466..52c7911075a 100644 --- a/src/test/run-pass/issue-20091.rs +++ b/src/test/run-pass/issue-20091.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-aarch64 +// ignore-emscripten #![feature(std_misc, os)] #[cfg(unix)] diff --git a/src/test/run-pass/issue-2190-1.rs b/src/test/run-pass/issue-2190-1.rs index 844826c45db..39375703514 100644 --- a/src/test/run-pass/issue-2190-1.rs +++ b/src/test/run-pass/issue-2190-1.rs @@ -9,6 +9,7 @@ // except according to those terms. // pretty-expanded FIXME #23616 +// ignore-emscripten use std::thread::Builder; diff --git a/src/test/run-pass/issue-24313.rs b/src/test/run-pass/issue-24313.rs index 9acfb04d781..9b2b474351d 100644 --- a/src/test/run-pass/issue-24313.rs +++ b/src/test/run-pass/issue-24313.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + use std::thread; use std::env; use std::process::Command; diff --git a/src/test/run-pass/issue-28950.rs b/src/test/run-pass/issue-28950.rs index efce148ea51..a905727afff 100644 --- a/src/test/run-pass/issue-28950.rs +++ b/src/test/run-pass/issue-28950.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten // compile-flags: -Z orbit=off // (blows the stack with MIR trans and no optimizations) diff --git a/src/test/run-pass/issue-29485.rs b/src/test/run-pass/issue-29485.rs index 9e8f5869437..9252762d1bd 100644 --- a/src/test/run-pass/issue-29485.rs +++ b/src/test/run-pass/issue-29485.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:issue-29485.rs +// ignore-emscripten #[feature(recover)] diff --git a/src/test/run-pass/issue-30490.rs b/src/test/run-pass/issue-30490.rs index ea603fc665d..035911302cf 100644 --- a/src/test/run-pass/issue-30490.rs +++ b/src/test/run-pass/issue-30490.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + // Previously libstd would set stdio descriptors of a child process // by `dup`ing the requested descriptors to inherit directly into the // stdio descriptors. This, however, would incorrectly handle cases diff --git a/src/test/run-pass/issue-33770.rs b/src/test/run-pass/issue-33770.rs index f5635fddaf9..76728a0d354 100644 --- a/src/test/run-pass/issue-33770.rs +++ b/src/test/run-pass/issue-33770.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + use std::process::{Command, Stdio}; use std::env; use std::sync::{Mutex, RwLock}; diff --git a/src/test/run-pass/linkage1.rs b/src/test/run-pass/linkage1.rs index 0794a5e0daf..17abf9cb1f2 100644 --- a/src/test/run-pass/linkage1.rs +++ b/src/test/run-pass/linkage1.rs @@ -10,6 +10,7 @@ // ignore-windows // ignore-macos +// ignore-emscripten // aux-build:linkage1.rs #![feature(linkage)] diff --git a/src/test/run-pass/multi-panic.rs b/src/test/run-pass/multi-panic.rs index 93e2a854ccb..86fe06b1765 100644 --- a/src/test/run-pass/multi-panic.rs +++ b/src/test/run-pass/multi-panic.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + fn check_for_no_backtrace(test: std::process::Output) { assert!(!test.status.success()); let err = String::from_utf8_lossy(&test.stderr); diff --git a/src/test/run-pass/no-stdio.rs b/src/test/run-pass/no-stdio.rs index 3658b6a508a..ad4d56ec50a 100644 --- a/src/test/run-pass/no-stdio.rs +++ b/src/test/run-pass/no-stdio.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + #![feature(libc)] extern crate libc; diff --git a/src/test/run-pass/panic-handler-chain.rs b/src/test/run-pass/panic-handler-chain.rs index 7c2e3f0c91b..1ad43f5f17f 100644 --- a/src/test/run-pass/panic-handler-chain.rs +++ b/src/test/run-pass/panic-handler-chain.rs @@ -7,6 +7,9 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. + +// ignore-emscripten no threads support + #![feature(panic_handler, const_fn, std_panic)] use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/src/test/run-pass/process-exit.rs b/src/test/run-pass/process-exit.rs index 9ef66ff2d71..a5d408448a0 100644 --- a/src/test/run-pass/process-exit.rs +++ b/src/test/run-pass/process-exit.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + use std::env; use std::process::{self, Command, Stdio}; diff --git a/src/test/run-pass/process-remove-from-env.rs b/src/test/run-pass/process-remove-from-env.rs index 3096fe4a266..cce5ef4fe17 100644 --- a/src/test/run-pass/process-remove-from-env.rs +++ b/src/test/run-pass/process-remove-from-env.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten use std::process::Command; use std::env; diff --git a/src/test/run-pass/process-spawn-with-unicode-params.rs b/src/test/run-pass/process-spawn-with-unicode-params.rs index a155ee396b6..d3d847127ee 100644 --- a/src/test/run-pass/process-spawn-with-unicode-params.rs +++ b/src/test/run-pass/process-spawn-with-unicode-params.rs @@ -17,6 +17,7 @@ // intact. // ignore-aarch64 +// ignore-emscripten use std::io::prelude::*; use std::io; diff --git a/src/test/run-pass/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index 23d5a08e216..f81c3f2e99d 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + #![feature(start)] use std::ffi::CStr; diff --git a/src/test/run-pass/segfault-no-out-of-stack.rs b/src/test/run-pass/segfault-no-out-of-stack.rs index 0158c4282da..df64d7140b4 100644 --- a/src/test/run-pass/segfault-no-out-of-stack.rs +++ b/src/test/run-pass/segfault-no-out-of-stack.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten can't run commands + #![feature(libc)] extern crate libc; diff --git a/src/test/run-pass/signal-exit-status.rs b/src/test/run-pass/signal-exit-status.rs index 51b369092f0..c7759ca743b 100644 --- a/src/test/run-pass/signal-exit-status.rs +++ b/src/test/run-pass/signal-exit-status.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-windows +// ignore-emscripten use std::env; use std::process::Command; diff --git a/src/test/run-pass/sigpipe-should-be-ignored.rs b/src/test/run-pass/sigpipe-should-be-ignored.rs index 7734a2e80c3..4eb4720e8d7 100644 --- a/src/test/run-pass/sigpipe-should-be-ignored.rs +++ b/src/test/run-pass/sigpipe-should-be-ignored.rs @@ -12,6 +12,7 @@ // doesn't die in a ball of fire, but rather it's gracefully handled. // ignore-aarch64 +// ignore-emscripten use std::env; use std::io::prelude::*; diff --git a/src/test/run-pass/sleep.rs b/src/test/run-pass/sleep.rs index 8b06b02f3cb..9acc6ff8cf0 100644 --- a/src/test/run-pass/sleep.rs +++ b/src/test/run-pass/sleep.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten no threads support + use std::thread::{self, sleep}; use std::time::Duration; use std::sync::{Arc, Mutex}; diff --git a/src/test/run-pass/wait-forked-but-failed-child.rs b/src/test/run-pass/wait-forked-but-failed-child.rs index 795c3f46f75..1d1c83cf12a 100644 --- a/src/test/run-pass/wait-forked-but-failed-child.rs +++ b/src/test/run-pass/wait-forked-but-failed-child.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten #![feature(libc)] From 60599df03b094c81923ab863c6fd616ef2c15806 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Tue, 9 Aug 2016 01:41:51 +0200 Subject: [PATCH 08/37] [emscripten] Disable code paths that don't work on emscripten --- src/libstd/sys/unix/mod.rs | 4 ++-- src/libstd/sys/unix/os.rs | 6 ++++-- src/libstd/sys/unix/thread.rs | 7 +++---- src/libunwind/libunwind.rs | 1 - src/test/run-pass/intrinsic-alignment.rs | 3 ++- src/test/run-pass/rec-align-u64.rs | 3 ++- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 1c25c8f77c1..23687e10e47 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -83,11 +83,11 @@ pub fn init() { } } - #[cfg(not(target_os = "nacl"))] + #[cfg(not(any(target_os = "nacl", target_os = "emscripten")))] unsafe fn reset_sigpipe() { assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != !0); } - #[cfg(target_os = "nacl")] + #[cfg(any(target_os = "nacl", target_os = "emscripten"))] unsafe fn reset_sigpipe() {} } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 9c57f25dfcc..c29e87f91c9 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -551,11 +551,13 @@ pub fn home_dir() -> Option { #[cfg(any(target_os = "android", target_os = "ios", - target_os = "nacl"))] + target_os = "nacl", + target_os = "emscripten"))] unsafe fn fallback() -> Option { None } #[cfg(not(any(target_os = "android", target_os = "ios", - target_os = "nacl")))] + target_os = "nacl", + target_os = "emscripten")))] unsafe fn fallback() -> Option { #[cfg(not(target_os = "solaris"))] unsafe fn getpwduid_r(me: libc::uid_t, passwd: &mut libc::passwd, diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 1061ca87f64..75e10d25853 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -81,8 +81,7 @@ impl Thread { } #[cfg(any(target_os = "linux", - target_os = "android", - target_os = "emscripten"))] + target_os = "android"))] pub fn set_name(name: &CStr) { const PR_SET_NAME: libc::c_int = 15; // pthread wrapper only appeared in glibc 2.12, so we use syscall @@ -118,9 +117,9 @@ impl Thread { name.as_ptr() as *mut libc::c_void); } } - #[cfg(any(target_env = "newlib", target_os = "solaris"))] + #[cfg(any(target_env = "newlib", target_os = "solaris", target_os = "emscripten"))] pub fn set_name(_name: &CStr) { - // Newlib and Illumos has no way to set a thread name. + // Newlib, Illumos and Emscripten have no way to set a thread name. } pub fn sleep(dur: Duration) { diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index 5e242db0a88..680ad3ecd64 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -60,7 +60,6 @@ pub const unwinder_private_data_size: usize = 2; pub const unwinder_private_data_size: usize = 2; #[cfg(target_arch = "asmjs")] -// FIXME: Copied from arm. Need to confirm. pub const unwinder_private_data_size: usize = 20; #[repr(C)] diff --git a/src/test/run-pass/intrinsic-alignment.rs b/src/test/run-pass/intrinsic-alignment.rs index f1e4f8dfa8c..cfae9903a95 100644 --- a/src/test/run-pass/intrinsic-alignment.rs +++ b/src/test/run-pass/intrinsic-alignment.rs @@ -24,7 +24,8 @@ mod rusti { target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd", - target_os = "solaris"))] + target_os = "solaris", + target_os = "emscripten"))] mod m { #[main] #[cfg(target_arch = "x86")] diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs index 2161864f0b6..4863979b3f6 100644 --- a/src/test/run-pass/rec-align-u64.rs +++ b/src/test/run-pass/rec-align-u64.rs @@ -42,7 +42,8 @@ struct Outer { target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd", - target_os = "solaris"))] + target_os = "solaris", + target_os = "emscripten"))] mod m { #[cfg(target_arch = "x86")] pub mod m { From c974749be8dccd2cf15409f8248e392a85574141 Mon Sep 17 00:00:00 2001 From: Luke Hinds Date: Wed, 10 Aug 2016 19:15:39 +0100 Subject: [PATCH 09/37] Update E0253.rs changed error text --- src/test/compile-fail/E0253.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/compile-fail/E0253.rs b/src/test/compile-fail/E0253.rs index 6093f7a81fe..5a06c01241b 100644 --- a/src/test/compile-fail/E0253.rs +++ b/src/test/compile-fail/E0253.rs @@ -16,6 +16,6 @@ mod foo { use foo::MyTrait::do_something; //~^ ERROR E0253 - //~|NOTE not directly importable + //~|NOTE cannot be imported directly fn main() {} From ae58a875945eaf2d827a6acae0b9900a5426537c Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 10 Aug 2016 14:35:09 -0500 Subject: [PATCH 10/37] add -mrelax-relocations=no to i686-musl and i586-gnu I've been experiencing #34978 with these two targets. This applies the hack in #35178 to these targets as well. --- mk/cfg/i586-unknown-linux-gnu.mk | 4 ++-- mk/cfg/i686-unknown-linux-musl.mk | 4 ++-- src/bootstrap/lib.rs | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mk/cfg/i586-unknown-linux-gnu.mk b/mk/cfg/i586-unknown-linux-gnu.mk index 14b9ebfdba6..fa2909196dc 100644 --- a/mk/cfg/i586-unknown-linux-gnu.mk +++ b/mk/cfg/i586-unknown-linux-gnu.mk @@ -7,8 +7,8 @@ CFG_LIB_NAME_i586-unknown-linux-gnu=lib$(1).so CFG_STATIC_LIB_NAME_i586-unknown-linux-gnu=lib$(1).a CFG_LIB_GLOB_i586-unknown-linux-gnu=lib$(1)-*.so CFG_LIB_DSYM_GLOB_i586-unknown-linux-gnu=lib$(1)-*.dylib.dSYM -CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS) -march=pentium -CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -g -fPIC -m32 $(CFLAGS) -march=pentium +CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS) -march=pentium -Wa,-mrelax-relocations=no +CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -g -fPIC -m32 $(CFLAGS) -march=pentium -Wa,-mrelax-relocations=no CFG_GCCISH_CXXFLAGS_i586-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) -march=pentium CFG_GCCISH_LINK_FLAGS_i586-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m32 CFG_GCCISH_DEF_FLAG_i586-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= diff --git a/mk/cfg/i686-unknown-linux-musl.mk b/mk/cfg/i686-unknown-linux-musl.mk index 80918728316..d6c1ce8967a 100644 --- a/mk/cfg/i686-unknown-linux-musl.mk +++ b/mk/cfg/i686-unknown-linux-musl.mk @@ -7,8 +7,8 @@ CFG_INSTALL_ONLY_RLIB_i686-unknown-linux-musl = 1 CFG_LIB_NAME_i686-unknown-linux-musl=lib$(1).so CFG_STATIC_LIB_NAME_i686-unknown-linux-musl=lib$(1).a CFG_LIB_GLOB_i686-unknown-linux-musl=lib$(1)-*.so -CFG_JEMALLOC_CFLAGS_i686-unknown-linux-musl := -m32 -Wl,-melf_i386 -CFG_GCCISH_CFLAGS_i686-unknown-linux-musl := -g -fPIC -m32 -Wl,-melf_i386 +CFG_JEMALLOC_CFLAGS_i686-unknown-linux-musl := -m32 -Wl,-melf_i386 -Wa,-mrelax-relocations=no +CFG_GCCISH_CFLAGS_i686-unknown-linux-musl := -g -fPIC -m32 -Wl,-melf_i386 -Wa,-mrelax-relocations=no CFG_GCCISH_CXXFLAGS_i686-unknown-linux-musl := CFG_GCCISH_LINK_FLAGS_i686-unknown-linux-musl := CFG_GCCISH_DEF_FLAG_i686-unknown-linux-musl := diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index acb7e0fadd9..239adedc0ff 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -858,8 +858,12 @@ impl Build { // This is a hack, because newer binutils broke things on some vms/distros // (i.e., linking against unknown relocs disabled by the following flag) // See: https://github.com/rust-lang/rust/issues/34978 - if target == "x86_64-unknown-linux-musl" { - base.push("-Wa,-mrelax-relocations=no".into()); + match target { + "i586-unknown-linux-gnu" | + "i686-unknown-linux-musl" | + "x86_64-unknown-linux-musl" => { + base.push("-Wa,-mrelax-relocations=no".into()); + } } return base } From 16cc8a767a70b15927933507321a5ce6cb00372d Mon Sep 17 00:00:00 2001 From: cgswords Date: Tue, 2 Aug 2016 09:41:21 -0700 Subject: [PATCH 11/37] Implemented a smarter concatenation system that will hopefully produce more efficient tokenstream usages. --- src/libsyntax/tokenstream.rs | 112 ++++++++++++++++++++++++++++------- 1 file changed, 92 insertions(+), 20 deletions(-) diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 89ead21cc10..0171f24101a 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -340,6 +340,11 @@ pub struct TokenStream { ts: InternalTS, } +// This indicates the maximum size for a leaf in the concatenation algorithm. +// If two leafs will be collectively smaller than this, they will be merged. +// If a leaf is larger than this, it will be concatenated at the top. +const LEAF_SIZE : usize = 32; + // NB If Leaf access proves to be slow, inroducing a secondary Leaf without the bounds // for unsliced Leafs may lead to some performance improvemenet. #[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] @@ -483,6 +488,37 @@ impl InternalTS { } } } + + fn to_vec(&self) -> Vec<&TokenTree> { + let mut res = Vec::with_capacity(self.len()); + fn traverse_and_append<'a>(res: &mut Vec<&'a TokenTree>, ts: &'a InternalTS) { + match *ts { + InternalTS::Empty(..) => {}, + InternalTS::Leaf { ref tts, offset, len, .. } => { + let mut to_app = tts[offset..offset + len].iter().collect(); + res.append(&mut to_app); + } + InternalTS::Node { ref left, ref right, .. } => { + traverse_and_append(res, left); + traverse_and_append(res, right); + } + } + } + traverse_and_append(&mut res, self); + res + } + + fn to_tts(&self) -> Vec { + self.to_vec().into_iter().cloned().collect::>() + } + + // Returns an internal node's children. + fn children(&self) -> Option<(Rc, Rc)> { + match *self { + InternalTS::Node { ref left, ref right, .. } => Some((left.clone(), right.clone())), + _ => None, + } + } } /// TokenStream operators include basic destructuring, boolean operations, `maybe_...` @@ -496,14 +532,17 @@ impl InternalTS { /// /// `maybe_path_prefix("a::b::c(a,b,c).foo()") -> (a::b::c, "(a,b,c).foo()")` impl TokenStream { + // Construct an empty node with a dummy span. pub fn mk_empty() -> TokenStream { TokenStream { ts: InternalTS::Empty(DUMMY_SP) } } + // Construct an empty node with the provided span. fn mk_spanned_empty(sp: Span) -> TokenStream { TokenStream { ts: InternalTS::Empty(sp) } } + // Construct a leaf node with a 0 offset and length equivalent to the input. fn mk_leaf(tts: Rc>, sp: Span) -> TokenStream { let len = tts.len(); TokenStream { @@ -516,6 +555,7 @@ impl TokenStream { } } + // Construct a leaf node with the provided values. fn mk_sub_leaf(tts: Rc>, offset: usize, len: usize, sp: Span) -> TokenStream { TokenStream { ts: InternalTS::Leaf { @@ -527,6 +567,7 @@ impl TokenStream { } } + // Construct an internal node with the provided values. fn mk_int_node(left: Rc, right: Rc, len: usize, @@ -561,11 +602,56 @@ impl TokenStream { } } - /// Concatenates two TokenStreams into a new TokenStream + /// Concatenates two TokenStreams into a new TokenStream. pub fn concat(left: TokenStream, right: TokenStream) -> TokenStream { - let new_len = left.len() + right.len(); - let new_span = combine_spans(left.span(), right.span()); - TokenStream::mk_int_node(Rc::new(left.ts), Rc::new(right.ts), new_len, new_span) + // This internal procedure performs 'aggressive compacting' during concatenation as + // follows: + // - If the nodes' combined total total length is less than 32, we copy both of + // them into a new vector and build a new leaf node. + // - If one node is an internal node and the other is a 'small' leaf (length<32), + // we recur down the internal node on the appropriate side. + // - Otherwise, we construct a new internal node that points to them as left and + // right. + fn concat_internal(left: Rc, right: Rc) -> TokenStream { + let llen = left.len(); + let rlen = right.len(); + let len = llen + rlen; + let span = combine_spans(left.span(), right.span()); + if len <= LEAF_SIZE { + let mut new_vec = left.to_tts(); + let mut rvec = right.to_tts(); + new_vec.append(&mut rvec); + return TokenStream::mk_leaf(Rc::new(new_vec), span); + } + + match (left.children(), right.children()) { + (Some((lleft, lright)), None) => { + if rlen <= LEAF_SIZE { + let new_right = concat_internal(lright, right); + TokenStream::mk_int_node(lleft, Rc::new(new_right.ts), len, span) + } else { + TokenStream::mk_int_node(left, right, len, span) + } + } + (None, Some((rleft, rright))) => { + if rlen <= LEAF_SIZE { + let new_left = concat_internal(left, rleft); + TokenStream::mk_int_node(Rc::new(new_left.ts), rright, len, span) + } else { + TokenStream::mk_int_node(left, right, len, span) + } + } + (_, _) => TokenStream::mk_int_node(left, right, len, span), + } + } + + if left.is_empty() { + right + } else if right.is_empty() { + left + } else { + concat_internal(Rc::new(left.ts), Rc::new(right.ts)) + } } /// Indicate if the TokenStream is empty. @@ -580,27 +666,13 @@ impl TokenStream { /// Convert a TokenStream into a vector of borrowed TokenTrees. pub fn to_vec(&self) -> Vec<&TokenTree> { - fn internal_to_vec(ts: &InternalTS) -> Vec<&TokenTree> { - match *ts { - InternalTS::Empty(..) => Vec::new(), - InternalTS::Leaf { ref tts, offset, len, .. } => { - tts[offset..offset + len].iter().collect() - } - InternalTS::Node { ref left, ref right, .. } => { - let mut v1 = internal_to_vec(left); - let mut v2 = internal_to_vec(right); - v1.append(&mut v2); - v1 - } - } - } - internal_to_vec(&self.ts) + self.ts.to_vec() } /// Convert a TokenStream into a vector of TokenTrees (by cloning the TokenTrees). /// (This operation is an O(n) deep copy of the underlying structure.) pub fn to_tts(&self) -> Vec { - self.to_vec().into_iter().cloned().collect::>() + self.ts.to_tts() } /// Return the TokenStream's span. From 92f7e85b303b67c2e412275ba663bb811388f9a4 Mon Sep 17 00:00:00 2001 From: Chiu-Hsiang Hsu Date: Thu, 11 Aug 2016 00:38:12 +0800 Subject: [PATCH 12/37] Update E0138 to new format --- src/librustc/middle/entry.rs | 9 +++++++-- src/test/compile-fail/E0138.rs | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 0a363fddd53..11bde922f47 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -132,8 +132,13 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) { if ctxt.start_fn.is_none() { ctxt.start_fn = Some((item.id, item.span)); } else { - span_err!(ctxt.session, item.span, E0138, - "multiple 'start' functions"); + struct_span_err!( + ctxt.session, item.span, E0138, + "multiple 'start' functions") + .span_label(ctxt.start_fn.unwrap().1, + &format!("previous `start` function here")) + .span_label(item.span, &format!("multiple `start` functions")) + .emit(); } }, EntryPointType::None => () diff --git a/src/test/compile-fail/E0138.rs b/src/test/compile-fail/E0138.rs index 97d85e5e71e..d4630d7c2ef 100644 --- a/src/test/compile-fail/E0138.rs +++ b/src/test/compile-fail/E0138.rs @@ -12,6 +12,9 @@ #[start] fn foo(argc: isize, argv: *const *const u8) -> isize {} +//~^ NOTE previous `start` function here #[start] -fn f(argc: isize, argv: *const *const u8) -> isize {} //~ ERROR E0138 +fn f(argc: isize, argv: *const *const u8) -> isize {} +//~^ ERROR E0138 +//~| NOTE multiple `start` functions From 4b54dd7fd9832beaf2b182d1a9be46b2e9a83e7e Mon Sep 17 00:00:00 2001 From: Andrii Dmytrenko Date: Thu, 11 Aug 2016 11:29:16 +0100 Subject: [PATCH 13/37] Use an existing constant name as an example. --- src/libcore/sync/atomic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 2a7a0b62329..5701a89d8bc 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -32,7 +32,7 @@ //! atomically-reference-counted shared pointer). //! //! Most atomic types may be stored in static variables, initialized using -//! the provided static initializers like `INIT_ATOMIC_BOOL`. Atomic statics +//! the provided static initializers like `ATOMIC_BOOL_INIT`. Atomic statics //! are often used for lazy global initialization. //! //! From c0ff3c1070f5983c96ddbfe702bd60679305e7b5 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 11 Aug 2016 11:22:39 -0500 Subject: [PATCH 14/37] fix match --- src/bootstrap/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 239adedc0ff..402a6736440 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -863,7 +863,8 @@ impl Build { "i686-unknown-linux-musl" | "x86_64-unknown-linux-musl" => { base.push("-Wa,-mrelax-relocations=no".into()); - } + }, + _ => {}, } return base } From b707a12a6bd5d499a3ae1d8c0378a7dee00442c0 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Thu, 11 Aug 2016 12:55:53 -0400 Subject: [PATCH 15/37] Allow compiling against a custom LLVM 3.9 installation --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 29f16da0581..18dc99dd6c3 100755 --- a/configure +++ b/configure @@ -1013,7 +1013,7 @@ then LLVM_VERSION=$($LLVM_CONFIG --version) case $LLVM_VERSION in - (3.[7-8]*) + (3.[7-9]*) msg "found ok version of LLVM: $LLVM_VERSION" ;; (*) From 4209f948b175b61056560f91dd0bd1719ba61deb Mon Sep 17 00:00:00 2001 From: crypto-universe Date: Thu, 11 Aug 2016 01:52:44 +0200 Subject: [PATCH 16/37] Add label to E0254 This issue #35513 is a part of #35233. r? @jonathandturner --- src/librustc_resolve/lib.rs | 7 +++++-- src/test/compile-fail/E0254.rs | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 860e569ba7e..896b4a1847d 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3370,8 +3370,11 @@ impl<'a> Resolver<'a> { let mut err = match (old_binding.is_extern_crate(), binding.is_extern_crate()) { (true, true) => struct_span_err!(self.session, span, E0259, "{}", msg), - (true, _) | (_, true) if binding.is_import() || old_binding.is_import() => - struct_span_err!(self.session, span, E0254, "{}", msg), + (true, _) | (_, true) if binding.is_import() || old_binding.is_import() => { + let mut e = struct_span_err!(self.session, span, E0254, "{}", msg); + e.span_label(span, &"already imported"); + e + }, (true, _) | (_, true) => struct_span_err!(self.session, span, E0260, "{}", msg), _ => match (old_binding.is_import(), binding.is_import()) { (false, false) => struct_span_err!(self.session, span, E0428, "{}", msg), diff --git a/src/test/compile-fail/E0254.rs b/src/test/compile-fail/E0254.rs index 28f9aea9657..e6916f377ea 100644 --- a/src/test/compile-fail/E0254.rs +++ b/src/test/compile-fail/E0254.rs @@ -9,6 +9,7 @@ // except according to those terms. extern crate collections; +//~^ NOTE previous import of `collections` here mod foo { pub trait collections { @@ -16,6 +17,8 @@ mod foo { } } -use foo::collections; //~ ERROR E0254 +use foo::collections; +//~^ ERROR E0254 +//~| NOTE already imported fn main() {} From 045c8c86244aa69843c7f55ec91f2330a3aaec4e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 8 Jul 2016 19:45:37 -0700 Subject: [PATCH 17/37] std: Optimize panic::catch_unwind slightly The previous implementation of this function was overly conservative with liberal usage of `Option` and `.unwrap()` which in theory never triggers. This commit essentially removes the `Option`s in favor of unsafe implementations, improving the code generation of the fast path for LLVM to see through what's happening more clearly. cc #34727 --- src/libstd/panicking.rs | 108 ++++++++++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 38 deletions(-) diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 8c1567939fb..5961fd59699 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -25,9 +25,10 @@ use cell::RefCell; use fmt; use intrinsics; use mem; +use ptr; use raw; -use sys_common::rwlock::RWLock; use sys::stdio::Stderr; +use sys_common::rwlock::RWLock; use sys_common::thread_info; use sys_common::util; use thread; @@ -255,46 +256,77 @@ pub use realstd::rt::update_panic_count; /// Invoke a closure, capturing the cause of an unwinding panic if one occurs. pub unsafe fn try R>(f: F) -> Result> { - let mut slot = None; - let mut f = Some(f); - let ret; + struct Data { + f: F, + r: R, + } - { - let mut to_run = || { - slot = Some(f.take().unwrap()()); - }; - let fnptr = get_call(&mut to_run); - let dataptr = &mut to_run as *mut _ as *mut u8; - let mut any_data = 0; - let mut any_vtable = 0; - let fnptr = mem::transmute::(fnptr); - let r = __rust_maybe_catch_panic(fnptr, - dataptr, - &mut any_data, - &mut any_vtable); - if r == 0 { - ret = Ok(()); - } else { - update_panic_count(-1); - ret = Err(mem::transmute(raw::TraitObject { - data: any_data as *mut _, - vtable: any_vtable as *mut _, - })); + // We do some sketchy operations with ownership here for the sake of + // performance. The `Data` structure is never actually fully valid, but + // instead it always contains at least one uninitialized field. We can only + // pass pointers down to `__rust_maybe_catch_panic` (can't pass objects by + // value), so we do all the ownership tracking here manully. + // + // Note that this is all invalid if any of these functions unwind, but the + // whole point of this function is to prevent that! As a result we go + // through a transition where: + // + // * First, only the closure we're going to call is initialized. The return + // value is uninitialized. + // * When we make the function call, the `do_call` function below, we take + // ownership of the function pointer, replacing it with uninitialized + // data. At this point the `Data` structure is entirely uninitialized, but + // it won't drop due to an unwind because it's owned on the other side of + // the catch panic. + // * If the closure successfully returns, we write the return value into the + // data's return slot. Note that `ptr::write` is used as it's overwriting + // uninitialized data. + // * Finally, when we come back out of the `__rust_maybe_catch_panic` we're + // in one of two states: + // + // 1. The closure didn't panic, in which case the return value was + // filled in. We have to be careful to `forget` the closure, + // however, as ownership was passed to the `do_call` function. + // 2. The closure panicked, in which case the return value wasn't + // filled in. In this case the entire `data` structure is invalid, + // so we forget the entire thing. + // + // Once we stack all that together we should have the "most efficient' + // method of calling a catch panic whilst juggling ownership. + let mut any_data = 0; + let mut any_vtable = 0; + let mut data = Data { + f: f, + r: mem::uninitialized(), + }; + + let r = __rust_maybe_catch_panic(do_call::, + &mut data as *mut _ as *mut u8, + &mut any_data, + &mut any_vtable); + + return if r == 0 { + let Data { f, r } = data; + mem::forget(f); + debug_assert!(update_panic_count(0) == 0); + Ok(r) + } else { + mem::forget(data); + update_panic_count(-1); + debug_assert!(update_panic_count(0) == 0); + Err(mem::transmute(raw::TraitObject { + data: any_data as *mut _, + vtable: any_vtable as *mut _, + })) + }; + + fn do_call R, R>(data: *mut u8) { + unsafe { + let data = data as *mut Data; + let f = ptr::read(&mut (*data).f); + ptr::write(&mut (*data).r, f()); } } - - debug_assert!(update_panic_count(0) == 0); - return ret.map(|()| { - slot.take().unwrap() - }); - - fn get_call(_: &mut F) -> fn(&mut F) { - call - } - - fn call(f: &mut F) { - f() - } } /// Determines whether the current thread is unwinding because of panic. From c99c2ea83810e72f139a7454dd06fb0306ee77f1 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 11 Aug 2016 20:41:04 +0200 Subject: [PATCH 18/37] doc: a value of type `&str` is called a "string slice" --- src/libcollections/string.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 70b514afd03..4f0f1e439af 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1152,7 +1152,7 @@ impl String { self.vec.set_len(len + amt); } - /// Inserts a string into this `String` at a byte position. + /// Inserts a string slice into this `String` at a byte position. /// /// This is an `O(n)` operation as it requires copying every element in the /// buffer. From 071410ba579e2d9be2cb549e51852dde6fef2f7c Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 11 Aug 2016 20:44:49 +0200 Subject: [PATCH 19/37] string: remove needless binding --- src/libcollections/string.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 70b514afd03..50716d03ac4 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1182,8 +1182,7 @@ impl String { reason = "recent addition", issue = "0")] pub fn insert_str(&mut self, idx: usize, string: &str) { - let len = self.len(); - assert!(idx <= len); + assert!(idx <= self.len()); assert!(self.is_char_boundary(idx)); unsafe { From c761184d1de1fec8b49ce1d97e63b5bacb15b7b0 Mon Sep 17 00:00:00 2001 From: crypto-universe Date: Thu, 11 Aug 2016 21:08:36 +0200 Subject: [PATCH 20/37] Fix tidy tests --- src/test/compile-fail/E0254.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/compile-fail/E0254.rs b/src/test/compile-fail/E0254.rs index e6916f377ea..3e4b7b9cad2 100644 --- a/src/test/compile-fail/E0254.rs +++ b/src/test/compile-fail/E0254.rs @@ -17,7 +17,7 @@ mod foo { } } -use foo::collections; +use foo::collections; //~^ ERROR E0254 //~| NOTE already imported From d099e30e48a20eea36a76ab968b8bd9001e0e1fa Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 7 Aug 2016 00:30:17 -0400 Subject: [PATCH 21/37] Introduce `as_slice` method on `std::vec::IntoIter` struct. Similar to the `as_slice` method on `core::slice::Iter` struct. --- src/libcollections/vec.rs | 25 ++++++++++++++++++++++--- src/libcollectionstest/lib.rs | 1 + src/libcollectionstest/vec.rs | 12 ++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 8b4fce158de..696ce3a2a03 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1714,6 +1714,27 @@ pub struct IntoIter { end: *const T, } +impl IntoIter { + /// Returns the remaining items of this iterator as a slice. + /// + /// # Examples + /// + /// ```rust + /// # #![feature(vec_into_iter_as_slice)] + /// let vec = vec!['a', 'b', 'c']; + /// let mut into_iter = vec.into_iter(); + /// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']); + /// let _ = into_iter.next().unwrap(); + /// assert_eq!(into_iter.as_slice(), &['b', 'c']); + /// ``` + #[unstable(feature = "vec_into_iter_as_slice", issue = "35601")] + pub fn as_slice(&self) -> &[T] { + unsafe { + slice::from_raw_parts(self.ptr, self.len()) + } + } +} + #[stable(feature = "rust1", since = "1.0.0")] unsafe impl Send for IntoIter {} #[stable(feature = "rust1", since = "1.0.0")] @@ -1796,9 +1817,7 @@ impl ExactSizeIterator for IntoIter {} #[stable(feature = "vec_into_iter_clone", since = "1.8.0")] impl Clone for IntoIter { fn clone(&self) -> IntoIter { - unsafe { - slice::from_raw_parts(self.ptr, self.len()).to_owned().into_iter() - } + self.as_slice().to_owned().into_iter() } } diff --git a/src/libcollectionstest/lib.rs b/src/libcollectionstest/lib.rs index 8ae63808f27..ab3231b2b99 100644 --- a/src/libcollectionstest/lib.rs +++ b/src/libcollectionstest/lib.rs @@ -28,6 +28,7 @@ #![feature(unboxed_closures)] #![feature(unicode)] #![feature(vec_deque_contains)] +#![feature(vec_into_iter_as_slice)] extern crate collections; extern crate test; diff --git a/src/libcollectionstest/vec.rs b/src/libcollectionstest/vec.rs index 7a6bd958a5f..0302b180aff 100644 --- a/src/libcollectionstest/vec.rs +++ b/src/libcollectionstest/vec.rs @@ -478,6 +478,18 @@ fn test_split_off() { assert_eq!(vec2, [5, 6]); } +#[test] +fn test_into_iter_as_slice() { + let vec = vec!['a', 'b', 'c']; + let mut into_iter = vec.into_iter(); + assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']); + let _ = into_iter.next().unwrap(); + assert_eq!(into_iter.as_slice(), &['b', 'c']); + let _ = into_iter.next().unwrap(); + let _ = into_iter.next().unwrap(); + assert_eq!(into_iter.as_slice(), &[]); +} + #[test] fn test_into_iter_count() { assert_eq!(vec![1, 2, 3].into_iter().count(), 3); From 01a766e5210157546a2b6c673700b9959289eff9 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 7 Aug 2016 10:08:40 -0400 Subject: [PATCH 22/37] Introduce `as_mut_slice` method on `std::vec::IntoIter` struct. --- src/libcollections/vec.rs | 38 ++++++++++++++++++++++++++--------- src/libcollectionstest/vec.rs | 11 ++++++++++ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 696ce3a2a03..a6f817a8962 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1446,13 +1446,12 @@ impl IntoIterator for Vec { #[inline] fn into_iter(mut self) -> IntoIter { unsafe { - let ptr = self.as_mut_ptr(); - assume(!ptr.is_null()); - let begin = ptr as *const T; + let begin = self.as_mut_ptr(); + assume(!begin.is_null()); let end = if mem::size_of::() == 0 { - arith_offset(ptr as *const i8, self.len() as isize) as *const T + arith_offset(begin as *const i8, self.len() as isize) as *const T } else { - ptr.offset(self.len() as isize) as *const T + begin.offset(self.len() as isize) as *const T }; let buf = ptr::read(&self.buf); mem::forget(self); @@ -1710,7 +1709,7 @@ impl<'a, T> FromIterator for Cow<'a, [T]> where T: Clone { #[stable(feature = "rust1", since = "1.0.0")] pub struct IntoIter { _buf: RawVec, - ptr: *const T, + ptr: *mut T, end: *const T, } @@ -1733,6 +1732,27 @@ impl IntoIter { slice::from_raw_parts(self.ptr, self.len()) } } + + /// Returns the remaining items of this iterator as a mutable slice. + /// + /// # Examples + /// + /// ```rust + /// # #![feature(vec_into_iter_as_slice)] + /// let vec = vec!['a', 'b', 'c']; + /// let mut into_iter = vec.into_iter(); + /// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']); + /// into_iter.as_mut_slice()[2] = 'z'; + /// assert_eq!(into_iter.next().unwrap(), 'a'); + /// assert_eq!(into_iter.next().unwrap(), 'b'); + /// assert_eq!(into_iter.next().unwrap(), 'z'); + /// ``` + #[unstable(feature = "vec_into_iter_as_slice", issue = "35601")] + pub fn as_mut_slice(&self) -> &mut [T] { + unsafe { + slice::from_raw_parts_mut(self.ptr, self.len()) + } + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1747,14 +1767,14 @@ impl Iterator for IntoIter { #[inline] fn next(&mut self) -> Option { unsafe { - if self.ptr == self.end { + if self.ptr as *const _ == self.end { None } else { if mem::size_of::() == 0 { // purposefully don't use 'ptr.offset' because for // vectors with 0-size elements this would return the // same pointer. - self.ptr = arith_offset(self.ptr as *const i8, 1) as *const T; + self.ptr = arith_offset(self.ptr as *const i8, 1) as *mut T; // Use a non-null pointer value Some(ptr::read(EMPTY as *mut T)) @@ -1797,7 +1817,7 @@ impl DoubleEndedIterator for IntoIter { } else { if mem::size_of::() == 0 { // See above for why 'ptr.offset' isn't used - self.end = arith_offset(self.end as *const i8, -1) as *const T; + self.end = arith_offset(self.end as *const i8, -1) as *mut T; // Use a non-null pointer value Some(ptr::read(EMPTY as *mut T)) diff --git a/src/libcollectionstest/vec.rs b/src/libcollectionstest/vec.rs index 0302b180aff..9556174bd22 100644 --- a/src/libcollectionstest/vec.rs +++ b/src/libcollectionstest/vec.rs @@ -490,6 +490,17 @@ fn test_into_iter_as_slice() { assert_eq!(into_iter.as_slice(), &[]); } +#[test] +fn test_into_iter_as_mut_slice() { + let vec = vec!['a', 'b', 'c']; + let mut into_iter = vec.into_iter(); + assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']); + into_iter.as_mut_slice()[0] = 'x'; + into_iter.as_mut_slice()[1] = 'y'; + assert_eq!(into_iter.next().unwrap(), 'x'); + assert_eq!(into_iter.as_slice(), &['y', 'c']); +} + #[test] fn test_into_iter_count() { assert_eq!(vec![1, 2, 3].into_iter().count(), 3); From fc97b5cc6f3662281012e56b9ed90a053ea85185 Mon Sep 17 00:00:00 2001 From: Mark-Simulacrum Date: Thu, 11 Aug 2016 15:46:10 -0600 Subject: [PATCH 23/37] Change stabilization version of no_std from 1.0 to 1.6. --- src/libsyntax/feature_gate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 29da0fb1a27..fdf7d6f7bfa 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -307,7 +307,7 @@ declare_features! ( (accepted, issue_5723_bootstrap, "1.0.0", None), (accepted, macro_rules, "1.0.0", None), // Allows using #![no_std] - (accepted, no_std, "1.0.0", None), + (accepted, no_std, "1.6.0", None), (accepted, slicing_syntax, "1.0.0", None), (accepted, struct_variant, "1.0.0", None), // These are used to test this portion of the compiler, they don't actually From 629f2aafcfb81c099816e7777650824676595a13 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 11 Aug 2016 19:04:11 -0400 Subject: [PATCH 24/37] Fix typo Didn't see this one at first. --- src/libstd/env.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 2c0de960561..75e4d271bf8 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -529,7 +529,7 @@ pub fn temp_dir() -> PathBuf { /// This sort of behavior has been known to [lead to privilege escalation] when /// used incorrectly, for example. /// -/// [lead to privledge escalation]: http://securityvulns.com/Wdocument183.html +/// [lead to privilege escalation]: http://securityvulns.com/Wdocument183.html /// /// # Examples /// From 42247372c6c507beed4d309ea5867579d5b65511 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 11 Aug 2016 21:47:56 -0700 Subject: [PATCH 25/37] Improve &-ptr printing --- src/librustc/ty/error.rs | 19 ++++++++++++++++++- src/test/compile-fail/coercion-slice.rs | 2 +- src/test/compile-fail/cross-borrow-trait.rs | 2 +- .../compile-fail/destructure-trait-ref.rs | 4 ++-- src/test/compile-fail/dst-bad-coercions.rs | 4 ++-- src/test/compile-fail/issue-12997-2.rs | 2 +- src/test/compile-fail/issue-16338.rs | 2 +- src/test/compile-fail/issue-17033.rs | 2 +- src/test/compile-fail/issue-20225.rs | 6 +++--- src/test/compile-fail/issue-29084.rs | 2 +- src/test/compile-fail/issue-5100.rs | 2 +- src/test/compile-fail/issue-5500.rs | 2 +- src/test/compile-fail/issue-7061.rs | 2 +- src/test/compile-fail/issue-7867.rs | 4 ++-- src/test/compile-fail/method-self-arg-1.rs | 2 +- src/test/compile-fail/overloaded-calls-bad.rs | 2 +- src/test/compile-fail/repeat_count.rs | 2 +- 17 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index bddc2dbdb7e..fd1a795574f 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -222,7 +222,24 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { ty::TyArray(_, n) => format!("array of {} elements", n), ty::TySlice(_) => "slice".to_string(), ty::TyRawPtr(_) => "*-ptr".to_string(), - ty::TyRef(_, _) => "&-ptr".to_string(), + ty::TyRef(region, tymut) => { + let tymut_string = tymut.to_string(); + if tymut_string == "_" || //unknown type name, + tymut_string.len() > 10 || //name longer than saying "reference", + region.to_string() != "" //... or a complex type + { + match tymut { + ty::TypeAndMut{mutbl, ..} => { + format!("{}reference", match mutbl { + hir::Mutability::MutMutable => "mutable ", + _ => "" + }) + } + } + } else { + format!("&{}", tymut_string) + } + } ty::TyFnDef(..) => format!("fn item"), ty::TyFnPtr(_) => "fn pointer".to_string(), ty::TyTrait(ref inner) => { diff --git a/src/test/compile-fail/coercion-slice.rs b/src/test/compile-fail/coercion-slice.rs index a619f33468f..6b468ff9662 100644 --- a/src/test/compile-fail/coercion-slice.rs +++ b/src/test/compile-fail/coercion-slice.rs @@ -15,5 +15,5 @@ fn main() { //~^ ERROR mismatched types //~| expected type `&[i32]` //~| found type `[{integer}; 1]` - //~| expected &-ptr, found array of 1 elements + //~| expected &[i32], found array of 1 elements } diff --git a/src/test/compile-fail/cross-borrow-trait.rs b/src/test/compile-fail/cross-borrow-trait.rs index ea9a29c0e2a..672ff464718 100644 --- a/src/test/compile-fail/cross-borrow-trait.rs +++ b/src/test/compile-fail/cross-borrow-trait.rs @@ -21,5 +21,5 @@ pub fn main() { let _y: &Trait = x; //~ ERROR mismatched types //~| expected type `&Trait` //~| found type `Box` - //~| expected &-ptr, found box + //~| expected &Trait, found box } diff --git a/src/test/compile-fail/destructure-trait-ref.rs b/src/test/compile-fail/destructure-trait-ref.rs index d0a31fbce91..89fb1e10590 100644 --- a/src/test/compile-fail/destructure-trait-ref.rs +++ b/src/test/compile-fail/destructure-trait-ref.rs @@ -42,12 +42,12 @@ fn main() { //~^ ERROR mismatched types //~| expected type `T` //~| found type `&_` - //~| expected trait T, found &-ptr + //~| expected trait T, found reference let &&&x = &(&1isize as &T); //~^ ERROR mismatched types //~| expected type `T` //~| found type `&_` - //~| expected trait T, found &-ptr + //~| expected trait T, found reference let box box x = box 1isize as Box; //~^ ERROR mismatched types //~| expected type `T` diff --git a/src/test/compile-fail/dst-bad-coercions.rs b/src/test/compile-fail/dst-bad-coercions.rs index b7a07e48799..883c16b0895 100644 --- a/src/test/compile-fail/dst-bad-coercions.rs +++ b/src/test/compile-fail/dst-bad-coercions.rs @@ -19,12 +19,12 @@ struct Foo { } pub fn main() { - // Test that we cannot convert from *-ptr to &-ptr + // Test that we cannot convert from *-ptr to &S and &T let x: *const S = &S; let y: &S = x; //~ ERROR mismatched types let y: &T = x; //~ ERROR mismatched types - // Test that we cannot convert from *-ptr to &-ptr (mut version) + // Test that we cannot convert from *-ptr to &S and &T (mut version) let x: *mut S = &mut S; let y: &S = x; //~ ERROR mismatched types let y: &T = x; //~ ERROR mismatched types diff --git a/src/test/compile-fail/issue-12997-2.rs b/src/test/compile-fail/issue-12997-2.rs index 436d9e91dc7..276d7f7c9ed 100644 --- a/src/test/compile-fail/issue-12997-2.rs +++ b/src/test/compile-fail/issue-12997-2.rs @@ -17,4 +17,4 @@ fn bar(x: isize) { } //~^ ERROR mismatched types //~| expected type `fn(&mut __test::test::Bencher)` //~| found type `fn(isize) {bar}` -//~| expected &-ptr, found isize +//~| expected mutable reference, found isize diff --git a/src/test/compile-fail/issue-16338.rs b/src/test/compile-fail/issue-16338.rs index c6ce0c4c95b..a4517e60d66 100644 --- a/src/test/compile-fail/issue-16338.rs +++ b/src/test/compile-fail/issue-16338.rs @@ -18,5 +18,5 @@ fn main() { //~^ ERROR mismatched types //~| expected type `&str` //~| found type `Slice<_>` - //~| expected &-ptr, found struct `Slice` + //~| expected &str, found struct `Slice` } diff --git a/src/test/compile-fail/issue-17033.rs b/src/test/compile-fail/issue-17033.rs index 0ec05b941a9..1cd43cbb0f8 100644 --- a/src/test/compile-fail/issue-17033.rs +++ b/src/test/compile-fail/issue-17033.rs @@ -12,7 +12,7 @@ fn f<'r>(p: &'r mut fn(p: &mut ())) { (*p)(()) //~ ERROR mismatched types //~| expected type `&mut ()` //~| found type `()` - //~| expected &-ptr, found () + //~| expected &mut (), found () } fn main() {} diff --git a/src/test/compile-fail/issue-20225.rs b/src/test/compile-fail/issue-20225.rs index b7845f1f116..f38961c427a 100644 --- a/src/test/compile-fail/issue-20225.rs +++ b/src/test/compile-fail/issue-20225.rs @@ -15,13 +15,13 @@ struct Foo; impl<'a, T> Fn<(&'a T,)> for Foo { extern "rust-call" fn call(&self, (_,): (T,)) {} //~^ ERROR: has an incompatible type for trait - //~| expected &-ptr + //~| expected reference } impl<'a, T> FnMut<(&'a T,)> for Foo { extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {} //~^ ERROR: has an incompatible type for trait - //~| expected &-ptr + //~| expected reference } impl<'a, T> FnOnce<(&'a T,)> for Foo { @@ -29,7 +29,7 @@ impl<'a, T> FnOnce<(&'a T,)> for Foo { extern "rust-call" fn call_once(self, (_,): (T,)) {} //~^ ERROR: has an incompatible type for trait - //~| expected &-ptr + //~| expected reference } fn main() {} diff --git a/src/test/compile-fail/issue-29084.rs b/src/test/compile-fail/issue-29084.rs index 00d2969a0f6..6cb6bbf1893 100644 --- a/src/test/compile-fail/issue-29084.rs +++ b/src/test/compile-fail/issue-29084.rs @@ -13,7 +13,7 @@ macro_rules! foo { fn bar(d: u8) { } bar(&mut $d); //~^ ERROR mismatched types - //~| expected u8, found &-ptr + //~| expected u8, found &mut u8 //~| expected type `u8` //~| found type `&mut u8` }} diff --git a/src/test/compile-fail/issue-5100.rs b/src/test/compile-fail/issue-5100.rs index 9e78b7b947f..a1f5d74b30e 100644 --- a/src/test/compile-fail/issue-5100.rs +++ b/src/test/compile-fail/issue-5100.rs @@ -52,7 +52,7 @@ fn main() { //~^ ERROR mismatched types //~| expected type `(bool, bool)` //~| found type `&_` -//~| expected tuple, found &-ptr +//~| expected tuple, found reference } diff --git a/src/test/compile-fail/issue-5500.rs b/src/test/compile-fail/issue-5500.rs index cacbf7656de..1cbb7588e17 100644 --- a/src/test/compile-fail/issue-5500.rs +++ b/src/test/compile-fail/issue-5500.rs @@ -13,5 +13,5 @@ fn main() { //~^ ERROR mismatched types //~| expected type `()` //~| found type `&_` - //~| expected (), found &-ptr + //~| expected (), found reference } diff --git a/src/test/compile-fail/issue-7061.rs b/src/test/compile-fail/issue-7061.rs index 1519d71dd3b..da6f49f3efe 100644 --- a/src/test/compile-fail/issue-7061.rs +++ b/src/test/compile-fail/issue-7061.rs @@ -15,7 +15,7 @@ impl<'a> BarStruct { //~^ ERROR mismatched types //~| expected type `Box` //~| found type `&'a mut BarStruct` - //~| expected box, found &-ptr + //~| expected box, found mutable reference } fn main() {} diff --git a/src/test/compile-fail/issue-7867.rs b/src/test/compile-fail/issue-7867.rs index ed465117344..7d9f8e90585 100644 --- a/src/test/compile-fail/issue-7867.rs +++ b/src/test/compile-fail/issue-7867.rs @@ -27,11 +27,11 @@ fn main() { //~^ ERROR mismatched types //~| expected type `&std::option::Option<{integer}>` //~| found type `std::option::Option<_>` - //~| expected &-ptr, found enum `std::option::Option` + //~| expected reference, found enum `std::option::Option` None => () //~^ ERROR mismatched types //~| expected type `&std::option::Option<{integer}>` //~| found type `std::option::Option<_>` - //~| expected &-ptr, found enum `std::option::Option` + //~| expected reference, found enum `std::option::Option` } } diff --git a/src/test/compile-fail/method-self-arg-1.rs b/src/test/compile-fail/method-self-arg-1.rs index 03816362d46..4c8800878f0 100644 --- a/src/test/compile-fail/method-self-arg-1.rs +++ b/src/test/compile-fail/method-self-arg-1.rs @@ -21,7 +21,7 @@ fn main() { Foo::bar(x); //~ ERROR mismatched types //~| expected type `&Foo` //~| found type `Foo` - //~| expected &-ptr, found struct `Foo` + //~| expected &Foo, found struct `Foo` Foo::bar(&42); //~ ERROR mismatched types //~| expected type `&Foo` //~| found type `&{integer}` diff --git a/src/test/compile-fail/overloaded-calls-bad.rs b/src/test/compile-fail/overloaded-calls-bad.rs index 5865d93e128..1825ec61f1e 100644 --- a/src/test/compile-fail/overloaded-calls-bad.rs +++ b/src/test/compile-fail/overloaded-calls-bad.rs @@ -36,7 +36,7 @@ fn main() { y: 3, }; let ans = s("what"); //~ ERROR mismatched types - //~^ NOTE expected isize, found &-ptr + //~^ NOTE expected isize, found reference //~| NOTE expected type //~| NOTE found type let ans = s(); diff --git a/src/test/compile-fail/repeat_count.rs b/src/test/compile-fail/repeat_count.rs index 555dd0f0c39..5d5113ce07c 100644 --- a/src/test/compile-fail/repeat_count.rs +++ b/src/test/compile-fail/repeat_count.rs @@ -38,7 +38,7 @@ fn main() { //~^ ERROR mismatched types //~| expected type `usize` //~| found type `&'static str` - //~| expected usize, found &-ptr + //~| expected usize, found reference //~| ERROR expected `usize` for repeat count, found string literal [E0306] //~| expected `usize` let f = [0; -4_isize]; From f76a737bae12788ba6180c13ec5fcba9177d80d4 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Mon, 8 Aug 2016 21:35:15 +0900 Subject: [PATCH 26/37] Correct span for pub_restricted field --- src/libsyntax/parse/parser.rs | 19 ++++++++------- .../span/pub-struct-field.rs} | 24 +++++++------------ src/test/ui/span/pub-struct-field.stderr | 19 +++++++++++++++ 3 files changed, 37 insertions(+), 25 deletions(-) rename src/test/{compile-fail/pub-struct-field-span-26083.rs => ui/span/pub-struct-field.rs} (52%) create mode 100644 src/test/ui/span/pub-struct-field.stderr diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c143e190c6f..72290a9d619 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3760,19 +3760,18 @@ impl<'a> Parser<'a> { } /// Parse a structure field - fn parse_name_and_ty(&mut self, pr: Visibility, - attrs: Vec ) -> PResult<'a, StructField> { - let lo = match pr { - Visibility::Inherited => self.span.lo, - _ => self.last_span.lo, - }; + fn parse_name_and_ty(&mut self, + lo: BytePos, + vis: Visibility, + attrs: Vec) + -> PResult<'a, StructField> { let name = self.parse_ident()?; self.expect(&token::Colon)?; let ty = self.parse_ty_sum()?; Ok(StructField { span: mk_sp(lo, self.last_span.hi), ident: Some(name), - vis: pr, + vis: vis, id: ast::DUMMY_NODE_ID, ty: ty, attrs: attrs, @@ -5092,10 +5091,11 @@ impl<'a> Parser<'a> { /// Parse a structure field declaration pub fn parse_single_struct_field(&mut self, + lo: BytePos, vis: Visibility, attrs: Vec ) -> PResult<'a, StructField> { - let a_var = self.parse_name_and_ty(vis, attrs)?; + let a_var = self.parse_name_and_ty(lo, vis, attrs)?; match self.token { token::Comma => { self.bump(); @@ -5116,8 +5116,9 @@ impl<'a> Parser<'a> { /// Parse an element of a struct definition fn parse_struct_decl_field(&mut self) -> PResult<'a, StructField> { let attrs = self.parse_outer_attributes()?; + let lo = self.span.lo; let vis = self.parse_visibility(true)?; - self.parse_single_struct_field(vis, attrs) + self.parse_single_struct_field(lo, vis, attrs) } // If `allow_path` is false, just parse the `pub` in `pub(path)` (but still parse `pub(crate)`) diff --git a/src/test/compile-fail/pub-struct-field-span-26083.rs b/src/test/ui/span/pub-struct-field.rs similarity index 52% rename from src/test/compile-fail/pub-struct-field-span-26083.rs rename to src/test/ui/span/pub-struct-field.rs index 0dc7e09f0e4..9f8f871200c 100644 --- a/src/test/compile-fail/pub-struct-field-span-26083.rs +++ b/src/test/ui/span/pub-struct-field.rs @@ -1,4 +1,4 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,23 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Regression test for issue #26083 -// Test that span for public struct fields start at `pub` instead of the identifier +// Regression test for issue #26083 and #35435 +// Test that span for public struct fields start at `pub` + +#![feature(pub_restricted)] struct Foo { - pub bar: u8, - - pub - //~^ error: field `bar` is already declared [E0124] bar: u8, - - pub bar: - //~^ error: field `bar` is already declared [E0124] - u8, - - bar: - //~^ error: field `bar` is already declared [E0124] - u8, + pub bar: u8, + pub(crate) bar: u8, } -fn main() { } +fn main() {} diff --git a/src/test/ui/span/pub-struct-field.stderr b/src/test/ui/span/pub-struct-field.stderr new file mode 100644 index 00000000000..2c002c34736 --- /dev/null +++ b/src/test/ui/span/pub-struct-field.stderr @@ -0,0 +1,19 @@ +error[E0124]: field `bar` is already declared + --> $DIR/pub-struct-field.rs:18:5 + | +17 | bar: u8, + | ------- `bar` first declared here +18 | pub bar: u8, + | ^^^^^^^^^^^ field already declared + +error[E0124]: field `bar` is already declared + --> $DIR/pub-struct-field.rs:19:5 + | +17 | bar: u8, + | ------- `bar` first declared here +18 | pub bar: u8, +19 | pub(crate) bar: u8, + | ^^^^^^^^^^^^^^^^^^ field already declared + +error: aborting due to 2 previous errors + From 3042fba44c82a42e427b9e301f3d3f3412e747dc Mon Sep 17 00:00:00 2001 From: Christophe Vu-Brugier Date: Fri, 12 Aug 2016 11:49:52 +0200 Subject: [PATCH 27/37] book: fix the hidden find() functions in error-handling.md The hidden find() functions always returns None. Consequently, one of the examples using find() prints "No file extension found" instead of "File extension: rs" which is the expected output. This patch fixes the issue by implementing find() with std::str::find(). Signed-off-by: Christophe Vu-Brugier --- src/doc/book/error-handling.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/book/error-handling.md b/src/doc/book/error-handling.md index 544f837d69b..6e13b464e4c 100644 --- a/src/doc/book/error-handling.md +++ b/src/doc/book/error-handling.md @@ -166,7 +166,7 @@ story. The other half is *using* the `find` function we've written. Let's try to use it to find the extension in a file name. ```rust -# fn find(_: &str, _: char) -> Option { None } +# fn find(haystack: &str, needle: char) -> Option { haystack.find(needle) } fn main() { let file_name = "foobar.rs"; match find(file_name, '.') { @@ -223,7 +223,7 @@ Getting the extension of a file name is a pretty common operation, so it makes sense to put it into a function: ```rust -# fn find(_: &str, _: char) -> Option { None } +# fn find(haystack: &str, needle: char) -> Option { haystack.find(needle) } // Returns the extension of the given file name, where the extension is defined // as all characters following the first `.`. // If `file_name` has no `.`, then `None` is returned. @@ -272,7 +272,7 @@ Armed with our new combinator, we can rewrite our `extension_explicit` method to get rid of the case analysis: ```rust -# fn find(_: &str, _: char) -> Option { None } +# fn find(haystack: &str, needle: char) -> Option { haystack.find(needle) } // Returns the extension of the given file name, where the extension is defined // as all characters following the first `.`. // If `file_name` has no `.`, then `None` is returned. From bfca761c8c61bb0b9aeb3f3289fa90e084fd9882 Mon Sep 17 00:00:00 2001 From: Matthew Piziak Date: Fri, 12 Aug 2016 12:15:06 -0400 Subject: [PATCH 28/37] fix small typos in std::convert documentation Fix subject-verb agreement in copypasta: "`AsRef` dereference" to "`AsRef` dereferences". Formalize "eg" to "e.g." Italicization of common Latin abbreviations seems to be going out of style in written English, so I left it plain. --- src/libcore/convert.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 48421abc7bb..e68f973d8d9 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -71,8 +71,8 @@ use result::Result; /// /// # Generic Impls /// -/// - `AsRef` auto-dereference if the inner type is a reference or a mutable -/// reference (eg: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`) +/// - `AsRef` auto-dereferences if the inner type is a reference or a mutable +/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`) /// #[stable(feature = "rust1", since = "1.0.0")] pub trait AsRef { @@ -88,8 +88,8 @@ pub trait AsRef { /// /// # Generic Impls /// -/// - `AsMut` auto-dereference if the inner type is a reference or a mutable -/// reference (eg: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`) +/// - `AsMut` auto-dereferences if the inner type is a reference or a mutable +/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`) /// #[stable(feature = "rust1", since = "1.0.0")] pub trait AsMut { From 4ab00e439768937e4079a27957255086b32a6501 Mon Sep 17 00:00:00 2001 From: Clement Miao Date: Fri, 12 Aug 2016 10:15:54 -0700 Subject: [PATCH 29/37] updated E0070 to new error format --- src/librustc_typeck/check/mod.rs | 9 +++++++-- src/test/compile-fail/issue-26093.rs | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 36fdba37061..499b1c64879 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3463,8 +3463,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let tcx = self.tcx; if !tcx.expr_is_lval(&lhs) { - span_err!(tcx.sess, expr.span, E0070, - "invalid left-hand side expression"); + struct_span_err!( + tcx.sess, expr.span, E0070, + "invalid left-hand side expression") + .span_label( + expr.span, + &format!("left-hand of expression not valid")) + .emit(); } let lhs_ty = self.expr_ty(&lhs); diff --git a/src/test/compile-fail/issue-26093.rs b/src/test/compile-fail/issue-26093.rs index 2f43388b7af..39a53648ccf 100644 --- a/src/test/compile-fail/issue-26093.rs +++ b/src/test/compile-fail/issue-26093.rs @@ -12,6 +12,7 @@ macro_rules! not_an_lvalue { ($thing:expr) => { $thing = 42; //~^ ERROR invalid left-hand side expression + //~^^ NOTE left-hand of expression not valid } } From 302a42304760ca5e52051d7c23d5ecd4a6758814 Mon Sep 17 00:00:00 2001 From: Krzysztof Garczynski Date: Sat, 13 Aug 2016 01:33:42 +0200 Subject: [PATCH 30/37] Update E0301 to the new format --- src/librustc_const_eval/check_match.rs | 4 +++- src/test/compile-fail/E0301.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index 3e88dec8cb2..0e56f351c77 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -1175,8 +1175,10 @@ impl<'a, 'gcx, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'gcx> { _: LoanCause) { match kind { MutBorrow => { - span_err!(self.cx.tcx.sess, span, E0301, + struct_span_err!(self.cx.tcx.sess, span, E0301, "cannot mutably borrow in a pattern guard") + .span_label(span, &format!("borrowed mutably in pattern guard")) + .emit(); } ImmBorrow | UniqueImmBorrow => {} } diff --git a/src/test/compile-fail/E0301.rs b/src/test/compile-fail/E0301.rs index 06e98289b0d..b7872509f54 100644 --- a/src/test/compile-fail/E0301.rs +++ b/src/test/compile-fail/E0301.rs @@ -12,6 +12,7 @@ fn main() { match Some(()) { None => { }, option if option.take().is_none() => {}, //~ ERROR E0301 + //~| NOTE borrowed mutably in pattern guard Some(_) => { } } } From 5402d28fe77bbaee77d0087590ecc4c35ec8f1ee Mon Sep 17 00:00:00 2001 From: Krzysztof Garczynski Date: Sat, 13 Aug 2016 02:33:52 +0200 Subject: [PATCH 31/37] Update E0302 to the new format --- src/librustc_const_eval/check_match.rs | 4 +++- src/test/compile-fail/E0302.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index 3e88dec8cb2..88497ab66a8 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -1185,7 +1185,9 @@ impl<'a, 'gcx, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'gcx> { fn mutate(&mut self, _: NodeId, span: Span, _: cmt, mode: MutateMode) { match mode { MutateMode::JustWrite | MutateMode::WriteAndRead => { - span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard") + struct_span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard") + .span_label(span, &format!("assignment in pattern guard")) + .emit(); } MutateMode::Init => {} } diff --git a/src/test/compile-fail/E0302.rs b/src/test/compile-fail/E0302.rs index 6a5ad40b109..5ad74fd6cab 100644 --- a/src/test/compile-fail/E0302.rs +++ b/src/test/compile-fail/E0302.rs @@ -12,6 +12,7 @@ fn main() { match Some(()) { None => { }, option if { option = None; false } => { }, //~ ERROR E0302 + //~| NOTE assignment in pattern guard Some(_) => { } } } From 08e470f9e12a84307b0689ee06d3420c1854fd37 Mon Sep 17 00:00:00 2001 From: Ahmed Charles Date: Fri, 12 Aug 2016 23:45:39 -0700 Subject: [PATCH 32/37] compiletest: Remove dead code. --- src/tools/compiletest/src/runtest.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index ae8e82e4e2f..e9ccc029bc3 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -137,10 +137,6 @@ impl<'test> TestCx<'test> { self.check_correct_failure_status(&proc_res); - if proc_res.status.success() { - self.fatal("process did not return an error status"); - } - let output_to_check = self.get_output(&proc_res); let expected_errors = errors::load_errors(&self.testpaths.file, self.revision); if !expected_errors.is_empty() { From bd90a1615111b8fff54f9b5fcf25491d42047c0f Mon Sep 17 00:00:00 2001 From: Clement Miao Date: Sat, 13 Aug 2016 00:03:04 -0700 Subject: [PATCH 33/37] updated E0067 to new error format --- src/librustc_typeck/check/op.rs | 8 +++++++- src/test/compile-fail/E0067.rs | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 63487683ec3..cdca988084c 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -41,7 +41,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let tcx = self.tcx; if !tcx.expr_is_lval(lhs_expr) { - span_err!(tcx.sess, lhs_expr.span, E0067, "invalid left-hand side expression"); + struct_span_err!( + tcx.sess, lhs_expr.span, + E0067, "invalid left-hand side expression") + .span_label( + lhs_expr.span, + &format!("invalid expression for left-hand side")) + .emit(); } } diff --git a/src/test/compile-fail/E0067.rs b/src/test/compile-fail/E0067.rs index a3fc30ee1c7..56d2e828062 100644 --- a/src/test/compile-fail/E0067.rs +++ b/src/test/compile-fail/E0067.rs @@ -13,4 +13,6 @@ use std::collections::LinkedList; fn main() { LinkedList::new() += 1; //~ ERROR E0368 //~^ ERROR E0067 + //~^^ NOTE invalid expression for left-hand side + //~| NOTE cannot use `+=` on type `std::collections::LinkedList<_>` } From 85388f0958f90f523102af1fb64c3b1a0aa164f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20manuel=20Barroso=20Galindo?= Date: Sat, 13 Aug 2016 16:32:43 +0700 Subject: [PATCH 34/37] E0094 error message updated Part of #35233 Fixes #35231 --- src/librustc_typeck/check/intrinsic.rs | 6 ++++-- src/test/compile-fail/E0094.rs | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 9051b1c8069..084bbff3383 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -51,10 +51,12 @@ fn equate_intrinsic_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, })); let i_n_tps = i_ty.generics.types.len(subst::FnSpace); if i_n_tps != n_tps { - span_err!(tcx.sess, it.span, E0094, + struct_span_err!(tcx.sess, it.span, E0094, "intrinsic has wrong number of type \ parameters: found {}, expected {}", - i_n_tps, n_tps); + i_n_tps, n_tps) + .span_label(it.span, &format!("expected {} type parameter", n_tps)) + .emit(); } else { require_same_types(ccx, TypeOrigin::IntrinsicType(it.span), diff --git a/src/test/compile-fail/E0094.rs b/src/test/compile-fail/E0094.rs index 3a31874b244..d09353a2038 100644 --- a/src/test/compile-fail/E0094.rs +++ b/src/test/compile-fail/E0094.rs @@ -11,6 +11,7 @@ #![feature(intrinsics)] extern "rust-intrinsic" { fn size_of() -> usize; //~ ERROR E0094 + //~| NOTE expected 1 type parameter } fn main() { From 6fbff4f06a7e5b62d985c2ce28c5303bf5b8fe43 Mon Sep 17 00:00:00 2001 From: Ahmed Charles Date: Sat, 13 Aug 2016 02:41:43 -0700 Subject: [PATCH 35/37] Ensure that attributes are spelled properly. --- src/doc/book/variable-bindings.md | 2 +- src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs | 2 +- src/test/run-pass/enum-variants.rs | 2 +- src/test/run-pass/fn-type-infer.rs | 2 +- src/test/run-pass/generic-tag.rs | 2 +- src/test/run-pass/issue-12660.rs | 2 +- src/test/run-pass/issue-1451.rs | 2 +- src/test/run-pass/issue-3878.rs | 2 +- src/test/run-pass/issue-4734.rs | 2 +- src/test/run-pass/issue-7911.rs | 2 +- src/test/run-pass/liveness-assign-imm-local-after-loop.rs | 2 +- src/test/run-pass/long-while.rs | 2 +- src/test/run-pass/match-phi.rs | 2 +- src/test/run-pass/output-slot-variants.rs | 2 +- src/test/run-pass/regions-fn-subtyping.rs | 2 +- src/test/run-pass/traits-default-method-mut.rs | 2 +- src/test/run-pass/typestate-cfg-nesting.rs | 2 +- src/test/run-pass/unique-move-drop.rs | 2 +- src/test/run-pass/unit.rs | 2 +- src/test/run-pass/unreachable-code-1.rs | 2 +- src/test/run-pass/unreachable-code.rs | 4 ++-- src/test/run-pass/unused-move.rs | 2 +- src/test/run-pass/while-loop-constraints-2.rs | 2 +- 23 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/doc/book/variable-bindings.md b/src/doc/book/variable-bindings.md index b6751f57a97..30e922d7f4d 100644 --- a/src/doc/book/variable-bindings.md +++ b/src/doc/book/variable-bindings.md @@ -125,7 +125,7 @@ warning, but it will still print "Hello, world!": ```text Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world) -src/main.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)] +src/main.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variables)] on by default src/main.rs:2 let x: i32; ^ diff --git a/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs b/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs index e9de95b95e5..460eab998c6 100644 --- a/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs +++ b/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs @@ -12,7 +12,7 @@ // ignore-pretty: does not work well with `--test` #![feature(quote, rustc_private)] -#![deny(unused_variable)] +#![deny(unused_variables)] extern crate syntax; diff --git a/src/test/run-pass/enum-variants.rs b/src/test/run-pass/enum-variants.rs index 77e6141d559..5eb7a243acf 100644 --- a/src/test/run-pass/enum-variants.rs +++ b/src/test/run-pass/enum-variants.rs @@ -11,7 +11,7 @@ // pretty-expanded FIXME #23616 #![allow(dead_assignment)] -#![allow(unused_variable)] +#![allow(unused_variables)] enum Animal { Dog (String, f64), diff --git a/src/test/run-pass/fn-type-infer.rs b/src/test/run-pass/fn-type-infer.rs index 3e1674a97e0..ad6c10611aa 100644 --- a/src/test/run-pass/fn-type-infer.rs +++ b/src/test/run-pass/fn-type-infer.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![allow(unused_variable)] +#![allow(unused_variables)] pub fn main() { // We should be able to type infer inside of ||s. diff --git a/src/test/run-pass/generic-tag.rs b/src/test/run-pass/generic-tag.rs index 942bdb97ba2..75fd9fcb7b6 100644 --- a/src/test/run-pass/generic-tag.rs +++ b/src/test/run-pass/generic-tag.rs @@ -11,7 +11,7 @@ // pretty-expanded FIXME #23616 #![allow(dead_assignment)] -#![allow(unused_variable)] +#![allow(unused_variables)] #![allow(unknown_features)] #![feature(box_syntax)] diff --git a/src/test/run-pass/issue-12660.rs b/src/test/run-pass/issue-12660.rs index 331f9d991d6..ebf390cfe4f 100644 --- a/src/test/run-pass/issue-12660.rs +++ b/src/test/run-pass/issue-12660.rs @@ -16,7 +16,7 @@ extern crate issue12660aux; use issue12660aux::{my_fn, MyStruct}; -#[allow(path_statement)] +#[allow(path_statements)] fn main() { my_fn(MyStruct); MyStruct; diff --git a/src/test/run-pass/issue-1451.rs b/src/test/run-pass/issue-1451.rs index 1cbe986e88a..b65a3a9ab70 100644 --- a/src/test/run-pass/issue-1451.rs +++ b/src/test/run-pass/issue-1451.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![allow(unused_variable)] +#![allow(unused_variables)] struct T { f: extern "Rust" fn() } struct S { f: extern "Rust" fn() } diff --git a/src/test/run-pass/issue-3878.rs b/src/test/run-pass/issue-3878.rs index c98110b9054..5d094af2149 100644 --- a/src/test/run-pass/issue-3878.rs +++ b/src/test/run-pass/issue-3878.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![allow(path_statement)] +#![allow(path_statements)] #![allow(unknown_features)] #![feature(box_syntax)] diff --git a/src/test/run-pass/issue-4734.rs b/src/test/run-pass/issue-4734.rs index 88a3b24d14f..9fb826712ad 100644 --- a/src/test/run-pass/issue-4734.rs +++ b/src/test/run-pass/issue-4734.rs @@ -12,7 +12,7 @@ // `e` is a type which requires a destructor. -#![allow(path_statement)] +#![allow(path_statements)] struct A { n: isize } struct B; diff --git a/src/test/run-pass/issue-7911.rs b/src/test/run-pass/issue-7911.rs index 3eb593708be..5324ddb49e7 100644 --- a/src/test/run-pass/issue-7911.rs +++ b/src/test/run-pass/issue-7911.rs @@ -13,7 +13,7 @@ // (Closes #7911) Test that we can use the same self expression // with different mutability in macro in two methods -#![allow(unused_variable)] // unused foobar_immut + foobar_mut +#![allow(unused_variables)] // unused foobar_immut + foobar_mut trait FooBar { fn dummy(&self) { } } diff --git a/src/test/run-pass/liveness-assign-imm-local-after-loop.rs b/src/test/run-pass/liveness-assign-imm-local-after-loop.rs index df89809ef1f..dfa08055046 100644 --- a/src/test/run-pass/liveness-assign-imm-local-after-loop.rs +++ b/src/test/run-pass/liveness-assign-imm-local-after-loop.rs @@ -12,7 +12,7 @@ #![allow(dead_assignment)] #![allow(unreachable_code)] -#![allow(unused_variable)] +#![allow(unused_variables)] fn test(_cond: bool) { let v: isize; diff --git a/src/test/run-pass/long-while.rs b/src/test/run-pass/long-while.rs index 6e0f1bb87a5..ce55c761202 100644 --- a/src/test/run-pass/long-while.rs +++ b/src/test/run-pass/long-while.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![allow(unused_variable)] +#![allow(unused_variables)] pub fn main() { let mut i: isize = 0; diff --git a/src/test/run-pass/match-phi.rs b/src/test/run-pass/match-phi.rs index ac070cb1f25..24185ffa412 100644 --- a/src/test/run-pass/match-phi.rs +++ b/src/test/run-pass/match-phi.rs @@ -11,7 +11,7 @@ // pretty-expanded FIXME #23616 #![allow(dead_assignment)] -#![allow(unused_variable)] +#![allow(unused_variables)] enum thing { a, b, c, } diff --git a/src/test/run-pass/output-slot-variants.rs b/src/test/run-pass/output-slot-variants.rs index 33489688d4a..4c3017c066e 100644 --- a/src/test/run-pass/output-slot-variants.rs +++ b/src/test/run-pass/output-slot-variants.rs @@ -11,7 +11,7 @@ // pretty-expanded FIXME #23616 #![allow(dead_assignment)] -#![allow(unused_variable)] +#![allow(unused_variables)] #![allow(unknown_features)] #![feature(box_syntax)] diff --git a/src/test/run-pass/regions-fn-subtyping.rs b/src/test/run-pass/regions-fn-subtyping.rs index e5b652c306f..fc42fbc714c 100644 --- a/src/test/run-pass/regions-fn-subtyping.rs +++ b/src/test/run-pass/regions-fn-subtyping.rs @@ -13,7 +13,7 @@ // pretty-expanded FIXME #23616 #![allow(dead_assignment)] -#![allow(unused_variable)] +#![allow(unused_variables)] #![allow(unknown_features)] // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. diff --git a/src/test/run-pass/traits-default-method-mut.rs b/src/test/run-pass/traits-default-method-mut.rs index 3f61eb47233..bcdadb1d90d 100644 --- a/src/test/run-pass/traits-default-method-mut.rs +++ b/src/test/run-pass/traits-default-method-mut.rs @@ -11,7 +11,7 @@ // pretty-expanded FIXME #23616 #![allow(dead_assignment)] -#![allow(unused_variable)] +#![allow(unused_variables)] trait Foo { fn foo(&self, mut v: isize) { v = 1; } diff --git a/src/test/run-pass/typestate-cfg-nesting.rs b/src/test/run-pass/typestate-cfg-nesting.rs index 86184f6cf0f..2acaff26269 100644 --- a/src/test/run-pass/typestate-cfg-nesting.rs +++ b/src/test/run-pass/typestate-cfg-nesting.rs @@ -11,7 +11,7 @@ // pretty-expanded FIXME #23616 #![allow(dead_assignment)] -#![allow(unused_variable)] +#![allow(unused_variables)] fn f() { let x = 10; let mut y = 11; diff --git a/src/test/run-pass/unique-move-drop.rs b/src/test/run-pass/unique-move-drop.rs index 530ba478910..c2813771b7c 100644 --- a/src/test/run-pass/unique-move-drop.rs +++ b/src/test/run-pass/unique-move-drop.rs @@ -9,7 +9,7 @@ // except according to those terms. -#![allow(unused_variable)] +#![allow(unused_variables)] #![allow(unknown_features)] #![feature(box_syntax)] diff --git a/src/test/run-pass/unit.rs b/src/test/run-pass/unit.rs index 2679c4c0331..67eceba020c 100644 --- a/src/test/run-pass/unit.rs +++ b/src/test/run-pass/unit.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![allow(unused_variable)] +#![allow(unused_variables)] #![allow(dead_assignment)] fn f(u: ()) { return u; } diff --git a/src/test/run-pass/unreachable-code-1.rs b/src/test/run-pass/unreachable-code-1.rs index c1c069236c8..189c5cdb9b7 100644 --- a/src/test/run-pass/unreachable-code-1.rs +++ b/src/test/run-pass/unreachable-code-1.rs @@ -10,7 +10,7 @@ #![allow(unreachable_code)] -#![allow(unused_variable)] +#![allow(unused_variables)] fn id(x: bool) -> bool { x } diff --git a/src/test/run-pass/unreachable-code.rs b/src/test/run-pass/unreachable-code.rs index e19fda5f872..5cb5e8c4f99 100644 --- a/src/test/run-pass/unreachable-code.rs +++ b/src/test/run-pass/unreachable-code.rs @@ -9,9 +9,9 @@ // except according to those terms. -#![allow(path_statement)] +#![allow(path_statements)] #![allow(unreachable_code)] -#![allow(unused_variable)] +#![allow(unused_variables)] fn id(x: bool) -> bool { x } diff --git a/src/test/run-pass/unused-move.rs b/src/test/run-pass/unused-move.rs index 015b6f80946..e4b9d14fb4b 100644 --- a/src/test/run-pass/unused-move.rs +++ b/src/test/run-pass/unused-move.rs @@ -14,7 +14,7 @@ // pretty-expanded FIXME #23616 -#![allow(path_statement)] +#![allow(path_statements)] #![allow(unknown_features)] #![feature(box_syntax)] diff --git a/src/test/run-pass/while-loop-constraints-2.rs b/src/test/run-pass/while-loop-constraints-2.rs index 6e339232475..6e9e7bc24d6 100644 --- a/src/test/run-pass/while-loop-constraints-2.rs +++ b/src/test/run-pass/while-loop-constraints-2.rs @@ -9,7 +9,7 @@ // except according to those terms. #![allow(dead_assignment)] -#![allow(unused_variable)] +#![allow(unused_variables)] pub fn main() { let mut y: isize = 42; From ab00b940bb6e47e5fc59d363396fe6fc9e3245c6 Mon Sep 17 00:00:00 2001 From: Ahmed Charles Date: Sat, 13 Aug 2016 02:45:53 -0700 Subject: [PATCH 36/37] Predicates haven't existed in almost 5 years. This test probably adds negative value other than historical amusement. --- src/test/run-pass/pred-not-bool.rs | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 src/test/run-pass/pred-not-bool.rs diff --git a/src/test/run-pass/pred-not-bool.rs b/src/test/run-pass/pred-not-bool.rs deleted file mode 100644 index f0f3d3d7bd8..00000000000 --- a/src/test/run-pass/pred-not-bool.rs +++ /dev/null @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// this checks that a pred with a non-bool return -// type is rejected, even if the pred is never used - -// pretty-expanded FIXME #23616 - -fn bad(_a: isize) -> isize { return 37; } //~ ERROR Non-boolean return type - -pub fn main() { } From 10fce6e2d7eae9ee8aae70aed219fcefbc12f8c8 Mon Sep 17 00:00:00 2001 From: Ivan Ukhov Date: Sun, 14 Aug 2016 06:59:43 +0200 Subject: [PATCH 37/37] Fix a couple of typos in RawVec --- src/liballoc/raw_vec.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 58c841151c0..cdb70ce5770 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -17,7 +17,7 @@ use super::boxed::Box; use core::ops::Drop; use core::cmp; -/// A low-level utility for more ergonomically allocating, reallocating, and deallocating a +/// A low-level utility for more ergonomically allocating, reallocating, and deallocating /// a buffer of memory on the heap without having to worry about all the corner cases /// involved. This type is excellent for building your own data structures like Vec and VecDeque. /// In particular: @@ -534,8 +534,8 @@ impl RawVec { /// Converts the entire buffer into `Box<[T]>`. /// /// While it is not *strictly* Undefined Behavior to call - /// this procedure while some of the RawVec is unintialized, - /// it cetainly makes it trivial to trigger it. + /// this procedure while some of the RawVec is uninitialized, + /// it certainly makes it trivial to trigger it. /// /// Note that this will correctly reconstitute any `cap` changes /// that may have been performed. (see description of type for details)