diff options
| author | Michał Krasnoborski <mkrdln@gmail.com> | 2017-02-03 17:48:07 +0100 |
|---|---|---|
| committer | Michał Krasnoborski <mkrdln@gmail.com> | 2017-02-03 17:48:07 +0100 |
| commit | 0267529681e2fac6ef4560afe7d8d439d04e6303 (patch) | |
| tree | 00bac1c7b714a59f1e4f230a64cb5427de2b62eb /src/test | |
| parent | ecda7f314fa79bbfbf2125c99fd66288ca83c875 (diff) | |
| parent | aed6410a7b0f15dc68536e0735787436526ba395 (diff) | |
| download | rust-0267529681e2fac6ef4560afe7d8d439d04e6303.tar.gz rust-0267529681e2fac6ef4560afe7d8d439d04e6303.zip | |
Merge remote-tracking branch 'upstream/master' into format-with-capacity
Diffstat (limited to 'src/test')
178 files changed, 909 insertions, 494 deletions
diff --git a/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs b/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs index dc88bfc4059..61b1a0a0b4d 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs @@ -36,11 +36,9 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_macro("identity", expand_identity); reg.register_syntax_extension( Symbol::intern("into_multi_foo"), - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. MultiModifier(Box::new(expand_into_foo_multi))); reg.register_syntax_extension( Symbol::intern("duplicate"), - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. MultiDecorator(Box::new(expand_duplicate))); } diff --git a/src/test/compile-fail-fulldeps/explore-issue-38412.rs b/src/test/compile-fail-fulldeps/explore-issue-38412.rs index aab92575321..b9839edea2d 100644 --- a/src/test/compile-fail-fulldeps/explore-issue-38412.rs +++ b/src/test/compile-fail-fulldeps/explore-issue-38412.rs @@ -25,21 +25,14 @@ use pub_and_stability::{Record, Trait, Tuple}; fn main() { // Okay let Record { .. } = Record::new(); - // Okay (for now; see RFC Issue #902) - let Tuple(..) = Tuple::new(); // Okay let Record { a_stable_pub: _, a_unstable_declared_pub: _, .. } = Record::new(); - // Okay (for now; see RFC Issue #902) - let Tuple(_, _, ..) = Tuple::new(); // analogous to above let Record { a_stable_pub: _, a_unstable_declared_pub: _, a_unstable_undeclared_pub: _, .. } = Record::new(); //~^^ ERROR use of unstable library feature 'unstable_undeclared' - let Tuple(_, _, _, ..) = Tuple::new(); // analogous to previous - //~^ ERROR use of unstable library feature 'unstable_undeclared' - let r = Record::new(); let t = Tuple::new(); diff --git a/src/test/compile-fail-fulldeps/gated-macro-reexports.rs b/src/test/compile-fail-fulldeps/gated-macro-reexports.rs index b3dbcb743a1..22c92623e1c 100644 --- a/src/test/compile-fail-fulldeps/gated-macro-reexports.rs +++ b/src/test/compile-fail-fulldeps/gated-macro-reexports.rs @@ -11,6 +11,7 @@ // Test that macro reexports item are gated by `macro_reexport` feature gate. // aux-build:macro_reexport_1.rs +// gate-test-macro_reexport #![crate_type = "dylib"] diff --git a/src/test/compile-fail-fulldeps/gated-quote.rs b/src/test/compile-fail-fulldeps/gated-quote.rs index dade0e946c5..51a9a87744a 100644 --- a/src/test/compile-fail-fulldeps/gated-quote.rs +++ b/src/test/compile-fail-fulldeps/gated-quote.rs @@ -15,6 +15,8 @@ // FIXME the error message that is current emitted seems pretty bad. +// gate-test-quote + #![feature(rustc_private)] #![allow(dead_code, unused_imports, unused_variables)] diff --git a/src/test/compile-fail/E0106.rs b/src/test/compile-fail/E0106.rs index dab03f0bccf..d5644ab0608 100644 --- a/src/test/compile-fail/E0106.rs +++ b/src/test/compile-fail/E0106.rs @@ -23,5 +23,17 @@ type MyStr = &str; //~^ ERROR E0106 //~| NOTE expected lifetime parameter +struct Baz<'a>(&'a str); +struct Buzz<'a, 'b>(&'a str, &'b str); + +struct Quux { + baz: Baz, + //~^ ERROR E0106 + //~| expected lifetime parameter + buzz: Buzz, + //~^ ERROR E0106 + //~| expected 2 lifetime parameters +} + fn main() { } diff --git a/src/test/compile-fail/E0107.rs b/src/test/compile-fail/E0107.rs index 5f333e17c47..16ebd3e9ca5 100644 --- a/src/test/compile-fail/E0107.rs +++ b/src/test/compile-fail/E0107.rs @@ -18,9 +18,6 @@ enum Bar { } struct Baz<'a, 'b, 'c> { - foo: Foo, - //~^ ERROR E0107 - //~| expected 1 lifetime parameter buzz: Buzz<'a>, //~^ ERROR E0107 //~| expected 2 lifetime parameters diff --git a/src/test/compile-fail/E0117.rs b/src/test/compile-fail/E0117.rs index e9375e67325..4ba9c3382f3 100644 --- a/src/test/compile-fail/E0117.rs +++ b/src/test/compile-fail/E0117.rs @@ -11,6 +11,7 @@ impl Drop for u32 {} //~ ERROR E0117 //~^ NOTE impl doesn't use types inside crate //~| NOTE the impl does not reference any types defined in this crate +//~| NOTE define and implement a trait or new type instead fn main() { } diff --git a/src/test/compile-fail/E0206.rs b/src/test/compile-fail/E0206.rs index 888e42ed3a1..1131e8e1b01 100644 --- a/src/test/compile-fail/E0206.rs +++ b/src/test/compile-fail/E0206.rs @@ -16,6 +16,7 @@ impl Copy for Foo { } //~| ERROR only traits defined in the current crate can be implemented for arbitrary types //~| NOTE impl doesn't use types inside crate //~| NOTE the impl does not reference any types defined in this crate +//~| NOTE define and implement a trait or new type instead #[derive(Copy, Clone)] struct Bar; diff --git a/src/test/compile-fail/E0451.rs b/src/test/compile-fail/E0451.rs index f7b106d160d..ace96c9983e 100644 --- a/src/test/compile-fail/E0451.rs +++ b/src/test/compile-fail/E0451.rs @@ -25,11 +25,6 @@ fn pat_match(foo: Bar::Foo) { //~^ NOTE field `b` is private } -fn pat_match_tuple(foo: Bar::FooTuple) { - let Bar::FooTuple(a,b) = foo; //~ ERROR E0451 - //~^ NOTE field `1` is private -} - fn main() { let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451 //~^ NOTE field `b` is private diff --git a/src/test/compile-fail/associated-types-project-from-hrtb-in-struct.rs b/src/test/compile-fail/associated-types-project-from-hrtb-in-struct.rs index 44ad0bb0113..e6251a0d318 100644 --- a/src/test/compile-fail/associated-types-project-from-hrtb-in-struct.rs +++ b/src/test/compile-fail/associated-types-project-from-hrtb-in-struct.rs @@ -22,10 +22,11 @@ struct SomeStruct<I : for<'x> Foo<&'x isize>> { //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context } -struct AnotherStruct<I : for<'x> Foo<&'x isize>> { - field: <I as Foo<&isize>>::A - //~^ ERROR missing lifetime specifier -} +// FIXME(eddyb) This one doesn't even compile because of the unsupported syntax. + +// struct AnotherStruct<I : for<'x> Foo<&'x isize>> { +// field: <I as for<'y> Foo<&'y isize>>::A +// } struct YetAnotherStruct<'a, I : for<'x> Foo<&'x isize>> { field: <I as Foo<&'a isize>>::A diff --git a/src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs b/src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs index a38a7bfb937..5e09473ab77 100644 --- a/src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs +++ b/src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs @@ -17,10 +17,7 @@ struct RefAny<'a, T>(&'a T); -impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> { - //~^ ERROR expected identifier, found `>` -} +impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {} +//~^ ERROR trailing attribute after type parameters -fn main() { - -} +fn main() {} diff --git a/src/test/compile-fail/autoderef-full-lval.rs b/src/test/compile-fail/autoderef-full-lval.rs index 0d666a49200..c152fdd9296 100644 --- a/src/test/compile-fail/autoderef-full-lval.rs +++ b/src/test/compile-fail/autoderef-full-lval.rs @@ -22,13 +22,14 @@ struct fish { fn main() { let a: clam = clam{x: box 1, y: box 2}; let b: clam = clam{x: box 10, y: box 20}; - let z: isize = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Box<isize>` + let z: isize = a.x + b.y; + //~^ ERROR binary operation `+` cannot be applied to type `std::boxed::Box<isize>` println!("{}", z); assert_eq!(z, 21); let forty: fish = fish{a: box 40}; let two: fish = fish{a: box 2}; let answer: isize = forty.a + two.a; - //~^ ERROR binary operation `+` cannot be applied to type `Box<isize>` + //~^ ERROR binary operation `+` cannot be applied to type `std::boxed::Box<isize>` println!("{}", answer); assert_eq!(answer, 42); } diff --git a/src/test/compile-fail/binary-op-on-double-ref.rs b/src/test/compile-fail/binary-op-on-double-ref.rs new file mode 100644 index 00000000000..a49cfaa1760 --- /dev/null +++ b/src/test/compile-fail/binary-op-on-double-ref.rs @@ -0,0 +1,20 @@ +// Copyright 2012-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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9]; + let vr = v.iter().filter(|x| { + x % 2 == 0 + //~^ ERROR binary operation `%` cannot be applied to type `&&{integer}` + //~| NOTE this is a reference of type that `%` can be applied to + //~| NOTE an implementation of `std::ops::Rem` might be missing for `&&{integer}` + }); + println!("{:?}", vr); +} diff --git a/src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue.rs b/src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue.rs index e4eca7e7ece..f58eca7c8ae 100644 --- a/src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue.rs +++ b/src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue.rs @@ -17,7 +17,6 @@ use std::collections::HashMap; fn main() { let tmp: Box<_>; let mut buggy_map: HashMap<usize, &usize> = HashMap::new(); - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough // but it is ok if we use a temporary diff --git a/src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs b/src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs index 530822f6c5b..d09cb73d670 100644 --- a/src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs +++ b/src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs @@ -35,7 +35,7 @@ fn copy_after_move() { let _x = a.x; //~^ value moved here let _y = a.y; //~ ERROR use of moved - //~^ move occurs because `a.x` has type `Box<isize>` + //~^ move occurs because `a.x` has type `std::boxed::Box<isize>` //~| value used here after move } @@ -44,7 +44,7 @@ fn move_after_move() { let _x = a.x; //~^ value moved here let _y = a.y; //~ ERROR use of moved - //~^ move occurs because `a.x` has type `Box<isize>` + //~^ move occurs because `a.x` has type `std::boxed::Box<isize>` //~| value used here after move } @@ -53,7 +53,7 @@ fn borrow_after_move() { let _x = a.x; //~^ value moved here let _y = &a.y; //~ ERROR use of moved - //~^ move occurs because `a.x` has type `Box<isize>` + //~^ move occurs because `a.x` has type `std::boxed::Box<isize>` //~| value used here after move } @@ -106,7 +106,7 @@ fn copy_after_move_nested() { let _x = a.x.x; //~^ value moved here let _y = a.y; //~ ERROR use of collaterally moved - //~^ NOTE move occurs because `a.x.x` has type `Box<isize>` + //~^ NOTE move occurs because `a.x.x` has type `std::boxed::Box<isize>` //~| value used here after move } @@ -115,7 +115,7 @@ fn move_after_move_nested() { let _x = a.x.x; //~^ value moved here let _y = a.y; //~ ERROR use of collaterally moved - //~^ NOTE move occurs because `a.x.x` has type `Box<isize>` + //~^ NOTE move occurs because `a.x.x` has type `std::boxed::Box<isize>` //~| value used here after move } @@ -124,7 +124,7 @@ fn borrow_after_move_nested() { let _x = a.x.x; //~^ value moved here let _y = &a.y; //~ ERROR use of collaterally moved - //~^ NOTE move occurs because `a.x.x` has type `Box<isize>` + //~^ NOTE move occurs because `a.x.x` has type `std::boxed::Box<isize>` //~| value used here after move } diff --git a/src/test/compile-fail/can-begin-expr-check.rs b/src/test/compile-fail/can-begin-expr-check.rs new file mode 100644 index 00000000000..68f219c6ed9 --- /dev/null +++ b/src/test/compile-fail/can-begin-expr-check.rs @@ -0,0 +1,30 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + + return; + return (); + return as (); + return return as (); + return return return; + + return if true { + () + } else { + () + }; + + loop { + return break as (); + } + + return enum; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `enum` +} diff --git a/src/test/compile-fail/coherence-impls-copy.rs b/src/test/compile-fail/coherence-impls-copy.rs index f686a146042..fe121a3bc48 100644 --- a/src/test/compile-fail/coherence-impls-copy.rs +++ b/src/test/compile-fail/coherence-impls-copy.rs @@ -37,6 +37,7 @@ impl Copy for (MyType, MyType) {} //~| ERROR only traits defined in the current crate can be implemented for arbitrary types //~| NOTE impl doesn't use types inside crate //~| NOTE the impl does not reference any types defined in this crate +//~| NOTE define and implement a trait or new type instead impl Copy for &'static NotSync {} //~^ ERROR the trait `Copy` may not be implemented for this type @@ -46,8 +47,9 @@ impl Copy for [MyType] {} //~^ ERROR the trait `Copy` may not be implemented for this type //~| NOTE type is not a structure or enumeration //~| ERROR only traits defined in the current crate can be implemented for arbitrary types -//~| NOTE impl doesn't use types inside crate //~| NOTE the impl does not reference any types defined in this crate +//~| NOTE define and implement a trait or new type instead +//~| NOTE impl doesn't use types inside crate impl Copy for &'static [NotSync] {} //~^ ERROR the trait `Copy` may not be implemented for this type @@ -55,6 +57,7 @@ impl Copy for &'static [NotSync] {} //~| ERROR only traits defined in the current crate can be implemented for arbitrary types //~| NOTE impl doesn't use types inside crate //~| NOTE the impl does not reference any types defined in this crate +//~| NOTE define and implement a trait or new type instead fn main() { } diff --git a/src/test/compile-fail/cross-borrow-trait.rs b/src/test/compile-fail/cross-borrow-trait.rs index 672ff464718..e5afccb9cf3 100644 --- a/src/test/compile-fail/cross-borrow-trait.rs +++ b/src/test/compile-fail/cross-borrow-trait.rs @@ -16,10 +16,8 @@ trait Trait { fn foo(&self) {} } impl Trait for Foo {} pub fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let x: Box<Trait> = Box::new(Foo); let _y: &Trait = x; //~ ERROR mismatched types //~| expected type `&Trait` - //~| found type `Box<Trait>` - //~| expected &Trait, found box + //~| found type `std::boxed::Box<Trait>` } diff --git a/src/test/compile-fail/destructure-trait-ref.rs b/src/test/compile-fail/destructure-trait-ref.rs index 89fb1e10590..835ec8e4a5e 100644 --- a/src/test/compile-fail/destructure-trait-ref.rs +++ b/src/test/compile-fail/destructure-trait-ref.rs @@ -51,6 +51,5 @@ fn main() { let box box x = box 1isize as Box<T>; //~^ ERROR mismatched types //~| expected type `T` - //~| found type `Box<_>` - //~| expected trait T, found box + //~| found type `std::boxed::Box<_>` } diff --git a/src/test/compile-fail/dst-bad-assign-2.rs b/src/test/compile-fail/dst-bad-assign-2.rs index 241fabf053c..10c8f1eed00 100644 --- a/src/test/compile-fail/dst-bad-assign-2.rs +++ b/src/test/compile-fail/dst-bad-assign-2.rs @@ -41,7 +41,6 @@ impl ToBar for Bar1 { pub fn main() { // Assignment. let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let z: Box<ToBar> = Box::new(Bar1 {f: 36}); f5.ptr = *z; //~^ ERROR `ToBar: std::marker::Sized` is not satisfied diff --git a/src/test/compile-fail/dst-bad-assign.rs b/src/test/compile-fail/dst-bad-assign.rs index 9e71ad24177..4f7d07600ad 100644 --- a/src/test/compile-fail/dst-bad-assign.rs +++ b/src/test/compile-fail/dst-bad-assign.rs @@ -41,7 +41,6 @@ impl ToBar for Bar1 { pub fn main() { // Assignment. let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let z: Box<ToBar> = Box::new(Bar1 {f: 36}); f5.ptr = Bar1 {f: 36}; //~^ ERROR mismatched types diff --git a/src/test/compile-fail/fn-trait-formatting.rs b/src/test/compile-fail/fn-trait-formatting.rs index e01a0412cef..6377550d3d2 100644 --- a/src/test/compile-fail/fn-trait-formatting.rs +++ b/src/test/compile-fail/fn-trait-formatting.rs @@ -16,18 +16,15 @@ fn main() { let _: () = (box |_: isize| {}) as Box<FnOnce(isize)>; //~^ ERROR mismatched types //~| expected type `()` - //~| found type `Box<std::ops::FnOnce(isize)>` - //~| expected (), found box + //~| found type `std::boxed::Box<std::ops::FnOnce(isize)>` let _: () = (box |_: isize, isize| {}) as Box<Fn(isize, isize)>; //~^ ERROR mismatched types //~| expected type `()` - //~| found type `Box<std::ops::Fn(isize, isize)>` - //~| expected (), found box + //~| found type `std::boxed::Box<std::ops::Fn(isize, isize)>` let _: () = (box || -> isize { unimplemented!() }) as Box<FnMut() -> isize>; //~^ ERROR mismatched types //~| expected type `()` - //~| found type `Box<std::ops::FnMut() -> isize>` - //~| expected (), found box + //~| found type `std::boxed::Box<std::ops::FnMut() -> isize>` needs_fn(1); //~^ ERROR : std::ops::Fn<(isize,)>` diff --git a/src/test/compile-fail/generic-non-trailing-defaults.rs b/src/test/compile-fail/generic-non-trailing-defaults.rs new file mode 100644 index 00000000000..77e55203263 --- /dev/null +++ b/src/test/compile-fail/generic-non-trailing-defaults.rs @@ -0,0 +1,20 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Heap; + +struct Vec<A = Heap, T>; +//~^ ERROR type parameters with a default must be trailing + +struct Foo<A, B = Vec<C>, C>; +//~^ ERROR type parameters with a default must be trailing +//~| ERROR type parameters with a default cannot use forward declared identifiers + +fn main() {} diff --git a/src/test/compile-fail/impl-trait/disallowed.rs b/src/test/compile-fail/impl-trait/disallowed.rs index 09aba5d8c91..0467c49b031 100644 --- a/src/test/compile-fail/impl-trait/disallowed.rs +++ b/src/test/compile-fail/impl-trait/disallowed.rs @@ -26,9 +26,9 @@ trait LazyToString { //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types } -// Note that the following impl doesn't error, because the trait is invalid. impl LazyToString for String { fn lazy_to_string<'a>(&'a self) -> impl Fn() -> String { + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types || self.clone() } } diff --git a/src/test/compile-fail/impl-trait/no-trait.rs b/src/test/compile-fail/impl-trait/no-trait.rs new file mode 100644 index 00000000000..ce61c5bf63d --- /dev/null +++ b/src/test/compile-fail/impl-trait/no-trait.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(conservative_impl_trait)] + +fn f() -> impl 'static {} //~ ERROR at least one trait must be specified + +fn main() {} diff --git a/src/test/compile-fail/issue-10291.rs b/src/test/compile-fail/issue-10291.rs index 43255db2ff3..d4e7dc7e9a3 100644 --- a/src/test/compile-fail/issue-10291.rs +++ b/src/test/compile-fail/issue-10291.rs @@ -9,7 +9,6 @@ // except according to those terms. fn test<'x>(x: &'x isize) { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { x //~ ERROR E0312 })); diff --git a/src/test/compile-fail/issue-11515.rs b/src/test/compile-fail/issue-11515.rs index f682d618ab6..7afb8314ea6 100644 --- a/src/test/compile-fail/issue-11515.rs +++ b/src/test/compile-fail/issue-11515.rs @@ -15,7 +15,6 @@ struct Test { } fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let closure: Box<Fn()+'static> = Box::new(|| ()); let test = box Test { func: closure }; //~ ERROR mismatched types } diff --git a/src/test/compile-fail/issue-13058.rs b/src/test/compile-fail/issue-13058.rs index de578257e46..408c6d411de 100644 --- a/src/test/compile-fail/issue-13058.rs +++ b/src/test/compile-fail/issue-13058.rs @@ -20,7 +20,6 @@ impl<'r> Itble<'r, usize, Range<usize>> for (usize, usize) { } fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool -//~^ HELP as shown: fn check<'r, I: Iterator<Item = usize>, T: Itble<'r, usize, I>>(cont: &'r T) { let cont_iter = cont.iter(); //~^ ERROR cannot infer an appropriate lifetime for autoref due to conflicting requirements diff --git a/src/test/compile-fail/issue-14915.rs b/src/test/compile-fail/issue-14915.rs index 18e4ccc3311..810d6656a8f 100644 --- a/src/test/compile-fail/issue-14915.rs +++ b/src/test/compile-fail/issue-14915.rs @@ -13,5 +13,6 @@ fn main() { let x: Box<isize> = box 0; - println!("{}", x + 1); //~ ERROR binary operation `+` cannot be applied to type `Box<isize>` + println!("{}", x + 1); + //~^ ERROR binary operation `+` cannot be applied to type `std::boxed::Box<isize>` } diff --git a/src/test/compile-fail/issue-17441.rs b/src/test/compile-fail/issue-17441.rs index 7d300bfb148..bddc9c13815 100644 --- a/src/test/compile-fail/issue-17441.rs +++ b/src/test/compile-fail/issue-17441.rs @@ -13,9 +13,8 @@ fn main() { //~^ ERROR cast to unsized type: `&[usize; 2]` as `[usize]` //~^^ HELP consider using an implicit coercion to `&[usize]` instead - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let _bar = Box::new(1_usize) as std::fmt::Debug; - //~^ ERROR cast to unsized type: `Box<usize>` as `std::fmt::Debug` + //~^ ERROR cast to unsized type: `std::boxed::Box<usize>` as `std::fmt::Debug` //~^^ HELP try casting to a `Box` instead let _baz = 1_usize as std::fmt::Debug; diff --git a/src/test/compile-fail/issue-17651.rs b/src/test/compile-fail/issue-17651.rs index 3ea136aca4b..4996da057dd 100644 --- a/src/test/compile-fail/issue-17651.rs +++ b/src/test/compile-fail/issue-17651.rs @@ -12,7 +12,6 @@ // and rejected. fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. (|| Box::new(*(&[0][..])))(); //~^ ERROR `[{integer}]: std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/issue-18783.rs b/src/test/compile-fail/issue-18783.rs index 5eb3c439df2..9a7b3781f1e 100644 --- a/src/test/compile-fail/issue-18783.rs +++ b/src/test/compile-fail/issue-18783.rs @@ -10,8 +10,6 @@ use std::cell::RefCell; -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - fn main() { let mut y = 1; let c = RefCell::new(vec![]); diff --git a/src/test/compile-fail/issue-20616-1.rs b/src/test/compile-fail/issue-20616-1.rs index 5b4f9942d28..a1949df661a 100644 --- a/src/test/compile-fail/issue-20616-1.rs +++ b/src/test/compile-fail/issue-20616-1.rs @@ -16,7 +16,7 @@ type Type_1_<'a, T> = &'a T; -type Type_1<'a T> = &'a T; //~ error: expected `,` or `>` after lifetime name, found `T` +type Type_1<'a T> = &'a T; //~ error: expected one of `,`, `:`, or `>`, found `T` //type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` diff --git a/src/test/compile-fail/issue-20616-2.rs b/src/test/compile-fail/issue-20616-2.rs index 65305ff3ac8..87b836d6872 100644 --- a/src/test/compile-fail/issue-20616-2.rs +++ b/src/test/compile-fail/issue-20616-2.rs @@ -19,7 +19,7 @@ type Type_1_<'a, T> = &'a T; //type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` -type Type_2 = Type_1_<'static ()>; //~ error: expected `,` or `>` after lifetime name, found `(` +type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,` or `>`, found `(` //type Type_3<T> = Box<T,,>; // error: expected type, found `,` diff --git a/src/test/compile-fail/issue-20616-3.rs b/src/test/compile-fail/issue-20616-3.rs index 101f81019d9..e5ed46d2cb3 100644 --- a/src/test/compile-fail/issue-20616-3.rs +++ b/src/test/compile-fail/issue-20616-3.rs @@ -22,7 +22,7 @@ type Type_1_<'a, T> = &'a T; //type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` -type Type_3<T> = Box<T,,>; //~ error: expected type, found `,` +type Type_3<T> = Box<T,,>; //~ error: expected one of `>`, identifier, lifetime, or type, found `,` //type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,` diff --git a/src/test/compile-fail/issue-20616-4.rs b/src/test/compile-fail/issue-20616-4.rs index 6450e9ed68c..9b731289e13 100644 --- a/src/test/compile-fail/issue-20616-4.rs +++ b/src/test/compile-fail/issue-20616-4.rs @@ -25,7 +25,8 @@ type Type_1_<'a, T> = &'a T; //type Type_3<T> = Box<T,,>; // error: expected type, found `,` -type Type_4<T> = Type_1_<'static,, T>; //~ error: expected type, found `,` +type Type_4<T> = Type_1_<'static,, T>; +//~^ error: expected one of `>`, identifier, lifetime, or type, found `,` type Type_5_<'a> = Type_1_<'a, ()>; diff --git a/src/test/compile-fail/issue-20616-5.rs b/src/test/compile-fail/issue-20616-5.rs index d1840427ad8..5e3b024da9a 100644 --- a/src/test/compile-fail/issue-20616-5.rs +++ b/src/test/compile-fail/issue-20616-5.rs @@ -31,7 +31,8 @@ type Type_1_<'a, T> = &'a T; type Type_5_<'a> = Type_1_<'a, ()>; -type Type_5<'a> = Type_1_<'a, (),,>; //~ error: expected type, found `,` +type Type_5<'a> = Type_1_<'a, (),,>; +//~^ error: expected one of `>`, identifier, lifetime, or type, found `,` //type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` diff --git a/src/test/compile-fail/issue-20616-6.rs b/src/test/compile-fail/issue-20616-6.rs index b0b5bc653f6..b6ee26f9f62 100644 --- a/src/test/compile-fail/issue-20616-6.rs +++ b/src/test/compile-fail/issue-20616-6.rs @@ -34,7 +34,8 @@ type Type_5_<'a> = Type_1_<'a, ()>; //type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` -type Type_6 = Type_5_<'a,,>; //~ error: expected type, found `,` +type Type_6 = Type_5_<'a,,>; +//~^ error: expected one of `>`, identifier, lifetime, or type, found `,` //type Type_7 = Box<(),,>; // error: expected type, found `,` diff --git a/src/test/compile-fail/issue-20616-7.rs b/src/test/compile-fail/issue-20616-7.rs index 0958f8b4ed2..fef3dd4e31d 100644 --- a/src/test/compile-fail/issue-20616-7.rs +++ b/src/test/compile-fail/issue-20616-7.rs @@ -37,7 +37,7 @@ type Type_5_<'a> = Type_1_<'a, ()>; //type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` -type Type_7 = Box<(),,>; //~ error: expected type, found `,` +type Type_7 = Box<(),,>; //~ error: expected one of `>`, identifier, lifetime, or type, found `,` //type Type_8<'a,,> = &'a (); // error: expected ident, found `,` diff --git a/src/test/compile-fail/issue-20616-8.rs b/src/test/compile-fail/issue-20616-8.rs index d6cf9acae9b..b7bef47c4f4 100644 --- a/src/test/compile-fail/issue-20616-8.rs +++ b/src/test/compile-fail/issue-20616-8.rs @@ -40,7 +40,7 @@ type Type_5_<'a> = Type_1_<'a, ()>; //type Type_7 = Box<(),,>; // error: expected type, found `,` -type Type_8<'a,,> = &'a (); //~ error: expected identifier, found `,` +type Type_8<'a,,> = &'a (); //~ error: expected one of `>`, identifier, or lifetime, found `,` //type Type_9<T,,> = Box<T>; // error: expected identifier, found `,` diff --git a/src/test/compile-fail/issue-20616-9.rs b/src/test/compile-fail/issue-20616-9.rs index d64cec446ef..5c16d24cef8 100644 --- a/src/test/compile-fail/issue-20616-9.rs +++ b/src/test/compile-fail/issue-20616-9.rs @@ -43,4 +43,4 @@ type Type_5_<'a> = Type_1_<'a, ()>; //type Type_8<'a,,> = &'a (); // error: expected identifier, found `,` -type Type_9<T,,> = Box<T>; //~ error: expected identifier, found `,` +type Type_9<T,,> = Box<T>; //~ error: expected one of `>`, identifier, or lifetime, found `,` diff --git a/src/test/compile-fail/issue-3763.rs b/src/test/compile-fail/issue-3763.rs index 085b4e76afb..851f5dfeabe 100644 --- a/src/test/compile-fail/issue-3763.rs +++ b/src/test/compile-fail/issue-3763.rs @@ -25,13 +25,11 @@ fn main() { let _woohoo = (&my_struct).priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let _woohoo = (Box::new(my_struct)).priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private (&my_struct).happyfun(); //~ ERROR method `happyfun` is private - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. (Box::new(my_struct)).happyfun(); //~ ERROR method `happyfun` is private let nope = my_struct.priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private diff --git a/src/test/compile-fail/issue-38412.rs b/src/test/compile-fail/issue-38412.rs index 00305eb2bc0..3b62aaf2ab8 100644 --- a/src/test/compile-fail/issue-38412.rs +++ b/src/test/compile-fail/issue-38412.rs @@ -10,7 +10,8 @@ fn main() { let Box(a) = loop { }; - //~^ ERROR field `0` of struct `std::boxed::Box` is private + //~^ ERROR expected tuple struct/variant, found struct `Box` + //~| ERROR expected tuple struct/variant, found struct `Box` // (The below is a trick to allow compiler to infer a type for // variable `a` without attempting to ascribe a type to the diff --git a/src/test/compile-fail/issue-4335.rs b/src/test/compile-fail/issue-4335.rs index 51f5fc5ee98..c5aae894c3e 100644 --- a/src/test/compile-fail/issue-4335.rs +++ b/src/test/compile-fail/issue-4335.rs @@ -13,7 +13,6 @@ fn id<T>(t: T) -> T { t } fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. id(Box::new(|| *v)) //~^ ERROR E0373 //~| NOTE `v` is borrowed here diff --git a/src/test/compile-fail/issue-5100.rs b/src/test/compile-fail/issue-5100.rs index a1f5d74b30e..9ef780aac8e 100644 --- a/src/test/compile-fail/issue-5100.rs +++ b/src/test/compile-fail/issue-5100.rs @@ -43,8 +43,7 @@ fn main() { box (true, false) => () //~^ ERROR mismatched types //~| expected type `(bool, bool)` -//~| found type `Box<_>` -//~| expected tuple, found box +//~| found type `std::boxed::Box<_>` } match (true, false) { diff --git a/src/test/compile-fail/issue-7061.rs b/src/test/compile-fail/issue-7061.rs index da6f49f3efe..b99f5b707ee 100644 --- a/src/test/compile-fail/issue-7061.rs +++ b/src/test/compile-fail/issue-7061.rs @@ -13,9 +13,8 @@ struct BarStruct; impl<'a> BarStruct { fn foo(&'a mut self) -> Box<BarStruct> { self } //~^ ERROR mismatched types - //~| expected type `Box<BarStruct>` + //~| expected type `std::boxed::Box<BarStruct>` //~| found type `&'a mut BarStruct` - //~| expected box, found mutable reference } fn main() {} diff --git a/src/test/compile-fail/kindck-impl-type-params-2.rs b/src/test/compile-fail/kindck-impl-type-params-2.rs index a455a7b2d5d..21aefc4f9c1 100644 --- a/src/test/compile-fail/kindck-impl-type-params-2.rs +++ b/src/test/compile-fail/kindck-impl-type-params-2.rs @@ -21,5 +21,5 @@ fn take_param<T:Foo>(foo: &T) { } fn main() { let x: Box<_> = box 3; take_param(&x); - //~^ ERROR `Box<{integer}>: std::marker::Copy` is not satisfied + //~^ ERROR `std::boxed::Box<{integer}>: std::marker::Copy` is not satisfied } diff --git a/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs b/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs index 7355c70ff95..43371eb6340 100644 --- a/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs +++ b/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs @@ -38,4 +38,28 @@ fn i(_x: isize) -> &isize { //~ ERROR missing lifetime specifier panic!() } +// Cases which used to work but now don't. + +type StaticStr = &'static str; // hides 'static +trait WithLifetime<'a> { + type Output; // can hide 'a +} + +// This worked because the type of the first argument contains +// 'static, although StaticStr doesn't even have parameters. +fn j(_x: StaticStr) -> &isize { //~ ERROR missing lifetime specifier +//~^ HELP this function's return type contains a borrowed value +//~| HELP consider giving it an explicit bounded or 'static lifetime + panic!() +} + +// This worked because the compiler resolved the argument type +// to <T as WithLifetime<'a>>::Output which has the hidden 'a. +fn k<'a, T: WithLifetime<'a>>(_x: T::Output) -> &isize { +//~^ ERROR missing lifetime specifier +//~| HELP this function's return type contains a borrowed value +//~| HELP consider giving it an explicit bounded or 'static lifetime + panic!() +} + fn main() {} diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs deleted file mode 100644 index d2d0dbf3e98..00000000000 --- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs +++ /dev/null @@ -1,36 +0,0 @@ -// 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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -use std::ops::Range; - -trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; } - -impl<'r> Itble<'r, usize, Range<usize>> for (usize, usize) { - fn iter(&'r self) -> Range<usize> { - let &(min, max) = self; - min..max - } -} - -fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool { -//~^ HELP: consider using an explicit lifetime parameter as shown: fn check<'r, I: Iterator<Item = usize>, T: Itble<'r, usize, I>>(cont: &'r T) - let cont_iter = cont.iter(); //~ ERROR: cannot infer - let result = cont_iter.fold(Some(0), |state, val| { - state.map_or(None, |mask| { - let bit = 1 << val; - if mask & bit == 0 {Some(mask|bit)} else {None} - }) - }); - result.is_some() -} - -fn main() {} diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs deleted file mode 100644 index 6b22d434804..00000000000 --- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs +++ /dev/null @@ -1,32 +0,0 @@ -// 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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -use std::marker::PhantomData; - -struct Bar<'x, 'y, 'z> { bar: &'y i32, baz: i32, marker: PhantomData<(&'x(),&'y(),&'z())> } -fn bar1<'a>(x: &Bar) -> (&'a i32, &'a i32, &'a i32) { - //~^ HELP consider using an explicit lifetime parameter as shown: fn bar1<'b, 'c, 'a>(x: &'a Bar<'b, 'a, 'c>) -> (&'a i32, &'a i32, &'a i32) - (x.bar, &x.baz, &x.baz) - //~^ ERROR E0312 - //~| ERROR cannot infer - //~| ERROR cannot infer -} - -fn bar2<'a, 'b, 'c>(x: &Bar<'a, 'b, 'c>) -> (&'a i32, &'a i32, &'a i32) { - //~^ HELP: consider using an explicit lifetime parameter as shown: fn bar2<'a, 'c>(x: &'a Bar<'a, 'a, 'c>) -> (&'a i32, &'a i32, &'a i32) - (x.bar, &x.baz, &x.baz) - //~^ ERROR E0312 - //~| ERROR cannot infer - //~| ERROR cannot infer -} - -fn main() { } diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs deleted file mode 100644 index 4323929e2e3..00000000000 --- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs +++ /dev/null @@ -1,57 +0,0 @@ -// 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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -use std::marker::PhantomData; - -struct Foo<'x> { bar: isize, marker: PhantomData<&'x ()> } -fn foo1<'a>(x: &Foo) -> &'a isize { -//~^ HELP: consider using an explicit lifetime parameter as shown: fn foo1<'a>(x: &'a Foo) -> &'a isize - &x.bar //~ ERROR: cannot infer -} - -fn foo2<'a, 'b>(x: &'a Foo) -> &'b isize { -//~^ HELP: consider using an explicit lifetime parameter as shown: fn foo2<'a>(x: &'a Foo) -> &'a isize - &x.bar //~ ERROR: cannot infer -} - -fn foo3<'a>(x: &Foo) -> (&'a isize, &'a isize) { -//~^ HELP: consider using an explicit lifetime parameter as shown: fn foo3<'a>(x: &'a Foo) -> (&'a isize, &'a isize) - (&x.bar, &x.bar) //~ ERROR: cannot infer - //~^ ERROR: cannot infer -} - -fn foo4<'a, 'b>(x: &'a Foo) -> (&'b isize, &'a isize, &'b isize) { -//~^ HELP: consider using an explicit lifetime parameter as shown: fn foo4<'a>(x: &'a Foo) -> (&'a isize, &'a isize, &'a isize) - (&x.bar, &x.bar, &x.bar) //~ ERROR: cannot infer - //~^ ERROR: cannot infer -} - -struct Cat<'x, T> { cat: &'x isize, t: T } -struct Dog<'y> { dog: &'y isize } - -fn cat2<'x, 'y>(x: Cat<'x, Dog<'y>>) -> &'x isize { - //~^ HELP consider using an explicit lifetime parameter as shown: fn cat2<'x>(x: Cat<'x, Dog<'x>>) -> &'x isize - x.t.dog //~ ERROR E0312 -} - -struct Baz<'x> { - bar: &'x isize -} - -impl<'a> Baz<'a> { - fn baz2<'b>(&self, x: &isize) -> (&'b isize, &'b isize) { - (self.bar, x) //~ ERROR E0312 - //~^ ERROR E0312 - } -} - -fn main() {} diff --git a/src/test/compile-fail/lint-ctypes.rs b/src/test/compile-fail/lint-ctypes.rs index 731c1edbfc0..ccc25b58228 100644 --- a/src/test/compile-fail/lint-ctypes.rs +++ b/src/test/compile-fail/lint-ctypes.rs @@ -34,7 +34,7 @@ extern { pub fn ptr_type2(size: *const Foo); //~ ERROR: found struct without pub fn slice_type(p: &[u32]); //~ ERROR: found Rust slice type pub fn str_type(p: &str); //~ ERROR: found Rust type - pub fn box_type(p: Box<u32>); //~ ERROR found Rust type + pub fn box_type(p: Box<u32>); //~ ERROR found struct without pub fn char_type(p: char); //~ ERROR found Rust type pub fn trait_type(p: &Clone); //~ ERROR found Rust trait type pub fn tuple_type(p: (i32, i32)); //~ ERROR found Rust tuple type @@ -42,7 +42,7 @@ extern { pub fn zero_size(p: ZeroSize); //~ ERROR found zero-size struct pub fn fn_type(p: RustFn); //~ ERROR found function pointer with Rust pub fn fn_type2(p: fn()); //~ ERROR found function pointer with Rust - pub fn fn_contained(p: RustBadRet); //~ ERROR: found Rust type + pub fn fn_contained(p: RustBadRet); //~ ERROR: found struct without pub fn good1(size: *const libc::c_int); pub fn good2(size: *const libc::c_uint); diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index e24441c5497..9dcf902a69f 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -24,7 +24,6 @@ impl<K, V> Map<K, V> for HashMap<K, V> {} fn main() { let x: Box<HashMap<isize, isize>> = box HashMap::new(); let x: Box<Map<isize, isize>> = x; - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let y: Box<Map<usize, isize>> = Box::new(x); - //~^ ERROR `Box<Map<isize, isize>>: Map<usize, isize>` is not satisfied + //~^ ERROR `std::boxed::Box<Map<isize, isize>>: Map<usize, isize>` is not satisfied } diff --git a/src/test/compile-fail/missing-block-hint.rs b/src/test/compile-fail/missing-block-hint.rs index 1f29ff4e05c..6a140e6f21c 100644 --- a/src/test/compile-fail/missing-block-hint.rs +++ b/src/test/compile-fail/missing-block-hint.rs @@ -15,6 +15,7 @@ fn main() { { if (foo) bar; //~ ERROR expected `{`, found `bar` - //^ HELP try placing this code inside a block + //~^ HELP try placing this code inside a block + //~| SUGGESTION { bar; } } } diff --git a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs index df9a3519d5d..d5296065999 100644 --- a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs @@ -38,7 +38,6 @@ fn innocent_looking_victim() { } fn conspirator<F>(mut f: F) where F: FnMut(&mut R, bool) { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let mut r = R {c: Box::new(f)}; f(&mut r, false) //~ ERROR use of moved value } diff --git a/src/test/compile-fail/object-does-not-impl-trait.rs b/src/test/compile-fail/object-does-not-impl-trait.rs index 6fa261dea71..8babc734c84 100644 --- a/src/test/compile-fail/object-does-not-impl-trait.rs +++ b/src/test/compile-fail/object-does-not-impl-trait.rs @@ -14,5 +14,5 @@ trait Foo {} fn take_foo<F:Foo>(f: F) {} fn take_object(f: Box<Foo>) { take_foo(f); } -//~^ ERROR `Box<Foo>: Foo` is not satisfied +//~^ ERROR `std::boxed::Box<Foo>: Foo` is not satisfied fn main() {} diff --git a/src/test/compile-fail/occurs-check-2.rs b/src/test/compile-fail/occurs-check-2.rs index 5cb60079fa4..a276af83dee 100644 --- a/src/test/compile-fail/occurs-check-2.rs +++ b/src/test/compile-fail/occurs-check-2.rs @@ -17,6 +17,6 @@ fn main() { f = box g; //~^ ERROR mismatched types //~| expected type `_` - //~| found type `Box<_>` + //~| found type `std::boxed::Box<_>` //~| cyclic type of infinite size } diff --git a/src/test/compile-fail/occurs-check.rs b/src/test/compile-fail/occurs-check.rs index 499124cb057..5b6a11e58c2 100644 --- a/src/test/compile-fail/occurs-check.rs +++ b/src/test/compile-fail/occurs-check.rs @@ -15,6 +15,6 @@ fn main() { f = box f; //~^ ERROR mismatched types //~| expected type `_` - //~| found type `Box<_>` + //~| found type `std::boxed::Box<_>` //~| cyclic type of infinite size } diff --git a/src/test/compile-fail/struct-path-self-feature-gate.rs b/src/test/compile-fail/privacy/legacy-ctor-visibility.rs index c40d0574955..fb65af230ac 100644 --- a/src/test/compile-fail/struct-path-self-feature-gate.rs +++ b/src/test/compile-fail/privacy/legacy-ctor-visibility.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,23 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// gate-test-more_struct_aliases +#![allow(unused)] -struct S; +use m::S; -trait Tr { - type A; -} - -fn f<T: Tr<A = S>>() { - let _ = T::A {}; - //~^ ERROR `Self` and associated types in struct expressions and patterns are unstable -} +mod m { + pub struct S(u8); -impl S { - fn f() { - let _ = Self {}; - //~^ ERROR `Self` and associated types in struct expressions and patterns are unstable + mod n { + use S; + fn f() { + S(10); + //~^ ERROR private struct constructors are not usable through reexports in outer modules + //~| WARN this was previously accepted + } } } diff --git a/src/test/compile-fail/privacy5.rs b/src/test/compile-fail/privacy5.rs index 9d6ae187cd3..599c1f87160 100644 --- a/src/test/compile-fail/privacy5.rs +++ b/src/test/compile-fail/privacy5.rs @@ -58,30 +58,31 @@ mod a { } fn this_crate() { - let a = a::A(()); //~ ERROR: cannot invoke tuple struct constructor - let b = a::B(2); //~ ERROR: cannot invoke tuple struct constructor - let c = a::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor + let a = a::A(()); //~ ERROR tuple struct `A` is private + let b = a::B(2); //~ ERROR tuple struct `B` is private + let c = a::C(2, 3); //~ ERROR tuple struct `C` is private let d = a::D(4); - let a::A(()) = a; //~ ERROR: field `0` of struct `a::A` is private - let a::A(_) = a; - match a { a::A(()) => {} } //~ ERROR: field `0` of struct `a::A` is private - match a { a::A(_) => {} } - - let a::B(_) = b; - let a::B(_b) = b; //~ ERROR: field `0` of struct `a::B` is private - match b { a::B(_) => {} } - match b { a::B(_b) => {} } //~ ERROR: field `0` of struct `a::B` is private - match b { a::B(1) => {} a::B(_) => {} } //~ ERROR: field `0` of struct `a::B` is private - - let a::C(_, _) = c; - let a::C(_a, _) = c; - let a::C(_, _b) = c; //~ ERROR: field `1` of struct `a::C` is private - let a::C(_a, _b) = c; //~ ERROR: field `1` of struct `a::C` is private - match c { a::C(_, _) => {} } - match c { a::C(_a, _) => {} } - match c { a::C(_, _b) => {} } //~ ERROR: field `1` of struct `a::C` is private - match c { a::C(_a, _b) => {} } //~ ERROR: field `1` of struct `a::C` is private + let a::A(()) = a; //~ ERROR tuple struct `A` is private + let a::A(_) = a; //~ ERROR tuple struct `A` is private + match a { a::A(()) => {} } //~ ERROR tuple struct `A` is private + match a { a::A(_) => {} } //~ ERROR tuple struct `A` is private + + let a::B(_) = b; //~ ERROR tuple struct `B` is private + let a::B(_b) = b; //~ ERROR tuple struct `B` is private + match b { a::B(_) => {} } //~ ERROR tuple struct `B` is private + match b { a::B(_b) => {} } //~ ERROR tuple struct `B` is private + match b { a::B(1) => {} a::B(_) => {} } //~ ERROR tuple struct `B` is private + //~^ ERROR tuple struct `B` is private + + let a::C(_, _) = c; //~ ERROR tuple struct `C` is private + let a::C(_a, _) = c; //~ ERROR tuple struct `C` is private + let a::C(_, _b) = c; //~ ERROR tuple struct `C` is private + let a::C(_a, _b) = c; //~ ERROR tuple struct `C` is private + match c { a::C(_, _) => {} } //~ ERROR tuple struct `C` is private + match c { a::C(_a, _) => {} } //~ ERROR tuple struct `C` is private + match c { a::C(_, _b) => {} } //~ ERROR tuple struct `C` is private + match c { a::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private let a::D(_) = d; let a::D(_d) = d; @@ -89,42 +90,38 @@ fn this_crate() { match d { a::D(_d) => {} } match d { a::D(1) => {} a::D(_) => {} } - let a2 = a::A; //~ ERROR: cannot invoke tuple struct constructor - let b2 = a::B; //~ ERROR: cannot invoke tuple struct constructor - let c2 = a::C; //~ ERROR: cannot invoke tuple struct constructor + let a2 = a::A; //~ ERROR tuple struct `A` is private + let b2 = a::B; //~ ERROR tuple struct `B` is private + let c2 = a::C; //~ ERROR tuple struct `C` is private let d2 = a::D; } fn xcrate() { - let a = other::A(()); //~ ERROR: cannot invoke tuple struct constructor - let b = other::B(2); //~ ERROR: cannot invoke tuple struct constructor - let c = other::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor + let a = other::A(()); //~ ERROR tuple struct `A` is private + let b = other::B(2); //~ ERROR tuple struct `B` is private + let c = other::C(2, 3); //~ ERROR tuple struct `C` is private let d = other::D(4); - let other::A(()) = a; //~ ERROR: field `0` of struct `other::A` is private - let other::A(_) = a; - match a { other::A(()) => {} } - //~^ ERROR: field `0` of struct `other::A` is private - match a { other::A(_) => {} } - - let other::B(_) = b; - let other::B(_b) = b; //~ ERROR: field `0` of struct `other::B` is private - match b { other::B(_) => {} } - match b { other::B(_b) => {} } - //~^ ERROR: field `0` of struct `other::B` is private - match b { other::B(1) => {} other::B(_) => {} } - //~^ ERROR: field `0` of struct `other::B` is private - - let other::C(_, _) = c; - let other::C(_a, _) = c; - let other::C(_, _b) = c; //~ ERROR: field `1` of struct `other::C` is private - let other::C(_a, _b) = c; //~ ERROR: field `1` of struct `other::C` is private - match c { other::C(_, _) => {} } - match c { other::C(_a, _) => {} } - match c { other::C(_, _b) => {} } - //~^ ERROR: field `1` of struct `other::C` is private - match c { other::C(_a, _b) => {} } - //~^ ERROR: field `1` of struct `other::C` is private + let other::A(()) = a; //~ ERROR tuple struct `A` is private + let other::A(_) = a; //~ ERROR tuple struct `A` is private + match a { other::A(()) => {} } //~ ERROR tuple struct `A` is private + match a { other::A(_) => {} } //~ ERROR tuple struct `A` is private + + let other::B(_) = b; //~ ERROR tuple struct `B` is private + let other::B(_b) = b; //~ ERROR tuple struct `B` is private + match b { other::B(_) => {} } //~ ERROR tuple struct `B` is private + match b { other::B(_b) => {} } //~ ERROR tuple struct `B` is private + match b { other::B(1) => {} other::B(_) => {} } //~ ERROR tuple struct `B` is private + //~^ ERROR tuple struct `B` is private + + let other::C(_, _) = c; //~ ERROR tuple struct `C` is private + let other::C(_a, _) = c; //~ ERROR tuple struct `C` is private + let other::C(_, _b) = c; //~ ERROR tuple struct `C` is private + let other::C(_a, _b) = c; //~ ERROR tuple struct `C` is private + match c { other::C(_, _) => {} } //~ ERROR tuple struct `C` is private + match c { other::C(_a, _) => {} } //~ ERROR tuple struct `C` is private + match c { other::C(_, _b) => {} } //~ ERROR tuple struct `C` is private + match c { other::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private let other::D(_) = d; let other::D(_d) = d; @@ -132,9 +129,9 @@ fn xcrate() { match d { other::D(_d) => {} } match d { other::D(1) => {} other::D(_) => {} } - let a2 = other::A; //~ ERROR: cannot invoke tuple struct constructor - let b2 = other::B; //~ ERROR: cannot invoke tuple struct constructor - let c2 = other::C; //~ ERROR: cannot invoke tuple struct constructor + let a2 = other::A; //~ ERROR tuple struct `A` is private + let b2 = other::B; //~ ERROR tuple struct `B` is private + let c2 = other::C; //~ ERROR tuple struct `C` is private let d2 = other::D; } diff --git a/src/test/compile-fail/region-bounds-on-objects-and-type-parameters.rs b/src/test/compile-fail/region-bounds-on-objects-and-type-parameters.rs index b8cbbdbe9ec..503b577b1f1 100644 --- a/src/test/compile-fail/region-bounds-on-objects-and-type-parameters.rs +++ b/src/test/compile-fail/region-bounds-on-objects-and-type-parameters.rs @@ -18,7 +18,7 @@ trait SomeTrait { } // Bounds on object types: -struct Foo<'a,'b,'c> { +struct Foo<'a,'b,'c> { //~ ERROR parameter `'b` is never used // All of these are ok, because we can derive exactly one bound: a: Box<IsStatic>, b: Box<Is<'static>>, @@ -28,7 +28,9 @@ struct Foo<'a,'b,'c> { f: Box<SomeTrait>, // OK, defaults to 'static due to RFC 599. g: Box<SomeTrait+'a>, - z: Box<Is<'a>+'b+'c>, //~ ERROR only a single explicit lifetime bound is permitted + z: Box<Is<'a>+'b+'c>, + //~^ ERROR only a single explicit lifetime bound is permitted + //~| ERROR lifetime bound not satisfied } fn test< diff --git a/src/test/compile-fail/region-object-lifetime-in-coercion.rs b/src/test/compile-fail/region-object-lifetime-in-coercion.rs index f95ee405895..687b2c344a3 100644 --- a/src/test/compile-fail/region-object-lifetime-in-coercion.rs +++ b/src/test/compile-fail/region-object-lifetime-in-coercion.rs @@ -14,8 +14,6 @@ trait Foo {} impl<'a> Foo for &'a [u8] {} -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - fn a(v: &[u8]) -> Box<Foo + 'static> { let x: Box<Foo + 'static> = Box::new(v); //~^ ERROR cannot infer an appropriate lifetime due to conflicting diff --git a/src/test/compile-fail/regions-close-associated-type-into-object.rs b/src/test/compile-fail/regions-close-associated-type-into-object.rs index 61897aac187..6b88abfca6c 100644 --- a/src/test/compile-fail/regions-close-associated-type-into-object.rs +++ b/src/test/compile-fail/regions-close-associated-type-into-object.rs @@ -10,8 +10,6 @@ #![feature(box_syntax)] -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - trait X {} trait Iter { diff --git a/src/test/compile-fail/regions-close-param-into-object.rs b/src/test/compile-fail/regions-close-param-into-object.rs index 7324d4a4a0e..c9063405bd7 100644 --- a/src/test/compile-fail/regions-close-param-into-object.rs +++ b/src/test/compile-fail/regions-close-param-into-object.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - trait X { fn foo(&self) {} } fn p1<T>(v: T) -> Box<X+'static> diff --git a/src/test/compile-fail/regions-infer-paramd-indirect.rs b/src/test/compile-fail/regions-infer-paramd-indirect.rs index fad115c2aed..c559992c865 100644 --- a/src/test/compile-fail/regions-infer-paramd-indirect.rs +++ b/src/test/compile-fail/regions-infer-paramd-indirect.rs @@ -32,8 +32,8 @@ impl<'a> set_f<'a> for c<'a> { fn set_f_bad(&mut self, b: Box<b>) { self.f = b; //~^ ERROR mismatched types - //~| expected type `Box<Box<&'a isize>>` - //~| found type `Box<Box<&isize>>` + //~| expected type `std::boxed::Box<std::boxed::Box<&'a isize>>` + //~| found type `std::boxed::Box<std::boxed::Box<&isize>>` //~| lifetime mismatch } } diff --git a/src/test/compile-fail/regions-nested-fns.rs b/src/test/compile-fail/regions-nested-fns.rs index 5ef2a701a60..010b7d17688 100644 --- a/src/test/compile-fail/regions-nested-fns.rs +++ b/src/test/compile-fail/regions-nested-fns.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - fn ignore<T>(t: T) {} fn nested<'x>(x: &'x isize) { diff --git a/src/test/compile-fail/regions-proc-bound-capture.rs b/src/test/compile-fail/regions-proc-bound-capture.rs index 48b6e8b773f..fb726e31af5 100644 --- a/src/test/compile-fail/regions-proc-bound-capture.rs +++ b/src/test/compile-fail/regions-proc-bound-capture.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - fn borrowed_proc<'a>(x: &'a isize) -> Box<FnMut()->(isize) + 'a> { // This is legal, because the region bound on `proc` // states that it captures `x`. diff --git a/src/test/compile-fail/regions-steal-closure.rs b/src/test/compile-fail/regions-steal-closure.rs index 59fe1ce3af1..7ca63b9896f 100644 --- a/src/test/compile-fail/regions-steal-closure.rs +++ b/src/test/compile-fail/regions-steal-closure.rs @@ -21,7 +21,6 @@ fn box_it<'r>(x: Box<FnMut() + 'r>) -> closure_box<'r> { fn main() { let mut cl_box = { let mut i = 3; - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough }; cl_box.cl.call_mut(()); diff --git a/src/test/compile-fail/rfc1623.rs b/src/test/compile-fail/rfc1623.rs index 083cc218eec..93635e7fdde 100644 --- a/src/test/compile-fail/rfc1623.rs +++ b/src/test/compile-fail/rfc1623.rs @@ -15,8 +15,10 @@ fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 { } // the boundaries of elision -static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = &(non_elidable as fn(&u8, &u8) -> &u8); +static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = //~^ ERROR missing lifetime specifier [E0106] + &(non_elidable as fn(&u8, &u8) -> &u8); + //~^ ERROR missing lifetime specifier [E0106] struct SomeStruct<'x, 'y, 'z: 'x> { foo: &'x Foo<'z>, diff --git a/src/test/compile-fail/E0450.rs b/src/test/compile-fail/str-concat-on-double-ref.rs index 200b58a3293..f85422f76d4 100644 --- a/src/test/compile-fail/E0450.rs +++ b/src/test/compile-fail/str-concat-on-double-ref.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,14 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -mod Bar { - pub struct Foo( bool, pub i32, f32, bool); - //~^ NOTE private field declared here - //~| NOTE private field declared here - //~| NOTE private field declared here -} - fn main() { - let f = Bar::Foo(false,1,0.1, true); //~ ERROR E0450 - //~^ NOTE cannot construct with a private field + let a: &String = &"1".to_owned(); + let b: &str = &"2"; + let c = a + b; + //~^ ERROR binary operation `+` cannot be applied to type `&std::string::String` + //~| NOTE an implementation of `std::ops::Add` might be missing for `&std::string::String` + println!("{:?}", c); } diff --git a/src/test/compile-fail/struct-path-associated-type.rs b/src/test/compile-fail/struct-path-associated-type.rs index ecaf269fcb1..660ac44ce0b 100644 --- a/src/test/compile-fail/struct-path-associated-type.rs +++ b/src/test/compile-fail/struct-path-associated-type.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(more_struct_aliases)] - struct S; trait Tr { diff --git a/src/test/compile-fail/struct-path-self-type-mismatch.rs b/src/test/compile-fail/struct-path-self-type-mismatch.rs index 8352bd6751f..f694e7d277c 100644 --- a/src/test/compile-fail/struct-path-self-type-mismatch.rs +++ b/src/test/compile-fail/struct-path-self-type-mismatch.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(more_struct_aliases)] - struct Foo<A> { inner: A } trait Bar { fn bar(); } diff --git a/src/test/compile-fail/struct-path-self.rs b/src/test/compile-fail/struct-path-self.rs index aeac199227b..067d6ac22dc 100644 --- a/src/test/compile-fail/struct-path-self.rs +++ b/src/test/compile-fail/struct-path-self.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(more_struct_aliases)] - struct S; trait Tr { diff --git a/src/test/compile-fail/terr-sorts.rs b/src/test/compile-fail/terr-sorts.rs index 592d7b3929b..fd92a26d0fc 100644 --- a/src/test/compile-fail/terr-sorts.rs +++ b/src/test/compile-fail/terr-sorts.rs @@ -20,8 +20,7 @@ fn want_foo(f: foo) {} fn have_bar(b: bar) { want_foo(b); //~ ERROR mismatched types //~| expected type `foo` - //~| found type `Box<foo>` - //~| expected struct `foo`, found box + //~| found type `std::boxed::Box<foo>` } fn main() {} diff --git a/src/test/compile-fail/trait-coercion-generic-bad.rs b/src/test/compile-fail/trait-coercion-generic-bad.rs index dd64085f6f6..3839e90ed9f 100644 --- a/src/test/compile-fail/trait-coercion-generic-bad.rs +++ b/src/test/compile-fail/trait-coercion-generic-bad.rs @@ -23,7 +23,6 @@ impl Trait<&'static str> for Struct { } fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let s: Box<Trait<isize>> = Box::new(Struct { person: "Fred" }); //~^ ERROR `Struct: Trait<isize>` is not satisfied s.f(1); diff --git a/src/test/compile-fail/trait-coercion-generic-regions.rs b/src/test/compile-fail/trait-coercion-generic-regions.rs index 9ba017e150e..18d3ded77f8 100644 --- a/src/test/compile-fail/trait-coercion-generic-regions.rs +++ b/src/test/compile-fail/trait-coercion-generic-regions.rs @@ -25,6 +25,5 @@ impl Trait<&'static str> for Struct { fn main() { let person = "Fred".to_string(); let person: &str = &person; //~ ERROR `person` does not live long enough - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let s: Box<Trait<&'static str>> = Box::new(Struct { person: person }); } diff --git a/src/test/compile-fail/trivial_casts.rs b/src/test/compile-fail/trivial_casts.rs index 7693d98a2f7..aabf0d26d5b 100644 --- a/src/test/compile-fail/trivial_casts.rs +++ b/src/test/compile-fail/trivial_casts.rs @@ -52,7 +52,8 @@ pub fn main() { let _: *mut [u32] = x; let x: Box<[u32; 3]> = Box::new([42, 43, 44]); - let _ = x as Box<[u32]>; //~ERROR trivial cast: `Box<[u32; 3]>` as `Box<[u32]>` + let _ = x as Box<[u32]>; + //~^ ERROR trivial cast: `std::boxed::Box<[u32; 3]>` as `std::boxed::Box<[u32]>` let x: Box<[u32; 3]> = Box::new([42, 43, 44]); let _: Box<[u32]> = x; @@ -70,7 +71,7 @@ pub fn main() { let _: *mut Foo = x; let x: Box<Bar> = Box::new(Bar); - let _ = x as Box<Foo>; //~ERROR trivial cast: `Box<Bar>` as `Box<Foo>` + let _ = x as Box<Foo>; //~ERROR trivial cast: `std::boxed::Box<Bar>` as `std::boxed::Box<Foo>` let x: Box<Bar> = Box::new(Bar); let _: Box<Foo> = x; diff --git a/src/test/compile-fail/type-mismatch-same-crate-name.rs b/src/test/compile-fail/type-mismatch-same-crate-name.rs index e74acaa71b0..4295d08a470 100644 --- a/src/test/compile-fail/type-mismatch-same-crate-name.rs +++ b/src/test/compile-fail/type-mismatch-same-crate-name.rs @@ -33,7 +33,7 @@ fn main() { //~^ ERROR mismatched types //~| Perhaps two different versions of crate `crate_a1` //~| expected trait `main::a::Bar` - //~| expected type `Box<main::a::Bar + 'static>` - //~| found type `Box<main::a::Bar>` + //~| expected type `std::boxed::Box<main::a::Bar + 'static>` + //~| found type `std::boxed::Box<main::a::Bar>` } } diff --git a/src/test/compile-fail/unboxed-closure-illegal-move.rs b/src/test/compile-fail/unboxed-closure-illegal-move.rs index 564b1b4669f..427be560760 100644 --- a/src/test/compile-fail/unboxed-closure-illegal-move.rs +++ b/src/test/compile-fail/unboxed-closure-illegal-move.rs @@ -18,8 +18,6 @@ fn to_fn<A,F:Fn<A>>(f: F) -> F { f } fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f } fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f } -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - fn main() { // By-ref cases { diff --git a/src/test/compile-fail/unboxed-closure-sugar-region.rs b/src/test/compile-fail/unboxed-closure-sugar-region.rs index 057b496bd43..18a1185d695 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-region.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-region.rs @@ -38,9 +38,9 @@ fn test<'a,'b>() { } fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) { +//~^ ERROR wrong number of lifetime parameters: expected 1, found 0 // Here, the omitted lifetimes are expanded to distinct things. - same_type(x, y) //~ ERROR cannot infer - //~^ ERROR cannot infer + same_type(x, y) } fn main() { } diff --git a/src/test/compile-fail/uninhabited-matches-feature-gated.rs b/src/test/compile-fail/uninhabited-matches-feature-gated.rs new file mode 100644 index 00000000000..0f8b0a6c238 --- /dev/null +++ b/src/test/compile-fail/uninhabited-matches-feature-gated.rs @@ -0,0 +1,50 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(slice_patterns)] + +enum Void {} + +fn main() { + let x: Result<u32, &'static Void> = Ok(23); + let _ = match x { //~ ERROR non-exhaustive + Ok(n) => n, + }; + + let x: &Void = unsafe { std::mem::uninitialized() }; + let _ = match x {}; + //~^ ERROR non-exhaustive + + let x: (Void,) = unsafe { std::mem::uninitialized() }; + let _ = match x {}; + //~^ ERROR non-exhaustive + + let x: [Void; 1] = unsafe { std::mem::uninitialized() }; + let _ = match x {}; + //~^ ERROR non-exhaustive + + let x: &[Void] = unsafe { std::mem::uninitialized() }; + let _ = match x { //~ ERROR non-exhaustive + &[] => (), + }; + + let x: Void = unsafe { std::mem::uninitialized() }; + let _ = match x {}; // okay + + let x: Result<u32, Void> = Ok(23); + let _ = match x { //~ ERROR non-exhaustive + Ok(x) => x, + }; + + let x: Result<u32, Void> = Ok(23); + let Ok(x) = x; + //~^ ERROR refutable +} + diff --git a/src/test/compile-fail/unique-pinned-nocopy.rs b/src/test/compile-fail/unique-pinned-nocopy.rs index d971940db38..c09feec1d4a 100644 --- a/src/test/compile-fail/unique-pinned-nocopy.rs +++ b/src/test/compile-fail/unique-pinned-nocopy.rs @@ -18,7 +18,6 @@ impl Drop for r { } fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let i = Box::new(r { b: true }); let _j = i.clone(); //~ ERROR no method named `clone` found println!("{:?}", i); diff --git a/src/test/compile-fail/where-equality-constraints.rs b/src/test/compile-fail/where-equality-constraints.rs new file mode 100644 index 00000000000..e449a736c75 --- /dev/null +++ b/src/test/compile-fail/where-equality-constraints.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f() where u8 = u16 {} +//~^ ERROR equality constraints are not yet supported in where clauses +fn g() where for<'a> &'static (u8,) == u16, {} +//~^ ERROR equality constraints are not yet supported in where clauses + +fn main() {} diff --git a/src/test/compile-fail/where-lifetime-resolution.rs b/src/test/compile-fail/where-lifetime-resolution.rs new file mode 100644 index 00000000000..f4c6842206d --- /dev/null +++ b/src/test/compile-fail/where-lifetime-resolution.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Trait1 {} +trait Trait2 {} + +fn f() where + for<'a> Trait1<'a>: Trait1<'a>, // OK + (for<'a> Trait1<'a>): Trait1<'a>, + //~^ ERROR use of undeclared lifetime name `'a` + for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, + //~^ ERROR use of undeclared lifetime name `'b` + //~| ERROR nested quantification of lifetimes +{} + +fn main() {} diff --git a/src/test/debuginfo/type-names.rs b/src/test/debuginfo/type-names.rs index 438a78743bb..57d40cccf2d 100644 --- a/src/test/debuginfo/type-names.rs +++ b/src/test/debuginfo/type-names.rs @@ -70,12 +70,12 @@ // BOX // gdb-command:whatis box1 -// gdbg-check:type = struct (Box<f32>, i32) -// gdbr-check:type = (Box<f32>, i32) +// gdbg-check:type = struct (alloc::boxed::Box<f32>, i32) +// gdbr-check:type = (alloc::boxed::Box<f32>, i32) // gdb-command:whatis box2 -// gdbg-check:type = struct (Box<type_names::mod1::mod2::Enum3<f32>>, i32) -// gdbr-check:type = (Box<type_names::mod1::mod2::Enum3<f32>>, i32) +// gdbg-check:type = struct (alloc::boxed::Box<type_names::mod1::mod2::Enum3<f32>>, i32) +// gdbr-check:type = (alloc::boxed::Box<type_names::mod1::mod2::Enum3<f32>>, i32) // REFERENCES @@ -196,8 +196,8 @@ // gdbr-check:type = (unsafe fn(type_names::GenericStruct<u16, u8>) -> type_names::mod1::Struct2, usize) // gdb-command:whatis extern_stdcall_fn_with_return_value -// gdbg-check:type = struct (extern "stdcall" fn(Box<isize>) -> usize, usize) -// gdbr-check:type = (extern "stdcall" fn(Box<isize>) -> usize, usize) +// gdbg-check:type = struct (extern "stdcall" fn(alloc::boxed::Box<isize>) -> usize, usize) +// gdbr-check:type = (extern "stdcall" fn(alloc::boxed::Box<isize>) -> usize, usize) // gdb-command:whatis generic_function_int // gdbg-check:type = struct (fn(isize) -> isize, usize) diff --git a/src/test/incremental/add_private_fn_at_krate_root_cc/auxiliary/point.rs b/src/test/incremental/add_private_fn_at_krate_root_cc/auxiliary/point.rs index adc2b23441e..1064c97b744 100644 --- a/src/test/incremental/add_private_fn_at_krate_root_cc/auxiliary/point.rs +++ b/src/test/incremental/add_private_fn_at_krate_root_cc/auxiliary/point.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Z incremental-cc + pub struct Point { pub x: f32, pub y: f32, diff --git a/src/test/incremental/callee_caller_cross_crate/auxiliary/a.rs b/src/test/incremental/callee_caller_cross_crate/auxiliary/a.rs index d802c9a8352..a02b71a753c 100644 --- a/src/test/incremental/callee_caller_cross_crate/auxiliary/a.rs +++ b/src/test/incremental/callee_caller_cross_crate/auxiliary/a.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Z incremental-cc + #![crate_type="rlib"] #[cfg(rpass1)] diff --git a/src/test/incremental/change_private_fn_cc/auxiliary/point.rs b/src/test/incremental/change_private_fn_cc/auxiliary/point.rs index dcc1ced635f..08eef2a73f6 100644 --- a/src/test/incremental/change_private_fn_cc/auxiliary/point.rs +++ b/src/test/incremental/change_private_fn_cc/auxiliary/point.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Z incremental-cc + pub struct Point { pub x: f32, pub y: f32, diff --git a/src/test/incremental/change_private_impl_method_cc/auxiliary/point.rs b/src/test/incremental/change_private_impl_method_cc/auxiliary/point.rs index 8df1cf54da2..e69dc51119e 100644 --- a/src/test/incremental/change_private_impl_method_cc/auxiliary/point.rs +++ b/src/test/incremental/change_private_impl_method_cc/auxiliary/point.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Z incremental-cc + pub struct Point { pub x: f32, pub y: f32, diff --git a/src/test/incremental/remove-private-item-cross-crate/auxiliary/a.rs b/src/test/incremental/remove-private-item-cross-crate/auxiliary/a.rs index 4d84e844ded..39547fb7359 100644 --- a/src/test/incremental/remove-private-item-cross-crate/auxiliary/a.rs +++ b/src/test/incremental/remove-private-item-cross-crate/auxiliary/a.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Z incremental-cc + #![allow(warnings)] #![crate_name = "a"] #![crate_type = "rlib"] diff --git a/src/test/incremental/rlib_cross_crate/auxiliary/a.rs b/src/test/incremental/rlib_cross_crate/auxiliary/a.rs index ff5fd634714..3ecd9aff3f8 100644 --- a/src/test/incremental/rlib_cross_crate/auxiliary/a.rs +++ b/src/test/incremental/rlib_cross_crate/auxiliary/a.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Z incremental-cc // no-prefer-dynamic #![crate_type="rlib"] diff --git a/src/test/incremental/struct_change_field_type_cross_crate/auxiliary/a.rs b/src/test/incremental/struct_change_field_type_cross_crate/auxiliary/a.rs index 2ddcaf15721..d14ebf78d82 100644 --- a/src/test/incremental/struct_change_field_type_cross_crate/auxiliary/a.rs +++ b/src/test/incremental/struct_change_field_type_cross_crate/auxiliary/a.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Z incremental-cc + #![crate_type="rlib"] #[cfg(rpass1)] diff --git a/src/test/incremental/type_alias_cross_crate/auxiliary/a.rs b/src/test/incremental/type_alias_cross_crate/auxiliary/a.rs index e1dba131770..0393bcda991 100644 --- a/src/test/incremental/type_alias_cross_crate/auxiliary/a.rs +++ b/src/test/incremental/type_alias_cross_crate/auxiliary/a.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Z incremental-cc + #![crate_type="rlib"] #[cfg(rpass1)] diff --git a/src/test/parse-fail/bounds-lifetime-1.rs b/src/test/parse-fail/bounds-lifetime-1.rs new file mode 100644 index 00000000000..824d243d5f8 --- /dev/null +++ b/src/test/parse-fail/bounds-lifetime-1.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b` + +fn main() {} diff --git a/src/test/parse-fail/bounds-lifetime-2.rs b/src/test/parse-fail/bounds-lifetime-2.rs new file mode 100644 index 00000000000..3c67dda70f5 --- /dev/null +++ b/src/test/parse-fail/bounds-lifetime-2.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+` + +fn main() {} diff --git a/src/test/parse-fail/bounds-lifetime-where-1.rs b/src/test/parse-fail/bounds-lifetime-where-1.rs new file mode 100644 index 00000000000..aae9d729987 --- /dev/null +++ b/src/test/parse-fail/bounds-lifetime-where-1.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A where 'a; //~ ERROR expected `:`, found `;` + +fn main() {} diff --git a/src/test/parse-fail/bounds-lifetime-where.rs b/src/test/parse-fail/bounds-lifetime-where.rs new file mode 100644 index 00000000000..0a30818bc96 --- /dev/null +++ b/src/test/parse-fail/bounds-lifetime-where.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A where 'a: 'b + 'c = u8; // OK +type A where 'a: 'b, = u8; // OK +type A where 'a: = u8; // OK +type A where 'a:, = u8; // OK +type A where 'a: 'b + 'c = u8; // OK +type A where = u8; // OK +type A where 'a: 'b + = u8; // OK +type A where , = u8; //~ ERROR expected one of `=`, lifetime, or type, found `,` + +fn main() {} diff --git a/src/test/parse-fail/bounds-lifetime.rs b/src/test/parse-fail/bounds-lifetime.rs new file mode 100644 index 00000000000..5113a6b4803 --- /dev/null +++ b/src/test/parse-fail/bounds-lifetime.rs @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +type A = for<'a: 'b + 'c> fn(); // OK +type A = for<'a: 'b,> fn(); // OK +type A = for<'a:> fn(); // OK +type A = for<'a:,> fn(); // OK +type A = for<'a> fn(); // OK +type A = for<> fn(); // OK +type A = for<'a: 'b +> fn(); // OK + +type A = for<'a, T> fn(); //~ ERROR only lifetime parameters can be used in this context +type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,` + +fn main() {} diff --git a/src/test/parse-fail/bounds-type-where.rs b/src/test/parse-fail/bounds-type-where.rs new file mode 100644 index 00000000000..9dc5d827744 --- /dev/null +++ b/src/test/parse-fail/bounds-type-where.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A where for<'a> for<'b> Trait1 + ?Trait2: 'a + Trait = u8; // OK +type A where T: Trait, = u8; // OK +type A where T: = u8; // OK +type A where T:, = u8; // OK +type A where T: Trait + Trait = u8; // OK +type A where = u8; // OK +type A where T: Trait + = u8; // OK +type A where T, = u8; +//~^ ERROR expected one of `!`, `(`, `+`, `::`, `:`, `<`, `==`, or `=`, found `,` + +fn main() {} diff --git a/src/test/parse-fail/bounds-type.rs b/src/test/parse-fail/bounds-type.rs new file mode 100644 index 00000000000..c224b44a14b --- /dev/null +++ b/src/test/parse-fail/bounds-type.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +struct S< + T: 'a + Tr, // OK + T: Tr + 'a, // OK + T: 'a, // OK + T:, // OK + T: ?for<'a: 'b + 'c> Trait, // OK + T: Tr +, // OK + T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds +>; + +fn main() {} diff --git a/src/test/parse-fail/issue-14303-path.rs b/src/test/parse-fail/issue-14303-path.rs index 431a917c2d9..f0d1feffec8 100644 --- a/src/test/parse-fail/issue-14303-path.rs +++ b/src/test/parse-fail/issue-14303-path.rs @@ -12,4 +12,3 @@ fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} //~^ ERROR lifetime parameters must be declared prior to type parameters -//~^^ ERROR expected pattern, found `'c` diff --git a/src/test/parse-fail/generic-non-trailing-defaults.rs b/src/test/parse-fail/issue-17904-2.rs index 2bb593258ae..3f41c0edd2e 100644 --- a/src/test/parse-fail/generic-non-trailing-defaults.rs +++ b/src/test/parse-fail/issue-17904-2.rs @@ -10,10 +10,6 @@ // compile-flags: -Z parse-only -Z continue-parse-after-error -struct Heap; - -struct Vec<A = Heap, T>; //~ ERROR type parameters with a default must be trailing - -struct Foo<A, B = Vec<C>, C>; //~ ERROR type parameters with a default must be trailing +struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found `where` fn main() {} diff --git a/src/test/parse-fail/issue-17904.rs b/src/test/parse-fail/issue-17904.rs index de5aeb02ab7..ae28ac76acb 100644 --- a/src/test/parse-fail/issue-17904.rs +++ b/src/test/parse-fail/issue-17904.rs @@ -13,7 +13,6 @@ struct Baz<U> where U: Eq(U); //This is parsed as the new Fn* style parenthesis syntax. struct Baz<U> where U: Eq(U) -> R; // Notice this parses as well. struct Baz<U>(U) where U: Eq; // This rightfully signals no error as well. -struct Foo<T> where T: Copy, (T); //~ ERROR unexpected token in `where` clause -struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found `where` +struct Foo<T> where T: Copy, (T); //~ ERROR expected one of `+`, `:`, `==`, or `=`, found `;` fn main() {} diff --git a/src/test/parse-fail/issue-32214.rs b/src/test/parse-fail/issue-32214.rs index 3ba59c8ee94..9e200094093 100644 --- a/src/test/parse-fail/issue-32214.rs +++ b/src/test/parse-fail/issue-32214.rs @@ -10,8 +10,7 @@ // compile-flags: -Z parse-only -Z continue-parse-after-error -pub fn test<W, I: Iterator<Item=(), W> >() { - //~^ ERROR expected `=`, found `>` -} +pub fn test<W, I: Iterator<Item=(), W> >() {} +//~^ ERROR type parameters must be declared prior to associated type bindings fn main() { } diff --git a/src/test/parse-fail/issue-39018.stderr b/src/test/parse-fail/issue-39018.stderr new file mode 100644 index 00000000000..ee1a32c4c16 --- /dev/null +++ b/src/test/parse-fail/issue-39018.stderr @@ -0,0 +1,28 @@ +error[E0369]: binary operation `+` cannot be applied to type `&'static str` + --> src/test/ui/span/issue-39018.rs:2:13 + | +2 | let x = "Hello " + "World!"; + | ^^^^^^^^ + | +note: `+` can't be used to concatenate two `&str` strings + --> src/test/ui/span/issue-39018.rs:2:13 + | +2 | let x = "Hello " + "World!"; + | ^^^^^^^^ +help: to_owned() can be used to create an owned `String` from a string reference. This allows concatenation since the `String` is owned. + | let x = "Hello ".to_owned() + "World!"; + +error[E0369]: binary operation `+` cannot be applied to type `World` + --> src/test/ui/span/issue-39018.rs:7:13 + | +7 | let y = World::Hello + World::Goodbye; + | ^^^^^^^^^^^^ + | +note: an implementation of `std::ops::Add` might be missing for `World` + --> src/test/ui/span/issue-39018.rs:7:13 + | +7 | let y = World::Hello + World::Goodbye; + | ^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/parse-fail/lifetime-semicolon.rs b/src/test/parse-fail/lifetime-semicolon.rs index 7010d0e7deb..e1975952fca 100644 --- a/src/test/parse-fail/lifetime-semicolon.rs +++ b/src/test/parse-fail/lifetime-semicolon.rs @@ -15,5 +15,4 @@ struct Foo<'a, 'b> { } fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {} -//~^ ERROR expected `,` or `>` after lifetime name, found `;` -//~^^ NOTE did you mean a single argument type &'a Type, or did you mean the comma-separated +//~^ ERROR expected one of `,` or `>`, found `;` diff --git a/src/test/parse-fail/tuple-float-index.rs b/src/test/parse-fail/tuple-float-index.rs index f3f5e356346..57ad89ad374 100644 --- a/src/test/parse-fail/tuple-float-index.rs +++ b/src/test/parse-fail/tuple-float-index.rs @@ -12,5 +12,6 @@ fn main () { (1, (2, 3)).1.1; //~ ERROR unexpected token - //~^ HELP try parenthesizing the first index; e.g., `(foo.1).1` + //~^ HELP try parenthesizing the first index + //~| SUGGESTION ((1, (2, 3)).1).1 } diff --git a/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs b/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs index 78d97454087..cf67b518fff 100644 --- a/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs +++ b/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs @@ -10,13 +10,13 @@ // compile-flags: -Z parse-only -Z continue-parse-after-error +// Empty predicate list is OK fn equal1<T>(_: &T, _: &T) -> bool where { -//~^ ERROR a `where` clause must have at least one predicate in it true } +// Empty bound list is OK fn equal2<T>(_: &T, _: &T) -> bool where T: { -//~^ ERROR each predicate in a `where` clause must have at least one bound true } diff --git a/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs b/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs index 29cc6b7db94..aa2f1626a6a 100644 --- a/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs +++ b/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs @@ -38,15 +38,12 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_macro("identity", expand_identity); reg.register_syntax_extension( Symbol::intern("into_multi_foo"), - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. MultiModifier(Box::new(expand_into_foo_multi))); reg.register_syntax_extension( Symbol::intern("duplicate"), - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. MultiDecorator(Box::new(expand_duplicate))); reg.register_syntax_extension( Symbol::intern("caller"), - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. MultiDecorator(Box::new(expand_caller))); } diff --git a/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs b/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs index ba2af77cdb2..3c8868f1664 100644 --- a/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs +++ b/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs @@ -48,6 +48,5 @@ impl TTMacroExpander for Expander { pub fn plugin_registrar(reg: &mut Registry) { let args = reg.args().to_owned(); reg.register_syntax_extension(Symbol::intern("plugin_args"), - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. NormalTT(Box::new(Expander { args: args, }), None, false)); } diff --git a/src/test/run-pass-fulldeps/deriving-encodable-decodable-box.rs b/src/test/run-pass-fulldeps/deriving-encodable-decodable-box.rs index 328cc134f3b..1573b080717 100644 --- a/src/test/run-pass-fulldeps/deriving-encodable-decodable-box.rs +++ b/src/test/run-pass-fulldeps/deriving-encodable-decodable-box.rs @@ -24,7 +24,6 @@ struct A { } fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let obj = A { foo: Box::new([true, false]) }; let s = json::encode(&obj).unwrap(); let obj2: A = json::decode(&s).unwrap(); diff --git a/src/test/run-pass-valgrind/dst-dtor-1.rs b/src/test/run-pass-valgrind/dst-dtor-1.rs index 995da8c73fa..4af642a106c 100644 --- a/src/test/run-pass-valgrind/dst-dtor-1.rs +++ b/src/test/run-pass-valgrind/dst-dtor-1.rs @@ -28,7 +28,6 @@ struct Fat<T: ?Sized> { pub fn main() { { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let _x: Box<Fat<Trait>> = Box::<Fat<Foo>>::new(Fat { f: Foo }); } unsafe { diff --git a/src/test/run-pass-valgrind/dst-dtor-2.rs b/src/test/run-pass-valgrind/dst-dtor-2.rs index 471169340d7..283b8202b35 100644 --- a/src/test/run-pass-valgrind/dst-dtor-2.rs +++ b/src/test/run-pass-valgrind/dst-dtor-2.rs @@ -25,7 +25,6 @@ struct Fat<T: ?Sized> { pub fn main() { { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let _x: Box<Fat<[Foo]>> = Box::<Fat<[Foo; 3]>>::new(Fat { f: [Foo, Foo, Foo] }); } unsafe { diff --git a/src/test/run-pass/associated-types-doubleendediterator-object.rs b/src/test/run-pass/associated-types-doubleendediterator-object.rs index dd194447740..0a6135080bb 100644 --- a/src/test/run-pass/associated-types-doubleendediterator-object.rs +++ b/src/test/run-pass/associated-types-doubleendediterator-object.rs @@ -26,7 +26,6 @@ fn pairwise_sub(mut t: Box<DoubleEndedIterator<Item=isize>>) -> isize { fn main() { let v = vec![1, 2, 3, 4, 5, 6]; - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let r = pairwise_sub(Box::new(v.into_iter())); assert_eq!(r, 9); } diff --git a/src/test/run-pass/auxiliary/issue13507.rs b/src/test/run-pass/auxiliary/issue13507.rs index ba50aed42c3..ee7d45b77bf 100644 --- a/src/test/run-pass/auxiliary/issue13507.rs +++ b/src/test/run-pass/auxiliary/issue13507.rs @@ -58,7 +58,7 @@ pub mod testtypes { // Tests TySlice pub type FooSlice = [u8]; - // Tests TyBox (of u8) + // Tests Box (of u8) pub type FooBox = Box<u8>; // Tests TyRawPtr diff --git a/src/test/run-pass/backtrace-debuginfo.rs b/src/test/run-pass/backtrace-debuginfo.rs index 72cf109fd59..626eccfc9ec 100644 --- a/src/test/run-pass/backtrace-debuginfo.rs +++ b/src/test/run-pass/backtrace-debuginfo.rs @@ -37,7 +37,6 @@ macro_rules! dump_and_die { target_os = "ios", target_os = "android", all(target_os = "linux", target_arch = "arm"), - target_os = "windows", target_os = "freebsd", target_os = "dragonfly", target_os = "bitrig", @@ -173,4 +172,3 @@ fn main() { run_test(&args[0]); } } - diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs index 75c665b04a1..834ce984e66 100644 --- a/src/test/run-pass/backtrace.rs +++ b/src/test/run-pass/backtrace.rs @@ -104,10 +104,6 @@ fn runtest(me: &str) { } fn main() { - if cfg!(windows) && cfg!(target_env = "gnu") { - return - } - let args: Vec<String> = env::args().collect(); if args.len() >= 2 && args[1] == "fail" { foo(); diff --git a/src/test/run-pass/coerce-expect-unsized.rs b/src/test/run-pass/coerce-expect-unsized.rs index e4792e7936b..a074aea9caa 100644 --- a/src/test/run-pass/coerce-expect-unsized.rs +++ b/src/test/run-pass/coerce-expect-unsized.rs @@ -19,15 +19,6 @@ use std::rc::Rc; // rvalue expressions to be unsized. See #20169 for more information. pub fn main() { - // FIXME #22405: We cannot infer the type `Box<[isize; k]>` for - // the r-value expression from the context `Box<[isize]>`, and - // therefore the `box EXPR` desugaring breaks down. - // - // One could reasonably claim that the `box EXPR` desugaring is - // effectively regressing half of Issue #20169. Hopefully we will - // eventually fix that, at which point the `Box::new` calls below - // should be replaced wth uses of `box`. - let _: Box<[isize]> = Box::new({ [1, 2, 3] }); let _: Box<[isize]> = Box::new(if true { [1, 2, 3] } else { [1, 3, 4] }); let _: Box<[isize]> = Box::new(match true { true => [1, 2, 3], false => [1, 3, 4] }); diff --git a/src/test/run-pass/deriving-default-box.rs b/src/test/run-pass/deriving-default-box.rs index dc31e71aad8..c9e5b014da3 100644 --- a/src/test/run-pass/deriving-default-box.rs +++ b/src/test/run-pass/deriving-default-box.rs @@ -21,7 +21,6 @@ struct A { pub fn main() { let a: A = Default::default(); - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let b: Box<[_]> = Box::<[bool; 0]>::new([]); assert_eq!(a.foo, b); } diff --git a/src/test/run-pass/deriving-eq-ord-boxed-slice.rs b/src/test/run-pass/deriving-eq-ord-boxed-slice.rs index f490cca6a69..16c49065008 100644 --- a/src/test/run-pass/deriving-eq-ord-boxed-slice.rs +++ b/src/test/run-pass/deriving-eq-ord-boxed-slice.rs @@ -12,7 +12,6 @@ struct Foo(Box<[u8]>); pub fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let a = Foo(Box::new([0, 1, 2])); let b = Foo(Box::new([0, 1, 2])); assert_eq!(a, b); diff --git a/src/test/run-pass/dst-deref-mut.rs b/src/test/run-pass/dst-deref-mut.rs index 0666e41738e..9fb4635765c 100644 --- a/src/test/run-pass/dst-deref-mut.rs +++ b/src/test/run-pass/dst-deref-mut.rs @@ -39,7 +39,6 @@ pub fn foo(arr: &mut Arr) { } fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let mut a = Arr { ptr: Box::new([1, 2, 3]) }; foo(&mut a); } diff --git a/src/test/run-pass/dst-deref.rs b/src/test/run-pass/dst-deref.rs index 957ed13a3d8..4a143873e6e 100644 --- a/src/test/run-pass/dst-deref.rs +++ b/src/test/run-pass/dst-deref.rs @@ -34,7 +34,6 @@ pub fn foo(arr: &Arr) { } fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let a = Arr { ptr: Box::new([1, 2, 3]) }; foo(&a); } diff --git a/src/test/run-pass/dst-struct.rs b/src/test/run-pass/dst-struct.rs index 94efa7a256b..56199c1aa61 100644 --- a/src/test/run-pass/dst-struct.rs +++ b/src/test/run-pass/dst-struct.rs @@ -127,7 +127,6 @@ pub fn main() { let f2 : Box<Fat<[isize]>> = f1; foo(&*f2); - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let f3 : Box<Fat<[isize]>> = Box::<Fat<[_; 3]>>::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }); foo(&*f3); diff --git a/src/test/run-pass/dst-trait.rs b/src/test/run-pass/dst-trait.rs index 9d12a4a34b7..d8d7d9a28bf 100644 --- a/src/test/run-pass/dst-trait.rs +++ b/src/test/run-pass/dst-trait.rs @@ -97,7 +97,6 @@ pub fn main() { // &* // - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let f7: Box<ToBar> = Box::new(Bar1 {f :42}); bar(&*f7); diff --git a/src/test/run-pass/empty-allocation-non-null.rs b/src/test/run-pass/empty-allocation-non-null.rs index af6e321e40a..3dbe7da6ac7 100644 --- a/src/test/run-pass/empty-allocation-non-null.rs +++ b/src/test/run-pass/empty-allocation-non-null.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - - pub fn main() { assert!(Some(Box::new(())).is_some()); diff --git a/src/test/run-pass/extern_fat_drop.rs b/src/test/run-pass/extern_fat_drop.rs index deb7e6bd539..8ce1f744dee 100644 --- a/src/test/run-pass/extern_fat_drop.rs +++ b/src/test/run-pass/extern_fat_drop.rs @@ -10,8 +10,6 @@ // aux-build:fat_drop.rs -#![feature(drop_in_place)] - extern crate fat_drop; fn main() { diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 2306fa9afa2..bd90ce683c4 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -62,7 +62,6 @@ mod map_reduce { } let ctrl_clone = ctrl.clone(); - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. ::map(input, Box::new(|a,b| emit(&mut intermediates, ctrl.clone(), a, b))); ctrl_clone.send(ctrl_proto::mapper_done).unwrap(); } diff --git a/src/test/run-pass/hrtb-precedence-of-plus.rs b/src/test/run-pass/hrtb-precedence-of-plus.rs index d93e52a8f5f..516278df178 100644 --- a/src/test/run-pass/hrtb-precedence-of-plus.rs +++ b/src/test/run-pass/hrtb-precedence-of-plus.rs @@ -17,7 +17,6 @@ // cause a compilation error. Issue #18772. fn adder(y: isize) -> Box<Fn(isize) -> isize + 'static> { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. Box::new(move |x| y + x) } diff --git a/src/test/run-pass/issue-11205.rs b/src/test/run-pass/issue-11205.rs index 679d494a473..25c66bf8d48 100644 --- a/src/test/run-pass/issue-11205.rs +++ b/src/test/run-pass/issue-11205.rs @@ -12,8 +12,6 @@ #![allow(dead_code)] -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - trait Foo { fn dummy(&self) { } } impl Foo for isize {} fn foo(_: [&Foo; 2]) {} diff --git a/src/test/run-pass/issue-11677.rs b/src/test/run-pass/issue-11677.rs index d4244d44439..62da3b14675 100644 --- a/src/test/run-pass/issue-11677.rs +++ b/src/test/run-pass/issue-11677.rs @@ -27,6 +27,5 @@ impl X<isize> for F { } fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. S {f: Box::new(F), g: Box::new(F) }; } diff --git a/src/test/run-pass/issue-12744.rs b/src/test/run-pass/issue-12744.rs index 56d1d3599c7..aec45216b1b 100644 --- a/src/test/run-pass/issue-12744.rs +++ b/src/test/run-pass/issue-12744.rs @@ -9,7 +9,6 @@ // except according to those terms. fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. fn test() -> Box<std::any::Any + 'static> { Box::new(1) } println!("{:?}", test()) } diff --git a/src/test/run-pass/issue-13808.rs b/src/test/run-pass/issue-13808.rs index c85c0117581..ccdfa0646c6 100644 --- a/src/test/run-pass/issue-13808.rs +++ b/src/test/run-pass/issue-13808.rs @@ -16,7 +16,6 @@ struct Foo<'a> { impl<'a> Foo<'a> { fn new<F>(listener: F) -> Foo<'a> where F: FnMut() + 'a { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. Foo { listener: Box::new(listener) } } } diff --git a/src/test/run-pass/issue-14589.rs b/src/test/run-pass/issue-14589.rs index b0893e21af7..8aaa24e991e 100644 --- a/src/test/run-pass/issue-14589.rs +++ b/src/test/run-pass/issue-14589.rs @@ -11,8 +11,6 @@ // All 3 expressions should work in that the argument gets // coerced to a trait object -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - // pretty-expanded FIXME #23616 fn main() { diff --git a/src/test/run-pass/issue-14919.rs b/src/test/run-pass/issue-14919.rs index d3c9fe9161c..df5d62e7699 100644 --- a/src/test/run-pass/issue-14919.rs +++ b/src/test/run-pass/issue-14919.rs @@ -31,7 +31,6 @@ trait IntoMatcher<'a, T> { impl<'a, 'b, F> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for F where F: FnMut(char) -> bool + 'b { fn into_matcher(self, s: &'a str) -> CharPredMatcher<'a, 'b> { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. CharPredMatcher { str: s, pred: Box::new(self), diff --git a/src/test/run-pass/issue-16668.rs b/src/test/run-pass/issue-16668.rs index 18861feb199..5613211b31d 100644 --- a/src/test/run-pass/issue-16668.rs +++ b/src/test/run-pass/issue-16668.rs @@ -16,7 +16,6 @@ struct Parser<'a, I, O> { impl<'a, I: 'a, O: 'a> Parser<'a, I, O> { fn compose<K: 'a>(mut self, mut rhs: Parser<'a, O, K>) -> Parser<'a, I, K> { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. Parser { parse: Box::new(move |x: I| { match (self.parse)(x) { diff --git a/src/test/run-pass/issue-17734.rs b/src/test/run-pass/issue-17734.rs index 0fc8eea778d..8178c1fd7c8 100644 --- a/src/test/run-pass/issue-17734.rs +++ b/src/test/run-pass/issue-17734.rs @@ -17,8 +17,6 @@ fn f(s: Box<str>) -> Box<str> { fn main() { // There is currently no safe way to construct a `Box<str>`, so improvise - // - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let box_arr: Box<[u8]> = Box::new(['h' as u8, 'e' as u8, 'l' as u8, 'l' as u8, 'o' as u8]); let box_str: Box<str> = unsafe { std::mem::transmute(box_arr) }; assert_eq!(&*box_str, "hello"); diff --git a/src/test/run-pass/issue-20575.rs b/src/test/run-pass/issue-20575.rs index e73492e7a7e..7db7e3b28e8 100644 --- a/src/test/run-pass/issue-20575.rs +++ b/src/test/run-pass/issue-20575.rs @@ -13,7 +13,6 @@ // pretty-expanded FIXME #23616 fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let functions: [Box<Fn() -> Option<()>>; 1] = [Box::new(|| None)]; let _: Option<Vec<()>> = functions.iter().map(|f| (*f)()).collect(); diff --git a/src/test/run-pass/issue-3052.rs b/src/test/run-pass/issue-3052.rs index 8f013ee4f3a..3b56b2e28ff 100644 --- a/src/test/run-pass/issue-3052.rs +++ b/src/test/run-pass/issue-3052.rs @@ -13,7 +13,6 @@ type Connection = Box<FnMut(Vec<u8>) + 'static>; fn f() -> Option<Connection> { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let mock_connection: Connection = Box::new(|_| {}); Some(mock_connection) } diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index 61de3c6385e..d1bf7e066cb 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -26,7 +26,6 @@ fn foo(name: String, samples_chan: Sender<Msg>) { thread::spawn(move|| { let mut samples_chan = samples_chan; - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let callback: SamplesFn = Box::new(move |buffer| { for i in 0..buffer.len() { println!("{}: {}", i, buffer[i]) diff --git a/src/test/run-pass/match-arm-statics.rs b/src/test/run-pass/match-arm-statics.rs index 9700ed24795..78a37f51837 100644 --- a/src/test/run-pass/match-arm-statics.rs +++ b/src/test/run-pass/match-arm-statics.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -g #[derive(PartialEq, Eq)] struct NewBool(bool); diff --git a/src/test/run-pass/newlambdas-ret-infer.rs b/src/test/run-pass/newlambdas-ret-infer.rs index 543dbb36b28..428eed0787a 100644 --- a/src/test/run-pass/newlambdas-ret-infer.rs +++ b/src/test/run-pass/newlambdas-ret-infer.rs @@ -11,7 +11,6 @@ // Test that the lambda kind is inferred correctly as a return // expression -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. // pretty-expanded FIXME #23616 fn unique() -> Box<FnMut()+'static> { return Box::new(|| ()); } diff --git a/src/test/run-pass/newlambdas-ret-infer2.rs b/src/test/run-pass/newlambdas-ret-infer2.rs index e8297173a58..439ea3f2b57 100644 --- a/src/test/run-pass/newlambdas-ret-infer2.rs +++ b/src/test/run-pass/newlambdas-ret-infer2.rs @@ -11,7 +11,6 @@ // Test that the lambda kind is inferred correctly as a return // expression -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. // pretty-expanded FIXME #23616 fn unique() -> Box<FnMut()+'static> { Box::new(|| ()) } diff --git a/src/test/run-pass/object-lifetime-default-from-ref-struct.rs b/src/test/run-pass/object-lifetime-default-from-ref-struct.rs index 910d933d46f..6aaf8920971 100644 --- a/src/test/run-pass/object-lifetime-default-from-ref-struct.rs +++ b/src/test/run-pass/object-lifetime-default-from-ref-struct.rs @@ -15,6 +15,8 @@ #![allow(dead_code)] +use std::fmt::Display; + trait Test { fn foo(&self) { } } @@ -23,6 +25,11 @@ struct Ref<'a,T:'a+?Sized> { r: &'a T } +struct Ref2<'a,'b,T:'a+'b+?Sized> { + a: &'a T, + b: &'b T +} + struct SomeStruct<'a> { t: Ref<'a,Test>, u: Ref<'a,Test+'a>, @@ -44,6 +51,17 @@ fn d<'a>(t: Ref<'a,Test+'a>, mut ss: SomeStruct<'a>) { ss.u = t; } +fn e<'a>(_: Ref<'a, Display+'static>) {} +fn g<'a, 'b>(_: Ref2<'a, 'b, Display+'static>) {} + fn main() { + // Inside a function body, we can just infer all + // lifetimes, to allow Ref<'tmp, Display+'static> + // and Ref2<'tmp, 'tmp, Display+'static>. + let x = &0 as &(Display+'static); + let r: Ref<Display> = Ref { r: x }; + let r2: Ref2<Display> = Ref2 { a: x, b: x }; + e(r); + g(r2); } diff --git a/src/test/run-pass/object-lifetime-default-from-rptr.rs b/src/test/run-pass/object-lifetime-default-from-rptr.rs index d9e0b22fbfa..cbff0d4dbaa 100644 --- a/src/test/run-pass/object-lifetime-default-from-rptr.rs +++ b/src/test/run-pass/object-lifetime-default-from-rptr.rs @@ -15,6 +15,8 @@ #![allow(dead_code)] +use std::fmt::Display; + trait Test { fn foo(&self) { } } @@ -40,6 +42,10 @@ fn d<'a>(t: &'a (Test+'a), mut ss: SomeStruct<'a>) { ss.u = t; } +fn e<'a>(_: &'a (Display+'static)) {} fn main() { + // Inside a function body, we can just infer both + // lifetimes, to allow &'tmp (Display+'static). + e(&0 as &Display); } diff --git a/src/test/run-pass/regions-fn-subtyping.rs b/src/test/run-pass/regions-fn-subtyping.rs index fc42fbc714c..c7a4accff85 100644 --- a/src/test/run-pass/regions-fn-subtyping.rs +++ b/src/test/run-pass/regions-fn-subtyping.rs @@ -16,8 +16,6 @@ #![allow(unused_variables)] #![allow(unknown_features)] -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - // Should pass region checking. fn ok(f: Box<FnMut(&usize)>) { // Here, g is a function that can accept a usize pointer with diff --git a/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs b/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs index 8eee54b3fec..ae4adbfb1f4 100644 --- a/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs +++ b/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs @@ -31,7 +31,6 @@ struct Foo<'a,'tcx:'a> { impl<'a,'tcx> Foo<'a,'tcx> { fn bother(&mut self) -> isize { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. self.elaborate_bounds(Box::new(|this| { // (*) Here: type of `this` is `&'f0 Foo<&'f1, '_2>`, // where `'f0` and `'f1` are fresh, free regions that diff --git a/src/test/run-pass/show-boxed-slice.rs b/src/test/run-pass/show-boxed-slice.rs index 03971668182..47d0737dfc4 100644 --- a/src/test/run-pass/show-boxed-slice.rs +++ b/src/test/run-pass/show-boxed-slice.rs @@ -12,6 +12,5 @@ struct Foo(Box<[u8]>); pub fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. println!("{:?}", Foo(Box::new([0, 1, 2]))); } diff --git a/src/test/run-pass/struct-path-associated-type.rs b/src/test/run-pass/struct-path-associated-type.rs index 292761dfd00..b033ed5c802 100644 --- a/src/test/run-pass/struct-path-associated-type.rs +++ b/src/test/run-pass/struct-path-associated-type.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(more_struct_aliases)] - struct S<T, U = u16> { a: T, b: U, diff --git a/src/test/run-pass/struct-path-self.rs b/src/test/run-pass/struct-path-self.rs index b569ab62c1b..c7a282c2a2f 100644 --- a/src/test/run-pass/struct-path-self.rs +++ b/src/test/run-pass/struct-path-self.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(more_struct_aliases)] - use std::ops::Add; struct S<T, U = u16> { diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index 9877dffe9df..c58442aa58f 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -105,7 +105,6 @@ fn check_legs(arc: Arc<Vec<Box<Pet+Sync+Send>>>) { } fn check_names(arc: Arc<Vec<Box<Pet+Sync+Send>>>) { for pet in arc.iter() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. pet.name(Box::new(|name| { assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8); })) diff --git a/src/test/run-pass/trait-coercion-generic.rs b/src/test/run-pass/trait-coercion-generic.rs index f9a22d5ccec..40453262ddf 100644 --- a/src/test/run-pass/trait-coercion-generic.rs +++ b/src/test/run-pass/trait-coercion-generic.rs @@ -26,7 +26,6 @@ impl Trait<&'static str> for Struct { pub fn main() { let a = Struct { x: 1, y: 2 }; - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let b: Box<Trait<&'static str>> = Box::new(a); b.f("Mary"); let c: &Trait<&'static str> = &a; diff --git a/src/test/run-pass/trait-coercion.rs b/src/test/run-pass/trait-coercion.rs index d40d9c89f89..130c6ee7521 100644 --- a/src/test/run-pass/trait-coercion.rs +++ b/src/test/run-pass/trait-coercion.rs @@ -30,8 +30,6 @@ impl Trait for Struct { fn foo(mut a: Box<Write>) {} -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - pub fn main() { let a = Struct { x: 1, y: 2 }; let b: Box<Trait> = Box::new(a); diff --git a/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs b/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs index a92fb05306f..789d2237c54 100644 --- a/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs +++ b/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs @@ -15,7 +15,6 @@ use std::ops::FnMut; fn make_adder(x: isize) -> Box<FnMut(isize)->isize + 'static> { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. Box::new(move |y| { x + y }) } diff --git a/src/test/run-pass/unboxed-closures-call-sugar-object.rs b/src/test/run-pass/unboxed-closures-call-sugar-object.rs index 5dd2343cfd1..e7307715471 100644 --- a/src/test/run-pass/unboxed-closures-call-sugar-object.rs +++ b/src/test/run-pass/unboxed-closures-call-sugar-object.rs @@ -13,7 +13,6 @@ use std::ops::FnMut; fn make_adder(x: isize) -> Box<FnMut(isize)->isize + 'static> { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. Box::new(move |y| { x + y }) } diff --git a/src/test/ui/lifetimes/consider-using-explicit-lifetime.rs b/src/test/ui/did_you_mean/issue-38147-1.rs index 603f55af465..136921dd0a5 100644 --- a/src/test/ui/lifetimes/consider-using-explicit-lifetime.rs +++ b/src/test/ui/did_you_mean/issue-38147-1.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,21 +8,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::str::FromStr; - -pub struct Foo<'a> { - field: &'a str, +struct Pass<'a> { + s: &'a mut String } -impl<'a> Foo<'a> { - fn bar(path: &str) -> Result<Self, ()> { - Ok(Foo { field: path }) +impl<'a> Pass<'a> { + fn f(&mut self) { + self.s.push('x'); } } -impl<'a> FromStr for Foo<'a> { - type Err = (); - fn from_str(path: &str) -> Result<Self, ()> { - Ok(Foo { field: path }) +struct Foo<'a> { + s: &'a mut String +} + +impl<'a> Foo<'a> { + fn f(&self) { + self.s.push('x'); } } + +fn main() {} diff --git a/src/test/ui/did_you_mean/issue-38147-1.stderr b/src/test/ui/did_you_mean/issue-38147-1.stderr new file mode 100644 index 00000000000..e9f2b1dad80 --- /dev/null +++ b/src/test/ui/did_you_mean/issue-38147-1.stderr @@ -0,0 +1,10 @@ +error[E0389]: cannot borrow data mutably in a `&` reference + --> $DIR/issue-38147-1.rs:27:9 + | +26 | fn f(&self) { + | ----- use `&mut self` here to make mutable +27 | self.s.push('x'); + | ^^^^^^ assignment into an immutable reference + +error: aborting due to previous error + diff --git a/src/test/ui/did_you_mean/issue-38147-2.rs b/src/test/ui/did_you_mean/issue-38147-2.rs new file mode 100644 index 00000000000..a5d533edf75 --- /dev/null +++ b/src/test/ui/did_you_mean/issue-38147-2.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Bar<'a> { + s: &'a String +} + +impl<'a> Bar<'a> { + fn f(&mut self) { + self.s.push('x'); + } +} + +fn main() {} diff --git a/src/test/ui/did_you_mean/issue-38147-2.stderr b/src/test/ui/did_you_mean/issue-38147-2.stderr new file mode 100644 index 00000000000..fdaf0cd44d9 --- /dev/null +++ b/src/test/ui/did_you_mean/issue-38147-2.stderr @@ -0,0 +1,11 @@ +error: cannot borrow immutable borrowed content `*self.s` as mutable + --> $DIR/issue-38147-2.rs:17:9 + | +12 | s: &'a String + | ------------- use `&'a mut String` here to make mutable +... +17 | self.s.push('x'); + | ^^^^^^ cannot borrow as mutable + +error: aborting due to previous error + diff --git a/src/test/ui/did_you_mean/issue-38147-3.rs b/src/test/ui/did_you_mean/issue-38147-3.rs new file mode 100644 index 00000000000..5e8f2d3eaef --- /dev/null +++ b/src/test/ui/did_you_mean/issue-38147-3.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Qux<'a> { + s: &'a String +} + +impl<'a> Qux<'a> { + fn f(&self) { + self.s.push('x'); + } +} + +fn main() {} diff --git a/src/test/ui/did_you_mean/issue-38147-3.stderr b/src/test/ui/did_you_mean/issue-38147-3.stderr new file mode 100644 index 00000000000..d2280fa561b --- /dev/null +++ b/src/test/ui/did_you_mean/issue-38147-3.stderr @@ -0,0 +1,13 @@ +error: cannot borrow immutable borrowed content `*self.s` as mutable + --> $DIR/issue-38147-3.rs:17:9 + | +12 | s: &'a String + | ------------- use `&'a mut String` here to make mutable +... +16 | fn f(&self) { + | ----- use `&mut self` here to make mutable +17 | self.s.push('x'); + | ^^^^^^ cannot borrow as mutable + +error: aborting due to previous error + diff --git a/src/test/ui/did_you_mean/issue-38147-4.rs b/src/test/ui/did_you_mean/issue-38147-4.rs new file mode 100644 index 00000000000..4eb20ceeed4 --- /dev/null +++ b/src/test/ui/did_you_mean/issue-38147-4.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo<'a> { + s: &'a mut String +} + +fn f(x: usize, f: &Foo) { + f.s.push('x'); +} + +fn main() {} diff --git a/src/test/ui/did_you_mean/issue-38147-4.stderr b/src/test/ui/did_you_mean/issue-38147-4.stderr new file mode 100644 index 00000000000..9a8853f4fbb --- /dev/null +++ b/src/test/ui/did_you_mean/issue-38147-4.stderr @@ -0,0 +1,10 @@ +error[E0389]: cannot borrow data mutably in a `&` reference + --> $DIR/issue-38147-4.rs:16:5 + | +15 | fn f(x: usize, f: &Foo) { + | ---- use `&mut Foo` here to make mutable +16 | f.s.push('x'); + | ^^^ assignment into an immutable reference + +error: aborting due to previous error + diff --git a/src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr b/src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr deleted file mode 100644 index 153aaa07833..00000000000 --- a/src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error: main function not found - -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/consider-using-explicit-lifetime.rs:19:12 - | -19 | Ok(Foo { field: path }) - | ^^^ - -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/consider-using-explicit-lifetime.rs:26:12 - | -26 | Ok(Foo { field: path }) - | ^^^ - | -help: consider using an explicit lifetime parameter as shown: fn from_str(path: &'a str) -> Result<Self, ()> - --> $DIR/consider-using-explicit-lifetime.rs:25:5 - | -25 | fn from_str(path: &str) -> Result<Self, ()> { - | _____^ starting here... -26 | | Ok(Foo { field: path }) -27 | | } - | |_____^ ...ending here - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr index c47975b0135..ccc9fb56772 100644 --- a/src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr +++ b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr @@ -4,8 +4,8 @@ error[E0308]: mismatched types 24 | a(x); //~ ERROR mismatched types [E0308] | ^ expected trait `Foo + std::marker::Send`, found trait `Foo` | - = note: expected type `Box<Foo + std::marker::Send + 'static>` - found type `Box<Foo + 'static>` + = note: expected type `std::boxed::Box<Foo + std::marker::Send + 'static>` + found type `std::boxed::Box<Foo + 'static>` error: aborting due to previous error diff --git a/src/test/compile-fail/uninhabited-reference-type-feature-gated.rs b/src/test/ui/resolve/auxiliary/privacy-struct-ctor.rs index 8f246eddbcd..f190f5dd053 100644 --- a/src/test/compile-fail/uninhabited-reference-type-feature-gated.rs +++ b/src/test/ui/resolve/auxiliary/privacy-struct-ctor.rs @@ -8,12 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum Void {} +#![feature(pub_restricted)] -fn main() { - let x: Result<u32, &'static Void> = Ok(23); - let _ = match x { //~ ERROR non-exhaustive - Ok(n) => n, - }; +pub mod m { + pub struct S(u8); + + pub mod n { + pub(m) struct Z(pub(m::n) u8); + } } +pub use m::S; diff --git a/src/test/ui/resolve/privacy-struct-ctor.rs b/src/test/ui/resolve/privacy-struct-ctor.rs new file mode 100644 index 00000000000..3d0c76c740a --- /dev/null +++ b/src/test/ui/resolve/privacy-struct-ctor.rs @@ -0,0 +1,48 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:privacy-struct-ctor.rs + +#![feature(pub_restricted)] + +extern crate privacy_struct_ctor as xcrate; + +mod m { + pub struct S(u8); + + pub mod n { + pub(m) struct Z(pub(m::n) u8); + } + + use m::n::Z; // OK, only the type is imported + + fn f() { + n::Z; //~ ERROR tuple struct `Z` is private + Z; + //~^ ERROR expected value, found struct `Z` + //~| NOTE tuple struct constructors with private fields are invisible outside of their mod + } +} + +use m::S; // OK, only the type is imported + +fn main() { + m::S; //~ ERROR tuple struct `S` is private + S; + //~^ ERROR expected value, found struct `S` + //~| NOTE constructor is not visible here due to private fields + m::n::Z; //~ ERROR tuple struct `Z` is private + + xcrate::m::S; //~ ERROR tuple struct `S` is private + xcrate::S; + //~^ ERROR expected value, found struct `xcrate::S` + //~| NOTE constructor is not visible here due to private fields + xcrate::m::n::Z; //~ ERROR tuple struct `Z` is private +} diff --git a/src/test/ui/resolve/privacy-struct-ctor.stderr b/src/test/ui/resolve/privacy-struct-ctor.stderr new file mode 100644 index 00000000000..30fdbb02cc7 --- /dev/null +++ b/src/test/ui/resolve/privacy-struct-ctor.stderr @@ -0,0 +1,68 @@ +error[E0423]: expected value, found struct `Z` + --> $DIR/privacy-struct-ctor.rs:28:9 + | +28 | Z; + | ^ + | | + | did you mean `Z { /* fields */ }`? + | constructor is not visible here due to private fields + | + = help: possible better candidate is found in another module, you can import it into scope: + `use m::n::Z;` + +error[E0423]: expected value, found struct `S` + --> $DIR/privacy-struct-ctor.rs:38:5 + | +38 | S; + | ^ + | | + | did you mean `S { /* fields */ }`? + | constructor is not visible here due to private fields + | + = help: possible better candidate is found in another module, you can import it into scope: + `use m::S;` + +error[E0423]: expected value, found struct `xcrate::S` + --> $DIR/privacy-struct-ctor.rs:44:5 + | +44 | xcrate::S; + | ^^^^^^^^^ + | | + | did you mean `xcrate::S { /* fields */ }`? + | constructor is not visible here due to private fields + | + = help: possible better candidate is found in another module, you can import it into scope: + `use m::S;` + +error: tuple struct `Z` is private + --> $DIR/privacy-struct-ctor.rs:27:9 + | +27 | n::Z; //~ ERROR tuple struct `Z` is private + | ^^^^ + +error: tuple struct `S` is private + --> $DIR/privacy-struct-ctor.rs:37:5 + | +37 | m::S; //~ ERROR tuple struct `S` is private + | ^^^^ + +error: tuple struct `Z` is private + --> $DIR/privacy-struct-ctor.rs:41:5 + | +41 | m::n::Z; //~ ERROR tuple struct `Z` is private + | ^^^^^^^ + +error: tuple struct `S` is private + --> $DIR/privacy-struct-ctor.rs:43:5 + | +43 | xcrate::m::S; //~ ERROR tuple struct `S` is private + | ^^^^^^^^^^^^ + +error: tuple struct `Z` is private + --> $DIR/privacy-struct-ctor.rs:47:5 + | +47 | xcrate::m::n::Z; //~ ERROR tuple struct `Z` is private + | ^^^^^^^^^^^^^^^ + +error: aborting due to 8 previous errors + 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 1109351bff8..b83a6aaebf3 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 @@ -12,7 +12,7 @@ error: cannot borrow immutable borrowed content `*x` as mutable 74 | fn deref_extend_mut_field1(x: &Own<Point>) -> &mut isize { | ----------- use `&mut Own<Point>` here to make mutable 75 | &mut x.y //~ ERROR cannot borrow - | ^ + | ^ cannot borrow 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 @@ -38,7 +38,7 @@ error: cannot borrow immutable borrowed content `*x` as mutable 101 | fn assign_field2<'a>(x: &'a Own<Point>) { | -------------- use `&'a mut Own<Point>` here to make mutable 102 | x.y = 3; //~ ERROR cannot borrow - | ^ + | ^ cannot borrow 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 @@ -64,7 +64,7 @@ error: cannot borrow immutable borrowed content `*x` as mutable 130 | fn deref_extend_mut_method1(x: &Own<Point>) -> &mut isize { | ----------- use `&mut Own<Point>` here to make mutable 131 | x.y_mut() //~ ERROR cannot borrow - | ^ + | ^ cannot borrow as mutable error: cannot borrow immutable argument `x` as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:139:6 @@ -80,7 +80,7 @@ error: cannot borrow immutable borrowed content `*x` as mutable 142 | fn assign_method2<'a>(x: &'a Own<Point>) { | -------------- use `&'a mut Own<Point>` here to make mutable 143 | *x.y_mut() = 3; //~ ERROR cannot borrow - | ^ + | ^ cannot borrow as mutable error: aborting due to 10 previous errors diff --git a/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr b/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr index a5b70459161..af954a4d792 100644 --- a/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr +++ b/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr @@ -12,7 +12,7 @@ error: cannot borrow immutable borrowed content `*x` as mutable 50 | fn deref_extend_mut1<'a>(x: &'a Own<isize>) -> &'a mut isize { | -------------- use `&'a mut Own<isize>` here to make mutable 51 | &mut **x //~ ERROR cannot borrow - | ^^ + | ^^ cannot borrow as mutable error: cannot borrow immutable argument `x` as mutable --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:59:6 @@ -28,7 +28,7 @@ error: cannot borrow immutable borrowed content `*x` as mutable 62 | fn assign2<'a>(x: &'a Own<isize>) { | -------------- use `&'a mut Own<isize>` here to make mutable 63 | **x = 3; //~ ERROR cannot borrow - | ^^ + | ^^ cannot borrow as mutable error: aborting due to 4 previous errors diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs index ba1ae64ec33..6264d111864 100644 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs +++ b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs @@ -18,7 +18,6 @@ struct Test<'a> { f: Box<FnMut() + 'a> } -// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. fn call<F>(mut f: F) where F: FnMut(Fn) { f(Box::new(|| { //~^ ERROR: cannot borrow `f` as mutable more than once @@ -58,7 +57,6 @@ fn test6() { fn test7() { fn foo<F>(_: F) where F: FnMut(Box<FnMut(isize)>, isize) {} let mut f = |g: Box<FnMut(isize)>, b: isize| {}; - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. f(Box::new(|a| { foo(f); //~^ ERROR cannot move `f` into closure because it is borrowed diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr index 16bb6001367..58b3f205fe3 100644 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr +++ b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr @@ -1,42 +1,44 @@ error[E0499]: cannot borrow `f` as mutable more than once at a time - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:23:16 + --> $DIR/borrowck-call-is-borrow-issue-12224.rs:22:16 | -23 | f(Box::new(|| { +22 | f(Box::new(|| { | - ^^ second mutable borrow occurs here | | | first mutable borrow occurs here -24 | //~^ ERROR: cannot borrow `f` as mutable more than once -25 | f((Box::new(|| {}))) +23 | //~^ ERROR: cannot borrow `f` as mutable more than once +24 | f((Box::new(|| {}))) | - borrow occurs due to use of `f` in closure -26 | })); +25 | })); | - first borrow ends here error: cannot borrow immutable borrowed content `*f` as mutable - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:36:5 + --> $DIR/borrowck-call-is-borrow-issue-12224.rs:35:5 | -35 | fn test2<F>(f: &F) where F: FnMut() { +34 | fn test2<F>(f: &F) where F: FnMut() { | -- use `&mut F` here to make mutable -36 | (*f)(); //~ ERROR: cannot borrow immutable borrowed content `*f` as mutable - | ^^^^ +35 | (*f)(); //~ ERROR: cannot borrow immutable borrowed content `*f` as mutable + | ^^^^ cannot borrow as mutable error: cannot borrow immutable `Box` content `*f.f` as mutable - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:44:5 + --> $DIR/borrowck-call-is-borrow-issue-12224.rs:43:5 | -44 | f.f.call_mut(()) //~ ERROR: cannot borrow immutable `Box` content `*f.f` as mutable - | ^^^ +42 | fn test4(f: &Test) { + | ----- use `&mut Test` here to make mutable +43 | f.f.call_mut(()) //~ ERROR: cannot borrow immutable `Box` content `*f.f` as mutable + | ^^^ cannot borrow as mutable error[E0504]: cannot move `f` into closure because it is borrowed - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:63:13 + --> $DIR/borrowck-call-is-borrow-issue-12224.rs:61:13 | -62 | f(Box::new(|a| { +60 | f(Box::new(|a| { | - borrow of `f` occurs here -63 | foo(f); +61 | foo(f); | ^ move into closure occurs here error[E0507]: cannot move out of captured outer variable in an `FnMut` closure - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:63:13 + --> $DIR/borrowck-call-is-borrow-issue-12224.rs:61:13 | -63 | foo(f); +61 | foo(f); | ^ cannot move out of captured outer variable in an `FnMut` closure error: aborting due to 5 previous errors diff --git a/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr b/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr index a1af1ca7408..2349bfaf75e 100644 --- a/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr +++ b/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr @@ -5,7 +5,7 @@ error: cannot borrow immutable borrowed content `*x` as mutable | ---- use `&mut Foo` here to make mutable 26 | x.f(); 27 | x.h(); //~ ERROR cannot borrow - | ^ + | ^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/span/borrowck-fn-in-const-b.stderr b/src/test/ui/span/borrowck-fn-in-const-b.stderr index 41f549c708a..251a9e4aa57 100644 --- a/src/test/ui/span/borrowck-fn-in-const-b.stderr +++ b/src/test/ui/span/borrowck-fn-in-const-b.stderr @@ -4,7 +4,7 @@ error: cannot borrow immutable borrowed content `*x` as mutable 16 | fn broken(x: &Vec<String>) { | ------------ use `&mut Vec<String>` here to make mutable 17 | x.push(format!("this is broken")); - | ^ + | ^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/span/borrowck-object-mutability.stderr b/src/test/ui/span/borrowck-object-mutability.stderr index 32e4da18056..4ef1cb9c239 100644 --- a/src/test/ui/span/borrowck-object-mutability.stderr +++ b/src/test/ui/span/borrowck-object-mutability.stderr @@ -5,13 +5,13 @@ error: cannot borrow immutable borrowed content `*x` as mutable | ---- use `&mut Foo` here to make mutable 18 | x.borrowed(); 19 | x.borrowed_mut(); //~ ERROR cannot borrow - | ^ + | ^ cannot borrow as mutable error: cannot borrow immutable `Box` content `*x` as mutable --> $DIR/borrowck-object-mutability.rs:29:5 | 29 | x.borrowed_mut(); //~ ERROR cannot borrow - | ^ + | ^ cannot borrow as mutable error: aborting due to 2 previous errors diff --git a/src/test/ui/span/coerce-suggestions.stderr b/src/test/ui/span/coerce-suggestions.stderr index c32fefcd0d6..6a70b8ff851 100644 --- a/src/test/ui/span/coerce-suggestions.stderr +++ b/src/test/ui/span/coerce-suggestions.stderr @@ -49,7 +49,7 @@ error[E0308]: mismatched types | ^^^^^ cyclic type of infinite size | = note: expected type `_` - found type `Box<_>` + found type `std::boxed::Box<_>` error: aborting due to 5 previous errors diff --git a/src/test/ui/span/issue-39018.rs b/src/test/ui/span/issue-39018.rs new file mode 100644 index 00000000000..1cbc5ff1d2a --- /dev/null +++ b/src/test/ui/span/issue-39018.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + let x = "Hello " + "World!"; + + // Make sure that the span outputs a warning + // for not having an implementation for std::ops::Add + // that won't output for the above string concatenation + let y = World::Hello + World::Goodbye; +} + +enum World { + Hello, + Goodbye, +} diff --git a/src/test/ui/span/issue-39018.stderr b/src/test/ui/span/issue-39018.stderr new file mode 100644 index 00000000000..a8cc74056ca --- /dev/null +++ b/src/test/ui/span/issue-39018.stderr @@ -0,0 +1,28 @@ +error[E0369]: binary operation `+` cannot be applied to type `&'static str` + --> $DIR/issue-39018.rs:12:13 + | +12 | let x = "Hello " + "World!"; + | ^^^^^^^^ + | +note: `+` can't be used to concatenate two `&str` strings + --> $DIR/issue-39018.rs:12:13 + | +12 | let x = "Hello " + "World!"; + | ^^^^^^^^ +help: to_owned() can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + | let x = "Hello ".to_owned() + "World!"; + +error[E0369]: binary operation `+` cannot be applied to type `World` + --> $DIR/issue-39018.rs:17:13 + | +17 | let y = World::Hello + World::Goodbye; + | ^^^^^^^^^^^^ + | +note: an implementation of `std::ops::Add` might be missing for `World` + --> $DIR/issue-39018.rs:17:13 + | +17 | let y = World::Hello + World::Goodbye; + | ^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/span/mut-arg-hint.stderr b/src/test/ui/span/mut-arg-hint.stderr index 58f66c13584..e4ed0622147 100644 --- a/src/test/ui/span/mut-arg-hint.stderr +++ b/src/test/ui/span/mut-arg-hint.stderr @@ -4,7 +4,7 @@ error: cannot borrow immutable borrowed content `*a` as mutable 17 | pub fn foo<'a>(mut a: &'a String) { | ---------- use `&'a mut String` here to make mutable 18 | a.push_str("foo"); - | ^ + | ^ cannot borrow as mutable error: cannot borrow immutable borrowed content `*a` as mutable --> $DIR/mut-arg-hint.rs:13:9 @@ -12,7 +12,7 @@ error: cannot borrow immutable borrowed content `*a` as mutable 12 | fn foo(mut a: &String) { | ------- use `&mut String` here to make mutable 13 | a.push_str("bar"); - | ^ + | ^ cannot borrow as mutable error: cannot borrow immutable borrowed content `*a` as mutable --> $DIR/mut-arg-hint.rs:25:9 @@ -20,7 +20,7 @@ error: cannot borrow immutable borrowed content `*a` as mutable 24 | pub fn foo(mut a: &String) { | ------- use `&mut String` here to make mutable 25 | a.push_str("foo"); - | ^ + | ^ cannot borrow as mutable error: aborting due to 3 previous errors |
