From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/fn/bad-main.rs | 1 - src/test/ui/fn/bad-main.stderr | 12 --- src/test/ui/fn/dyn-fn-alignment.rs | 23 ----- src/test/ui/fn/expr-fn-panic.rs | 11 --- src/test/ui/fn/expr-fn.rs | 62 -------------- src/test/ui/fn/fn-bad-block-type.rs | 5 -- src/test/ui/fn/fn-bad-block-type.stderr | 11 --- src/test/ui/fn/fn-closure-mutable-capture.rs | 12 --- src/test/ui/fn/fn-closure-mutable-capture.stderr | 15 ---- src/test/ui/fn/fn-compare-mismatch.rs | 7 -- src/test/ui/fn/fn-compare-mismatch.stderr | 26 ------ src/test/ui/fn/fn-item-type.rs | 53 ------------ src/test/ui/fn/fn-item-type.stderr | 97 ---------------------- src/test/ui/fn/fn-recover-return-sign.fixed | 28 ------- src/test/ui/fn/fn-recover-return-sign.rs | 28 ------- src/test/ui/fn/fn-recover-return-sign.stderr | 26 ------ src/test/ui/fn/fn-recover-return-sign2.rs | 8 -- src/test/ui/fn/fn-recover-return-sign2.stderr | 14 ---- src/test/ui/fn/fn-trait-formatting.rs | 21 ----- src/test/ui/fn/fn-trait-formatting.stderr | 60 ------------- src/test/ui/fn/fun-call-variants.rs | 12 --- .../fn/implied-bounds-unnorm-associated-type-2.rs | 23 ----- .../implied-bounds-unnorm-associated-type-2.stderr | 17 ---- .../fn/implied-bounds-unnorm-associated-type-3.rs | 22 ----- .../fn/implied-bounds-unnorm-associated-type-4.rs | 24 ------ .../implied-bounds-unnorm-associated-type-4.stderr | 14 ---- .../fn/implied-bounds-unnorm-associated-type-5.rs | 23 ----- .../implied-bounds-unnorm-associated-type-5.stderr | 19 ----- .../ui/fn/implied-bounds-unnorm-associated-type.rs | 23 ----- .../implied-bounds-unnorm-associated-type.stderr | 14 ---- src/test/ui/fn/issue-80179.rs | 27 ------ src/test/ui/fn/issue-80179.stderr | 21 ----- src/test/ui/fn/keyword-order.rs | 6 -- src/test/ui/fn/keyword-order.stderr | 16 ---- src/test/ui/fn/nested-function-names-issue-8587.rs | 42 ---------- .../fn/signature-error-reporting-under-verbose.rs | 15 ---- .../signature-error-reporting-under-verbose.stderr | 19 ----- 37 files changed, 857 deletions(-) delete mode 100644 src/test/ui/fn/bad-main.rs delete mode 100644 src/test/ui/fn/bad-main.stderr delete mode 100644 src/test/ui/fn/dyn-fn-alignment.rs delete mode 100644 src/test/ui/fn/expr-fn-panic.rs delete mode 100644 src/test/ui/fn/expr-fn.rs delete mode 100644 src/test/ui/fn/fn-bad-block-type.rs delete mode 100644 src/test/ui/fn/fn-bad-block-type.stderr delete mode 100644 src/test/ui/fn/fn-closure-mutable-capture.rs delete mode 100644 src/test/ui/fn/fn-closure-mutable-capture.stderr delete mode 100644 src/test/ui/fn/fn-compare-mismatch.rs delete mode 100644 src/test/ui/fn/fn-compare-mismatch.stderr delete mode 100644 src/test/ui/fn/fn-item-type.rs delete mode 100644 src/test/ui/fn/fn-item-type.stderr delete mode 100644 src/test/ui/fn/fn-recover-return-sign.fixed delete mode 100644 src/test/ui/fn/fn-recover-return-sign.rs delete mode 100644 src/test/ui/fn/fn-recover-return-sign.stderr delete mode 100644 src/test/ui/fn/fn-recover-return-sign2.rs delete mode 100644 src/test/ui/fn/fn-recover-return-sign2.stderr delete mode 100644 src/test/ui/fn/fn-trait-formatting.rs delete mode 100644 src/test/ui/fn/fn-trait-formatting.stderr delete mode 100644 src/test/ui/fn/fun-call-variants.rs delete mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type-2.rs delete mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type-2.stderr delete mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type-3.rs delete mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type-4.rs delete mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type-4.stderr delete mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type-5.rs delete mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type-5.stderr delete mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type.rs delete mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr delete mode 100644 src/test/ui/fn/issue-80179.rs delete mode 100644 src/test/ui/fn/issue-80179.stderr delete mode 100644 src/test/ui/fn/keyword-order.rs delete mode 100644 src/test/ui/fn/keyword-order.stderr delete mode 100644 src/test/ui/fn/nested-function-names-issue-8587.rs delete mode 100644 src/test/ui/fn/signature-error-reporting-under-verbose.rs delete mode 100644 src/test/ui/fn/signature-error-reporting-under-verbose.stderr (limited to 'src/test/ui/fn') diff --git a/src/test/ui/fn/bad-main.rs b/src/test/ui/fn/bad-main.rs deleted file mode 100644 index 751159961..000000000 --- a/src/test/ui/fn/bad-main.rs +++ /dev/null @@ -1 +0,0 @@ -fn main(x: isize) { } //~ ERROR: `main` function has wrong type [E0580] diff --git a/src/test/ui/fn/bad-main.stderr b/src/test/ui/fn/bad-main.stderr deleted file mode 100644 index 675b66d05..000000000 --- a/src/test/ui/fn/bad-main.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0580]: `main` function has wrong type - --> $DIR/bad-main.rs:1:1 - | -LL | fn main(x: isize) { } - | ^^^^^^^^^^^^^^^^^ incorrect number of function parameters - | - = note: expected fn pointer `fn()` - found fn pointer `fn(isize)` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0580`. diff --git a/src/test/ui/fn/dyn-fn-alignment.rs b/src/test/ui/fn/dyn-fn-alignment.rs deleted file mode 100644 index cedfd1cf2..000000000 --- a/src/test/ui/fn/dyn-fn-alignment.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-pass - -#![allow(dead_code)] -#[repr(align(256))] -struct A { - v: u8, -} - -impl A { - fn f(&self) -> *const A { - self - } -} - -fn f2(v: u8) -> Box *const A> { - let a = A { v }; - Box::new(move || a.f()) -} - -fn main() { - let addr = f2(0)(); - assert_eq!(addr as usize % 256, 0, "addr: {:?}", addr); -} diff --git a/src/test/ui/fn/expr-fn-panic.rs b/src/test/ui/fn/expr-fn-panic.rs deleted file mode 100644 index 123b57f97..000000000 --- a/src/test/ui/fn/expr-fn-panic.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-fail -// error-pattern:explicit panic -// ignore-emscripten no processes - -fn f() -> ! { - panic!() -} - -fn main() { - f(); -} diff --git a/src/test/ui/fn/expr-fn.rs b/src/test/ui/fn/expr-fn.rs deleted file mode 100644 index 253cbfd5d..000000000 --- a/src/test/ui/fn/expr-fn.rs +++ /dev/null @@ -1,62 +0,0 @@ -// run-pass -#![allow(unused_braces)] - -fn test_int() { - fn f() -> isize { 10 } - assert_eq!(f(), 10); -} - -fn test_vec() { - fn f() -> Vec { vec![10, 11] } - let vect = f(); - assert_eq!(vect[1], 11); -} - -fn test_generic() { - fn f(t: T) -> T { t } - assert_eq!(f(10), 10); -} - -fn test_alt() { - fn f() -> isize { match true { false => { 10 } true => { 20 } } } - assert_eq!(f(), 20); -} - -fn test_if() { - fn f() -> isize { if true { 10 } else { 20 } } - assert_eq!(f(), 10); -} - -fn test_block() { - fn f() -> isize { { 10 } } - assert_eq!(f(), 10); -} - -fn test_ret() { - fn f() -> isize { - return 10 // no semi - - } - assert_eq!(f(), 10); -} - - -// From issue #372 -fn test_372() { - fn f() -> isize { let x = { 3 }; x } - assert_eq!(f(), 3); -} - -fn test_nil() { () } - -pub fn main() { - test_int(); - test_vec(); - test_generic(); - test_alt(); - test_if(); - test_block(); - test_ret(); - test_372(); - test_nil(); -} diff --git a/src/test/ui/fn/fn-bad-block-type.rs b/src/test/ui/fn/fn-bad-block-type.rs deleted file mode 100644 index 01dcff058..000000000 --- a/src/test/ui/fn/fn-bad-block-type.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:mismatched types - -fn f() -> isize { true } - -fn main() { } diff --git a/src/test/ui/fn/fn-bad-block-type.stderr b/src/test/ui/fn/fn-bad-block-type.stderr deleted file mode 100644 index 13ebfd1e2..000000000 --- a/src/test/ui/fn/fn-bad-block-type.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/fn-bad-block-type.rs:3:19 - | -LL | fn f() -> isize { true } - | ----- ^^^^ expected `isize`, found `bool` - | | - | expected `isize` because of return type - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/fn/fn-closure-mutable-capture.rs b/src/test/ui/fn/fn-closure-mutable-capture.rs deleted file mode 100644 index 97141886f..000000000 --- a/src/test/ui/fn/fn-closure-mutable-capture.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub fn bar(_f: F) {} //~ NOTE change this to accept `FnMut` instead of `Fn` - -pub fn foo() { - let mut x = 0; - bar(move || x = 1); - //~^ ERROR cannot assign to `x`, as it is a captured variable in a `Fn` closure - //~| NOTE cannot assign - //~| NOTE expects `Fn` instead of `FnMut` - //~| NOTE in this closure -} - -fn main() {} diff --git a/src/test/ui/fn/fn-closure-mutable-capture.stderr b/src/test/ui/fn/fn-closure-mutable-capture.stderr deleted file mode 100644 index 03e3d545a..000000000 --- a/src/test/ui/fn/fn-closure-mutable-capture.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure - --> $DIR/fn-closure-mutable-capture.rs:5:17 - | -LL | pub fn bar(_f: F) {} - | - change this to accept `FnMut` instead of `Fn` -... -LL | bar(move || x = 1); - | --- ------- ^^^^^ cannot assign - | | | - | | in this closure - | expects `Fn` instead of `FnMut` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/fn/fn-compare-mismatch.rs b/src/test/ui/fn/fn-compare-mismatch.rs deleted file mode 100644 index d734d54e8..000000000 --- a/src/test/ui/fn/fn-compare-mismatch.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn main() { - fn f() { } - fn g() { } - let x = f == g; - //~^ ERROR binary operation `==` cannot be applied - //~| ERROR mismatched types -} diff --git a/src/test/ui/fn/fn-compare-mismatch.stderr b/src/test/ui/fn/fn-compare-mismatch.stderr deleted file mode 100644 index df838cb11..000000000 --- a/src/test/ui/fn/fn-compare-mismatch.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0369]: binary operation `==` cannot be applied to type `fn() {f}` - --> $DIR/fn-compare-mismatch.rs:4:15 - | -LL | let x = f == g; - | - ^^ - fn() {g} - | | - | fn() {f} - | -help: use parentheses to call these - | -LL | let x = f() == g(); - | ++ ++ - -error[E0308]: mismatched types - --> $DIR/fn-compare-mismatch.rs:4:18 - | -LL | let x = f == g; - | ^ expected fn item, found a different fn item - | - = note: expected fn item `fn() {f}` - found fn item `fn() {g}` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0308, E0369. -For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/fn/fn-item-type.rs b/src/test/ui/fn/fn-item-type.rs deleted file mode 100644 index 1831e6cbf..000000000 --- a/src/test/ui/fn/fn-item-type.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Test that the types of distinct fn items are not compatible by -// default. See also `run-pass/fn-item-type-*.rs`. - -fn foo(x: isize) -> isize { x * 2 } -fn bar(x: isize) -> isize { x * 4 } - -fn eq(x: T, y: T) { } - -trait Foo { fn foo() { /* this is a default fn */ } } -impl Foo for T { /* `foo` is still default here */ } - -fn main() { - eq(foo::, bar::); - //~^ ERROR mismatched types - //~| expected fn item `fn(_) -> _ {foo::}` - //~| found fn item `fn(_) -> _ {bar::}` - //~| expected fn item, found a different fn item - //~| different `fn` items always have unique types, even if their signatures are the same - //~| change the expected type to be function pointer - //~| if the expected type is due to type inference, cast the expected `fn` to a function pointer - - eq(foo::, foo::); - //~^ ERROR mismatched types - //~| expected `u8`, found `i8` - //~| different `fn` items always have unique types, even if their signatures are the same - //~| change the expected type to be function pointer - //~| if the expected type is due to type inference, cast the expected `fn` to a function pointer - - eq(bar::, bar::>); - //~^ ERROR mismatched types - //~| found fn item `fn(_) -> _ {bar::>}` - //~| expected struct `String`, found struct `Vec` - //~| different `fn` items always have unique types, even if their signatures are the same - //~| change the expected type to be function pointer - //~| if the expected type is due to type inference, cast the expected `fn` to a function pointer - - // Make sure we distinguish between trait methods correctly. - eq(::foo, ::foo); - //~^ ERROR mismatched types - //~| expected `u8`, found `u16` - //~| different `fn` items always have unique types, even if their signatures are the same - //~| change the expected type to be function pointer - //~| if the expected type is due to type inference, cast the expected `fn` to a function pointer - - eq(foo::, bar:: as fn(isize) -> isize); - //~^ ERROR mismatched types - //~| found fn pointer `fn(_) -> _` - //~| expected fn item, found fn pointer - //~| change the expected type to be function pointer - //~| if the expected type is due to type inference, cast the expected `fn` to a function pointer - - eq(foo:: as fn(isize) -> isize, bar::); // ok! -} diff --git a/src/test/ui/fn/fn-item-type.stderr b/src/test/ui/fn/fn-item-type.stderr deleted file mode 100644 index f03a47d5c..000000000 --- a/src/test/ui/fn/fn-item-type.stderr +++ /dev/null @@ -1,97 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/fn-item-type.rs:13:19 - | -LL | eq(foo::, bar::); - | -- ^^^^^^^^^ expected fn item, found a different fn item - | | - | arguments to this function are incorrect - | - = note: expected fn item `fn(_) -> _ {foo::}` - found fn item `fn(_) -> _ {bar::}` - = note: different `fn` items always have unique types, even if their signatures are the same - = help: change the expected type to be function pointer `fn(isize) -> isize` - = help: if the expected type is due to type inference, cast the expected `fn` to a function pointer: `foo:: as fn(isize) -> isize` -note: function defined here - --> $DIR/fn-item-type.rs:7:4 - | -LL | fn eq(x: T, y: T) { } - | ^^ ---- - -error[E0308]: mismatched types - --> $DIR/fn-item-type.rs:22:19 - | -LL | eq(foo::, foo::); - | -- ^^^^^^^^^ expected `u8`, found `i8` - | | - | arguments to this function are incorrect - | - = note: expected fn item `fn(_) -> _ {foo::}` - found fn item `fn(_) -> _ {foo::}` - = note: different `fn` items always have unique types, even if their signatures are the same - = help: change the expected type to be function pointer `fn(isize) -> isize` - = help: if the expected type is due to type inference, cast the expected `fn` to a function pointer: `foo:: as fn(isize) -> isize` -note: function defined here - --> $DIR/fn-item-type.rs:7:4 - | -LL | fn eq(x: T, y: T) { } - | ^^ ---- - -error[E0308]: mismatched types - --> $DIR/fn-item-type.rs:29:23 - | -LL | eq(bar::, bar::>); - | -- ^^^^^^^^^^^^^^ expected struct `String`, found struct `Vec` - | | - | arguments to this function are incorrect - | - = note: expected fn item `fn(_) -> _ {bar::}` - found fn item `fn(_) -> _ {bar::>}` - = note: different `fn` items always have unique types, even if their signatures are the same - = help: change the expected type to be function pointer `fn(isize) -> isize` - = help: if the expected type is due to type inference, cast the expected `fn` to a function pointer: `bar:: as fn(isize) -> isize` -note: function defined here - --> $DIR/fn-item-type.rs:7:4 - | -LL | fn eq(x: T, y: T) { } - | ^^ ---- - -error[E0308]: mismatched types - --> $DIR/fn-item-type.rs:38:26 - | -LL | eq(::foo, ::foo); - | -- ^^^^^^^^^^^^^^^^^ expected `u8`, found `u16` - | | - | arguments to this function are incorrect - | - = note: expected fn item `fn() {::foo}` - found fn item `fn() {::foo}` - = note: different `fn` items always have unique types, even if their signatures are the same - = help: change the expected type to be function pointer `fn()` - = help: if the expected type is due to type inference, cast the expected `fn` to a function pointer: `::foo as fn()` -note: function defined here - --> $DIR/fn-item-type.rs:7:4 - | -LL | fn eq(x: T, y: T) { } - | ^^ ---- - -error[E0308]: mismatched types - --> $DIR/fn-item-type.rs:45:19 - | -LL | eq(foo::, bar:: as fn(isize) -> isize); - | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn item, found fn pointer - | | - | arguments to this function are incorrect - | - = note: expected fn item `fn(_) -> _ {foo::}` - found fn pointer `fn(_) -> _` - = help: change the expected type to be function pointer `fn(isize) -> isize` - = help: if the expected type is due to type inference, cast the expected `fn` to a function pointer: `foo:: as fn(isize) -> isize` -note: function defined here - --> $DIR/fn-item-type.rs:7:4 - | -LL | fn eq(x: T, y: T) { } - | ^^ ---- - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/fn/fn-recover-return-sign.fixed b/src/test/ui/fn/fn-recover-return-sign.fixed deleted file mode 100644 index 076be6a35..000000000 --- a/src/test/ui/fn/fn-recover-return-sign.fixed +++ /dev/null @@ -1,28 +0,0 @@ -// run-rustfix -#![allow(unused)] -fn a() -> usize { 0 } -//~^ ERROR return types are denoted using `->` - -fn b()-> usize { 0 } -//~^ ERROR return types are denoted using `->` - -fn bar(_: u32) {} - -fn baz() -> *const dyn Fn(u32) { unimplemented!() } - -fn foo() { - match () { - _ if baz() == &bar as &dyn Fn(u32) => (), - () => (), - } -} - -fn main() { - let foo = |a: bool| -> bool { a }; - //~^ ERROR return types are denoted using `->` - dbg!(foo(false)); - - let bar = |a: bool|-> bool { a }; - //~^ ERROR return types are denoted using `->` - dbg!(bar(false)); -} diff --git a/src/test/ui/fn/fn-recover-return-sign.rs b/src/test/ui/fn/fn-recover-return-sign.rs deleted file mode 100644 index 0656023c0..000000000 --- a/src/test/ui/fn/fn-recover-return-sign.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-rustfix -#![allow(unused)] -fn a() => usize { 0 } -//~^ ERROR return types are denoted using `->` - -fn b(): usize { 0 } -//~^ ERROR return types are denoted using `->` - -fn bar(_: u32) {} - -fn baz() -> *const dyn Fn(u32) { unimplemented!() } - -fn foo() { - match () { - _ if baz() == &bar as &dyn Fn(u32) => (), - () => (), - } -} - -fn main() { - let foo = |a: bool| => bool { a }; - //~^ ERROR return types are denoted using `->` - dbg!(foo(false)); - - let bar = |a: bool|: bool { a }; - //~^ ERROR return types are denoted using `->` - dbg!(bar(false)); -} diff --git a/src/test/ui/fn/fn-recover-return-sign.stderr b/src/test/ui/fn/fn-recover-return-sign.stderr deleted file mode 100644 index 983109730..000000000 --- a/src/test/ui/fn/fn-recover-return-sign.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: return types are denoted using `->` - --> $DIR/fn-recover-return-sign.rs:3:8 - | -LL | fn a() => usize { 0 } - | ^^ help: use `->` instead - -error: return types are denoted using `->` - --> $DIR/fn-recover-return-sign.rs:6:7 - | -LL | fn b(): usize { 0 } - | ^ help: use `->` instead - -error: return types are denoted using `->` - --> $DIR/fn-recover-return-sign.rs:21:25 - | -LL | let foo = |a: bool| => bool { a }; - | ^^ help: use `->` instead - -error: return types are denoted using `->` - --> $DIR/fn-recover-return-sign.rs:25:24 - | -LL | let bar = |a: bool|: bool { a }; - | ^ help: use `->` instead - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/fn/fn-recover-return-sign2.rs b/src/test/ui/fn/fn-recover-return-sign2.rs deleted file mode 100644 index 31f56565c..000000000 --- a/src/test/ui/fn/fn-recover-return-sign2.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Separate test file because `Fn() => bool` isn't getting fixed and rustfix complained that -// even though a fix was applied the code was still incorrect - -fn foo() => impl Fn() => bool { - //~^ ERROR return types are denoted using `->` - //~| ERROR expected one of `+`, `->`, `::`, `where`, or `{`, found `=>` - unimplemented!() -} diff --git a/src/test/ui/fn/fn-recover-return-sign2.stderr b/src/test/ui/fn/fn-recover-return-sign2.stderr deleted file mode 100644 index 25ee8dd0c..000000000 --- a/src/test/ui/fn/fn-recover-return-sign2.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: return types are denoted using `->` - --> $DIR/fn-recover-return-sign2.rs:4:10 - | -LL | fn foo() => impl Fn() => bool { - | ^^ help: use `->` instead - -error: expected one of `+`, `->`, `::`, `where`, or `{`, found `=>` - --> $DIR/fn-recover-return-sign2.rs:4:23 - | -LL | fn foo() => impl Fn() => bool { - | ^^ expected one of `+`, `->`, `::`, `where`, or `{` - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/fn/fn-trait-formatting.rs b/src/test/ui/fn/fn-trait-formatting.rs deleted file mode 100644 index 636ac7107..000000000 --- a/src/test/ui/fn/fn-trait-formatting.rs +++ /dev/null @@ -1,21 +0,0 @@ -fn needs_fn(x: F) where F: Fn(isize) -> isize {} - - - -fn main() { - let _: () = Box::new(|_: isize| {}) as Box; - //~^ ERROR mismatched types - //~| expected unit type `()` - //~| found struct `Box` - let _: () = Box::new(|_: isize, isize| {}) as Box; - //~^ ERROR mismatched types - //~| expected unit type `()` - //~| found struct `Box` - let _: () = Box::new(|| -> isize { unimplemented!() }) as Box isize>; - //~^ ERROR mismatched types - //~| expected unit type `()` - //~| found struct `Box isize>` - - needs_fn(1); - //~^ ERROR expected a `Fn<(isize,)>` closure, found `{integer}` -} diff --git a/src/test/ui/fn/fn-trait-formatting.stderr b/src/test/ui/fn/fn-trait-formatting.stderr deleted file mode 100644 index 2a674d3c1..000000000 --- a/src/test/ui/fn/fn-trait-formatting.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/fn-trait-formatting.rs:6:17 - | -LL | let _: () = Box::new(|_: isize| {}) as Box; - | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found struct `Box` - | | - | expected due to this - | - = note: expected unit type `()` - found struct `Box` -help: use parentheses to call this trait object - | -LL | let _: () = (Box::new(|_: isize| {}) as Box)(/* isize */); - | + ++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/fn-trait-formatting.rs:10:17 - | -LL | let _: () = Box::new(|_: isize, isize| {}) as Box; - | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found struct `Box` - | | - | expected due to this - | - = note: expected unit type `()` - found struct `Box` -help: use parentheses to call this trait object - | -LL | let _: () = (Box::new(|_: isize, isize| {}) as Box)(/* isize */, /* isize */); - | + +++++++++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/fn-trait-formatting.rs:14:17 - | -LL | let _: () = Box::new(|| -> isize { unimplemented!() }) as Box isize>; - | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found struct `Box` - | | - | expected due to this - | - = note: expected unit type `()` - found struct `Box isize>` - -error[E0277]: expected a `Fn<(isize,)>` closure, found `{integer}` - --> $DIR/fn-trait-formatting.rs:19:14 - | -LL | needs_fn(1); - | -------- ^ expected an `Fn<(isize,)>` closure, found `{integer}` - | | - | required by a bound introduced by this call - | - = help: the trait `Fn<(isize,)>` is not implemented for `{integer}` -note: required by a bound in `needs_fn` - --> $DIR/fn-trait-formatting.rs:1:31 - | -LL | fn needs_fn(x: F) where F: Fn(isize) -> isize {} - | ^^^^^^^^^^^^^^^^^^ required by this bound in `needs_fn` - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/fn/fun-call-variants.rs b/src/test/ui/fn/fun-call-variants.rs deleted file mode 100644 index 5b83e2620..000000000 --- a/src/test/ui/fn/fun-call-variants.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass - -fn ho(f: F) -> isize where F: FnOnce(isize) -> isize { let n: isize = f(3); return n; } - -fn direct(x: isize) -> isize { return x + 1; } - -pub fn main() { - let a: isize = direct(3); // direct - let b: isize = ho(direct); // indirect unbound - - assert_eq!(a, b); -} diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type-2.rs b/src/test/ui/fn/implied-bounds-unnorm-associated-type-2.rs deleted file mode 100644 index 5d9245556..000000000 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// check-fail - -trait Trait { - type Type; -} - -impl Trait for T { - type Type = (); -} - -fn f<'a, 'b>(_: <&'a &'b () as Trait>::Type) -where - 'a: 'a, - 'b: 'b, -{ -} - -fn g<'a, 'b>() { - f::<'a, 'b>(()); - //~^ ERROR lifetime may not live long enough -} - -fn main() {} diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type-2.stderr b/src/test/ui/fn/implied-bounds-unnorm-associated-type-2.stderr deleted file mode 100644 index 0c3df04ea..000000000 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type-2.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/implied-bounds-unnorm-associated-type-2.rs:19:5 - | -LL | fn g<'a, 'b>() { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | f::<'a, 'b>(()); - | ^^^^^^^^^^^^^^^ requires that `'b` must outlive `'a` - | - = help: consider adding the following bound: `'b: 'a` - = note: requirement occurs because of a function pointer to `f` - = note: the function `f` is invariant over the parameter `'a` - = help: see for more information about variance - -error: aborting due to previous error - diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type-3.rs b/src/test/ui/fn/implied-bounds-unnorm-associated-type-3.rs deleted file mode 100644 index 888f74cf6..000000000 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type-3.rs +++ /dev/null @@ -1,22 +0,0 @@ -// check-pass - -pub trait Yokeable<'a>: 'static { - type Output: 'a; -} - -impl<'a, T: 'static + ?Sized> Yokeable<'a> for &'static T { - type Output = &'a T; -} - -pub trait ZeroCopyFrom: for<'a> Yokeable<'a> { - /// Clone the cart `C` into a [`Yokeable`] struct, which may retain references into `C`. - fn zero_copy_from<'b>(cart: &'b C) -> >::Output; -} - -impl ZeroCopyFrom<[T]> for &'static [T] { - fn zero_copy_from<'b>(cart: &'b [T]) -> &'b [T] { - cart - } -} - -fn main() {} diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type-4.rs b/src/test/ui/fn/implied-bounds-unnorm-associated-type-4.rs deleted file mode 100644 index 12859252c..000000000 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type-4.rs +++ /dev/null @@ -1,24 +0,0 @@ -// A regression test for #98543 - -trait Trait { - type Type; -} - -impl Trait for T { - type Type = (); -} - -fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str -where - &'a &'b (): Trait, // <- adding this bound is the change from #91068 -{ - s -} - -fn main() { - let x = String::from("Hello World!"); - let y = f(&x, ()); - drop(x); - //~^ ERROR cannot move out of `x` because it is borrowed - println!("{}", y); -} diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type-4.stderr b/src/test/ui/fn/implied-bounds-unnorm-associated-type-4.stderr deleted file mode 100644 index fcbaa91d1..000000000 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type-4.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/implied-bounds-unnorm-associated-type-4.rs:21:10 - | -LL | let y = f(&x, ()); - | -- borrow of `x` occurs here -LL | drop(x); - | ^ move out of `x` occurs here -LL | -LL | println!("{}", y); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type-5.rs b/src/test/ui/fn/implied-bounds-unnorm-associated-type-5.rs deleted file mode 100644 index 2a9a6a8cc..000000000 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type-5.rs +++ /dev/null @@ -1,23 +0,0 @@ -trait Trait<'a>: 'a { - type Type; -} - -// if the `T: 'a` bound gets implied we would probably get ub here again -impl<'a, T> Trait<'a> for T { - //~^ ERROR the parameter type `T` may not live long enough - type Type = (); -} - -fn f<'a, 'b>(s: &'b str, _: <&'b () as Trait<'a>>::Type) -> &'a str -where - &'b (): Trait<'a>, -{ - s -} - -fn main() { - let x = String::from("Hello World!"); - let y = f(&x, ()); - drop(x); - println!("{}", y); -} diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type-5.stderr b/src/test/ui/fn/implied-bounds-unnorm-associated-type-5.stderr deleted file mode 100644 index 458756a3d..000000000 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type-5.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/implied-bounds-unnorm-associated-type-5.rs:6:13 - | -LL | impl<'a, T> Trait<'a> for T { - | ^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/implied-bounds-unnorm-associated-type-5.rs:1:18 - | -LL | trait Trait<'a>: 'a { - | ^^ -help: consider adding an explicit lifetime bound... - | -LL | impl<'a, T: 'a> Trait<'a> for T { - | ++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs b/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs deleted file mode 100644 index d58d25036..000000000 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs +++ /dev/null @@ -1,23 +0,0 @@ -// check-fail -// See issue #91068. We check that the unnormalized associated types in -// function signatures are implied - -trait Trait { - type Type; -} - -impl Trait for T { - type Type = (); -} - -fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str { - s -} - -fn main() { - let x = String::from("Hello World!"); - let y = f(&x, ()); - drop(x); - //~^ ERROR cannot move out of `x` because it is borrowed - println!("{}", y); -} diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr b/src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr deleted file mode 100644 index e35f46e44..000000000 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/implied-bounds-unnorm-associated-type.rs:20:10 - | -LL | let y = f(&x, ()); - | -- borrow of `x` occurs here -LL | drop(x); - | ^ move out of `x` occurs here -LL | -LL | println!("{}", y); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/fn/issue-80179.rs b/src/test/ui/fn/issue-80179.rs deleted file mode 100644 index fcef6f1b6..000000000 --- a/src/test/ui/fn/issue-80179.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Functions with a type placeholder `_` as the return type should -// show a function pointer suggestion when given a function item -// and suggest how to return closures correctly from a function. -// This is a regression test of #80179 - -fn returns_i32() -> i32 { - 0 -} - -fn returns_fn_ptr() -> _ { -//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] -//~| NOTE not allowed in type signatures -//~| HELP replace with the correct return type -//~| SUGGESTION fn() -> i32 - returns_i32 -} - -fn returns_closure() -> _ { -//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] -//~| NOTE not allowed in type signatures -//~| HELP consider using an `Fn`, `FnMut`, or `FnOnce` trait bound -//~| NOTE for more information on `Fn` traits and closure types, see -// https://doc.rust-lang.org/book/ch13-01-closures.html - || 0 -} - -fn main() {} diff --git a/src/test/ui/fn/issue-80179.stderr b/src/test/ui/fn/issue-80179.stderr deleted file mode 100644 index 2ca4ae982..000000000 --- a/src/test/ui/fn/issue-80179.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/issue-80179.rs:10:24 - | -LL | fn returns_fn_ptr() -> _ { - | ^ - | | - | not allowed in type signatures - | help: replace with the correct return type: `fn() -> i32` - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/issue-80179.rs:18:25 - | -LL | fn returns_closure() -> _ { - | ^ not allowed in type signatures - | - = help: consider using an `Fn`, `FnMut`, or `FnOnce` trait bound - = note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0121`. diff --git a/src/test/ui/fn/keyword-order.rs b/src/test/ui/fn/keyword-order.rs deleted file mode 100644 index 8a21db673..000000000 --- a/src/test/ui/fn/keyword-order.rs +++ /dev/null @@ -1,6 +0,0 @@ -// edition:2018 - -default pub const async unsafe extern fn err() {} //~ ERROR `default` is not followed by an item -//~^ ERROR expected item, found keyword `pub` - -pub default const async unsafe extern fn ok() {} diff --git a/src/test/ui/fn/keyword-order.stderr b/src/test/ui/fn/keyword-order.stderr deleted file mode 100644 index d3b140c85..000000000 --- a/src/test/ui/fn/keyword-order.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: `default` is not followed by an item - --> $DIR/keyword-order.rs:3:1 - | -LL | default pub const async unsafe extern fn err() {} - | ^^^^^^^ the `default` qualifier - | - = note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default` - -error: expected item, found keyword `pub` - --> $DIR/keyword-order.rs:3:9 - | -LL | default pub const async unsafe extern fn err() {} - | ^^^ expected item - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/fn/nested-function-names-issue-8587.rs b/src/test/ui/fn/nested-function-names-issue-8587.rs deleted file mode 100644 index 8fafd41d9..000000000 --- a/src/test/ui/fn/nested-function-names-issue-8587.rs +++ /dev/null @@ -1,42 +0,0 @@ -// run-pass -// Make sure nested functions are separate, even if they have -// equal name. -// -// Issue #8587 - - -pub struct X; - -impl X { - fn f(&self) -> isize { - #[inline(never)] - fn inner() -> isize { - 0 - } - inner() - } - - fn g(&self) -> isize { - #[inline(never)] - fn inner_2() -> isize { - 1 - } - inner_2() - } - - fn h(&self) -> isize { - #[inline(never)] - fn inner() -> isize { - 2 - } - inner() - } -} - -pub fn main() { - let n = X; - assert_eq!(n.f(), 0); - assert_eq!(n.g(), 1); - // This test `h` used to fail. - assert_eq!(n.h(), 2); -} diff --git a/src/test/ui/fn/signature-error-reporting-under-verbose.rs b/src/test/ui/fn/signature-error-reporting-under-verbose.rs deleted file mode 100644 index d7a8c95e8..000000000 --- a/src/test/ui/fn/signature-error-reporting-under-verbose.rs +++ /dev/null @@ -1,15 +0,0 @@ -// compile-flags: -Zverbose - -fn foo(_: i32, _: i32) {} - -fn needs_ptr(_: fn(i32, u32)) {} -//~^ NOTE function defined here -//~| NOTE - -fn main() { - needs_ptr(foo); - //~^ ERROR mismatched types - //~| NOTE expected `u32`, found `i32` - //~| NOTE expected fn pointer `fn(i32, u32)` - //~| NOTE arguments to this function are incorrect -} diff --git a/src/test/ui/fn/signature-error-reporting-under-verbose.stderr b/src/test/ui/fn/signature-error-reporting-under-verbose.stderr deleted file mode 100644 index 6260fc8dc..000000000 --- a/src/test/ui/fn/signature-error-reporting-under-verbose.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/signature-error-reporting-under-verbose.rs:10:15 - | -LL | needs_ptr(foo); - | --------- ^^^ expected `u32`, found `i32` - | | - | arguments to this function are incorrect - | - = note: expected fn pointer `fn(i32, u32)` - found fn item `fn(i32, i32) {foo}` -note: function defined here - --> $DIR/signature-error-reporting-under-verbose.rs:5:4 - | -LL | fn needs_ptr(_: fn(i32, u32)) {} - | ^^^^^^^^^ --------------- - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. -- cgit v1.2.3