From c2e26121dbf6f2ca08e772415b80bc2d80c0d952 Mon Sep 17 00:00:00 2001 From: James Mantooth Date: Wed, 17 Jan 2018 05:23:21 -0600 Subject: [PATCH 01/14] Punctuation and clarity fixes. --- src/doc/unstable-book/src/language-features/generators.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/unstable-book/src/language-features/generators.md b/src/doc/unstable-book/src/language-features/generators.md index 7a559a7bec866..e8e2132dca254 100644 --- a/src/doc/unstable-book/src/language-features/generators.md +++ b/src/doc/unstable-book/src/language-features/generators.md @@ -139,11 +139,11 @@ closure-like semantics. Namely: types and such. * Traits like `Send` and `Sync` are automatically implemented for a `Generator` - depending on the captured variables of the environment. Unlike closures though + depending on the captured variables of the environment. Unlike closures, generators also depend on variables live across suspension points. This means that although the ambient environment may be `Send` or `Sync`, the generator itself may not be due to internal variables live across `yield` points being - not-`Send` or not-`Sync`. Note, though, that generators, like closures, do + not-`Send` or not-`Sync`. Note that generators, like closures, do not implement traits like `Copy` or `Clone` automatically. * Whenever a generator is dropped it will drop all captured environment @@ -155,7 +155,7 @@ lifted at a future date, the design is ongoing! ### Generators as state machines -In the compiler generators are currently compiled as state machines. Each +In the compiler, generators are currently compiled as state machines. Each `yield` expression will correspond to a different state that stores all live variables over that suspension point. Resumption of a generator will dispatch on the current state and then execute internally until a `yield` is reached, at From 831ff775703eb5126f741fc3be1cf829ec060011 Mon Sep 17 00:00:00 2001 From: Corentin Henry Date: Thu, 25 Jan 2018 15:08:48 -0800 Subject: [PATCH 02/14] implement Send for process::Command on unix closes https://github.com/rust-lang/rust/issues/47751 --- src/libstd/sys/unix/process/process_common.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index c53bcdbf8e36f..b09fc36dee0be 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -87,6 +87,11 @@ pub enum Stdio { Fd(FileDesc), } +// Command is not Send by default due to the Command.argv field containing a raw pointers. However +// it is safe to implement Send, because anyway, these pointers point to memory owned by the +// Command.args field. +unsafe impl Send for Command {} + impl Command { pub fn new(program: &OsStr) -> Command { let mut saw_nul = false; From 9e6ed17c4f5befef64fa9e8a1d2b2f155c345cac Mon Sep 17 00:00:00 2001 From: Corentin Henry Date: Fri, 26 Jan 2018 07:22:43 -0800 Subject: [PATCH 03/14] make Command.argv Send on unix platforms Implementing Send for a specific field rather than the whole struct is safer: if a field is changed/modified and becomes non-Send, we can catch it. --- src/libstd/sys/unix/process/process_common.rs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index b09fc36dee0be..7e057401fab70 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -45,7 +45,7 @@ pub struct Command { // other keys. program: CString, args: Vec, - argv: Vec<*const c_char>, + argv: Argv, env: CommandEnv, cwd: Option, @@ -58,6 +58,12 @@ pub struct Command { stderr: Option, } +// Create a new type for argv, so that we can make it `Send` +struct Argv(Vec<*const c_char>); + +// It is safe to make Argv Send, because it contains pointers to memory owned by `Command.args` +unsafe impl Send for Argv {} + // passed back to std::process with the pipes connected to the child, if any // were requested pub struct StdioPipes { @@ -87,17 +93,12 @@ pub enum Stdio { Fd(FileDesc), } -// Command is not Send by default due to the Command.argv field containing a raw pointers. However -// it is safe to implement Send, because anyway, these pointers point to memory owned by the -// Command.args field. -unsafe impl Send for Command {} - impl Command { pub fn new(program: &OsStr) -> Command { let mut saw_nul = false; let program = os2c(program, &mut saw_nul); Command { - argv: vec![program.as_ptr(), ptr::null()], + argv: Argv(vec![program.as_ptr(), ptr::null()]), program, args: Vec::new(), env: Default::default(), @@ -116,8 +117,8 @@ impl Command { // Overwrite the trailing NULL pointer in `argv` and then add a new null // pointer. let arg = os2c(arg, &mut self.saw_nul); - self.argv[self.args.len() + 1] = arg.as_ptr(); - self.argv.push(ptr::null()); + self.argv.0[self.args.len() + 1] = arg.as_ptr(); + self.argv.0.push(ptr::null()); // Also make sure we keep track of the owned value to schedule a // destructor for this memory. @@ -138,7 +139,7 @@ impl Command { self.saw_nul } pub fn get_argv(&self) -> &Vec<*const c_char> { - &self.argv + &self.argv.0 } #[allow(dead_code)] From 0ac465924e6ae4380b25c38cbc14f425796fa2af Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 26 Jan 2018 15:33:05 +0000 Subject: [PATCH 04/14] Add line numbers and columns to error messages spanning multiple files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If an error message is emitted that spans several files, only the primary file currently has line and column data attached. This is useful information, even in files other than the one in which the error occurs. We can often work out which line and column the error corresponds to in other files — in this case it is helpful to add them (in the case of ambiguity, the first relevant line/column is picked, which is still helpful than none). --- src/librustc_errors/emitter.rs | 13 ++++++++++++- src/librustc_errors/snippet.rs | 3 ++- src/test/ui/cross-file-errors/main.rs | 16 ++++++++++++++++ src/test/ui/cross-file-errors/main.stderr | 11 +++++++++++ src/test/ui/cross-file-errors/underscore.rs | 20 ++++++++++++++++++++ src/tools/compiletest/src/runtest.rs | 2 +- 6 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/cross-file-errors/main.rs create mode 100644 src/test/ui/cross-file-errors/main.stderr create mode 100644 src/test/ui/cross-file-errors/underscore.rs diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 58f851aea3817..a9f228ca729b1 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1013,8 +1013,19 @@ impl EmitterWriter { // Then, the secondary file indicator buffer.prepend(buffer_msg_line_offset + 1, "::: ", Style::LineNumber); + let loc = if let Some(first_line) = annotated_file.lines.first() { + let col = if let Some(first_annotation) = first_line.annotations.first() { + format!(":{}", first_annotation.start_col + 1) + } else { "".to_string() }; + format!("{}:{}{}", + annotated_file.file.name, + cm.doctest_offset_line(first_line.line_index), + col) + } else { + annotated_file.file.name.to_string() + }; buffer.append(buffer_msg_line_offset + 1, - &annotated_file.file.name.to_string(), + &loc, Style::LineAndColumn); for _ in 0..max_line_num_len { buffer.prepend(buffer_msg_line_offset + 1, " ", Style::NoStyle); diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index c2f4701999ea9..6035f33c822ce 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -27,7 +27,8 @@ pub struct FileInfo { /// The "primary file", if any, gets a `-->` marker instead of /// `>>>`, and has a line-number/column printed and not just a - /// filename. It appears first in the listing. It is known to + /// filename (other files are not guaranteed to have line numbers + /// or columns). It appears first in the listing. It is known to /// contain at least one primary span, though primary spans (which /// are designated with `^^^`) may also occur in other files. primary_span: Option, diff --git a/src/test/ui/cross-file-errors/main.rs b/src/test/ui/cross-file-errors/main.rs new file mode 100644 index 0000000000000..8eae79a21a983 --- /dev/null +++ b/src/test/ui/cross-file-errors/main.rs @@ -0,0 +1,16 @@ +// Copyright 2018 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. + +#[macro_use] +mod underscore; + +fn main() { + underscore!(); +} diff --git a/src/test/ui/cross-file-errors/main.stderr b/src/test/ui/cross-file-errors/main.stderr new file mode 100644 index 0000000000000..a1cdae10edfcd --- /dev/null +++ b/src/test/ui/cross-file-errors/main.stderr @@ -0,0 +1,11 @@ +error: expected expression, found `_` + --> $DIR/underscore.rs:18:9 + | +18 | _ + | ^ + | + ::: $DIR/main.rs:15:5 + | +15 | underscore!(); + | -------------- in this macro invocation + diff --git a/src/test/ui/cross-file-errors/underscore.rs b/src/test/ui/cross-file-errors/underscore.rs new file mode 100644 index 0000000000000..312b3b8f4ddd5 --- /dev/null +++ b/src/test/ui/cross-file-errors/underscore.rs @@ -0,0 +1,20 @@ +// Copyright 2018 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. + +// We want this file only so we can test cross-file error +// messages, but we don't want it in an external crate. +// ignore-test +#![crate_type = "lib"] + +macro_rules! underscore { + () => ( + _ + ) +} diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index bf5fc00428df2..abf62a060b83b 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1402,7 +1402,7 @@ impl<'test> TestCx<'test> { } /// For each `aux-build: foo/bar` annotation, we check to find the - /// file in a `aux` directory relative to the test itself. + /// file in a `auxiliary` directory relative to the test itself. fn compute_aux_test_paths(&self, rel_ab: &str) -> TestPaths { let test_ab = self.testpaths .file From 077d3434aa8a2a3064afcc1c9406a49d0acf0a8d Mon Sep 17 00:00:00 2001 From: Corentin Henry Date: Fri, 26 Jan 2018 07:33:58 -0800 Subject: [PATCH 05/14] add test checking that process::Command is Send --- src/libstd/process.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 5c66ac6ddded8..9b2f815b71383 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1843,4 +1843,10 @@ mod tests { } assert!(events > 0); } + + #[test] + fn test_command_implements_send() { + fn take_send_type(_: T) {} + take_send_type(Command::new("")) + } } From aa6cc6e1898067c4311e260960bca776f3e02715 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 26 Jan 2018 16:56:37 +0000 Subject: [PATCH 06/14] Fix test in macro_backtrace --- src/test/ui/macro_backtrace/main.stderr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/ui/macro_backtrace/main.stderr b/src/test/ui/macro_backtrace/main.stderr index 5990f71b3ca0a..48138ee711b3f 100644 --- a/src/test/ui/macro_backtrace/main.stderr +++ b/src/test/ui/macro_backtrace/main.stderr @@ -22,7 +22,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found 27 | ping!(); | -------- in this macro invocation | - ::: + ::: :1:1 | 1 | ( ) => { pong ! ( ) ; } | ------------------------- @@ -42,7 +42,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found 28 | deep!(); | -------- in this macro invocation (#1) | - ::: + ::: :1:1 | 1 | ( ) => { foo ! ( ) ; } | ------------------------ @@ -50,7 +50,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | | in this macro invocation (#2) | in this expansion of `deep!` (#1) | - ::: + ::: :1:1 | 1 | ( ) => { bar ! ( ) ; } | ------------------------ @@ -58,7 +58,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | | in this macro invocation (#3) | in this expansion of `foo!` (#2) | - ::: + ::: :1:1 | 1 | ( ) => { ping ! ( ) ; } | ------------------------- @@ -66,7 +66,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | | in this macro invocation (#4) | in this expansion of `bar!` (#3) | - ::: + ::: :1:1 | 1 | ( ) => { pong ! ( ) ; } | ------------------------- From a21b7b3b162932011b83f4703fb87030c216e962 Mon Sep 17 00:00:00 2001 From: varkor Date: Sat, 27 Jan 2018 15:16:42 +0000 Subject: [PATCH 07/14] Improve formatting of else block --- src/librustc_errors/emitter.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index a9f228ca729b1..63c4ae5561c92 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1016,7 +1016,9 @@ impl EmitterWriter { let loc = if let Some(first_line) = annotated_file.lines.first() { let col = if let Some(first_annotation) = first_line.annotations.first() { format!(":{}", first_annotation.start_col + 1) - } else { "".to_string() }; + } else { + "".to_string() + }; format!("{}:{}{}", annotated_file.file.name, cm.doctest_offset_line(first_line.line_index), From 2497d10ff34bf4d03283e4562143762426492789 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Sun, 28 Jan 2018 13:47:06 +0100 Subject: [PATCH 08/14] Whitelist aes x86 feature flag Required to fix https://github.com/rust-lang-nursery/stdsimd/issues/295 in stdsimd. r? @alexcrichton --- src/librustc_trans/llvm_util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_trans/llvm_util.rs b/src/librustc_trans/llvm_util.rs index 15988008de2fc..39ef3db9dc2f6 100644 --- a/src/librustc_trans/llvm_util.rs +++ b/src/librustc_trans/llvm_util.rs @@ -88,7 +88,7 @@ const X86_WHITELIST: &'static [&'static str] = &["avx\0", "avx2\0", "bmi\0", "bm "ssse3\0", "tbm\0", "lzcnt\0", "popcnt\0", "sse4a\0", "rdrnd\0", "rdseed\0", "fma\0", "xsave\0", "xsaveopt\0", "xsavec\0", - "xsaves\0", + "xsaves\0", "aes\0", "avx512bw\0", "avx512cd\0", "avx512dq\0", "avx512er\0", "avx512f\0", "avx512ifma\0", From b32dbbc67e4ffa15c3abed2b6329f5029da7671b Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Sun, 28 Jan 2018 18:50:03 +0100 Subject: [PATCH 09/14] Whitelist v7 feature for ARM and AARCH64. Needed for `v7` features in `coresimd`. See https://github.com/rust-lang-nursery/stdsimd/blob/b2f7be24d5043a88427f9a5258ca9a51ede6d029/coresimd/src/arm/v7.rs#L40 which used to work but doesn't anymore. r? alexcrichton --- src/librustc_trans/llvm_util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_trans/llvm_util.rs b/src/librustc_trans/llvm_util.rs index 15988008de2fc..a517c29032d9f 100644 --- a/src/librustc_trans/llvm_util.rs +++ b/src/librustc_trans/llvm_util.rs @@ -79,9 +79,9 @@ unsafe fn configure_llvm(sess: &Session) { // detection code will walk past the end of the feature array, // leading to crashes. -const ARM_WHITELIST: &'static [&'static str] = &["neon\0", "vfp2\0", "vfp3\0", "vfp4\0"]; +const ARM_WHITELIST: &'static [&'static str] = &["neon\0", "v7\0", "vfp2\0", "vfp3\0", "vfp4\0"]; -const AARCH64_WHITELIST: &'static [&'static str] = &["neon\0"]; +const AARCH64_WHITELIST: &'static [&'static str] = &["neon\0", "v7\0"]; const X86_WHITELIST: &'static [&'static str] = &["avx\0", "avx2\0", "bmi\0", "bmi2\0", "sse\0", "sse2\0", "sse3\0", "sse4.1\0", "sse4.2\0", From 7b4cbbd12d88c8e64d9c7aa1e326c7c78f2a7ed9 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 28 Jan 2018 21:50:01 -0500 Subject: [PATCH 10/14] Document that `Index` ops can panic on `HashMap` & `BTreeMap`. Fixes https://github.com/rust-lang/rust/issues/47011. --- src/liballoc/btree/map.rs | 5 +++++ src/libstd/collections/hash/map.rs | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/liballoc/btree/map.rs b/src/liballoc/btree/map.rs index b114dc640fbaf..b320bed54320a 100644 --- a/src/liballoc/btree/map.rs +++ b/src/liballoc/btree/map.rs @@ -1748,6 +1748,11 @@ impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap { type Output = V; + /// Returns a reference to the value corresponding to the supplied key. + /// + /// # Panics + /// + /// Panics if the key is not present in the `BTreeMap`. #[inline] fn index(&self, key: &Q) -> &V { self.get(key).expect("no entry found for key") diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index b01420f36a0c3..82a687ae5e493 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1384,9 +1384,14 @@ impl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap { type Output = V; + /// Returns a reference to the value corresponding to the supplied key. + /// + /// # Panics + /// + /// Panics if the key is not present in the `HashMap`. #[inline] - fn index(&self, index: &Q) -> &V { - self.get(index).expect("no entry found for key") + fn index(&self, key: &Q) -> &V { + self.get(key).expect("no entry found for key") } } From e09a8bd70c4804234af900f19fbb883045ba8d0d Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 28 Jan 2018 17:09:47 -0700 Subject: [PATCH 11/14] Add per-stage RUSTFLAGS: RUSTFLAGS_STAGE_{0,1,2} and RUSTFLAGS_STAGE_NOT_0 Fixes #47658. --- src/bootstrap/builder.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 79058984b1352..1272643edd259 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -469,6 +469,18 @@ impl<'a> Builder<'a> { stage = compiler.stage; } + let mut extra_args = env::var(&format!("RUSTFLAGS_STAGE_{}", stage)).unwrap_or_default(); + if stage != 0 { + let s = env::var("RUSTFLAGS_STAGE_NOT_0").unwrap_or_default(); + extra_args.push_str(" "); + extra_args.push_str(&s); + } + + if !extra_args.is_empty() { + cargo.env("RUSTFLAGS", + format!("{} {}", env::var("RUSTFLAGS").unwrap_or_default(), extra_args)); + } + // Customize the compiler we're running. Specify the compiler to cargo // as our shim and then pass it some various options used to configure // how the actual compiler itself is called. From 8389b66c1883a44d1d79b932313a40d9c6eb116e Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 29 Jan 2018 17:11:09 +0100 Subject: [PATCH 12/14] Increase test coverage of use_nested_groups --- src/test/run-pass/use-nested-groups.rs | 7 ++++++ src/test/ui/use-nested-groups-error.rs | 27 ++++++++++++++++++++++ src/test/ui/use-nested-groups-error.stderr | 8 +++++++ 3 files changed, 42 insertions(+) create mode 100644 src/test/ui/use-nested-groups-error.rs create mode 100644 src/test/ui/use-nested-groups-error.stderr diff --git a/src/test/run-pass/use-nested-groups.rs b/src/test/run-pass/use-nested-groups.rs index 74a82afd462b8..a28f8da9ff882 100644 --- a/src/test/run-pass/use-nested-groups.rs +++ b/src/test/run-pass/use-nested-groups.rs @@ -24,12 +24,19 @@ mod a { } } +// Test every possible part of the syntax use a::{B, d::{self, *, g::H}}; +// Test a more common use case +use std::sync::{Arc, atomic::{AtomicBool, Ordering}}; + fn main() { let _: B; let _: E; let _: F; let _: H; let _: d::g::I; + + let _: Arc; + let _: Ordering; } diff --git a/src/test/ui/use-nested-groups-error.rs b/src/test/ui/use-nested-groups-error.rs new file mode 100644 index 0000000000000..a9b6b3ee70d57 --- /dev/null +++ b/src/test/ui/use-nested-groups-error.rs @@ -0,0 +1,27 @@ +// Copyright 2018 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. + +#![feature(use_nested_groups)] + +mod a { + pub mod b1 { + pub enum C2 {} + } + + pub enum B2 {} +} + +use a::{b1::{C1, C2}, B2}; +//~^ ERROR unresolved import `a::b1::C1` + +fn main() { + let _: C2; + let _: B2; +} diff --git a/src/test/ui/use-nested-groups-error.stderr b/src/test/ui/use-nested-groups-error.stderr new file mode 100644 index 0000000000000..cae34684c8e38 --- /dev/null +++ b/src/test/ui/use-nested-groups-error.stderr @@ -0,0 +1,8 @@ +error[E0432]: unresolved import `a::b1::C1` + --> $DIR/use-nested-groups-error.rs:21:14 + | +21 | use a::{b1::{C1, C2}, B2}; + | ^^ no `C1` in `a::b1`. Did you mean to use `C2`? + +error: aborting due to previous error + From 898fdcc3eda5c5fa32e893b27f066d2dad77ea77 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Wed, 24 Jan 2018 15:11:15 -0200 Subject: [PATCH 13/14] Make run-pass/env-home-dir.rs test more robust Remove the assumption that home_dir always returns Some This allows the test to be executed with [cross](https://github.com/japaric/cross). --- src/test/run-pass/env-home-dir.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/run-pass/env-home-dir.rs b/src/test/run-pass/env-home-dir.rs index 22e440c6ffa51..449d3b044e920 100644 --- a/src/test/run-pass/env-home-dir.rs +++ b/src/test/run-pass/env-home-dir.rs @@ -16,6 +16,9 @@ use std::env::*; use std::path::PathBuf; +/// When HOME is not set, some platforms return `None`, but others return `Some` with a default. +/// Just check that it is not "/home/MountainView". + #[cfg(unix)] fn main() { let oldhome = var("HOME"); @@ -27,7 +30,7 @@ fn main() { if cfg!(target_os = "android") { assert!(home_dir().is_none()); } else { - assert!(home_dir().is_some()); + assert_ne!(home_dir(), Some(PathBuf::from("/home/MountainView"))); } } From adeb0aeb4a21fe3a944285ad72dab01c10765398 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 29 Jan 2018 13:28:23 -0500 Subject: [PATCH 14/14] move comment right onto the line in question --- src/test/run-pass/env-home-dir.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/run-pass/env-home-dir.rs b/src/test/run-pass/env-home-dir.rs index 449d3b044e920..9bbff1eeb81f3 100644 --- a/src/test/run-pass/env-home-dir.rs +++ b/src/test/run-pass/env-home-dir.rs @@ -16,9 +16,6 @@ use std::env::*; use std::path::PathBuf; -/// When HOME is not set, some platforms return `None`, but others return `Some` with a default. -/// Just check that it is not "/home/MountainView". - #[cfg(unix)] fn main() { let oldhome = var("HOME"); @@ -30,6 +27,9 @@ fn main() { if cfg!(target_os = "android") { assert!(home_dir().is_none()); } else { + // When HOME is not set, some platforms return `None`, + // but others return `Some` with a default. + // Just check that it is not "/home/MountainView". assert_ne!(home_dir(), Some(PathBuf::from("/home/MountainView"))); } }