Auto merge of #106215 - matthiaskrgr:rollup-53r89ww, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #106028 (docs/test: add UI test and long-form error docs for `E0461`)
 - #106172 (Suggest `impl Iterator` when possible for `_` return type)
 - #106173 (Deduplicate `op` methods)
 - #106176 (Recover `fn` keyword as `Fn` trait in bounds)
 - #106194 (rustdoc: combine common sidebar background color CSS rules)
 - #106199 (Silence knock-down errors on `[type error]` bindings)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-12-28 17:00:00 +00:00
commit 270c94e484
36 changed files with 502 additions and 397 deletions

View file

@ -378,10 +378,6 @@ img {
filter: var(--rust-logo-filter);
}
.sidebar, .mobile-topbar, .sidebar-menu-toggle {
background-color: var(--sidebar-background-color);
}
.sidebar {
font-size: 0.875rem;
flex: 0 0 200px;
@ -400,7 +396,8 @@ img {
overflow-y: hidden;
}
.source .sidebar, #src-sidebar-toggle, #source-sidebar {
.sidebar, .mobile-topbar, .sidebar-menu-toggle,
#src-sidebar-toggle, #source-sidebar {
background-color: var(--sidebar-background-color);
}

View file

@ -1,7 +1,52 @@
// The goal of this test is to ensure that the sidebar is working as expected in the source
// code pages.
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
// First: desktop mode.
show-text: true
// First, check the sidebar colors.
define-function: (
"check-colors",
(theme, color, background_color),
[
("local-storage", {
"rustdoc-theme": |theme|,
"rustdoc-use-system-theme": "false",
}),
("reload"),
// Checking results colors.
("assert-css", (".source .sidebar", {
"color": |color|,
"background-color": |background_color|
}, ALL)),
],
)
call-function: (
"check-colors",
{
"theme": "ayu",
"color": "rgb(197, 197, 197)",
"background_color": "rgb(20, 25, 31)",
}
)
call-function: (
"check-colors",
{
"theme": "dark",
"color": "rgb(221, 221, 221)",
"background_color": "rgb(80, 80, 80)",
}
)
call-function: (
"check-colors",
{
"theme": "light",
"color": "rgb(0, 0, 0)",
"background_color": "rgb(245, 245, 245)",
}
)
// Next, desktop mode layout.
size: (1100, 800)
// We check that the sidebar isn't expanded and has the expected width.
assert-css: ("nav.sidebar", {"width": "50px"})

View file

@ -2,6 +2,50 @@
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
assert-property: (".sidebar", {"clientWidth": "200"})
show-text: true
// First, check the sidebar colors.
define-function: (
"check-colors",
(theme, color, background_color),
[
("local-storage", {
"rustdoc-theme": |theme|,
"rustdoc-use-system-theme": "false",
}),
("reload"),
// Checking results colors.
("assert-css", (".sidebar", {
"color": |color|,
"background-color": |background_color|
}, ALL)),
],
)
call-function: (
"check-colors",
{
"theme": "ayu",
"color": "rgb(197, 197, 197)",
"background_color": "rgb(20, 25, 31)",
}
)
call-function: (
"check-colors",
{
"theme": "dark",
"color": "rgb(221, 221, 221)",
"background_color": "rgb(80, 80, 80)",
}
)
call-function: (
"check-colors",
{
"theme": "light",
"color": "rgb(0, 0, 0)",
"background_color": "rgb(245, 245, 245)",
}
)
local-storage: {"rustdoc-theme": "light"}
// We reload the page so the local storage settings are being used.
reload:

View file

@ -1,13 +1,13 @@
// compile-flags: -Z teach
trait SomeTrait {
fn foo(); //~ associated function `foo` has no `self` parameter
fn foo(&self);
}
struct S;
impl SomeTrait for S {
fn foo(&self) {}
}
fn main() {
let trait_obj: &dyn SomeTrait = SomeTrait;
//~^ ERROR expected value, found trait `SomeTrait`
//~| ERROR E0038
let trait_obj: &dyn SomeTrait = &S;
let &invalid = trait_obj;
//~^ ERROR E0033

View file

@ -1,31 +1,3 @@
error[E0423]: expected value, found trait `SomeTrait`
--> $DIR/E0033-teach.rs:8:37
|
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
| ^^^^^^^^^ not a value
error[E0038]: the trait `SomeTrait` cannot be made into an object
--> $DIR/E0033-teach.rs:8:20
|
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
| ^^^^^^^^^^^^^^ `SomeTrait` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/E0033-teach.rs:4:8
|
LL | trait SomeTrait {
| --------- this trait cannot be made into an object...
LL | fn foo();
| ^^^ ...because associated function `foo` has no `self` parameter
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self);
| +++++
help: alternatively, consider constraining `foo` so it does not apply to trait objects
|
LL | fn foo() where Self: Sized;
| +++++++++++++++++
error[E0033]: type `&dyn SomeTrait` cannot be dereferenced
--> $DIR/E0033-teach.rs:12:9
|
@ -36,7 +8,6 @@ LL | let &invalid = trait_obj;
You can read more about trait objects in the Trait Objects section of the Reference: https://doc.rust-lang.org/reference/types.html#trait-objects
error: aborting due to 3 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0033, E0038, E0423.
For more information about an error, try `rustc --explain E0033`.
For more information about this error, try `rustc --explain E0033`.

View file

@ -1,11 +1,12 @@
trait SomeTrait {
fn foo(); //~ associated function `foo` has no `self` parameter
fn foo(&self);
}
struct S;
impl SomeTrait for S {
fn foo(&self) {}
}
fn main() {
let trait_obj: &dyn SomeTrait = SomeTrait;
//~^ ERROR expected value, found trait `SomeTrait`
//~| ERROR E0038
let trait_obj: &dyn SomeTrait = &S;
let &invalid = trait_obj;
//~^ ERROR E0033

View file

@ -1,38 +1,9 @@
error[E0423]: expected value, found trait `SomeTrait`
--> $DIR/E0033.rs:6:37
|
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
| ^^^^^^^^^ not a value
error[E0038]: the trait `SomeTrait` cannot be made into an object
--> $DIR/E0033.rs:6:20
|
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
| ^^^^^^^^^^^^^^ `SomeTrait` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/E0033.rs:2:8
|
LL | trait SomeTrait {
| --------- this trait cannot be made into an object...
LL | fn foo();
| ^^^ ...because associated function `foo` has no `self` parameter
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self);
| +++++
help: alternatively, consider constraining `foo` so it does not apply to trait objects
|
LL | fn foo() where Self: Sized;
| +++++++++++++++++
error[E0033]: type `&dyn SomeTrait` cannot be dereferenced
--> $DIR/E0033.rs:10:9
--> $DIR/E0033.rs:11:9
|
LL | let &invalid = trait_obj;
| ^^^^^^^^ type `&dyn SomeTrait` cannot be dereferenced
error: aborting due to 3 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0033, E0038, E0423.
For more information about an error, try `rustc --explain E0033`.
For more information about this error, try `rustc --explain E0033`.

View file

@ -7,10 +7,8 @@ fn main() {
//~^ ERROR: character literal may only contain one codepoint
if x == y {}
//~^ ERROR: can't compare `&str` with `char`
if y == z {} // no error here
if x == z {}
//~^ ERROR: can't compare `&str` with `char`
let a: usize = "";
//~^ ERROR: mismatched types

View file

@ -31,49 +31,14 @@ help: if you meant to write a `str` literal, use double quotes
LL | let z = "ef";
| ~~~~
error[E0277]: can't compare `&str` with `char`
--> $DIR/lex-bad-char-literals-6.rs:9:10
|
LL | if x == y {}
| ^^ no implementation for `&str == char`
|
= help: the trait `PartialEq<char>` is not implemented for `&str`
= help: the following other types implement trait `PartialEq<Rhs>`:
<&'a str as PartialEq<OsString>>
<&'a str as PartialEq<String>>
<&'b str as PartialEq<Cow<'a, str>>>
<str as PartialEq<Cow<'a, str>>>
<str as PartialEq<OsStr>>
<str as PartialEq<OsString>>
<str as PartialEq<String>>
<str as PartialEq>
error[E0308]: mismatched types
--> $DIR/lex-bad-char-literals-6.rs:15:20
--> $DIR/lex-bad-char-literals-6.rs:13:20
|
LL | let a: usize = "";
| ----- ^^ expected `usize`, found `&str`
| |
| expected due to this
error[E0277]: can't compare `&str` with `char`
--> $DIR/lex-bad-char-literals-6.rs:12:10
|
LL | if x == z {}
| ^^ no implementation for `&str == char`
|
= help: the trait `PartialEq<char>` is not implemented for `&str`
= help: the following other types implement trait `PartialEq<Rhs>`:
<&'a str as PartialEq<OsString>>
<&'a str as PartialEq<String>>
<&'b str as PartialEq<Cow<'a, str>>>
<str as PartialEq<Cow<'a, str>>>
<str as PartialEq<OsStr>>
<str as PartialEq<OsString>>
<str as PartialEq<String>>
<str as PartialEq>
error: aborting due to 4 previous errors
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
For more information about this error, try `rustc --explain E0308`.

View file

@ -4,21 +4,13 @@ fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn())
//~^ ERROR expected identifier, found keyword `fn`
//~| ERROR expected identifier, found keyword `fn`
//~| ERROR expected identifier, found keyword `fn`
//~| ERROR cannot find trait `r#fn` in this scope
//~| ERROR cannot find trait `r#fn` in this scope
//~| ERROR cannot find trait `r#fn` in this scope
//~| HELP a trait with a similar name exists
//~| HELP a trait with a similar name exists
//~| HELP a trait with a similar name exists
//~| HELP escape `fn` to use it as an identifier
//~| HELP escape `fn` to use it as an identifier
//~| HELP escape `fn` to use it as an identifier
//~| HELP use `Fn` to refer to the trait
//~| HELP use `Fn` to refer to the trait
//~| HELP use `Fn` to refer to the trait
where
G: fn(),
//~^ ERROR expected identifier, found keyword `fn`
//~| ERROR cannot find trait `r#fn` in this scope
//~| HELP a trait with a similar name exists
//~| HELP escape `fn` to use it as an identifier
//~| HELP use `Fn` to refer to the trait
{}
fn _g<A: struct, B>(_: impl struct, _: &dyn struct)

View file

@ -2,48 +2,48 @@ error: expected identifier, found keyword `fn`
--> $DIR/kw-in-trait-bounds.rs:3:10
|
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn())
| ^^ expected identifier, found keyword
| ^^
|
help: escape `fn` to use it as an identifier
help: use `Fn` to refer to the trait
|
LL | fn _f<F: r#fn(), G>(_: impl fn(), _: &dyn fn())
| ++
LL | fn _f<F: Fn(), G>(_: impl fn(), _: &dyn fn())
| ~~
error: expected identifier, found keyword `fn`
--> $DIR/kw-in-trait-bounds.rs:3:27
|
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn())
| ^^ expected identifier, found keyword
| ^^
|
help: escape `fn` to use it as an identifier
help: use `Fn` to refer to the trait
|
LL | fn _f<F: fn(), G>(_: impl r#fn(), _: &dyn fn())
| ++
LL | fn _f<F: fn(), G>(_: impl Fn(), _: &dyn fn())
| ~~
error: expected identifier, found keyword `fn`
--> $DIR/kw-in-trait-bounds.rs:3:41
|
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn())
| ^^ expected identifier, found keyword
| ^^
|
help: escape `fn` to use it as an identifier
help: use `Fn` to refer to the trait
|
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn r#fn())
| ++
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn Fn())
| ~~
error: expected identifier, found keyword `fn`
--> $DIR/kw-in-trait-bounds.rs:17:4
--> $DIR/kw-in-trait-bounds.rs:11:4
|
LL | G: fn(),
| ^^ expected identifier, found keyword
| ^^
|
help: escape `fn` to use it as an identifier
help: use `Fn` to refer to the trait
|
LL | G: r#fn(),
| ++
LL | G: Fn(),
| ~~
error: expected identifier, found keyword `struct`
--> $DIR/kw-in-trait-bounds.rs:24:10
--> $DIR/kw-in-trait-bounds.rs:16:10
|
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct)
| ^^^^^^ expected identifier, found keyword
@ -54,7 +54,7 @@ LL | fn _g<A: r#struct, B>(_: impl struct, _: &dyn struct)
| ++
error: expected identifier, found keyword `struct`
--> $DIR/kw-in-trait-bounds.rs:24:29
--> $DIR/kw-in-trait-bounds.rs:16:29
|
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct)
| ^^^^^^ expected identifier, found keyword
@ -65,7 +65,7 @@ LL | fn _g<A: struct, B>(_: impl r#struct, _: &dyn struct)
| ++
error: expected identifier, found keyword `struct`
--> $DIR/kw-in-trait-bounds.rs:24:45
--> $DIR/kw-in-trait-bounds.rs:16:45
|
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct)
| ^^^^^^ expected identifier, found keyword
@ -76,7 +76,7 @@ LL | fn _g<A: struct, B>(_: impl struct, _: &dyn r#struct)
| ++
error: expected identifier, found keyword `struct`
--> $DIR/kw-in-trait-bounds.rs:38:8
--> $DIR/kw-in-trait-bounds.rs:30:8
|
LL | B: struct,
| ^^^^^^ expected identifier, found keyword
@ -86,44 +86,8 @@ help: escape `struct` to use it as an identifier
LL | B: r#struct,
| ++
error[E0405]: cannot find trait `r#fn` in this scope
--> $DIR/kw-in-trait-bounds.rs:3:10
|
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn())
| ^^ help: a trait with a similar name exists (notice the capitalization): `Fn`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here
error[E0405]: cannot find trait `r#fn` in this scope
--> $DIR/kw-in-trait-bounds.rs:17:4
|
LL | G: fn(),
| ^^ help: a trait with a similar name exists (notice the capitalization): `Fn`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here
error[E0405]: cannot find trait `r#fn` in this scope
--> $DIR/kw-in-trait-bounds.rs:3:27
|
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn())
| ^^ help: a trait with a similar name exists (notice the capitalization): `Fn`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here
error[E0405]: cannot find trait `r#fn` in this scope
--> $DIR/kw-in-trait-bounds.rs:3:41
|
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn())
| ^^ help: a trait with a similar name exists (notice the capitalization): `Fn`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here
error[E0405]: cannot find trait `r#struct` in this scope
--> $DIR/kw-in-trait-bounds.rs:24:10
--> $DIR/kw-in-trait-bounds.rs:16:10
|
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct)
| ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct`
@ -132,7 +96,7 @@ LL | trait Struct {}
| ------------ similarly named trait `Struct` defined here
error[E0405]: cannot find trait `r#struct` in this scope
--> $DIR/kw-in-trait-bounds.rs:38:8
--> $DIR/kw-in-trait-bounds.rs:30:8
|
LL | B: struct,
| ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct`
@ -141,7 +105,7 @@ LL | trait Struct {}
| ------------ similarly named trait `Struct` defined here
error[E0405]: cannot find trait `r#struct` in this scope
--> $DIR/kw-in-trait-bounds.rs:24:29
--> $DIR/kw-in-trait-bounds.rs:16:29
|
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct)
| ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct`
@ -150,7 +114,7 @@ LL | trait Struct {}
| ------------ similarly named trait `Struct` defined here
error[E0405]: cannot find trait `r#struct` in this scope
--> $DIR/kw-in-trait-bounds.rs:24:45
--> $DIR/kw-in-trait-bounds.rs:16:45
|
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct)
| ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct`
@ -158,6 +122,6 @@ LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct)
LL | trait Struct {}
| ------------ similarly named trait `Struct` defined here
error: aborting due to 16 previous errors
error: aborting due to 12 previous errors
For more information about this error, try `rustc --explain E0405`.

View file

@ -0,0 +1,12 @@
fn foo(_: impl fn() -> i32) {}
//~^ ERROR expected identifier, found keyword `fn`
fn foo2<T: fn(i32)>(_: T) {}
//~^ ERROR expected identifier, found keyword `fn`
fn main() {
foo(|| ());
//~^ mismatched types
foo2(|_: ()| {});
//~^ type mismatch in closure arguments
}

View file

@ -0,0 +1,48 @@
error: expected identifier, found keyword `fn`
--> $DIR/recover-fn-trait-from-fn-kw.rs:1:16
|
LL | fn foo(_: impl fn() -> i32) {}
| ^^
|
help: use `Fn` to refer to the trait
|
LL | fn foo(_: impl Fn() -> i32) {}
| ~~
error: expected identifier, found keyword `fn`
--> $DIR/recover-fn-trait-from-fn-kw.rs:4:12
|
LL | fn foo2<T: fn(i32)>(_: T) {}
| ^^
|
help: use `Fn` to refer to the trait
|
LL | fn foo2<T: Fn(i32)>(_: T) {}
| ~~
error[E0308]: mismatched types
--> $DIR/recover-fn-trait-from-fn-kw.rs:8:12
|
LL | foo(|| ());
| ^^ expected `i32`, found `()`
error[E0631]: type mismatch in closure arguments
--> $DIR/recover-fn-trait-from-fn-kw.rs:10:5
|
LL | foo2(|_: ()| {});
| ^^^^ ------- found signature defined here
| |
| expected due to this
|
= note: expected closure signature `fn(i32) -> _`
found closure signature `fn(()) -> _`
note: required by a bound in `foo2`
--> $DIR/recover-fn-trait-from-fn-kw.rs:4:12
|
LL | fn foo2<T: fn(i32)>(_: T) {}
| ^^^^^^^ required by this bound in `foo2`
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0308, E0631.
For more information about an error, try `rustc --explain E0308`.

View file

@ -1,9 +1,13 @@
// The purpose of this test is not to validate the output of the compiler.
// Instead, it ensures the suggestion is generated without performing an arithmetic overflow.
fn main() {
let x = not_found; //~ ERROR cannot find value `not_found` in this scope
simd_gt::<()>(x);
//~^ ERROR this associated function takes 0 generic arguments but 1 generic argument was supplied
//~| ERROR cannot find function `simd_gt` in this scope
struct S;
impl S {
fn foo(&self) {}
}
fn main() {
let x = S;
foo::<()>(x);
//~^ ERROR this associated function takes 0 generic arguments but 1 generic argument was supplied
//~| ERROR cannot find function `foo` in this scope
}

View file

@ -1,30 +1,30 @@
error[E0425]: cannot find value `not_found` in this scope
--> $DIR/issue-104287.rs:5:13
|
LL | let x = not_found;
| ^^^^^^^^^ not found in this scope
error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/issue-104287.rs:6:5
--> $DIR/issue-104287.rs:10:5
|
LL | simd_gt::<()>(x);
| ^^^^^^^------ help: remove these generics
LL | foo::<()>(x);
| ^^^------ help: remove these generics
| |
| expected 0 generic arguments
|
note: associated function defined here, with 0 generic parameters
--> $DIR/issue-104287.rs:6:8
|
LL | fn foo(&self) {}
| ^^^
error[E0425]: cannot find function `simd_gt` in this scope
--> $DIR/issue-104287.rs:6:5
error[E0425]: cannot find function `foo` in this scope
--> $DIR/issue-104287.rs:10:5
|
LL | simd_gt::<()>(x);
| ^^^^^^^ not found in this scope
LL | foo::<()>(x);
| ^^^ not found in this scope
|
help: use the `.` operator to call the method `SimdPartialOrd::simd_gt` on `[type error]`
help: use the `.` operator to call the method `foo` on `&S`
|
LL - simd_gt::<()>(x);
LL + x.simd_gt();
LL - foo::<()>(x);
LL + x.foo();
|
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0107, E0425.
For more information about an error, try `rustc --explain E0107`.

View file

@ -19,7 +19,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
LL | const C: _ = || 42;
| ^ not allowed in type signatures
|
note: however, the inferred type `[closure@$DIR/unnamable-types.rs:17:14: 17:16]` cannot be named
note: however, the inferred type `[closure@unnamable-types.rs:17:14]` cannot be named
--> $DIR/unnamable-types.rs:17:14
|
LL | const C: _ = || 42;
@ -31,7 +31,7 @@ error: missing type for `const` item
LL | const D = S { t: { let i = 0; move || -> i32 { i } } };
| ^
|
note: however, the inferred type `S<[closure@$DIR/unnamable-types.rs:23:31: 23:45]>` cannot be named
note: however, the inferred type `S<[closure@unnamable-types.rs:23:31]>` cannot be named
--> $DIR/unnamable-types.rs:23:11
|
LL | const D = S { t: { let i = 0; move || -> i32 { i } } };

View file

@ -0,0 +1,17 @@
// fn foo() -> String {
// String::new()
// }
fn test(s: &str) {
println!("{}", s);
}
fn test2(s: String) {
println!("{}", s);
}
fn main() {
let x = foo(); //~ERROR cannot find function `foo` in this scope
test(&x);
test2(x); // Does not complain about `x` being a `&str`.
}

View file

@ -0,0 +1,9 @@
error[E0425]: cannot find function `foo` in this scope
--> $DIR/quiet-type-err-let-binding.rs:14:13
|
LL | let x = foo();
| ^^^ not found in this scope
error: aborting due to previous error
For more information about this error, try `rustc --explain E0425`.

View file

@ -220,3 +220,11 @@ fn value() -> Option<&'static _> {
const _: Option<_> = map(value);
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
fn evens_squared(n: usize) -> _ {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
(1..n).filter(|x| x % 2 == 0).map(|x| x * x)
}
const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants

View file

@ -428,6 +428,27 @@ LL | const _: Option<_> = map(value);
| not allowed in type signatures
| help: replace with the correct type: `Option<u8>`
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
--> $DIR/typeck_type_placeholder_item.rs:224:31
|
LL | fn evens_squared(n: usize) -> _ {
| ^
| |
| not allowed in type signatures
| help: replace with an appropriate return type: `impl Iterator<Item = usize>`
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
--> $DIR/typeck_type_placeholder_item.rs:229:10
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^ not allowed in type signatures
|
note: however, the inferred type `Map<Filter<Range<i32>, [closure@typeck_type_placeholder_item.rs:229:29]>, [closure@typeck_type_placeholder_item.rs:229:49]>` cannot be named
--> $DIR/typeck_type_placeholder_item.rs:229:14
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
--> $DIR/typeck_type_placeholder_item.rs:140:31
|
@ -636,7 +657,7 @@ LL | const D: _ = 42;
| not allowed in type signatures
| help: replace with the correct type: `i32`
error: aborting due to 69 previous errors
error: aborting due to 71 previous errors
Some errors have detailed explanations: E0121, E0282, E0403.
For more information about an error, try `rustc --explain E0121`.