From dd68685e48db23b340ec31024c4c4aa2d6180a16 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 30 Oct 2018 00:21:39 +0300 Subject: resolve: Fix ICE in macro import error recovery --- src/test/ui/imports/issue-55457.rs | 8 ++++++++ src/test/ui/imports/issue-55457.stderr | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/test/ui/imports/issue-55457.rs create mode 100644 src/test/ui/imports/issue-55457.stderr (limited to 'src/test') diff --git a/src/test/ui/imports/issue-55457.rs b/src/test/ui/imports/issue-55457.rs new file mode 100644 index 00000000000..9c6750fd48c --- /dev/null +++ b/src/test/ui/imports/issue-55457.rs @@ -0,0 +1,8 @@ +use NonExistent; //~ ERROR unresolved import `NonExistent` +use non_existent::non_existent; //~ ERROR unresolved import `non_existent` + +#[non_existent] //~ ERROR cannot determine resolution for the attribute macro `non_existent` +#[derive(NonExistent)] //~ ERROR cannot determine resolution for the derive macro `NonExistent` +struct S; + +fn main() {} diff --git a/src/test/ui/imports/issue-55457.stderr b/src/test/ui/imports/issue-55457.stderr new file mode 100644 index 00000000000..363dec06237 --- /dev/null +++ b/src/test/ui/imports/issue-55457.stderr @@ -0,0 +1,31 @@ +error[E0432]: unresolved import `NonExistent` + --> $DIR/issue-55457.rs:1:5 + | +LL | use NonExistent; //~ ERROR unresolved import `NonExistent` + | ^^^^^^^^^^^ no `NonExistent` in the root. Did you mean to use `non_existent`? + +error[E0432]: unresolved import `non_existent` + --> $DIR/issue-55457.rs:2:5 + | +LL | use non_existent::non_existent; //~ ERROR unresolved import `non_existent` + | ^^^^^^^^^^^^ Maybe a missing `extern crate non_existent;`? + +error: cannot determine resolution for the derive macro `NonExistent` + --> $DIR/issue-55457.rs:5:10 + | +LL | #[derive(NonExistent)] //~ ERROR cannot determine resolution for the derive macro `NonExistent` + | ^^^^^^^^^^^ + | + = note: import resolution is stuck, try simplifying macro imports + +error: cannot determine resolution for the attribute macro `non_existent` + --> $DIR/issue-55457.rs:4:3 + | +LL | #[non_existent] //~ ERROR cannot determine resolution for the attribute macro `non_existent` + | ^^^^^^^^^^^^ + | + = note: import resolution is stuck, try simplifying macro imports + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0432`. -- cgit 1.4.1-3-g733a5 From ff5226cd2fa12fe82c7cef8112905af7cb48fe9d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 1 Nov 2018 14:17:39 -0700 Subject: std: Enable usage of `thread_local!` through imports The `thread_local!` macro delegated to an internal macro but it didn't do so in a macros-and-the-module-system compatible fashion, meaning if a `#![no_std]` crate imported `std` and tried to use `thread_local!` it would fail due to missing a lookup of an internal macro. This commit switches the macro to instead use `$crate` to invoke other macros, ensuring that it'll work when `thread_local!` is imported alone. --- src/libstd/thread/local.rs | 8 ++++---- src/test/run-pass/thread-local-not-in-prelude.rs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 src/test/run-pass/thread-local-not-in-prelude.rs (limited to 'src/test') diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 59f100fad1b..74bed0a64c5 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -145,13 +145,13 @@ macro_rules! thread_local { // process multiple declarations ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => ( - __thread_local_inner!($(#[$attr])* $vis $name, $t, $init); - thread_local!($($rest)*); + $crate::__thread_local_inner!($(#[$attr])* $vis $name, $t, $init); + $crate::thread_local!($($rest)*); ); // handle a single declaration ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => ( - __thread_local_inner!($(#[$attr])* $vis $name, $t, $init); + $crate::__thread_local_inner!($(#[$attr])* $vis $name, $t, $init); ); } @@ -201,7 +201,7 @@ macro_rules! __thread_local_inner { }; ($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $init:expr) => { $(#[$attr])* $vis const $name: $crate::thread::LocalKey<$t> = - __thread_local_inner!(@key $(#[$attr])* $vis $name, $t, $init); + $crate::__thread_local_inner!(@key $(#[$attr])* $vis $name, $t, $init); } } diff --git a/src/test/run-pass/thread-local-not-in-prelude.rs b/src/test/run-pass/thread-local-not-in-prelude.rs new file mode 100644 index 00000000000..0c365597b82 --- /dev/null +++ b/src/test/run-pass/thread-local-not-in-prelude.rs @@ -0,0 +1,18 @@ +// 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. + +#![no_std] + +extern crate std; + +std::thread_local!(static A: usize = 30); + +fn main() { +} -- cgit 1.4.1-3-g733a5 From 89cf577c73b70e66157d9a4ff6560e738d039ab1 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 2 Nov 2018 01:43:18 +0300 Subject: Fix tracking issue numbers for some unstable features --- src/libsyntax/feature_gate.rs | 12 ++++++------ .../ui/feature-gates/feature-gate-allow_fail.stderr | 2 +- .../feature-gate-crate_visibility_modifier.stderr | 2 +- .../feature-gate-extern_crate_item_prelude.stderr | 18 +++++++++--------- .../feature-gates/feature-gate-extern_in_paths.stderr | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/test') diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index da0ec33030e..0ddeedfb50d 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -349,7 +349,7 @@ declare_features! ( (active, abi_thiscall, "1.19.0", None, None), // Allows a test to fail without failing the whole suite - (active, allow_fail, "1.19.0", Some(42219), None), + (active, allow_fail, "1.19.0", Some(46488), None), // Allows unsized tuple coercion. (active, unsized_tuple_coercion, "1.20.0", Some(42877), None), @@ -376,7 +376,7 @@ declare_features! ( (active, non_exhaustive, "1.22.0", Some(44109), None), // `crate` as visibility modifier, synonymous to `pub(crate)` - (active, crate_visibility_modifier, "1.23.0", Some(45388), None), + (active, crate_visibility_modifier, "1.23.0", Some(53120), None), // extern types (active, extern_types, "1.23.0", Some(43467), None), @@ -391,13 +391,13 @@ declare_features! ( (active, generic_associated_types, "1.23.0", Some(44265), None), // `extern` in paths - (active, extern_in_paths, "1.23.0", Some(44660), None), + (active, extern_in_paths, "1.23.0", Some(55600), None), // Use `?` as the Kleene "at most one" operator (active, macro_at_most_once_rep, "1.25.0", Some(48075), None), // Infer static outlives requirements; RFC 2093 - (active, infer_static_outlives_requirements, "1.26.0", Some(44493), None), + (active, infer_static_outlives_requirements, "1.26.0", Some(54185), None), // Multiple patterns with `|` in `if let` and `while let` (active, if_while_or_patterns, "1.26.0", Some(48215), None), @@ -466,7 +466,7 @@ declare_features! ( (active, test_2018_feature, "1.31.0", Some(0), Some(Edition::Edition2018)), // Support for arbitrary delimited token streams in non-macro attributes - (active, unrestricted_attribute_tokens, "1.30.0", Some(44690), None), + (active, unrestricted_attribute_tokens, "1.30.0", Some(55208), None), // Allows `use x::y;` to resolve through `self::x`, not just `::x` (active, uniform_paths, "1.30.0", Some(53130), None), @@ -503,7 +503,7 @@ declare_features! ( (active, underscore_const_names, "1.31.0", Some(54912), None), // `extern crate foo as bar;` puts `bar` into extern prelude. - (active, extern_crate_item_prelude, "1.31.0", Some(54658), None), + (active, extern_crate_item_prelude, "1.31.0", Some(55599), None), // `reason = ` in lint attributes and `expect` lint attribute (active, lint_reasons, "1.31.0", Some(54503), None), diff --git a/src/test/ui/feature-gates/feature-gate-allow_fail.stderr b/src/test/ui/feature-gates/feature-gate-allow_fail.stderr index 3f8ad32437d..736fad44b8b 100644 --- a/src/test/ui/feature-gates/feature-gate-allow_fail.stderr +++ b/src/test/ui/feature-gates/feature-gate-allow_fail.stderr @@ -1,4 +1,4 @@ -error[E0658]: allow_fail attribute is currently unstable (see issue #42219) +error[E0658]: allow_fail attribute is currently unstable (see issue #46488) --> $DIR/feature-gate-allow_fail.rs:13:1 | LL | #[allow_fail] //~ ERROR allow_fail attribute is currently unstable diff --git a/src/test/ui/feature-gates/feature-gate-crate_visibility_modifier.stderr b/src/test/ui/feature-gates/feature-gate-crate_visibility_modifier.stderr index d0ee40504fb..e1c1dcbcd79 100644 --- a/src/test/ui/feature-gates/feature-gate-crate_visibility_modifier.stderr +++ b/src/test/ui/feature-gates/feature-gate-crate_visibility_modifier.stderr @@ -1,4 +1,4 @@ -error[E0658]: `crate` visibility modifier is experimental (see issue #45388) +error[E0658]: `crate` visibility modifier is experimental (see issue #53120) --> $DIR/feature-gate-crate_visibility_modifier.rs:11:1 | LL | crate struct Bender { //~ ERROR `crate` visibility modifier is experimental diff --git a/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.stderr b/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.stderr index cabfb56d7a8..bbd4b630263 100644 --- a/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.stderr +++ b/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.stderr @@ -1,4 +1,4 @@ -error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658) +error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599) --> $DIR/feature-gate-extern_crate_item_prelude.rs:26:9 | LL | use alloc; @@ -6,7 +6,7 @@ LL | use alloc; | = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable -error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658) +error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599) --> $DIR/feature-gate-extern_crate_item_prelude.rs:28:9 | LL | use alloc::boxed; @@ -14,7 +14,7 @@ LL | use alloc::boxed; | = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable -error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658) +error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599) --> $DIR/feature-gate-extern_crate_item_prelude.rs:33:11 | LL | use ::alloc; @@ -22,7 +22,7 @@ LL | use ::alloc; | = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable -error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658) +error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599) --> $DIR/feature-gate-extern_crate_item_prelude.rs:35:11 | LL | use ::alloc::boxed; @@ -30,7 +30,7 @@ LL | use ::alloc::boxed; | = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable -error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658) +error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599) --> $DIR/feature-gate-extern_crate_item_prelude.rs:9:17 | LL | let v = alloc::vec![0]; @@ -38,7 +38,7 @@ LL | let v = alloc::vec![0]; | = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable -error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658) +error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599) --> $DIR/feature-gate-extern_crate_item_prelude.rs:11:18 | LL | type A = alloc::boxed::Box; @@ -46,7 +46,7 @@ LL | type A = alloc::boxed::Box; | = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable -error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658) +error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599) --> $DIR/feature-gate-extern_crate_item_prelude.rs:18:19 | LL | let v = ::alloc::vec![0]; @@ -54,7 +54,7 @@ LL | let v = ::alloc::vec![0]; | = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable -error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658) +error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599) --> $DIR/feature-gate-extern_crate_item_prelude.rs:20:20 | LL | type A = ::alloc::boxed::Box; @@ -62,7 +62,7 @@ LL | type A = ::alloc::boxed::Box; | = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable -error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658) +error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599) --> $DIR/feature-gate-extern_crate_item_prelude.rs:42:14 | LL | type A = core::boxed::Box; diff --git a/src/test/ui/feature-gates/feature-gate-extern_in_paths.stderr b/src/test/ui/feature-gates/feature-gate-extern_in_paths.stderr index 535ed94565c..a73533b6178 100644 --- a/src/test/ui/feature-gates/feature-gate-extern_in_paths.stderr +++ b/src/test/ui/feature-gates/feature-gate-extern_in_paths.stderr @@ -1,4 +1,4 @@ -error[E0658]: `extern` in paths is experimental (see issue #44660) +error[E0658]: `extern` in paths is experimental (see issue #55600) --> $DIR/feature-gate-extern_in_paths.rs:14:13 | LL | let _ = extern::std::vec::Vec::new(); //~ ERROR `extern` in paths is experimental -- cgit 1.4.1-3-g733a5 From 29d2ceae7c03fb4a4d99e4e766cf212fb9582ffa Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 2 Nov 2018 02:22:30 +0300 Subject: Remove deprecated unstable `#[panic_implementation]` It was superseded by `#[panic_handler]` --- src/librustc/middle/dead.rs | 6 ++---- src/librustc/middle/lang_items.rs | 4 +--- src/librustc_mir/monomorphize/partitioning.rs | 2 +- src/librustc_typeck/check/mod.rs | 2 +- src/libsyntax/feature_gate.rs | 15 ++------------ src/test/run-make/wasm-symbols-not-imported/foo.rs | 4 +--- .../feature-gate-panic-implementation.rs | 21 ------------------- .../feature-gate-panic-implementation.stderr | 11 ---------- .../panic-implementation-deprecated.rs | 24 ---------------------- .../panic-implementation-deprecated.stderr | 14 ------------- 10 files changed, 8 insertions(+), 95 deletions(-) delete mode 100644 src/test/ui/feature-gates/feature-gate-panic-implementation.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-panic-implementation.stderr delete mode 100644 src/test/ui/panic-implementation/panic-implementation-deprecated.rs delete mode 100644 src/test/ui/panic-implementation/panic-implementation-deprecated.stderr (limited to 'src/test') diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index dc5f7361725..c5bcfd48cf3 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -291,10 +291,8 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>, return true; } - // (To be) stable attribute for #[lang = "panic_impl"] - if attr::contains_name(attrs, "panic_implementation") || - attr::contains_name(attrs, "panic_handler") - { + // Stable attribute for #[lang = "panic_impl"] + if attr::contains_name(attrs, "panic_handler") { return true; } diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 45de958e72e..931f466e422 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -204,9 +204,7 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> { if let Some(value) = attribute.value_str() { return Some((value, attribute.span)); } - } else if attribute.check_name("panic_implementation") || - attribute.check_name("panic_handler") - { + } else if attribute.check_name("panic_handler") { return Some((Symbol::intern("panic_impl"), attribute.span)) } else if attribute.check_name("alloc_error_handler") { return Some((Symbol::intern("oom"), attribute.span)) diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index f0a35ca7adb..fd63bf79da9 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -505,7 +505,7 @@ fn mono_item_visibility( // // * First is weak lang items. These are basically mechanisms for // libcore to forward-reference symbols defined later in crates like - // the standard library or `#[panic_implementation]` definitions. The + // the standard library or `#[panic_handler]` definitions. The // definition of these weak lang items needs to be referenceable by // libcore, so we're no longer a candidate for internalization. // Removal of these functions can't be done by LLVM but rather must be diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 17784a4681d..694cd0c2718 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1167,7 +1167,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, } } - // Check that a function marked as `#[panic_implementation]` has signature `fn(&PanicInfo) -> !` + // Check that a function marked as `#[panic_handler]` has signature `fn(&PanicInfo) -> !` if let Some(panic_impl_did) = fcx.tcx.lang_items().panic_impl() { if panic_impl_did == fcx.tcx.hir.local_def_id(fn_id) { if let Some(panic_info_did) = fcx.tcx.lang_items().panic_info() { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 0ddeedfb50d..dd5eacb86eb 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -448,9 +448,6 @@ declare_features! ( // Integer match exhaustiveness checking (active, exhaustive_integer_patterns, "1.30.0", Some(50907), None), - // RFC 2070: #[panic_implementation] / #[panic_handler] - (active, panic_implementation, "1.28.0", Some(44489), None), - // #[doc(keyword = "...")] (active, doc_keyword, "1.28.0", Some(51315), None), @@ -541,6 +538,8 @@ declare_features! ( Some("subsumed by `#![feature(proc_macro_hygiene)]`")), (removed, proc_macro_gen, "1.27.0", Some(54727), None, Some("subsumed by `#![feature(proc_macro_hygiene)]`")), + (removed, panic_implementation, "1.28.0", Some(44489), None, + Some("subsumed by `#[panic_handler]`")), ); declare_features! ( @@ -1160,16 +1159,6 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG "infer 'static lifetime requirements", cfg_fn!(infer_static_outlives_requirements))), - // RFC 2070 (deprecated attribute name) - ("panic_implementation", - Normal, - Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/44489\ - #issuecomment-415140224", - Some("replace this attribute with `#[panic_handler]`")), - "panic_implementation", - "this attribute was renamed to `panic_handler`", - cfg_fn!(panic_implementation))), - // RFC 2070 ("panic_handler", Normal, Ungated), diff --git a/src/test/run-make/wasm-symbols-not-imported/foo.rs b/src/test/run-make/wasm-symbols-not-imported/foo.rs index 156db486a47..dcc2f4f5223 100644 --- a/src/test/run-make/wasm-symbols-not-imported/foo.rs +++ b/src/test/run-make/wasm-symbols-not-imported/foo.rs @@ -9,8 +9,6 @@ // except according to those terms. #![crate_type = "cdylib"] - -#![feature(panic_implementation)] #![no_std] use core::panic::PanicInfo; @@ -20,7 +18,7 @@ pub extern fn foo() { panic!() } -#[panic_implementation] +#[panic_handler] fn panic(_info: &PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/feature-gates/feature-gate-panic-implementation.rs b/src/test/ui/feature-gates/feature-gate-panic-implementation.rs deleted file mode 100644 index ca51154884f..00000000000 --- a/src/test/ui/feature-gates/feature-gate-panic-implementation.rs +++ /dev/null @@ -1,21 +0,0 @@ -// 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. - -// compile-flags:-C panic=abort - -#![no_std] -#![no_main] - -use core::panic::PanicInfo; - -#[panic_implementation] //~ ERROR this attribute was renamed to `panic_handler` (see issue #44489) -fn panic(info: &PanicInfo) -> ! { - loop {} -} diff --git a/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr b/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr deleted file mode 100644 index a54780468c4..00000000000 --- a/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: this attribute was renamed to `panic_handler` (see issue #44489) - --> $DIR/feature-gate-panic-implementation.rs:18:1 - | -LL | #[panic_implementation] //~ ERROR this attribute was renamed to `panic_handler` (see issue #44489) - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(panic_implementation)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/panic-implementation/panic-implementation-deprecated.rs b/src/test/ui/panic-implementation/panic-implementation-deprecated.rs deleted file mode 100644 index c4bec01f6af..00000000000 --- a/src/test/ui/panic-implementation/panic-implementation-deprecated.rs +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -// compile-flags:-C panic=abort - -#![deny(deprecated)] -#![feature(panic_implementation)] -#![no_std] - -use core::panic::PanicInfo; - -#[panic_implementation] -fn panic(info: &PanicInfo) -> ! { - loop {} -} - -fn main() {} diff --git a/src/test/ui/panic-implementation/panic-implementation-deprecated.stderr b/src/test/ui/panic-implementation/panic-implementation-deprecated.stderr deleted file mode 100644 index fabfba94878..00000000000 --- a/src/test/ui/panic-implementation/panic-implementation-deprecated.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: use of deprecated attribute `panic_implementation`: this attribute was renamed to `panic_handler`. See https://github.com/rust-lang/rust/issues/44489#issuecomment-415140224 - --> $DIR/panic-implementation-deprecated.rs:19:1 - | -LL | #[panic_implementation] - | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this attribute with `#[panic_handler]` - | -note: lint level defined here - --> $DIR/panic-implementation-deprecated.rs:13:9 - | -LL | #![deny(deprecated)] - | ^^^^^^^^^^ - -error: aborting due to previous error - -- cgit 1.4.1-3-g733a5 From 8277ba2d30996067c39ee3405bd141b11ffdb855 Mon Sep 17 00:00:00 2001 From: varkor Date: Sat, 3 Nov 2018 21:09:53 +0000 Subject: Make "all possible cases" help message uniform with existing help messages Specifically no capitalisation or trailing full stops. --- src/librustc_mir/hair/pattern/check_match.rs | 4 ++-- src/test/ui/error-codes/E0004-2.stderr | 2 +- src/test/ui/issues/issue-3096-1.stderr | 2 +- src/test/ui/issues/issue-3096-2.stderr | 2 +- src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/test') diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index f2ae5774da8..735ceef229a 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -238,8 +238,8 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { is non-empty", pat_ty)); span_help!(&mut err, scrut.span, - "Please ensure that all possible cases are being handled; \ - possibly adding wildcards or more match arms."); + "ensure that all possible cases are being handled, \ + possibly by adding wildcards or more match arms"); err.emit(); } // If the type *is* uninhabited, it's vacuously exhaustive diff --git a/src/test/ui/error-codes/E0004-2.stderr b/src/test/ui/error-codes/E0004-2.stderr index 6a4392df35d..900812787bc 100644 --- a/src/test/ui/error-codes/E0004-2.stderr +++ b/src/test/ui/error-codes/E0004-2.stderr @@ -4,7 +4,7 @@ error[E0004]: non-exhaustive patterns: type std::option::Option is non-empt LL | match x { } //~ ERROR E0004 | ^ | -help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms. +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms --> $DIR/E0004-2.rs:14:11 | LL | match x { } //~ ERROR E0004 diff --git a/src/test/ui/issues/issue-3096-1.stderr b/src/test/ui/issues/issue-3096-1.stderr index 783e831a2a5..b2bfe6b5e8c 100644 --- a/src/test/ui/issues/issue-3096-1.stderr +++ b/src/test/ui/issues/issue-3096-1.stderr @@ -4,7 +4,7 @@ error[E0004]: non-exhaustive patterns: type () is non-empty LL | match () { } //~ ERROR non-exhaustive | ^^ | -help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms. +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms --> $DIR/issue-3096-1.rs:12:11 | LL | match () { } //~ ERROR non-exhaustive diff --git a/src/test/ui/issues/issue-3096-2.stderr b/src/test/ui/issues/issue-3096-2.stderr index 6031f25c03d..bb9dfabe7be 100644 --- a/src/test/ui/issues/issue-3096-2.stderr +++ b/src/test/ui/issues/issue-3096-2.stderr @@ -4,7 +4,7 @@ error[E0004]: non-exhaustive patterns: type *const bottom is non-empty LL | match x { } //~ ERROR non-exhaustive patterns | ^ | -help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms. +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms --> $DIR/issue-3096-2.rs:15:11 | LL | match x { } //~ ERROR non-exhaustive patterns diff --git a/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr b/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr index d86ebda027e..83fd736a997 100644 --- a/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr +++ b/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr @@ -10,7 +10,7 @@ error[E0004]: non-exhaustive patterns: type &Void is non-empty LL | let _ = match x {}; //~ ERROR non-exhaustive | ^ | -help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms. +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms --> $DIR/uninhabited-matches-feature-gated.rs:20:19 | LL | let _ = match x {}; //~ ERROR non-exhaustive @@ -22,7 +22,7 @@ error[E0004]: non-exhaustive patterns: type (Void,) is non-empty LL | let _ = match x {}; //~ ERROR non-exhaustive | ^ | -help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms. +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms --> $DIR/uninhabited-matches-feature-gated.rs:23:19 | LL | let _ = match x {}; //~ ERROR non-exhaustive @@ -34,7 +34,7 @@ error[E0004]: non-exhaustive patterns: type [Void; 1] is non-empty LL | let _ = match x {}; //~ ERROR non-exhaustive | ^ | -help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms. +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms --> $DIR/uninhabited-matches-feature-gated.rs:26:19 | LL | let _ = match x {}; //~ ERROR non-exhaustive -- cgit 1.4.1-3-g733a5 From ba09ed520864b5c64f56aa2311ee18fa72a3ceb6 Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 4 Nov 2018 18:36:30 +0100 Subject: Update test to force error under NLL. In each of the three cases in this test, there is a mutable borrow of some field of the union and then a shared borrow of some other field immediately following. Under NLL, the mutable borrow is killed straight away as it isn't used later - therefore not causing a conflict with the shared borrow. This commit adds a use of the first mutable borrow to force the intended errors to appear under NLL. --- .../union-borrow-move-parent-sibling.nll.stderr | 47 ++++++++++++++++++---- .../ui/union/union-borrow-move-parent-sibling.rs | 17 +++++--- .../union/union-borrow-move-parent-sibling.stderr | 27 +++++++------ 3 files changed, 65 insertions(+), 26 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr b/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr index a4f5e41b529..6b18aff9f6b 100644 --- a/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr +++ b/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr @@ -1,33 +1,64 @@ +error[E0502]: cannot borrow `u.y` as immutable because it is also borrowed as mutable + --> $DIR/union-borrow-move-parent-sibling.rs:25:13 + | +LL | let a = &mut u.x.0; + | ---------- mutable borrow occurs here +LL | let b = &u.y; //~ ERROR cannot borrow `u.y` + | ^^^^ immutable borrow occurs here +LL | use_borrow(a); + | - mutable borrow later used here + error[E0382]: use of moved value: `u` - --> $DIR/union-borrow-move-parent-sibling.rs:29:13 + --> $DIR/union-borrow-move-parent-sibling.rs:32:13 | LL | let a = u.x.0; | ----- value moved here -LL | let a = u.y; //~ ERROR use of moved value: `u.y` +LL | let b = u.y; //~ ERROR use of moved value: `u.y` | ^^^ value used here after move | = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait +error[E0502]: cannot borrow `u.y` as immutable because it is also borrowed as mutable + --> $DIR/union-borrow-move-parent-sibling.rs:38:13 + | +LL | let a = &mut (u.x.0).0; + | -------------- mutable borrow occurs here +LL | let b = &u.y; //~ ERROR cannot borrow `u.y` + | ^^^^ immutable borrow occurs here +LL | use_borrow(a); + | - mutable borrow later used here + error[E0382]: use of moved value: `u` - --> $DIR/union-borrow-move-parent-sibling.rs:41:13 + --> $DIR/union-borrow-move-parent-sibling.rs:45:13 | LL | let a = (u.x.0).0; | --------- value moved here -LL | let a = u.y; //~ ERROR use of moved value: `u.y` +LL | let b = u.y; //~ ERROR use of moved value: `u.y` | ^^^ value used here after move | = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait +error[E0502]: cannot borrow `u.x` as immutable because it is also borrowed as mutable + --> $DIR/union-borrow-move-parent-sibling.rs:51:13 + | +LL | let a = &mut *u.y; + | --------- mutable borrow occurs here +LL | let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) + | ^^^^ immutable borrow occurs here +LL | use_borrow(a); + | - mutable borrow later used here + error[E0382]: use of moved value: `u` - --> $DIR/union-borrow-move-parent-sibling.rs:53:13 + --> $DIR/union-borrow-move-parent-sibling.rs:58:13 | LL | let a = *u.y; | ---- value moved here -LL | let a = u.x; //~ ERROR use of moved value: `u.x` +LL | let b = u.x; //~ ERROR use of moved value: `u.x` | ^^^ value used here after move | = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait -error: aborting due to 3 previous errors +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0382`. +Some errors occurred: E0382, E0502. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/union/union-borrow-move-parent-sibling.rs b/src/test/ui/union/union-borrow-move-parent-sibling.rs index 5f504feabb2..99a073b838c 100644 --- a/src/test/ui/union/union-borrow-move-parent-sibling.rs +++ b/src/test/ui/union/union-borrow-move-parent-sibling.rs @@ -17,40 +17,45 @@ union U { y: Box>, } +fn use_borrow(_: &T) {} + unsafe fn parent_sibling_borrow() { let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = &mut u.x.0; - let a = &u.y; //~ ERROR cannot borrow `u.y` + let b = &u.y; //~ ERROR cannot borrow `u.y` + use_borrow(a); } unsafe fn parent_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = u.x.0; - let a = u.y; //~ ERROR use of moved value: `u.y` + let b = u.y; //~ ERROR use of moved value: `u.y` } unsafe fn grandparent_sibling_borrow() { let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = &mut (u.x.0).0; - let a = &u.y; //~ ERROR cannot borrow `u.y` + let b = &u.y; //~ ERROR cannot borrow `u.y` + use_borrow(a); } unsafe fn grandparent_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = (u.x.0).0; - let a = u.y; //~ ERROR use of moved value: `u.y` + let b = u.y; //~ ERROR use of moved value: `u.y` } unsafe fn deref_sibling_borrow() { let mut u = U { y: Box::default() }; let a = &mut *u.y; - let a = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) + let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) + use_borrow(a); } unsafe fn deref_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = *u.y; - let a = u.x; //~ ERROR use of moved value: `u.x` + let b = u.x; //~ ERROR use of moved value: `u.x` } diff --git a/src/test/ui/union/union-borrow-move-parent-sibling.stderr b/src/test/ui/union/union-borrow-move-parent-sibling.stderr index d855435416e..daf5a4f4fcc 100644 --- a/src/test/ui/union/union-borrow-move-parent-sibling.stderr +++ b/src/test/ui/union/union-borrow-move-parent-sibling.stderr @@ -1,59 +1,62 @@ error[E0502]: cannot borrow `u.y` as immutable because `u.x.0` is also borrowed as mutable - --> $DIR/union-borrow-move-parent-sibling.rs:23:14 + --> $DIR/union-borrow-move-parent-sibling.rs:25:14 | LL | let a = &mut u.x.0; | ----- mutable borrow occurs here -LL | let a = &u.y; //~ ERROR cannot borrow `u.y` +LL | let b = &u.y; //~ ERROR cannot borrow `u.y` | ^^^ immutable borrow occurs here +LL | use_borrow(a); LL | } | - mutable borrow ends here error[E0382]: use of moved value: `u.y` - --> $DIR/union-borrow-move-parent-sibling.rs:29:9 + --> $DIR/union-borrow-move-parent-sibling.rs:32:9 | LL | let a = u.x.0; | - value moved here -LL | let a = u.y; //~ ERROR use of moved value: `u.y` +LL | let b = u.y; //~ ERROR use of moved value: `u.y` | ^ value used here after move | = note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait error[E0502]: cannot borrow `u.y` as immutable because `u.x.0.0` is also borrowed as mutable - --> $DIR/union-borrow-move-parent-sibling.rs:35:14 + --> $DIR/union-borrow-move-parent-sibling.rs:38:14 | LL | let a = &mut (u.x.0).0; | --------- mutable borrow occurs here -LL | let a = &u.y; //~ ERROR cannot borrow `u.y` +LL | let b = &u.y; //~ ERROR cannot borrow `u.y` | ^^^ immutable borrow occurs here +LL | use_borrow(a); LL | } | - mutable borrow ends here error[E0382]: use of moved value: `u.y` - --> $DIR/union-borrow-move-parent-sibling.rs:41:9 + --> $DIR/union-borrow-move-parent-sibling.rs:45:9 | LL | let a = (u.x.0).0; | - value moved here -LL | let a = u.y; //~ ERROR use of moved value: `u.y` +LL | let b = u.y; //~ ERROR use of moved value: `u.y` | ^ value used here after move | = note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait error[E0502]: cannot borrow `u` (via `u.x`) as immutable because `u` is also borrowed as mutable (via `*u.y`) - --> $DIR/union-borrow-move-parent-sibling.rs:47:14 + --> $DIR/union-borrow-move-parent-sibling.rs:51:14 | LL | let a = &mut *u.y; | ---- mutable borrow occurs here (via `*u.y`) -LL | let a = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) +LL | let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) | ^^^ immutable borrow occurs here (via `u.x`) +LL | use_borrow(a); LL | } | - mutable borrow ends here error[E0382]: use of moved value: `u.x` - --> $DIR/union-borrow-move-parent-sibling.rs:53:9 + --> $DIR/union-borrow-move-parent-sibling.rs:58:9 | LL | let a = *u.y; | - value moved here -LL | let a = u.x; //~ ERROR use of moved value: `u.x` +LL | let b = u.x; //~ ERROR use of moved value: `u.x` | ^ value used here after move | = note: move occurs because `u.x` has type `[type error]`, which does not implement the `Copy` trait -- cgit 1.4.1-3-g733a5 From 2a1dc1eff62313bfa37eef6a2681269bda5f8439 Mon Sep 17 00:00:00 2001 From: jsirs <44773712+jsirs@users.noreply.github.com> Date: Mon, 5 Nov 2018 14:33:43 +0200 Subject: Add test Add test for incompleately implemented add trait, see issue #31076 --- src/test/ui/issues/issue-31076.rs | 15 +++++++++++++++ src/test/ui/issues/issue-31076.stderr | 11 +++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/test/ui/issues/issue-31076.rs create mode 100644 src/test/ui/issues/issue-31076.stderr (limited to 'src/test') diff --git a/src/test/ui/issues/issue-31076.rs b/src/test/ui/issues/issue-31076.rs new file mode 100644 index 00000000000..3d235720c38 --- /dev/null +++ b/src/test/ui/issues/issue-31076.rs @@ -0,0 +1,15 @@ +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized {} + +#[lang="add"] +trait Add {} + +impl Add for i32 {} + +fn main() { + let x = 5 + 6; + //~^ ERROR binary operation `+` cannot be applied to type `{integer}` +} diff --git a/src/test/ui/issues/issue-31076.stderr b/src/test/ui/issues/issue-31076.stderr new file mode 100644 index 00000000000..a667034bd8c --- /dev/null +++ b/src/test/ui/issues/issue-31076.stderr @@ -0,0 +1,11 @@ +error[E0369]: binary operation `+` cannot be applied to type `{integer}` + --> $DIR/typeck-issue-31076-correct-trait-impl.rs:13:13 + | +LL | let x = 5 + 6; + | ^^^^^ + | + = note: an implementation of `std::ops::Add` might be missing for `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0369`. -- cgit 1.4.1-3-g733a5 From 9fb2e0618e3a718ae12cd45b5ee39f9076ff3e79 Mon Sep 17 00:00:00 2001 From: jsirs <44773712+jsirs@users.noreply.github.com> Date: Mon, 5 Nov 2018 15:54:10 +0200 Subject: update test to include concrete type (i32) --- src/test/ui/issues/issue-31076.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/test') diff --git a/src/test/ui/issues/issue-31076.rs b/src/test/ui/issues/issue-31076.rs index 3d235720c38..e4531072e9b 100644 --- a/src/test/ui/issues/issue-31076.rs +++ b/src/test/ui/issues/issue-31076.rs @@ -12,4 +12,6 @@ impl Add for i32 {} fn main() { let x = 5 + 6; //~^ ERROR binary operation `+` cannot be applied to type `{integer}` + let y = 5i32 + 6i32; + //~^ ERROR binary operation `+` cannot be applied to type `i32` } -- cgit 1.4.1-3-g733a5 From 87c22f2b141018d9283d3956468c43106d8765aa Mon Sep 17 00:00:00 2001 From: jsirs <44773712+jsirs@users.noreply.github.com> Date: Mon, 5 Nov 2018 15:57:07 +0200 Subject: add test for i32, fix incorrect location --- src/test/ui/issues/issue-31076.stderr | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/issues/issue-31076.stderr b/src/test/ui/issues/issue-31076.stderr index a667034bd8c..3a13f02d9f4 100644 --- a/src/test/ui/issues/issue-31076.stderr +++ b/src/test/ui/issues/issue-31076.stderr @@ -1,11 +1,19 @@ error[E0369]: binary operation `+` cannot be applied to type `{integer}` - --> $DIR/typeck-issue-31076-correct-trait-impl.rs:13:13 + --> $DIR/issue-31076.rs:13:13 | LL | let x = 5 + 6; | ^^^^^ | = note: an implementation of `std::ops::Add` might be missing for `{integer}` -error: aborting due to previous error +error[E0369]: binary operation `+` cannot be applied to type `i32` + --> $DIR/issue-31076.rs:15:13 + | +LL | let y = 5i32 + 6i32; + | ^^^^^^^^^^^ + | + = note: an implementation of `std::ops::Add` might be missing for `i32` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0369`. -- cgit 1.4.1-3-g733a5 From 5f524ed5c4b0d5e0bf6a6ea52284704411712c82 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 12:59:40 +0100 Subject: Switch to using revisions in borrowck-lend-flow-loop.rs Most of the time we want to robustify tests, but in this case this test is deliberately encoding artifacts of AST-borrowck. So instead of adding artificial uses that would obscure the aspects of AST-borrowck that are being tests, we instead use revisions and then mark the cases that apply to NLL as well as AST-borrowck. --- .../ui/borrowck/borrowck-lend-flow-loop.ast.stderr | 93 ++++++++++++++++++++++ .../ui/borrowck/borrowck-lend-flow-loop.nll.stderr | 10 +-- src/test/ui/borrowck/borrowck-lend-flow-loop.rs | 50 ++++++------ .../ui/borrowck/borrowck-lend-flow-loop.stderr | 93 ---------------------- 4 files changed, 123 insertions(+), 123 deletions(-) create mode 100644 src/test/ui/borrowck/borrowck-lend-flow-loop.ast.stderr delete mode 100644 src/test/ui/borrowck/borrowck-lend-flow-loop.stderr (limited to 'src/test') diff --git a/src/test/ui/borrowck/borrowck-lend-flow-loop.ast.stderr b/src/test/ui/borrowck/borrowck-lend-flow-loop.ast.stderr new file mode 100644 index 00000000000..1844d827599 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-lend-flow-loop.ast.stderr @@ -0,0 +1,93 @@ +error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable + --> $DIR/borrowck-lend-flow-loop.rs:35:17 + | +LL | let mut x = &mut v; + | - mutable borrow occurs here +... +LL | borrow(&*v); //[ast]~ ERROR cannot borrow + | ^^ immutable borrow occurs here +LL | } +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable + --> $DIR/borrowck-lend-flow-loop.rs:45:17 + | +LL | let mut x = &mut v; + | - mutable borrow occurs here +LL | for _ in 0..3 { +LL | borrow(&*v); //[ast]~ ERROR cannot borrow + | ^^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable + --> $DIR/borrowck-lend-flow-loop.rs:57:25 + | +LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + | ^^ mutable borrow occurs here +LL | _x = &v; + | - immutable borrow occurs here +LL | } +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable + --> $DIR/borrowck-lend-flow-loop.rs:69:25 + | +LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + | ^^ mutable borrow occurs here +LL | _x = &v; + | - immutable borrow occurs here +LL | } +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable + --> $DIR/borrowck-lend-flow-loop.rs:86:21 + | +LL | _x = &v; + | - immutable borrow occurs here +... +LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + | ^^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable + --> $DIR/borrowck-lend-flow-loop.rs:100:21 + | +LL | _x = &v; + | - immutable borrow occurs here +... +LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + | ^^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable + --> $DIR/borrowck-lend-flow-loop.rs:109:17 + | +LL | borrow(&*v); //[ast]~ ERROR cannot borrow + | ^^ immutable borrow occurs here +... +LL | x = &mut v; //[ast]~ ERROR cannot borrow + | - mutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0499]: cannot borrow `v` as mutable more than once at a time + --> $DIR/borrowck-lend-flow-loop.rs:112:22 + | +LL | x = &mut v; //[ast]~ ERROR cannot borrow + | ^ mutable borrow starts here in previous iteration of loop +... +LL | } + | - mutable borrow ends here + +error: aborting due to 8 previous errors + +Some errors occurred: E0499, E0502. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr index 388fc9c5fa8..19de3582c88 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr @@ -4,9 +4,9 @@ error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mut LL | let mut x = &mut v; | ------ mutable borrow occurs here LL | for _ in 0..3 { -LL | borrow(&*v); //~ ERROR cannot borrow +LL | borrow(&*v); //[ast]~ ERROR cannot borrow | ^^^ immutable borrow occurs here -LL | } +... LL | *x = box 5; | -- mutable borrow used here, in later iteration of loop @@ -15,10 +15,10 @@ error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mut | LL | **x += 1; | -------- mutable borrow used here, in later iteration of loop -LL | borrow(&*v); //~ ERROR cannot borrow +LL | borrow(&*v); //[ast]~ ERROR cannot borrow | ^^^ immutable borrow occurs here -LL | if cond2 { -LL | x = &mut v; //~ ERROR cannot borrow +... +LL | x = &mut v; //[ast]~ ERROR cannot borrow | ------ mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-lend-flow-loop.rs b/src/test/ui/borrowck/borrowck-lend-flow-loop.rs index f09e7ffd7e4..7008e5cef4b 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-loop.rs +++ b/src/test/ui/borrowck/borrowck-lend-flow-loop.rs @@ -1,18 +1,18 @@ -// 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. - -// Note: the borrowck analysis is currently flow-insensitive. -// Therefore, some of these errors are marked as spurious and could be -// corrected by a simple change to the analysis. The others are -// either genuine or would require more advanced changes. The latter -// cases are noted. +// revisions: ast nll + +// Since we are testing nll migration explicitly as a separate +// revision, don't worry about the --compare-mode=nll on this test. + +// ignore-compare-mode-nll + +//[ast]compile-flags: -Z borrowck=ast +//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows + +// Note: the borrowck analysis was originally a flow-insensitive pass +// over the AST. Therefore, some of these (AST) errors are marked as +// spurious and are corrected by the flow-sensitive (NLL) analysis. +// The others are either genuine or would require more advanced +// changes. The latter cases are noted. #![feature(box_syntax)] @@ -32,7 +32,7 @@ fn loop_overarching_alias_mut() { let mut x = &mut v; **x += 1; loop { - borrow(&*v); //~ ERROR cannot borrow + borrow(&*v); //[ast]~ ERROR cannot borrow } } @@ -42,11 +42,11 @@ fn block_overarching_alias_mut() { let mut v: Box<_> = box 3; let mut x = &mut v; for _ in 0..3 { - borrow(&*v); //~ ERROR cannot borrow + borrow(&*v); //[ast]~ ERROR cannot borrow + //[nll]~^ ERROR cannot borrow } *x = box 5; } - fn loop_aliased_mut() { // In this instance, the borrow is carried through the loop. @@ -54,7 +54,7 @@ fn loop_aliased_mut() { let mut w: Box<_> = box 4; let mut _x = &w; loop { - borrow_mut(&mut *v); //~ ERROR cannot borrow + borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow _x = &v; } } @@ -66,7 +66,7 @@ fn while_aliased_mut() { let mut w: Box<_> = box 4; let mut _x = &w; while cond() { - borrow_mut(&mut *v); //~ ERROR cannot borrow + borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow _x = &v; } } @@ -83,7 +83,7 @@ fn loop_aliased_mut_break() { _x = &v; break; } - borrow_mut(&mut *v); //~ ERROR cannot borrow + borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow } fn while_aliased_mut_break() { @@ -97,7 +97,7 @@ fn while_aliased_mut_break() { _x = &v; break; } - borrow_mut(&mut *v); //~ ERROR cannot borrow + borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow } fn while_aliased_mut_cond(cond: bool, cond2: bool) { @@ -106,13 +106,13 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) { let mut x = &mut w; while cond { **x += 1; - borrow(&*v); //~ ERROR cannot borrow + borrow(&*v); //[ast]~ ERROR cannot borrow + //[nll]~^ ERROR cannot borrow if cond2 { - x = &mut v; //~ ERROR cannot borrow + x = &mut v; //[ast]~ ERROR cannot borrow } } } - fn loop_break_pops_scopes<'r, F>(_v: &'r mut [usize], mut f: F) where F: FnMut(&'r mut usize) -> bool, { diff --git a/src/test/ui/borrowck/borrowck-lend-flow-loop.stderr b/src/test/ui/borrowck/borrowck-lend-flow-loop.stderr deleted file mode 100644 index 534e30b564d..00000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow-loop.stderr +++ /dev/null @@ -1,93 +0,0 @@ -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:35:17 - | -LL | let mut x = &mut v; - | - mutable borrow occurs here -... -LL | borrow(&*v); //~ ERROR cannot borrow - | ^^ immutable borrow occurs here -LL | } -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:45:17 - | -LL | let mut x = &mut v; - | - mutable borrow occurs here -LL | for _ in 0..3 { -LL | borrow(&*v); //~ ERROR cannot borrow - | ^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:57:25 - | -LL | borrow_mut(&mut *v); //~ ERROR cannot borrow - | ^^ mutable borrow occurs here -LL | _x = &v; - | - immutable borrow occurs here -LL | } -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:69:25 - | -LL | borrow_mut(&mut *v); //~ ERROR cannot borrow - | ^^ mutable borrow occurs here -LL | _x = &v; - | - immutable borrow occurs here -LL | } -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:86:21 - | -LL | _x = &v; - | - immutable borrow occurs here -... -LL | borrow_mut(&mut *v); //~ ERROR cannot borrow - | ^^ mutable borrow occurs here -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:100:21 - | -LL | _x = &v; - | - immutable borrow occurs here -... -LL | borrow_mut(&mut *v); //~ ERROR cannot borrow - | ^^ mutable borrow occurs here -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:109:17 - | -LL | borrow(&*v); //~ ERROR cannot borrow - | ^^ immutable borrow occurs here -LL | if cond2 { -LL | x = &mut v; //~ ERROR cannot borrow - | - mutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0499]: cannot borrow `v` as mutable more than once at a time - --> $DIR/borrowck-lend-flow-loop.rs:111:22 - | -LL | x = &mut v; //~ ERROR cannot borrow - | ^ mutable borrow starts here in previous iteration of loop -... -LL | } - | - mutable borrow ends here - -error: aborting due to 8 previous errors - -Some errors occurred: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. -- cgit 1.4.1-3-g733a5 From cd52b3c2dccf64829112fe56995e25f2b75591df Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 13:07:51 +0100 Subject: Make `ui/span/borrowck-borrow-overloaded-auto-deref-mut.rs` robust w.r.t. NLL. --- ...wck-borrow-overloaded-auto-deref-mut.nll.stderr | 25 ++++++++++++++++++++-- .../borrowck-borrow-overloaded-auto-deref-mut.rs | 6 ++++-- ...orrowck-borrow-overloaded-auto-deref-mut.stderr | 2 ++ 3 files changed, 29 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr index 4a693a3b05d..389a1116c16 100644 --- a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr +++ b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr @@ -14,6 +14,16 @@ LL | fn deref_extend_mut_field1(x: &Own) -> &mut isize { LL | &mut x.y //~ ERROR cannot borrow | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:88:19 + | +LL | let _x = &mut x.x; + | - first mutable borrow occurs here +LL | let _y = &mut x.y; //~ ERROR cannot borrow + | ^ second mutable borrow occurs here +LL | use_mut(_x); + | -- first borrow later used here + error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:98:5 | @@ -30,6 +40,16 @@ LL | fn assign_field2<'a>(x: &'a Own) { LL | x.y = 3; //~ ERROR cannot borrow | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:111:5 + | +LL | let _p: &mut Point = &mut **x; + | -- first mutable borrow occurs here +LL | x.y = 3; //~ ERROR cannot borrow + | ^ second mutable borrow occurs here +LL | use_mut(_p); + | -- first borrow later used here + error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:119:5 | @@ -62,6 +82,7 @@ LL | fn assign_method2<'a>(x: &'a Own) { LL | *x.y_mut() = 3; //~ ERROR cannot borrow | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error: aborting due to 8 previous errors +error: aborting due to 10 previous errors -For more information about this error, try `rustc --explain E0596`. +Some errors occurred: E0499, E0596. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.rs b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.rs index 764d05be879..48eb2e239f7 100644 --- a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.rs +++ b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.rs @@ -86,8 +86,8 @@ fn deref_extend_mut_field3(x: &mut Own) { let _x = &mut x.x; let _y = &mut x.y; //~ ERROR cannot borrow + use_mut(_x); } - fn deref_extend_mut_field4<'a>(x: &'a mut Own) { let p = &mut **x; let _x = &mut p.x; @@ -109,8 +109,8 @@ fn assign_field3<'a>(x: &'a mut Own) { fn assign_field4<'a>(x: &'a mut Own) { let _p: &mut Point = &mut **x; x.y = 3; //~ ERROR cannot borrow + use_mut(_p); } - fn deref_imm_method(x: Own) { let __isize = x.get(); } @@ -148,3 +148,5 @@ fn assign_method3<'a>(x: &'a mut Own) { } pub fn main() {} + +fn use_mut(_: &mut T) {} diff --git a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr index d91ff696423..864357fee9f 100644 --- a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr +++ b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr @@ -21,6 +21,7 @@ LL | let _x = &mut x.x; | - first mutable borrow occurs here LL | let _y = &mut x.y; //~ ERROR cannot borrow | ^ second mutable borrow occurs here +LL | use_mut(_x); LL | } | - first borrow ends here @@ -47,6 +48,7 @@ LL | let _p: &mut Point = &mut **x; | -- first mutable borrow occurs here LL | x.y = 3; //~ ERROR cannot borrow | ^ second mutable borrow occurs here +LL | use_mut(_p); LL | } | - first borrow ends here -- cgit 1.4.1-3-g733a5 From affddf68c623390aa5566dad6357892d9e0ae278 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 13:49:58 +0100 Subject: Make `ui/issues/issue-17263.rs` robust w.r.t. NLL. --- src/test/ui/issues/issue-17263.ast.stderr | 26 +++++++++++++++++++++ src/test/ui/issues/issue-17263.nll.stderr | 6 ++--- src/test/ui/issues/issue-17263.rs | 38 ++++++++++++++++++++----------- src/test/ui/issues/issue-17263.stderr | 26 --------------------- 4 files changed, 54 insertions(+), 42 deletions(-) create mode 100644 src/test/ui/issues/issue-17263.ast.stderr delete mode 100644 src/test/ui/issues/issue-17263.stderr (limited to 'src/test') diff --git a/src/test/ui/issues/issue-17263.ast.stderr b/src/test/ui/issues/issue-17263.ast.stderr new file mode 100644 index 00000000000..3d42dcb52f5 --- /dev/null +++ b/src/test/ui/issues/issue-17263.ast.stderr @@ -0,0 +1,26 @@ +error[E0499]: cannot borrow `x` (via `x.b`) as mutable more than once at a time + --> $DIR/issue-17263.rs:17:34 + | +LL | let (a, b) = (&mut x.a, &mut x.b); + | --- ^^^ second mutable borrow occurs here (via `x.b`) + | | + | first mutable borrow occurs here (via `x.a`) +... +LL | } + | - first borrow ends here + +error[E0502]: cannot borrow `foo` (via `foo.b`) as immutable because `foo` is also borrowed as mutable (via `foo.a`) + --> $DIR/issue-17263.rs:21:32 + | +LL | let (c, d) = (&mut foo.a, &foo.b); + | ----- ^^^^^ immutable borrow occurs here (via `foo.b`) + | | + | mutable borrow occurs here (via `foo.a`) +... +LL | } + | - mutable borrow ends here + +error: aborting due to 2 previous errors + +Some errors occurred: E0499, E0502. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/issues/issue-17263.nll.stderr b/src/test/ui/issues/issue-17263.nll.stderr index d6009e8078d..cdb574b8b9f 100644 --- a/src/test/ui/issues/issue-17263.nll.stderr +++ b/src/test/ui/issues/issue-17263.nll.stderr @@ -1,12 +1,12 @@ error: compilation successful --> $DIR/issue-17263.rs:15:1 | -LL | / fn main() { #![rustc_error] // rust-lang/rust#49855 +LL | / fn main() { //[nll]~ ERROR compilation successful LL | | let mut x: Box<_> = box Foo { a: 1, b: 2 }; LL | | let (a, b) = (&mut x.a, &mut x.b); -LL | | //~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time +LL | | //[ast]~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time ... | -LL | | //~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable +LL | | use_mut(a); LL | | } | |_^ diff --git a/src/test/ui/issues/issue-17263.rs b/src/test/ui/issues/issue-17263.rs index b251f9a4152..754f3b90aac 100644 --- a/src/test/ui/issues/issue-17263.rs +++ b/src/test/ui/issues/issue-17263.rs @@ -1,23 +1,35 @@ -// Copyright 2014 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 diagnostic quality for cases where AST-borrowck treated +// `Box` as other types (see rust-lang/rfcs#130). NLL again treats +// `Box` specially. We capture the differences via revisions. +// revisions: ast nll +//[ast]compile-flags: -Z borrowck=ast +//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows + +// don't worry about the --compare-mode=nll on this test. +// ignore-compare-mode-nll #![feature(box_syntax, rustc_attrs)] struct Foo { a: isize, b: isize } - -fn main() { #![rustc_error] // rust-lang/rust#49855 +#[rustc_error] // rust-lang/rust#49855 +fn main() { //[nll]~ ERROR compilation successful let mut x: Box<_> = box Foo { a: 1, b: 2 }; let (a, b) = (&mut x.a, &mut x.b); - //~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time + //[ast]~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time let mut foo: Box<_> = box Foo { a: 1, b: 2 }; let (c, d) = (&mut foo.a, &foo.b); - //~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable + //[ast]~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable + + // We explicitly use the references created above to illustrate + // that NLL is accepting this code *not* because of artificially + // short lifetimes, but rather because it understands that all the + // references are of disjoint parts of memory. + use_imm(d); + use_mut(c); + use_mut(b); + use_mut(a); } + +fn use_mut(_: &mut T) { } +fn use_imm(_: &T) { } diff --git a/src/test/ui/issues/issue-17263.stderr b/src/test/ui/issues/issue-17263.stderr deleted file mode 100644 index 4767fbbcfbb..00000000000 --- a/src/test/ui/issues/issue-17263.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0499]: cannot borrow `x` (via `x.b`) as mutable more than once at a time - --> $DIR/issue-17263.rs:17:34 - | -LL | let (a, b) = (&mut x.a, &mut x.b); - | --- ^^^ second mutable borrow occurs here (via `x.b`) - | | - | first mutable borrow occurs here (via `x.a`) -... -LL | } - | - first borrow ends here - -error[E0502]: cannot borrow `foo` (via `foo.b`) as immutable because `foo` is also borrowed as mutable (via `foo.a`) - --> $DIR/issue-17263.rs:21:32 - | -LL | let (c, d) = (&mut foo.a, &foo.b); - | ----- ^^^^^ immutable borrow occurs here (via `foo.b`) - | | - | mutable borrow occurs here (via `foo.a`) -LL | //~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable -LL | } - | - mutable borrow ends here - -error: aborting due to 2 previous errors - -Some errors occurred: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. -- cgit 1.4.1-3-g733a5 From 9f9bf94b8dcb9acc4c0419dec256d1ece3139b1c Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 13:55:00 +0100 Subject: Make `ui/borrowck/borrowck-overloaded-index-move-index.rs` robust w.r.t. NLL. --- ...borrowck-overloaded-index-move-index.nll.stderr | 29 ++++++++++++++++++++-- .../borrowck-overloaded-index-move-index.rs | 4 +++ 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.nll.stderr index 824d8298ecb..198d086aa3b 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.nll.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.nll.stderr @@ -1,3 +1,27 @@ +error[E0505]: cannot move out of `s` because it is borrowed + --> $DIR/borrowck-overloaded-index-move-index.rs:60:22 + | +LL | let rs = &mut s; + | ------ borrow of `s` occurs here +LL | +LL | println!("{}", f[s]); + | ^ move out of `s` occurs here +... +LL | use_mut(rs); + | -- borrow later used here + +error[E0505]: cannot move out of `s` because it is borrowed + --> $DIR/borrowck-overloaded-index-move-index.rs:63:7 + | +LL | let rs = &mut s; + | ------ borrow of `s` occurs here +... +LL | f[s] = 10; + | ^ move out of `s` occurs here +... +LL | use_mut(rs); + | -- borrow later used here + error[E0382]: use of moved value: `s` --> $DIR/borrowck-overloaded-index-move-index.rs:63:7 | @@ -9,6 +33,7 @@ LL | f[s] = 10; | = note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait -error: aborting due to previous error +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0382`. +Some errors occurred: E0382, E0505. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.rs b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.rs index d8615d19053..e95423a8e83 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.rs +++ b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.rs @@ -71,4 +71,8 @@ fn main() { let _j = &i; println!("{}", s[i]); // no error, i is copy println!("{}", s[i]); + + use_mut(rs); } + +fn use_mut(_: &mut T) { } -- cgit 1.4.1-3-g733a5 From 6c7d82e1ca246e914e96beb1874a75f7306ac9dd Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 14:05:23 +0100 Subject: Make `ui/borrowck/borrowck-reborrow-from-mut.rs` robust w.r.t. NLL. --- .../borrowck/borrowck-reborrow-from-mut.nll.stderr | 109 ++++++++++++++++++++- src/test/ui/borrowck/borrowck-reborrow-from-mut.rs | 35 ++++--- .../ui/borrowck/borrowck-reborrow-from-mut.stderr | 10 +- 3 files changed, 135 insertions(+), 19 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-mut.nll.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-mut.nll.stderr index 4c81bb8eb30..1b4f9e77da8 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-mut.nll.stderr +++ b/src/test/ui/borrowck/borrowck-reborrow-from-mut.nll.stderr @@ -1,3 +1,107 @@ +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-reborrow-from-mut.rs:23:17 + | +LL | let _bar1 = &mut foo.bar1; + | ------------- first mutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ second mutable borrow occurs here +LL | use_mut(_bar1); + | ----- first borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-reborrow-from-mut.rs:28:17 + | +LL | let _bar1 = &mut foo.bar1; + | ------------- mutable borrow occurs here +LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^ immutable borrow occurs here +LL | use_mut(_bar1); + | ----- mutable borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-reborrow-from-mut.rs:33:17 + | +LL | let _bar1 = &foo.bar1; + | --------- immutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ mutable borrow occurs here +LL | use_imm(_bar1); + | ----- immutable borrow later used here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-reborrow-from-mut.rs:55:21 + | +LL | let _bar1 = &mut foo.bar1; + | ------------- first mutable borrow occurs here +LL | match *foo { +LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} + | ^^^^^^^^^^^^^ second mutable borrow occurs here +... +LL | use_mut(_bar1); + | ----- first borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-reborrow-from-mut.rs:62:17 + | +LL | let _bar1 = &mut foo.bar1.int1; + | ------------------ mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^ immutable borrow occurs here +LL | let _foo2 = &*foo; //~ ERROR cannot borrow +LL | use_mut(_bar1); + | ----- mutable borrow later used here + +error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-reborrow-from-mut.rs:63:17 + | +LL | let _bar1 = &mut foo.bar1.int1; + | ------------------ mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow +LL | let _foo2 = &*foo; //~ ERROR cannot borrow + | ^^^^^ immutable borrow occurs here +LL | use_mut(_bar1); + | ----- mutable borrow later used here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-reborrow-from-mut.rs:68:17 + | +LL | let _bar1 = &mut foo.bar1.int1; + | ------------------ first mutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ second mutable borrow occurs here +LL | use_mut(_bar1); + | ----- first borrow later used here + +error[E0499]: cannot borrow `*foo` as mutable more than once at a time + --> $DIR/borrowck-reborrow-from-mut.rs:73:17 + | +LL | let _bar1 = &mut foo.bar1.int1; + | ------------------ first mutable borrow occurs here +LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow + | ^^^^^^^^^ second mutable borrow occurs here +LL | use_mut(_bar1); + | ----- first borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-reborrow-from-mut.rs:78:17 + | +LL | let _bar1 = &foo.bar1.int1; + | -------------- immutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ mutable borrow occurs here +LL | use_imm(_bar1); + | ----- immutable borrow later used here + +error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-reborrow-from-mut.rs:83:17 + | +LL | let _bar1 = &foo.bar1.int1; + | -------------- immutable borrow occurs here +LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow + | ^^^^^^^^^ mutable borrow occurs here +LL | use_imm(_bar1); + | ----- immutable borrow later used here + error[E0596]: cannot borrow `foo.bar1` as mutable, as it is behind a `&` reference --> $DIR/borrowck-reborrow-from-mut.rs:98:17 | @@ -6,6 +110,7 @@ LL | fn borrow_mut_from_imm(foo: &Foo) { LL | let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error: aborting due to previous error +error: aborting due to 11 previous errors -For more information about this error, try `rustc --explain E0596`. +Some errors occurred: E0499, E0502, E0596. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-mut.rs b/src/test/ui/borrowck/borrowck-reborrow-from-mut.rs index 6f5dfa67be5..9235d900a7e 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-mut.rs +++ b/src/test/ui/borrowck/borrowck-reborrow-from-mut.rs @@ -21,79 +21,79 @@ struct Bar { fn borrow_same_field_twice_mut_mut(foo: &mut Foo) { let _bar1 = &mut foo.bar1; let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + use_mut(_bar1); } - fn borrow_same_field_twice_mut_imm(foo: &mut Foo) { let _bar1 = &mut foo.bar1; let _bar2 = &foo.bar1; //~ ERROR cannot borrow + use_mut(_bar1); } - fn borrow_same_field_twice_imm_mut(foo: &mut Foo) { let _bar1 = &foo.bar1; let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + use_imm(_bar1); } - fn borrow_same_field_twice_imm_imm(foo: &mut Foo) { let _bar1 = &foo.bar1; let _bar2 = &foo.bar1; + use_imm(_bar1); } - fn borrow_both_mut(foo: &mut Foo) { let _bar1 = &mut foo.bar1; let _bar2 = &mut foo.bar2; + use_mut(_bar1); } - fn borrow_both_mut_pattern(foo: &mut Foo) { match *foo { - Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => + { use_mut(_bar1); use_mut(_bar2); } } } - fn borrow_var_and_pattern(foo: &mut Foo) { let _bar1 = &mut foo.bar1; match *foo { Foo { bar1: ref mut _bar1, bar2: _ } => {} //~^ ERROR cannot borrow } + use_mut(_bar1); } - fn borrow_mut_and_base_imm(foo: &mut Foo) { let _bar1 = &mut foo.bar1.int1; let _foo1 = &foo.bar1; //~ ERROR cannot borrow let _foo2 = &*foo; //~ ERROR cannot borrow + use_mut(_bar1); } - fn borrow_mut_and_base_mut(foo: &mut Foo) { let _bar1 = &mut foo.bar1.int1; let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + use_mut(_bar1); } - fn borrow_mut_and_base_mut2(foo: &mut Foo) { let _bar1 = &mut foo.bar1.int1; let _foo2 = &mut *foo; //~ ERROR cannot borrow + use_mut(_bar1); } - fn borrow_imm_and_base_mut(foo: &mut Foo) { let _bar1 = &foo.bar1.int1; let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + use_imm(_bar1); } - fn borrow_imm_and_base_mut2(foo: &mut Foo) { let _bar1 = &foo.bar1.int1; let _foo2 = &mut *foo; //~ ERROR cannot borrow + use_imm(_bar1); } - fn borrow_imm_and_base_imm(foo: &mut Foo) { let _bar1 = &foo.bar1.int1; let _foo1 = &foo.bar1; let _foo2 = &*foo; + use_imm(_bar1); } - fn borrow_mut_and_imm(foo: &mut Foo) { let _bar1 = &mut foo.bar1; let _foo1 = &foo.bar2; + use_mut(_bar1); } - fn borrow_mut_from_imm(foo: &Foo) { let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow } @@ -101,6 +101,9 @@ fn borrow_mut_from_imm(foo: &Foo) { fn borrow_long_path_both_mut(foo: &mut Foo) { let _bar1 = &mut foo.bar1.int1; let _foo1 = &mut foo.bar2.int2; + use_mut(_bar1); } - fn main() {} + +fn use_mut(_: &mut T) { } +fn use_imm(_: &T) { } diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr index 00660ff8484..1310e38cb3e 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr +++ b/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr @@ -5,6 +5,7 @@ LL | let _bar1 = &mut foo.bar1; | -------- first mutable borrow occurs here LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^ second mutable borrow occurs here +LL | use_mut(_bar1); LL | } | - first borrow ends here @@ -15,6 +16,7 @@ LL | let _bar1 = &mut foo.bar1; | -------- mutable borrow occurs here LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^ immutable borrow occurs here +LL | use_mut(_bar1); LL | } | - mutable borrow ends here @@ -25,6 +27,7 @@ LL | let _bar1 = &foo.bar1; | -------- immutable borrow occurs here LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^ mutable borrow occurs here +LL | use_imm(_bar1); LL | } | - immutable borrow ends here @@ -47,7 +50,7 @@ LL | let _bar1 = &mut foo.bar1.int1; | ------------- mutable borrow occurs here LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^ immutable borrow occurs here -LL | let _foo2 = &*foo; //~ ERROR cannot borrow +... LL | } | - mutable borrow ends here @@ -59,6 +62,7 @@ LL | let _bar1 = &mut foo.bar1.int1; LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow LL | let _foo2 = &*foo; //~ ERROR cannot borrow | ^^^^ immutable borrow occurs here +LL | use_mut(_bar1); LL | } | - mutable borrow ends here @@ -69,6 +73,7 @@ LL | let _bar1 = &mut foo.bar1.int1; | ------------- first mutable borrow occurs here LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^ second mutable borrow occurs here +LL | use_mut(_bar1); LL | } | - first borrow ends here @@ -79,6 +84,7 @@ LL | let _bar1 = &mut foo.bar1.int1; | ------------- first mutable borrow occurs here LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow | ^^^^ second mutable borrow occurs here +LL | use_mut(_bar1); LL | } | - first borrow ends here @@ -89,6 +95,7 @@ LL | let _bar1 = &foo.bar1.int1; | ------------- immutable borrow occurs here LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^ mutable borrow occurs here +LL | use_imm(_bar1); LL | } | - immutable borrow ends here @@ -99,6 +106,7 @@ LL | let _bar1 = &foo.bar1.int1; | ------------- immutable borrow occurs here LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow | ^^^^ mutable borrow occurs here +LL | use_imm(_bar1); LL | } | - immutable borrow ends here -- cgit 1.4.1-3-g733a5 From 9843a38632dcf4f33325bbef57ef4a1e55c48d6d Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 14:32:00 +0100 Subject: Make `ui/borrowck/borrowck-unboxed-closures.rs` robust w.r.t. NLL. --- src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr | 14 ++++++++++++-- src/test/ui/borrowck/borrowck-unboxed-closures.rs | 4 +++- src/test/ui/borrowck/borrowck-unboxed-closures.stderr | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr b/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr index 3fbb747db24..ee5ad58290e 100644 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr +++ b/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr @@ -1,3 +1,13 @@ +error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-unboxed-closures.rs:13:5 + | +LL | let g = &mut f; + | ------ mutable borrow occurs here +LL | f(1, 2); //~ ERROR cannot borrow `f` as immutable + | ^ immutable borrow occurs here +LL | use_mut(g); + | - mutable borrow later used here + error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable --> $DIR/borrowck-unboxed-closures.rs:17:5 | @@ -16,7 +26,7 @@ LL | f(1, 2); //~ ERROR use of moved value | = note: move occurs because `f` has type `F`, which does not implement the `Copy` trait -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors occurred: E0382, E0596. +Some errors occurred: E0382, E0502, E0596. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.rs b/src/test/ui/borrowck/borrowck-unboxed-closures.rs index 4813b4b6a72..43f143a492f 100644 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.rs +++ b/src/test/ui/borrowck/borrowck-unboxed-closures.rs @@ -11,8 +11,8 @@ fn a isize>(mut f: F) { let g = &mut f; f(1, 2); //~ ERROR cannot borrow `f` as immutable + use_mut(g); } - fn b isize>(f: F) { f(1, 2); //~ ERROR cannot borrow immutable argument } @@ -23,3 +23,5 @@ fn c isize>(f: F) { } fn main() {} + +fn use_mut(_: &mut T) { } diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr index 0c067c47004..6ee1a6245a5 100644 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr +++ b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr @@ -5,6 +5,7 @@ LL | let g = &mut f; | - mutable borrow occurs here LL | f(1, 2); //~ ERROR cannot borrow `f` as immutable | ^ immutable borrow occurs here +LL | use_mut(g); LL | } | - mutable borrow ends here -- cgit 1.4.1-3-g733a5 From 41a1ee923ee9b3d1e9eb4aa76c048f4f1d3ede12 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 14:36:58 +0100 Subject: Make `ui/unop-move-semantics.rs` robust w.r.t. NLL. --- src/test/ui/unop-move-semantics.nll.stderr | 27 +++++++++++++++++++++++++-- src/test/ui/unop-move-semantics.rs | 7 +++++-- 2 files changed, 30 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/unop-move-semantics.nll.stderr b/src/test/ui/unop-move-semantics.nll.stderr index 111940aab2c..bfc7736b2f3 100644 --- a/src/test/ui/unop-move-semantics.nll.stderr +++ b/src/test/ui/unop-move-semantics.nll.stderr @@ -9,6 +9,29 @@ LL | x.clone(); //~ ERROR: use of moved value | = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/unop-move-semantics.rs:25:6 + | +LL | let m = &x; + | -- borrow of `x` occurs here +... +LL | !x; //~ ERROR: cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here +... +LL | use_mut(n); use_imm(m); + | - borrow later used here + +error[E0505]: cannot move out of `y` because it is borrowed + --> $DIR/unop-move-semantics.rs:27:6 + | +LL | let n = &mut y; + | ------ borrow of `y` occurs here +... +LL | !y; //~ ERROR: cannot move out of `y` because it is borrowed + | ^ move out of `y` occurs here +LL | use_mut(n); use_imm(m); + | - borrow later used here + error[E0507]: cannot move out of borrowed content --> $DIR/unop-move-semantics.rs:34:6 | @@ -21,7 +44,7 @@ error[E0507]: cannot move out of borrowed content LL | !*n; //~ ERROR: cannot move out of borrowed content | ^^ cannot move out of borrowed content -error: aborting due to 3 previous errors +error: aborting due to 5 previous errors -Some errors occurred: E0382, E0507. +Some errors occurred: E0382, E0505, E0507. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/unop-move-semantics.rs b/src/test/ui/unop-move-semantics.rs index 94656667598..fcbbe546a31 100644 --- a/src/test/ui/unop-move-semantics.rs +++ b/src/test/ui/unop-move-semantics.rs @@ -25,8 +25,8 @@ fn move_borrowed>(x: T, mut y: T) { !x; //~ ERROR: cannot move out of `x` because it is borrowed !y; //~ ERROR: cannot move out of `y` because it is borrowed + use_mut(n); use_imm(m); } - fn illegal_dereference>(mut x: T, y: T) { let m = &mut x; let n = &y; @@ -34,6 +34,9 @@ fn illegal_dereference>(mut x: T, y: T) { !*m; //~ ERROR: cannot move out of borrowed content !*n; //~ ERROR: cannot move out of borrowed content + use_imm(n); use_mut(m); } - fn main() {} + +fn use_mut(_: &mut T) { } +fn use_imm(_: &T) { } -- cgit 1.4.1-3-g733a5 From 62a2bb129499d7f9cf84ec21874775611ac67125 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 14:44:14 +0100 Subject: Remove `println!`'s from `ui/issues/issue-52126-assign-op-invariance.rs` This is not strictly necessary to make this test "more robust with respect to NLL"; its just an attempt to narrow the scope of the test and focus on its core. --- src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr | 6 +++--- src/test/ui/issues/issue-52126-assign-op-invariance.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr b/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr index b25b063f3b6..2165d951102 100644 --- a/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr +++ b/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr @@ -3,9 +3,9 @@ error[E0597]: `line` does not live long enough | LL | let v: Vec<&str> = line.split_whitespace().collect(); | ^^^^ borrowed value does not live long enough -LL | //~^ ERROR `line` does not live long enough -LL | println!("accumulator before add_assign {:?}", acc.map); - | ------- borrow used here, in later iteration of loop +... +LL | acc += cnt2; + | --- borrow used here, in later iteration of loop ... LL | } | - `line` dropped here while still borrowed diff --git a/src/test/ui/issues/issue-52126-assign-op-invariance.rs b/src/test/ui/issues/issue-52126-assign-op-invariance.rs index b26ad9bc37d..1a353f9ea7c 100644 --- a/src/test/ui/issues/issue-52126-assign-op-invariance.rs +++ b/src/test/ui/issues/issue-52126-assign-op-invariance.rs @@ -43,7 +43,7 @@ pub fn panics() { for line in vec!["123456789".to_string(), "12345678".to_string()] { let v: Vec<&str> = line.split_whitespace().collect(); //~^ ERROR `line` does not live long enough - println!("accumulator before add_assign {:?}", acc.map); + // println!("accumulator before add_assign {:?}", acc.map); let mut map = HashMap::new(); for str_ref in v { let e = map.entry(str_ref); @@ -53,7 +53,7 @@ pub fn panics() { } let cnt2 = Counter{map}; acc += cnt2; - println!("accumulator after add_assign {:?}", acc.map); + // println!("accumulator after add_assign {:?}", acc.map); // line gets dropped here but references are kept in acc.map } } -- cgit 1.4.1-3-g733a5 From e940801592b123e6ff03b355137ca568d11b4c4d Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 14:48:35 +0100 Subject: Make `ui/binop-move-semantics.rs` robust w.r.t. NLL. --- src/test/ui/binop/binop-move-semantics.nll.stderr | 27 +++++++++++++++++++++-- src/test/ui/binop/binop-move-semantics.rs | 7 ++++-- 2 files changed, 30 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/binop/binop-move-semantics.nll.stderr b/src/test/ui/binop/binop-move-semantics.nll.stderr index 545a60f6770..612375f9047 100644 --- a/src/test/ui/binop/binop-move-semantics.nll.stderr +++ b/src/test/ui/binop/binop-move-semantics.nll.stderr @@ -20,6 +20,29 @@ LL | x.clone(); //~ ERROR: use of moved value | = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/binop-move-semantics.rs:31:5 + | +LL | let m = &x; + | -- borrow of `x` occurs here +... +LL | x //~ ERROR: cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here +... +LL | use_mut(n); use_imm(m); + | - borrow later used here + +error[E0505]: cannot move out of `y` because it is borrowed + --> $DIR/binop-move-semantics.rs:33:5 + | +LL | let n = &mut y; + | ------ borrow of `y` occurs here +... +LL | y; //~ ERROR: cannot move out of `y` because it is borrowed + | ^ move out of `y` occurs here +LL | use_mut(n); use_imm(m); + | - borrow later used here + error[E0507]: cannot move out of borrowed content --> $DIR/binop-move-semantics.rs:40:5 | @@ -62,7 +85,7 @@ LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also b | | immutable borrow later used here | mutable borrow occurs here -error: aborting due to 6 previous errors +error: aborting due to 8 previous errors -Some errors occurred: E0382, E0502, E0507. +Some errors occurred: E0382, E0502, E0505, E0507. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/binop/binop-move-semantics.rs b/src/test/ui/binop/binop-move-semantics.rs index cff0064497a..f6fad8b46dd 100644 --- a/src/test/ui/binop/binop-move-semantics.rs +++ b/src/test/ui/binop/binop-move-semantics.rs @@ -31,8 +31,8 @@ fn move_borrowed>(x: T, mut y: T) { x //~ ERROR: cannot move out of `x` because it is borrowed + y; //~ ERROR: cannot move out of `y` because it is borrowed + use_mut(n); use_imm(m); } - fn illegal_dereference>(mut x: T, y: T) { let m = &mut x; let n = &y; @@ -40,8 +40,8 @@ fn illegal_dereference>(mut x: T, y: T) { *m //~ ERROR: cannot move out of borrowed content + *n; //~ ERROR: cannot move out of borrowed content + use_imm(n); use_mut(m); } - struct Foo; impl<'a, 'b> Add<&'b Foo> for &'a mut Foo { @@ -73,3 +73,6 @@ fn immut_plus_mut() { } fn main() {} + +fn use_mut(_: &mut T) { } +fn use_imm(_: &T) { } -- cgit 1.4.1-3-g733a5 From f7ded5dcb6d917f4cd68ec7781c655dbe030f000 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 14:55:30 +0100 Subject: Removed overlapping_spans.{rs,stderr,nll.stderr}. This is based on the feedback from estebank: """ I believe that test can be removed outright. It'd be impossible for a new change to go through that breaks this kind of output without it being picked up by multiple other `stderr` tests. This is an artifact of the transition period to the "new" output style. """ see: https://github.com/rust-lang/rust/issues/52663#issuecomment-422155551 --- .../ui/codemap_tests/overlapping_spans.nll.stderr | 17 ---------------- src/test/ui/codemap_tests/overlapping_spans.rs | 23 ---------------------- src/test/ui/codemap_tests/overlapping_spans.stderr | 12 ----------- 3 files changed, 52 deletions(-) delete mode 100644 src/test/ui/codemap_tests/overlapping_spans.nll.stderr delete mode 100644 src/test/ui/codemap_tests/overlapping_spans.rs delete mode 100644 src/test/ui/codemap_tests/overlapping_spans.stderr (limited to 'src/test') diff --git a/src/test/ui/codemap_tests/overlapping_spans.nll.stderr b/src/test/ui/codemap_tests/overlapping_spans.nll.stderr deleted file mode 100644 index e334472f9d6..00000000000 --- a/src/test/ui/codemap_tests/overlapping_spans.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/overlapping_spans.rs:20:11 - | -LL | match (S {f:"foo".to_string()}) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here -LL | S {f:_s} => {} //~ ERROR cannot move out - | -- data moved here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/overlapping_spans.rs:21:14 - | -LL | S {f:_s} => {} //~ ERROR cannot move out - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/codemap_tests/overlapping_spans.rs b/src/test/ui/codemap_tests/overlapping_spans.rs deleted file mode 100644 index 467e90bd5a5..00000000000 --- a/src/test/ui/codemap_tests/overlapping_spans.rs +++ /dev/null @@ -1,23 +0,0 @@ -// 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. - -#[derive(Debug)] -struct Foo { } - -struct S {f:String} -impl Drop for S { - fn drop(&mut self) { println!("{}", self.f); } -} - -fn main() { - match (S {f:"foo".to_string()}) { - S {f:_s} => {} //~ ERROR cannot move out - } -} diff --git a/src/test/ui/codemap_tests/overlapping_spans.stderr b/src/test/ui/codemap_tests/overlapping_spans.stderr deleted file mode 100644 index 62a4f08e156..00000000000 --- a/src/test/ui/codemap_tests/overlapping_spans.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/overlapping_spans.rs:21:9 - | -LL | S {f:_s} => {} //~ ERROR cannot move out - | ^^^^^--^ - | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` - | cannot move out of here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0509`. -- cgit 1.4.1-3-g733a5 From fe29cd0a3d1ebff0d90f3e4ebc929f944863be4c Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 15:24:25 +0100 Subject: Add `ui/borrowck/borrowck-closures-mut-of-mut.rs`. This is a variant of `ui/borrowck/borrowck-closures-mut-of-imm.rs` that I used to help identify what changes I needed to make to the latter file in order to recover its instances of E0524 under NLL. (Basically this test includes the changes you'd need to make to `ui/borrowck/borrowck-closures-mut-of-imm.rs` in order to get rid of occurrences of E0596. And then I realized that one needs to add invocations of the closures in order to properly extend the mutable reborrows in a manner such that NLL will roughly match AST-borrowck.) --- .../borrowck/borrowck-closures-mut-of-mut.nll.stderr | 18 ++++++++++++++++++ src/test/ui/borrowck/borrowck-closures-mut-of-mut.rs | 20 ++++++++++++++++++++ .../ui/borrowck/borrowck-closures-mut-of-mut.stderr | 18 ++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr create mode 100644 src/test/ui/borrowck/borrowck-closures-mut-of-mut.rs create mode 100644 src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr (limited to 'src/test') diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr new file mode 100644 index 00000000000..18f95f232cd --- /dev/null +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr @@ -0,0 +1,18 @@ +error[E0524]: two closures require unique access to `x` at the same time + --> $DIR/borrowck-closures-mut-of-mut.rs:14:18 + | +LL | let mut c1 = || set(&mut *x); + | -- - first borrow occurs due to use of `x` in closure + | | + | first closure is constructed here +LL | let mut c2 = || set(&mut *x); + | ^^ - second borrow occurs due to use of `x` in closure + | | + | second closure is constructed here +LL | //~^ ERROR two closures require unique access to `x` at the same time +LL | c2(); c1(); + | -- first borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0524`. diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-mut.rs b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.rs new file mode 100644 index 00000000000..50c6f2c585e --- /dev/null +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.rs @@ -0,0 +1,20 @@ +// Tests that two closures cannot simultaneously both have mutable +// access to the variable. Related to issue #6801. + +fn get(x: &isize) -> isize { + *x +} + +fn set(x: &mut isize) { + *x = 4; +} + +fn a(x: &mut isize) { + let mut c1 = || set(&mut *x); + let mut c2 = || set(&mut *x); + //~^ ERROR two closures require unique access to `x` at the same time + c2(); c1(); +} + +fn main() { +} diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr new file mode 100644 index 00000000000..2c5587710a1 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr @@ -0,0 +1,18 @@ +error[E0524]: two closures require unique access to `x` at the same time + --> $DIR/borrowck-closures-mut-of-mut.rs:14:18 + | +LL | let mut c1 = || set(&mut *x); + | -- - previous borrow occurs due to use of `x` in closure + | | + | first closure is constructed here +LL | let mut c2 = || set(&mut *x); + | ^^ - borrow occurs due to use of `x` in closure + | | + | second closure is constructed here +... +LL | } + | - borrow from first closure ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0524`. -- cgit 1.4.1-3-g733a5 From c25319fcfc5046b91b773c87edbfdb087e875343 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 15:25:11 +0100 Subject: Update `ui/borrowck/borrowck-closures-mut-of-imm.rs` robust w.r.t. NLL. --- .../borrowck-closures-mut-of-imm.nll.stderr | 33 ++++++++++++++++------ .../ui/borrowck/borrowck-closures-mut-of-imm.rs | 5 ++-- .../borrowck/borrowck-closures-mut-of-imm.stderr | 30 ++++++++++---------- 3 files changed, 43 insertions(+), 25 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr index e8fae63a5d6..160a84c480c 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr @@ -1,15 +1,32 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-closures-mut-of-imm.rs:23:21 + --> $DIR/borrowck-closures-mut-of-imm.rs:23:25 | -LL | let c1 = || set(&mut *x); - | ^^^^^^^ cannot borrow as mutable +LL | let mut c1 = || set(&mut *x); + | ^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-closures-mut-of-imm.rs:25:21 + --> $DIR/borrowck-closures-mut-of-imm.rs:25:25 | -LL | let c2 = || set(&mut *x); - | ^^^^^^^ cannot borrow as mutable +LL | let mut c2 = || set(&mut *x); + | ^^^^^^^ cannot borrow as mutable -error: aborting due to 2 previous errors +error[E0524]: two closures require unique access to `x` at the same time + --> $DIR/borrowck-closures-mut-of-imm.rs:25:18 + | +LL | let mut c1 = || set(&mut *x); + | -- - first borrow occurs due to use of `x` in closure + | | + | first closure is constructed here +LL | //~^ ERROR cannot borrow +LL | let mut c2 = || set(&mut *x); + | ^^ - second borrow occurs due to use of `x` in closure + | | + | second closure is constructed here +... +LL | c2(); c1(); + | -- first borrow later used here + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0596`. +Some errors occurred: E0524, E0596. +For more information about an error, try `rustc --explain E0524`. diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.rs b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.rs index dc2f0e8395f..3bf4f17fde1 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.rs +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.rs @@ -20,11 +20,12 @@ fn set(x: &mut isize) { } fn a(x: &isize) { - let c1 = || set(&mut *x); + let mut c1 = || set(&mut *x); //~^ ERROR cannot borrow - let c2 = || set(&mut *x); + let mut c2 = || set(&mut *x); //~^ ERROR cannot borrow //~| ERROR two closures require unique access to `x` at the same time + c2(); c1(); } fn main() { diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr index 87eb52b6aa6..c248595d571 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr @@ -1,30 +1,30 @@ error[E0524]: two closures require unique access to `x` at the same time - --> $DIR/borrowck-closures-mut-of-imm.rs:25:14 + --> $DIR/borrowck-closures-mut-of-imm.rs:25:18 | -LL | let c1 = || set(&mut *x); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first closure is constructed here +LL | let mut c1 = || set(&mut *x); + | -- - previous borrow occurs due to use of `x` in closure + | | + | first closure is constructed here LL | //~^ ERROR cannot borrow -LL | let c2 = || set(&mut *x); - | ^^ - borrow occurs due to use of `x` in closure - | | - | second closure is constructed here +LL | let mut c2 = || set(&mut *x); + | ^^ - borrow occurs due to use of `x` in closure + | | + | second closure is constructed here ... LL | } | - borrow from first closure ends here error[E0596]: cannot borrow immutable borrowed content `***x` as mutable - --> $DIR/borrowck-closures-mut-of-imm.rs:23:26 + --> $DIR/borrowck-closures-mut-of-imm.rs:23:30 | -LL | let c1 = || set(&mut *x); - | ^^ cannot borrow as mutable +LL | let mut c1 = || set(&mut *x); + | ^^ cannot borrow as mutable error[E0596]: cannot borrow immutable borrowed content `***x` as mutable - --> $DIR/borrowck-closures-mut-of-imm.rs:25:26 + --> $DIR/borrowck-closures-mut-of-imm.rs:25:30 | -LL | let c2 = || set(&mut *x); - | ^^ cannot borrow as mutable +LL | let mut c2 = || set(&mut *x); + | ^^ cannot borrow as mutable error: aborting due to 3 previous errors -- cgit 1.4.1-3-g733a5 From cf715827187791a82dd8401ca210d1e881b8e3e5 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 16:19:51 +0100 Subject: Use `// revisions` in the dropck-eyepatch tests instead of relying on compare-mode=nll. NLL has increased precision in its analysis of drop order, and we want the test annotations to deliberately reflect this by having fewer ERROR annotations for NLL than for AST-borrowck. The best way to get this effect is via `// revisions`. As a drive-by, also added uses of all the borrows just to make it clear that NLL isn't somehow sidestepping things by using shorter borrows than you might have otherwise expected. (Of course, the added uses do not make all that much difference since the relevant types all declare `impl Drop` and thus those drops have implicit uses anyway.) --- .../dropck/dropck-eyepatch-extern-crate.ast.stderr | 69 ++++++++++++++++++++++ src/test/ui/dropck/dropck-eyepatch-extern-crate.rs | 35 ++++++----- .../ui/dropck/dropck-eyepatch-extern-crate.stderr | 69 ---------------------- .../ui/dropck/dropck-eyepatch-reorder.ast.stderr | 69 ++++++++++++++++++++++ src/test/ui/dropck/dropck-eyepatch-reorder.rs | 35 ++++++----- src/test/ui/dropck/dropck-eyepatch-reorder.stderr | 69 ---------------------- src/test/ui/dropck/dropck-eyepatch.ast.stderr | 69 ++++++++++++++++++++++ src/test/ui/dropck/dropck-eyepatch.rs | 35 ++++++----- src/test/ui/dropck/dropck-eyepatch.stderr | 69 ---------------------- 9 files changed, 264 insertions(+), 255 deletions(-) create mode 100644 src/test/ui/dropck/dropck-eyepatch-extern-crate.ast.stderr delete mode 100644 src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr create mode 100644 src/test/ui/dropck/dropck-eyepatch-reorder.ast.stderr delete mode 100644 src/test/ui/dropck/dropck-eyepatch-reorder.stderr create mode 100644 src/test/ui/dropck/dropck-eyepatch.ast.stderr delete mode 100644 src/test/ui/dropck/dropck-eyepatch.stderr (limited to 'src/test') diff --git a/src/test/ui/dropck/dropck-eyepatch-extern-crate.ast.stderr b/src/test/ui/dropck/dropck-eyepatch-extern-crate.ast.stderr new file mode 100644 index 00000000000..31adb2f3f14 --- /dev/null +++ b/src/test/ui/dropck/dropck-eyepatch-extern-crate.ast.stderr @@ -0,0 +1,69 @@ +error[E0597]: `c` does not live long enough + --> $DIR/dropck-eyepatch-extern-crate.rs:41:20 + | +LL | dt = Dt("dt", &c); + | ^ borrowed value does not live long enough +... +LL | } + | - `c` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c` does not live long enough + --> $DIR/dropck-eyepatch-extern-crate.rs:43:20 + | +LL | dr = Dr("dr", &c); + | ^ borrowed value does not live long enough +... +LL | } + | - `c` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-extern-crate.rs:47:20 + | +LL | dt = Dt("dt", &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-extern-crate.rs:50:20 + | +LL | dr = Dr("dr", &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-extern-crate.rs:57:29 + | +LL | pt = Pt("pt", &c_long, &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-extern-crate.rs:59:29 + | +LL | pr = Pr("pr", &c_long, &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs b/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs index 3e531d9fd60..68065639398 100644 --- a/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs +++ b/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs @@ -1,12 +1,12 @@ -// 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. +// The behavior of AST-borrowck and NLL explcitly differ here due to +// NLL's increased precision; so we use revisions and do not worry +// about the --compare-mode=nll on this test. + +// revisions: ast nll +//[ast]compile-flags: -Z borrowck=ast +//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows + +// ignore-compare-mode-nll // aux-build:dropck_eyepatch_extern_crate.rs @@ -39,29 +39,32 @@ fn main() { #![rustc_error] // rust-lang/rust#49855 // Error: destructor order imprecisely modelled dt = Dt("dt", &c); - //~^ ERROR `c` does not live long enough + //[ast]~^ ERROR `c` does not live long enough dr = Dr("dr", &c); - //~^ ERROR `c` does not live long enough + //[ast]~^ ERROR `c` does not live long enough // Error: `c_shortest` dies too soon for the references in dtors to be valid. dt = Dt("dt", &c_shortest); - //~^ ERROR `c_shortest` does not live long enough + //[ast]~^ ERROR `c_shortest` does not live long enough + //[nll]~^^ ERROR `c_shortest` does not live long enough dr = Dr("dr", &c_shortest); - //~^ ERROR `c_shortest` does not live long enough - + //[ast]~^ ERROR `c_shortest` does not live long enough // No error: Drop impl asserts .1 (A and &'a _) are not accessed pt = Pt("pt", &c_shortest, &c_long); pr = Pr("pr", &c_shortest, &c_long); // Error: Drop impl's assertion does not apply to `B` nor `&'b _` pt = Pt("pt", &c_long, &c_shortest); - //~^ ERROR `c_shortest` does not live long enough + //[ast]~^ ERROR `c_shortest` does not live long enough pr = Pr("pr", &c_long, &c_shortest); - //~^ ERROR `c_shortest` does not live long enough + //[ast]~^ ERROR `c_shortest` does not live long enough // No error: St and Sr have no destructor. st = St("st", &c_shortest); sr = Sr("sr", &c_shortest); println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); + use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1); } + +fn use_imm(_: &T) { } diff --git a/src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr b/src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr deleted file mode 100644 index 35db46f4fae..00000000000 --- a/src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:41:20 - | -LL | dt = Dt("dt", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:43:20 - | -LL | dr = Dr("dr", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:47:20 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:49:20 - | -LL | dr = Dr("dr", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:57:29 - | -LL | pt = Pt("pt", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:59:29 - | -LL | pr = Pr("pr", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.ast.stderr b/src/test/ui/dropck/dropck-eyepatch-reorder.ast.stderr new file mode 100644 index 00000000000..ddd47e97434 --- /dev/null +++ b/src/test/ui/dropck/dropck-eyepatch-reorder.ast.stderr @@ -0,0 +1,69 @@ +error[E0597]: `c` does not live long enough + --> $DIR/dropck-eyepatch-reorder.rs:58:20 + | +LL | dt = Dt("dt", &c); + | ^ borrowed value does not live long enough +... +LL | } + | - `c` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c` does not live long enough + --> $DIR/dropck-eyepatch-reorder.rs:60:20 + | +LL | dr = Dr("dr", &c); + | ^ borrowed value does not live long enough +... +LL | } + | - `c` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-reorder.rs:64:20 + | +LL | dt = Dt("dt", &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-reorder.rs:67:20 + | +LL | dr = Dr("dr", &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-reorder.rs:74:29 + | +LL | pt = Pt("pt", &c_long, &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-reorder.rs:76:29 + | +LL | pr = Pr("pr", &c_long, &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.rs b/src/test/ui/dropck/dropck-eyepatch-reorder.rs index 1806dc71424..16aaa261257 100644 --- a/src/test/ui/dropck/dropck-eyepatch-reorder.rs +++ b/src/test/ui/dropck/dropck-eyepatch-reorder.rs @@ -1,12 +1,12 @@ -// 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. +// The behavior of AST-borrowck and NLL explcitly differ here due to +// NLL's increased precision; so we use revisions and do not worry +// about the --compare-mode=nll on this test. + +// revisions: ast nll +//[ast]compile-flags: -Z borrowck=ast +//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows + +// ignore-compare-mode-nll #![feature(dropck_eyepatch, rustc_attrs)] @@ -56,29 +56,32 @@ fn main() { #![rustc_error] // rust-lang/rust#49855 // Error: destructor order imprecisely modelled dt = Dt("dt", &c); - //~^ ERROR `c` does not live long enough + //[ast]~^ ERROR `c` does not live long enough dr = Dr("dr", &c); - //~^ ERROR `c` does not live long enough + //[ast]~^ ERROR `c` does not live long enough // Error: `c_shortest` dies too soon for the references in dtors to be valid. dt = Dt("dt", &c_shortest); - //~^ ERROR `c_shortest` does not live long enough + //[ast]~^ ERROR `c_shortest` does not live long enough + //[nll]~^^ ERROR `c_shortest` does not live long enough dr = Dr("dr", &c_shortest); - //~^ ERROR `c_shortest` does not live long enough - + //[ast]~^ ERROR `c_shortest` does not live long enough // No error: Drop impl asserts .1 (A and &'a _) are not accessed pt = Pt("pt", &c_shortest, &c_long); pr = Pr("pr", &c_shortest, &c_long); // Error: Drop impl's assertion does not apply to `B` nor `&'b _` pt = Pt("pt", &c_long, &c_shortest); - //~^ ERROR `c_shortest` does not live long enough + //[ast]~^ ERROR `c_shortest` does not live long enough pr = Pr("pr", &c_long, &c_shortest); - //~^ ERROR `c_shortest` does not live long enough + //[ast]~^ ERROR `c_shortest` does not live long enough // No error: St and Sr have no destructor. st = St("st", &c_shortest); sr = Sr("sr", &c_shortest); println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); + use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1); } + +fn use_imm(_: &T) { } diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.stderr b/src/test/ui/dropck/dropck-eyepatch-reorder.stderr deleted file mode 100644 index 9984a7b9409..00000000000 --- a/src/test/ui/dropck/dropck-eyepatch-reorder.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:58:20 - | -LL | dt = Dt("dt", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:60:20 - | -LL | dr = Dr("dr", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:64:20 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:66:20 - | -LL | dr = Dr("dr", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:74:29 - | -LL | pt = Pt("pt", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:76:29 - | -LL | pr = Pr("pr", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch.ast.stderr b/src/test/ui/dropck/dropck-eyepatch.ast.stderr new file mode 100644 index 00000000000..0952ed0d6b7 --- /dev/null +++ b/src/test/ui/dropck/dropck-eyepatch.ast.stderr @@ -0,0 +1,69 @@ +error[E0597]: `c` does not live long enough + --> $DIR/dropck-eyepatch.rs:81:20 + | +LL | dt = Dt("dt", &c); + | ^ borrowed value does not live long enough +... +LL | } + | - `c` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c` does not live long enough + --> $DIR/dropck-eyepatch.rs:83:20 + | +LL | dr = Dr("dr", &c); + | ^ borrowed value does not live long enough +... +LL | } + | - `c` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch.rs:87:20 + | +LL | dt = Dt("dt", &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch.rs:90:20 + | +LL | dr = Dr("dr", &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch.rs:98:29 + | +LL | pt = Pt("pt", &c_long, &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch.rs:100:29 + | +LL | pr = Pr("pr", &c_long, &c_shortest); + | ^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `c_shortest` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch.rs b/src/test/ui/dropck/dropck-eyepatch.rs index 40d3ff050e2..d7a671fd33c 100644 --- a/src/test/ui/dropck/dropck-eyepatch.rs +++ b/src/test/ui/dropck/dropck-eyepatch.rs @@ -1,12 +1,12 @@ -// 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. +// The behavior of AST-borrowck and NLL explcitly differ here due to +// NLL's increased precision; so we use revisions and do not worry +// about the --compare-mode=nll on this test. + +// revisions: ast nll +//[ast]compile-flags: -Z borrowck=ast +//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows + +// ignore-compare-mode-nll #![feature(dropck_eyepatch, rustc_attrs)] @@ -79,16 +79,16 @@ fn main() { #![rustc_error] // rust-lang/rust#49855 // Error: destructor order imprecisely modelled dt = Dt("dt", &c); - //~^ ERROR `c` does not live long enough + //[ast]~^ ERROR `c` does not live long enough dr = Dr("dr", &c); - //~^ ERROR `c` does not live long enough + //[ast]~^ ERROR `c` does not live long enough // Error: `c_shortest` dies too soon for the references in dtors to be valid. dt = Dt("dt", &c_shortest); - //~^ ERROR `c_shortest` does not live long enough + //[ast]~^ ERROR `c_shortest` does not live long enough + //[nll]~^^ ERROR `c_shortest` does not live long enough dr = Dr("dr", &c_shortest); - //~^ ERROR `c_shortest` does not live long enough - + //[ast]~^ ERROR `c_shortest` does not live long enough // No error: Drop impl asserts .1 (A and &'a _) are not accessed pt = Pt("pt", &c_shortest, &c_long); @@ -96,13 +96,16 @@ fn main() { #![rustc_error] // rust-lang/rust#49855 // Error: Drop impl's assertion does not apply to `B` nor `&'b _` pt = Pt("pt", &c_long, &c_shortest); - //~^ ERROR `c_shortest` does not live long enough + //[ast]~^ ERROR `c_shortest` does not live long enough pr = Pr("pr", &c_long, &c_shortest); - //~^ ERROR `c_shortest` does not live long enough + //[ast]~^ ERROR `c_shortest` does not live long enough // No error: St and Sr have no destructor. st = St("st", &c_shortest); sr = Sr("sr", &c_shortest); println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); + use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1); } + +fn use_imm(_: &T) { } diff --git a/src/test/ui/dropck/dropck-eyepatch.stderr b/src/test/ui/dropck/dropck-eyepatch.stderr deleted file mode 100644 index 7cdf645941d..00000000000 --- a/src/test/ui/dropck/dropck-eyepatch.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch.rs:81:20 - | -LL | dt = Dt("dt", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch.rs:83:20 - | -LL | dr = Dr("dr", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:87:20 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:89:20 - | -LL | dr = Dr("dr", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:98:29 - | -LL | pt = Pt("pt", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:100:29 - | -LL | pr = Pr("pr", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0597`. -- cgit 1.4.1-3-g733a5 From b75fbbf54095d5430ddf0f93c7210fe6f9007bc6 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 16:29:41 +0100 Subject: Make `ui/borrowck/borrowck-overloaded-call.rs` robust w.r.t. NLL. --- src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr | 14 ++++++++++++-- src/test/ui/borrowck/borrowck-overloaded-call.rs | 4 +++- src/test/ui/borrowck/borrowck-overloaded-call.stderr | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr index dc8d731dede..0c4f2fa9d71 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr @@ -1,3 +1,13 @@ +error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-overloaded-call.rs:69:5 + | +LL | let sp = &mut s; + | ------ mutable borrow occurs here +LL | s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + | ^ immutable borrow occurs here +LL | use_mut(sp); + | -- mutable borrow later used here + error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable --> $DIR/borrowck-overloaded-call.rs:77:5 | @@ -17,7 +27,7 @@ LL | s(" world".to_string()); //~ ERROR use of moved value: `s` | = note: move occurs because `s` has type `SFnOnce`, which does not implement the `Copy` trait -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors occurred: E0382, E0596. +Some errors occurred: E0382, E0502, E0596. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-call.rs b/src/test/ui/borrowck/borrowck-overloaded-call.rs index 41f3e472cd1..b2401fbbc04 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-call.rs +++ b/src/test/ui/borrowck/borrowck-overloaded-call.rs @@ -67,8 +67,8 @@ fn f() { }; let sp = &mut s; s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + use_mut(sp); } - fn g() { let s = SFnMut { x: 1, @@ -86,3 +86,5 @@ fn h() { } fn main() {} + +fn use_mut(_: &mut T) { } diff --git a/src/test/ui/borrowck/borrowck-overloaded-call.stderr b/src/test/ui/borrowck/borrowck-overloaded-call.stderr index fa2473adc2f..bb5bafbbc7b 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-call.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-call.stderr @@ -5,6 +5,7 @@ LL | let sp = &mut s; | - mutable borrow occurs here LL | s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable | ^ immutable borrow occurs here +LL | use_mut(sp); LL | } | - mutable borrow ends here -- cgit 1.4.1-3-g733a5 From fff9ddedcef8a869a4665414bf4f5a122eeab823 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Nov 2018 16:37:18 +0100 Subject: For feature-gate-nll test, turn off testing modes that externally enable NLL. --- .../ui/feature-gates/feature-gate-nll.nll.stderr | 13 ------------- src/test/ui/feature-gates/feature-gate-nll.rs | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 24 deletions(-) delete mode 100644 src/test/ui/feature-gates/feature-gate-nll.nll.stderr (limited to 'src/test') diff --git a/src/test/ui/feature-gates/feature-gate-nll.nll.stderr b/src/test/ui/feature-gates/feature-gate-nll.nll.stderr deleted file mode 100644 index 81de0d14aa7..00000000000 --- a/src/test/ui/feature-gates/feature-gate-nll.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: compilation successful - --> $DIR/feature-gate-nll.rs:13:1 - | -LL | / fn main() { #![rustc_error] // rust-lang/rust#49855 -LL | | let mut x = 33; -LL | | -LL | | let p = &x; -LL | | x = 22; //~ ERROR cannot assign to `x` because it is borrowed [E0506] -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/feature-gates/feature-gate-nll.rs b/src/test/ui/feature-gates/feature-gate-nll.rs index 752b1fa821f..14c48fb48a0 100644 --- a/src/test/ui/feature-gates/feature-gate-nll.rs +++ b/src/test/ui/feature-gates/feature-gate-nll.rs @@ -1,16 +1,16 @@ -// Copyright 2015 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(rustc_attrs)] +// This is a test checking that if you do not opt into NLL then you +// should not get the effects of NLL applied to the test. + +// Don't use 2018 edition, since that turns on NLL (migration mode). +// edition:2015 + +// Don't use compare-mode=nll, since that turns on NLL. +// ignore-compare-mode-nll + + #![allow(dead_code)] -fn main() { #![rustc_error] // rust-lang/rust#49855 +fn main() { let mut x = 33; let p = &x; -- cgit 1.4.1-3-g733a5