From e91b625e86794462c54c3f1bfaeebb2acb709bf9 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Wed, 20 Jul 2016 16:43:53 -0400 Subject: [PATCH 01/41] 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 95aa6468dd9a6..2c0de96056149 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/41] 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 06af200e47839..eb694319f42ef 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/41] 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 0000000000000..8acd88deef2d0 --- /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 127489a89636898bf40101e39faaf91f2f0a308f Mon Sep 17 00:00:00 2001 From: DarkEld3r Date: Tue, 9 Aug 2016 13:13:04 +0300 Subject: [PATCH 04/41] Update compiler error 0093 to use new error format --- src/librustc_typeck/check/intrinsic.rs | 7 +++++-- src/test/compile-fail/E0093.rs | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 8a53c59b4c7fa..33452b441ca81 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -297,8 +297,11 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) { } ref other => { - span_err!(tcx.sess, it.span, E0093, - "unrecognized intrinsic function: `{}`", *other); + struct_span_err!(tcx.sess, it.span, E0093, + "unrecognized intrinsic function: `{}`", + *other) + .span_label(it.span, &format!("unrecognized intrinsic")) + .emit(); return; } }; diff --git a/src/test/compile-fail/E0093.rs b/src/test/compile-fail/E0093.rs index 9b23f6d984ee1..fdc48455a679c 100644 --- a/src/test/compile-fail/E0093.rs +++ b/src/test/compile-fail/E0093.rs @@ -10,7 +10,9 @@ #![feature(intrinsics)] extern "rust-intrinsic" { - fn foo(); //~ ERROR E0093 + fn foo(); + //~^ ERROR E0093 + //~| NOTE unrecognized intrinsic } fn main() { From 1a6fac7ed24b52571ea4b20b440b0acb6e0d8992 Mon Sep 17 00:00:00 2001 From: ShyamSundarB Date: Mon, 8 Aug 2016 00:12:53 +0530 Subject: [PATCH 05/41] 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 4e251793f6917..eab16bd5bd1b5 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 50ffa52e88ba4..deba31db5dfcf 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 fdfd41a456bf6..25568a323e161 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 6287256e866c9..b58fbce8bc648 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 41e88e2f492a9..3313e07667a1c 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 06/41] 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 6986f99926e1e..1e40aa7d18766 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 28fcf4452b3e8..6093f7a81fea1 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 07/41] [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 09f96782e7184..d6ac3ef6c9c50 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 08/41] [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 e6eaefb049080..f884bb2098eb1 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 2975835a27149..26261348020f8 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 09759326afd91..183a522bba749 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 f42a6ab162b70..838005cbc9119 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 f1ce17c0736b6..f26706d1754e0 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 72f952fb6c0df..5b83ce48e5dad 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 039245bfd08ba..130526e72b19c 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 f9e1b651a4933..a8014768d7847 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 ce675547a6819..912cb4c5e8775 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 d22fa6494f036..89af1db7c78f1 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 2110f0b3bf9d6..bcb0c62d9fef4 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 d17056e6d799d..a96d189afaa86 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 3f6f1aa6b5fe3..8efc4cb1b1725 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 c81e16ebb7c60..b350bd1a4ccbf 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 66201ff901f30..8f455c2fe4e1e 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 c260aa95b57f1..e1c2c5684fb5f 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 7e24c8f73ab70..513ab91489c8d 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 ba6815d5b7c69..ffe6b646794e1 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 9562d113ada70..d4f3d15b320d7 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 1fe443484665b..52c7911075ae9 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 844826c45db92..393757035141d 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 9acfb04d781e0..9b2b474351df6 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 efce148ea51d4..a905727afff4f 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 9e8f58694377a..9252762d1bdad 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 ea603fc665dda..035911302cf24 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 f5635fddaf951..76728a0d354b2 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 0794a5e0daf2f..17abf9cb1f251 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 93e2a854ccb2a..86fe06b176532 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 3658b6a508ab2..ad4d56ec50ac0 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 7c2e3f0c91baf..1ad43f5f17fb9 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 9ef66ff2d713c..a5d408448a033 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 3096fe4a266c9..cce5ef4fe17c3 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 a155ee396b614..d3d847127ee95 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 23d5a08e21644..f81c3f2e99d36 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 0158c4282dae7..df64d7140b4b5 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 51b369092f0f4..c7759ca743bbb 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 7734a2e80c3c4..4eb4720e8d7be 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 8b06b02f3cba5..9acc6ff8cf084 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 795c3f46f7579..1d1c83cf12a15 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 09/41] [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 1c25c8f77c196..23687e10e476d 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 9c57f25dfcce8..c29e87f91c9a7 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 1061ca87f6470..75e10d2585308 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 5e242db0a888d..680ad3ecd64a6 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 f1e4f8dfa8c83..cfae9903a95e5 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 2161864f0b696..4863979b3f6c2 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 10/41] 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 6093f7a81fea1..5a06c01241b4b 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 11/41] 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 14b9ebfdba668..fa2909196dcf1 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 80918728316a6..d6c1ce8967a20 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 acb7e0fadd90a..239adedc0ff65 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 12/41] 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 89ead21cc10cb..0171f24101aec 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 13/41] 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 0a363fddd5312..11bde922f47f2 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 97d85e5e71e08..d4630d7c2effb 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 14/41] 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 2a7a0b6232936..5701a89d8bc42 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 b9762f8b8c5576fec873132876c4ea0f624e486c Mon Sep 17 00:00:00 2001 From: "Panashe M. Fundira" Date: Mon, 8 Aug 2016 16:37:44 -0400 Subject: [PATCH 15/41] Update E0033 to the new error format --- src/librustc_typeck/check/_match.rs | 8 +++++--- src/test/compile-fail/E0033.rs | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 5f255cc1fb730..db161379920e3 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -347,9 +347,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let ty::TyTrait(..) = mt.ty.sty { // This is "x = SomeTrait" being reduced from // "let &x = &SomeTrait" or "let box x = Box", an error. - span_err!(self.tcx.sess, span, E0033, - "type `{}` cannot be dereferenced", - self.ty_to_string(expected)); + let type_str = self.ty_to_string(expected); + struct_span_err!(self.tcx.sess, span, E0033, + "type `{}` cannot be dereferenced", type_str) + .span_label(span, &format!("type `{}` cannot be dereferenced", type_str)) + .emit(); return false } } diff --git a/src/test/compile-fail/E0033.rs b/src/test/compile-fail/E0033.rs index 946600013f33d..fe75b6b1f0f1b 100644 --- a/src/test/compile-fail/E0033.rs +++ b/src/test/compile-fail/E0033.rs @@ -15,5 +15,9 @@ trait SomeTrait { fn main() { let trait_obj: &SomeTrait = SomeTrait; //~ ERROR E0425 //~^ ERROR E0038 - let &invalid = trait_obj; //~ ERROR E0033 + //~| method `foo` has no receiver + + let &invalid = trait_obj; + //~^ ERROR E0033 + //~| NOTE type `&SomeTrait` cannot be dereferenced } From c0ff3c1070f5983c96ddbfe702bd60679305e7b5 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 11 Aug 2016 11:22:39 -0500 Subject: [PATCH 16/41] 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 239adedc0ff65..402a6736440c8 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 17/41] 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 29f16da058129..18dc99dd6c34c 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 1c378925a16ee93f6391dfb6855e449309b8e34a Mon Sep 17 00:00:00 2001 From: Jesus Garlea Date: Fri, 5 Aug 2016 23:01:49 -0500 Subject: [PATCH 18/41] Update E0220 message to new format --- src/librustc_typeck/astconv.rs | 11 +++++++---- src/test/compile-fail/E0220.rs | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index a11df5ae05d6f..52e531eb8dc73 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1267,10 +1267,13 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { -> Result, ErrorReported> { if bounds.is_empty() { - span_err!(self.tcx().sess, span, E0220, - "associated type `{}` not found for `{}`", - assoc_name, - ty_param_name); + struct_span_err!(self.tcx().sess, span, E0220, + "associated type `{}` not found for `{}`", + assoc_name, + ty_param_name) + .span_label(span, &format!("associated type `{}` not found", + assoc_name)) + .emit(); return Err(ErrorReported); } diff --git a/src/test/compile-fail/E0220.rs b/src/test/compile-fail/E0220.rs index 17e2b18b3745e..42b2634a55614 100644 --- a/src/test/compile-fail/E0220.rs +++ b/src/test/compile-fail/E0220.rs @@ -13,6 +13,7 @@ trait Trait { } type Foo = Trait; //~ ERROR E0220 + //~| NOTE associated type `F` not found //~^ ERROR E0191 fn main() { From 80beeb35744f97d65759fec662043cbe34857e8b Mon Sep 17 00:00:00 2001 From: "Panashe M. Fundira" Date: Thu, 11 Aug 2016 14:03:38 -0400 Subject: [PATCH 19/41] Add additional error note --- src/test/compile-fail/E0033.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/compile-fail/E0033.rs b/src/test/compile-fail/E0033.rs index fe75b6b1f0f1b..8a1cd2ef4b71c 100644 --- a/src/test/compile-fail/E0033.rs +++ b/src/test/compile-fail/E0033.rs @@ -16,6 +16,7 @@ fn main() { let trait_obj: &SomeTrait = SomeTrait; //~ ERROR E0425 //~^ ERROR E0038 //~| method `foo` has no receiver + //~| NOTE the trait `SomeTrait` cannot be made into an object let &invalid = trait_obj; //~^ ERROR E0033 From 4209f948b175b61056560f91dd0bd1719ba61deb Mon Sep 17 00:00:00 2001 From: crypto-universe Date: Thu, 11 Aug 2016 01:52:44 +0200 Subject: [PATCH 20/41] 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 860e569ba7e5e..896b4a1847de9 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 28f9aea96572c..e6916f377ea12 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 21/41] 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 | 104 ++++++++++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 36 deletions(-) diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 8c1567939fb37..5961fd59699c1 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,45 +256,76 @@ 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; - - { - 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 _, - })); - } + struct Data { + f: F, + r: R, } - debug_assert!(update_panic_count(0) == 0); - return ret.map(|()| { - slot.take().unwrap() - }); + // 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(), + }; - fn get_call(_: &mut F) -> fn(&mut F) { - call - } + 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 call(f: &mut F) { - f() + 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()); + } } } From c99c2ea83810e72f139a7454dd06fb0306ee77f1 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 11 Aug 2016 20:41:04 +0200 Subject: [PATCH 22/41] 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 70b514afd035f..4f0f1e439af3f 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 23/41] 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 70b514afd035f..50716d03ac470 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 24/41] 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 e6916f377ea12..3e4b7b9cad2d4 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 25/41] 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 8b4fce158de46..696ce3a2a03e9 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 8ae63808f2740..ab3231b2b9955 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 7a6bd958a5f8c..0302b180aff56 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 26/41] 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 696ce3a2a03e9..a6f817a89624c 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 0302b180aff56..9556174bd2294 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 27/41] 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 29da0fb1a2735..fdf7d6f7bfa0f 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 28/41] 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 2c0de96056149..75e4d271bf8b5 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 29/41] 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 bddc2dbdb7e77..fd1a795574f2f 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 a619f33468f4a..6b468ff96620d 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 ea9a29c0e2ae5..672ff464718f8 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 d0a31fbce91ed..89fb1e105900d 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 b7a07e487994d..883c16b089581 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 436d9e91dc72f..276d7f7c9ed33 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 c6ce0c4c95b8b..a4517e60d66e1 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 0ec05b941a960..1cd43cbb0f857 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 b7845f1f1168a..f38961c427ae9 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 00d2969a0f67d..6cb6bbf1893fc 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 9e78b7b947f98..a1f5d74b30e36 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 cacbf7656def2..1cbb7588e17df 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 1519d71dd3be2..da6f49f3efe91 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 ed465117344d4..7d9f8e9058521 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 03816362d46c3..4c8800878f07d 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 5865d93e1282f..1825ec61f1ed7 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 555dd0f0c3945..5d5113ce07c71 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 30/41] 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 c143e190c6fc1..72290a9d619a6 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 0dc7e09f0e4db..9f8f871200ca5 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` -struct Foo { - pub bar: u8, +#![feature(pub_restricted)] - pub - //~^ error: field `bar` is already declared [E0124] +struct Foo { 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 0000000000000..2c002c34736c5 --- /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 31/41] 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 544f837d69b26..6e13b464e4c25 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 32/41] 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 48421abc7bbdf..e68f973d8d940 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 33/41] 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 36fdba3706109..499b1c6487974 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 2f43388b7afb0..39a53648ccf8a 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 34/41] 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 3e88dec8cb27a..0e56f351c77c3 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 06e98289b0d57..b7872509f5408 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 35/41] 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 3e88dec8cb27a..88497ab66a804 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 6a5ad40b10907..5ad74fd6cab05 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 36/41] 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 ae8e82e4e2f60..e9ccc029bc3cf 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 37/41] 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 63487683ec3b9..cdca988084cce 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 a3fc30ee1c71a..56d2e82806230 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 38/41] 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 9051b1c8069bd..084bbff338346 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 3a31874b24422..d09353a203800 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 39/41] 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 b6751f57a9721..30e922d7f4dc0 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 e9de95b95e5fd..460eab998c6fb 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 77e6141d5592d..5eb7a243acf0c 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 3e1674a97e089..ad6c10611aaa0 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 942bdb97ba203..75fd9fcb7b6d8 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 331f9d991d681..ebf390cfe4fc3 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 1cbe986e88af0..b65a3a9ab7084 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 c98110b9054be..5d094af2149e1 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 88a3b24d14fc8..9fb826712adc0 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 3eb593708bee8..5324ddb49e79f 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 df89809ef1fed..dfa080550469a 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 6e0f1bb87a5fb..ce55c76120235 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 ac070cb1f2542..24185ffa4128f 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 33489688d4a5c..4c3017c066e81 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 e5b652c306f4d..fc42fbc714c09 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 3f61eb47233b6..bcdadb1d90d38 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 86184f6cf0f43..2acaff262690b 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 530ba4789102e..c2813771b7c34 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 2679c4c033121..67eceba020c80 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 c1c069236c88d..189c5cdb9b747 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 e19fda5f872d2..5cb5e8c4f99cd 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 015b6f80946f8..e4b9d14fb4b30 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 6e3392324753b..6e9e7bc24d6a0 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 40/41] 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 f0f3d3d7bd886..0000000000000 --- 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 41/41] 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 58c841151c0f0..cdb70ce57708a 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)