diff --git a/Cargo.lock b/Cargo.lock index 6ddc7944092da..80c90243e5db7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -575,9 +575,9 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9975aefa63997ef75ca9cf013ff1bb81487aaa0b622c21053afd3b92979a7af" +checksum = "438ac08ddc5efe81452f984a9e33ba425b00b31d1f48e6acd9e2210aa28cc52e" dependencies = [ "cc", "rustc-std-workspace-core", diff --git a/RELEASES.md b/RELEASES.md index 427aa71b4b5dc..7e18f1befddec 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,100 @@ +Version 1.42.0 (2020-03-12) +========================== + +Language +-------- +- [You can now use the slice pattern syntax with subslices.][67712] e.g. + ```rust + fn foo(words: &[&str]) { + match words { + ["Hello", "World", "!", ..] => println!("Hello World!"), + ["Foo", "Bar", ..] => println!("Baz"), + rest => println!("{:?}", rest), + } + } + ``` +- [You can now use `#[repr(transparent)]` on univariant `enum`s.][68122] Meaning + that you can create an enum that has the exact layout and ABI of the type + it contains. +- [There are some *syntax-only* changes:][67131] + - `default` is syntactically allowed before items in `trait` definitions. + - Items in `impl`s (i.e. `const`s, `type`s, and `fn`s) may syntactically + leave out their bodies in favor of `;`. + - Bounds on associated types in `impl`s are now syntactically allowed + (e.g. `type Foo: Ord;`). + - `...` (the C-variadic type) may occur syntactically directly as the type of + any function parameter. + + These are still rejected *semantically*, so you will likely receive an error + but these changes can be seen and parsed by procedural macros and + conditional compilation. + +Compiler +-------- +- [Added tier 2\* support for `armv7a-none-eabi`.][68253] +- [Added tier 2 support for `riscv64gc-unknown-linux-gnu`.][68339] +- [`Option::{expect,unwrap}` and + `Result::{expect, expect_err, unwrap, unwrap_err}` now produce panic messages + pointing to the location where they were called, rather than + `core`'s internals. ][67887] + +\* Refer to Rust's [platform support page][forge-platform-support] for more +information on Rust's tiered platform support. + +Libraries +--------- +- [`iter::Empty` now implements `Send` and `Sync` for any `T`.][68348] +- [`Pin::{map_unchecked, map_unchecked_mut}` no longer require the return type + to implement `Sized`.][67935] +- [`io::Cursor` now derives `PartialEq` and `Eq`.][67233] +- [`Layout::new` is now `const`.][66254] +- [Added Standard Library support for `riscv64gc-unknown-linux-gnu`.][66899] + + +Stabilized APIs +--------------- +- [`CondVar::wait_while`] +- [`CondVar::wait_timeout_while`] +- [`DebugMap::key`] +- [`DebugMap::value`] +- [`ManuallyDrop::take`] +- [`matches!`] +- [`ptr::slice_from_raw_parts_mut`] +- [`ptr::slice_from_raw_parts`] + +Cargo +----- +- [You no longer need to include `extern crate proc_macro;` to be able to + `use proc_macro;` in the `2018` edition.][cargo/7700] + +Compatibility Notes +------------------- +- [`Error::description` has been deprecated, and its use will now produce a + warning.][66919] It's recommended to use `Display`/`to_string` instead. + +[68253]: https://github.com/rust-lang/rust/pull/68253/ +[68348]: https://github.com/rust-lang/rust/pull/68348/ +[67935]: https://github.com/rust-lang/rust/pull/67935/ +[68339]: https://github.com/rust-lang/rust/pull/68339/ +[68122]: https://github.com/rust-lang/rust/pull/68122/ +[67712]: https://github.com/rust-lang/rust/pull/67712/ +[67887]: https://github.com/rust-lang/rust/pull/67887/ +[67131]: https://github.com/rust-lang/rust/pull/67131/ +[67233]: https://github.com/rust-lang/rust/pull/67233/ +[66899]: https://github.com/rust-lang/rust/pull/66899/ +[66919]: https://github.com/rust-lang/rust/pull/66919/ +[66254]: https://github.com/rust-lang/rust/pull/66254/ +[cargo/7700]: https://github.com/rust-lang/cargo/pull/7700 +[`DebugMap::key`]: https://doc.rust-lang.org/stable/std/fmt/struct.DebugMap.html#method.key +[`DebugMap::value`]: https://doc.rust-lang.org/stable/std/fmt/struct.DebugMap.html#method.value +[`ManuallyDrop::take`]: https://doc.rust-lang.org/stable/std/mem/struct.ManuallyDrop.html#method.take +[`matches!`]: https://doc.rust-lang.org/stable/std/macro.matches.html +[`ptr::slice_from_raw_parts_mut`]: https://doc.rust-lang.org/stable/std/ptr/fn.slice_from_raw_parts_mut.html +[`ptr::slice_from_raw_parts`]: https://doc.rust-lang.org/stable/std/ptr/fn.slice_from_raw_parts.html +[`CondVar::wait_while`]: https://doc.rust-lang.org/stable/std/sync/struct.Condvar.html#method.wait_while +[`CondVar::wait_timeout_while`]: https://doc.rust-lang.org/stable/std/sync/struct.Condvar.html#method.wait_timeout_while + + Version 1.41.1 (2020-02-27) =========================== @@ -8,6 +105,7 @@ Version 1.41.1 (2020-02-27) [69225]: https://github.com/rust-lang/rust/issues/69225 [69145]: https://github.com/rust-lang/rust/pull/69145 + Version 1.41.0 (2020-01-30) =========================== diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 3c217c1d64373..0796c46e0d595 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -132,12 +132,11 @@ impl<'a> DiagnosticBuilder<'a> { let handler = self.0.handler; - // We need to use `ptr::read` because `DiagnosticBuilder` implements `Drop`. - let diagnostic; - unsafe { - diagnostic = std::ptr::read(&self.0.diagnostic); - std::mem::forget(self); - }; + // We must use `Level::Cancelled` for `dummy` to avoid an ICE about an + // unused diagnostic. + let dummy = Diagnostic::new(Level::Cancelled, ""); + let diagnostic = std::mem::replace(&mut self.0.diagnostic, dummy); + // Logging here is useful to help track down where in logs an error was // actually emitted. debug!("buffer: diagnostic={:?}", diagnostic); diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 17b293401f89e..19f72e3a3e2bd 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -446,22 +446,12 @@ impl Handler { } /// Stash a given diagnostic with the given `Span` and `StashKey` as the key for later stealing. - /// If the diagnostic with this `(span, key)` already exists, this will result in an ICE. pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic) { let mut inner = self.inner.borrow_mut(); - if let Some(mut old_diag) = inner.stashed_diagnostics.insert((span, key), diag) { - // We are removing a previously stashed diagnostic which should not happen. - old_diag.level = Bug; - old_diag.note(&format!( - "{}:{}: already existing stashed diagnostic with (span = {:?}, key = {:?})", - file!(), - line!(), - span, - key - )); - inner.emit_diag_at_span(old_diag, span); - panic!(ExplicitBug); - } + // FIXME(Centril, #69537): Consider reintroducing panic on overwriting a stashed diagnostic + // if/when we have a more robust macro-friendly replacement for `(span, key)` as a key. + // See the PR for a discussion. + inner.stashed_diagnostics.insert((span, key), diag); } /// Steal a previously stashed diagnostic with the given `Span` and `StashKey` as the key. diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index b4c2b85241f96..2d704145e9640 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -1311,6 +1311,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty_span: Span, ) { if variant.recovered { + self.set_tainted_by_errors(); return; } let mut err = self.type_error_struct_with_diag( diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 843872d0ff99a..cdf2304b839d1 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -316,7 +316,7 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> { } fn ty_infer(&self, _: Option<&ty::GenericParamDef>, span: Span) -> Ty<'tcx> { - self.tcx().sess.delay_span_bug(span, "bad placeholder type"); + placeholder_type_error(self.tcx(), span, &[], vec![span], false); self.tcx().types.err } diff --git a/src/test/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/Makefile b/src/test/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/Makefile new file mode 100644 index 0000000000000..2f16ad3285994 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/Makefile @@ -0,0 +1,17 @@ +# Regression test for issue #68794 +# +# Verify that no text relocations are accidentally introduced by linking a +# minimal rust staticlib. +# +# The test links a rust static library into a shared library, and checks that +# the linker doesn't have to flag the resulting file as containing TEXTRELs. + +-include ../tools.mk + +# only-linux + +all: + $(RUSTC) foo.rs + $(CC) bar.c $(call STATICLIB,foo) -fPIC -shared -o $(call DYLIB,bar) \ + $(EXTRACFLAGS) $(EXTRACXXFLAGS) + readelf -d $(call DYLIB,bar) | grep TEXTREL; test $$? -eq 1 diff --git a/src/test/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/bar.c b/src/test/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/bar.c new file mode 100644 index 0000000000000..bb4036b06e13b --- /dev/null +++ b/src/test/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/bar.c @@ -0,0 +1,6 @@ +void foo(); + +int main() { + foo(); + return 0; +} diff --git a/src/test/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/foo.rs b/src/test/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/foo.rs new file mode 100644 index 0000000000000..a3e865b638ed4 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/foo.rs @@ -0,0 +1,8 @@ +#![crate_type = "staticlib"] + +#[no_mangle] +pub extern "C" fn foo(x: u32) { + // using the println! makes it so that enough code from the standard + // library is included (see issue #68794) + println!("foo: {}", x); +} diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.rs b/src/test/ui/did_you_mean/bad-assoc-ty.rs index fccfb7911cecf..f02931eeb6fc3 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.rs +++ b/src/test/ui/did_you_mean/bad-assoc-ty.rs @@ -17,6 +17,7 @@ type D = (u8, u8)::AssocTy; type E = _::AssocTy; //~^ ERROR missing angle brackets in associated item path //~| ERROR the type placeholder `_` is not allowed within types on item signatures +//~| ERROR the type placeholder `_` is not allowed within types on item signatures type F = &'static (u8)::AssocTy; //~^ ERROR missing angle brackets in associated item path diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.stderr b/src/test/ui/did_you_mean/bad-assoc-ty.stderr index 7d3c99bda6b6a..4fdd407bff3d5 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-ty.stderr @@ -29,25 +29,25 @@ LL | type E = _::AssocTy; | ^^^^^^^^^^ help: try: `<_>::AssocTy` error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:21:19 + --> $DIR/bad-assoc-ty.rs:22:19 | LL | type F = &'static (u8)::AssocTy; | ^^^^^^^^^^^^^ help: try: `<(u8)>::AssocTy` error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:27:10 + --> $DIR/bad-assoc-ty.rs:28:10 | LL | type G = dyn 'static + (Send)::AssocTy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `::AssocTy` error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:44:10 + --> $DIR/bad-assoc-ty.rs:45:10 | LL | type I = ty!()::AssocTy; | ^^^^^^^^^^^^^^ help: try: `::AssocTy` error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:37:19 + --> $DIR/bad-assoc-ty.rs:38:19 | LL | ($ty: ty) => ($ty::AssocTy); | ^^^^^^^^^^^^ help: try: `<$ty>::AssocTy` @@ -85,26 +85,32 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa LL | type E = _::AssocTy; | ^ not allowed in type signatures +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/bad-assoc-ty.rs:17:10 + | +LL | type E = _::AssocTy; + | ^ not allowed in type signatures + error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:21:19 + --> $DIR/bad-assoc-ty.rs:22:19 | LL | type F = &'static (u8)::AssocTy; | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `::AssocTy` error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:27:10 + --> $DIR/bad-assoc-ty.rs:28:10 | LL | type G = dyn 'static + (Send)::AssocTy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::marker::Send + 'static) as Trait>::AssocTy` error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:33:10 + --> $DIR/bad-assoc-ty.rs:34:10 | LL | type H = Fn(u8) -> (u8)::Output; | ^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::ops::Fn(u8) -> u8 + 'static) as Trait>::Output` error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:37:19 + --> $DIR/bad-assoc-ty.rs:38:19 | LL | ($ty: ty) => ($ty::AssocTy); | ^^^^^^^^^^^^ help: use fully-qualified syntax: `::AssocTy` @@ -113,12 +119,12 @@ LL | type J = ty!(u8); | ------- in this macro invocation error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:44:10 + --> $DIR/bad-assoc-ty.rs:45:10 | LL | type I = ty!()::AssocTy; | ^^^^^^^^^^^^^^ help: use fully-qualified syntax: `::AssocTy` -error: aborting due to 19 previous errors +error: aborting due to 20 previous errors Some errors have detailed explanations: E0121, E0223. For more information about an error, try `rustc --explain E0121`. diff --git a/src/test/ui/issues/issue-69396-const-no-type-in-macro.rs b/src/test/ui/issues/issue-69396-const-no-type-in-macro.rs new file mode 100644 index 0000000000000..69fc0c1cbb96b --- /dev/null +++ b/src/test/ui/issues/issue-69396-const-no-type-in-macro.rs @@ -0,0 +1,17 @@ +macro_rules! suite { + ( $( $fn:ident; )* ) => { + $( + const A = "A".$fn(); + //~^ ERROR the name `A` is defined multiple times + //~| ERROR missing type for `const` item + //~| ERROR the type placeholder `_` is not allowed within types + )* + } +} + +suite! { + len; + is_empty; +} + +fn main() {} diff --git a/src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr b/src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr new file mode 100644 index 0000000000000..c12ce166efe7a --- /dev/null +++ b/src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr @@ -0,0 +1,48 @@ +error[E0428]: the name `A` is defined multiple times + --> $DIR/issue-69396-const-no-type-in-macro.rs:4:13 + | +LL | const A = "A".$fn(); + | ^^^^^^^^^^^^^^^^^^^^ + | | + | `A` redefined here + | previous definition of the value `A` here +... +LL | / suite! { +LL | | len; +LL | | is_empty; +LL | | } + | |_- in this macro invocation + | + = note: `A` must be defined only once in the value namespace of this module + +error: missing type for `const` item + --> $DIR/issue-69396-const-no-type-in-macro.rs:4:19 + | +LL | const A = "A".$fn(); + | ^ help: provide a type for the item: `A: usize` +... +LL | / suite! { +LL | | len; +LL | | is_empty; +LL | | } + | |_- in this macro invocation + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/issue-69396-const-no-type-in-macro.rs:4:19 + | +LL | const A = "A".$fn(); + | ^ + | | + | not allowed in type signatures + | help: replace `_` with the correct type: `bool` +... +LL | / suite! { +LL | | len; +LL | | is_empty; +LL | | } + | |_- in this macro invocation + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0121, E0428. +For more information about an error, try `rustc --explain E0121`. diff --git a/src/test/ui/self/self-infer.rs b/src/test/ui/self/self-infer.rs index 0956f2a56918c..77c80521236a0 100644 --- a/src/test/ui/self/self-infer.rs +++ b/src/test/ui/self/self-infer.rs @@ -2,7 +2,9 @@ struct S; impl S { fn f(self: _) {} //~ERROR the type placeholder `_` is not allowed within types on item sig + //~^ ERROR the type placeholder `_` is not allowed within types on item sig fn g(self: &_) {} //~ERROR the type placeholder `_` is not allowed within types on item sig + //~^ ERROR the type placeholder `_` is not allowed within types on item sig } fn main() {} diff --git a/src/test/ui/self/self-infer.stderr b/src/test/ui/self/self-infer.stderr index 1475b212b56a6..d6bf8b44d6099 100644 --- a/src/test/ui/self/self-infer.stderr +++ b/src/test/ui/self/self-infer.stderr @@ -1,3 +1,9 @@ +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/self-infer.rs:4:16 + | +LL | fn f(self: _) {} + | ^ not allowed in type signatures + error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/self-infer.rs:4:16 | @@ -10,7 +16,13 @@ LL | fn f(self: T) {} | ^^^ ^ error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/self-infer.rs:5:17 + --> $DIR/self-infer.rs:6:17 + | +LL | fn g(self: &_) {} + | ^ not allowed in type signatures + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/self-infer.rs:6:17 | LL | fn g(self: &_) {} | ^ not allowed in type signatures @@ -20,6 +32,6 @@ help: use type parameters instead LL | fn g(self: &T) {} | ^^^ ^ -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0121`. diff --git a/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.rs b/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.rs new file mode 100644 index 0000000000000..571692a5374da --- /dev/null +++ b/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.rs @@ -0,0 +1,9 @@ +// Regression test for #69378: no type for node after struct parse recovery + +struct Foo { 0: u8 } //~ ERROR expected identifier + +fn test(f: Foo) { + Foo{foo: 4, ..f}; +} + +fn main() {} diff --git a/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr b/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr new file mode 100644 index 0000000000000..6bc9c8498c9d1 --- /dev/null +++ b/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `0` + --> $DIR/issue-69378-ice-on-invalid-type-node-after-recovery.rs:3:14 + | +LL | struct Foo { 0: u8 } + | ^ expected identifier + +error: aborting due to previous error + diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.rs b/src/test/ui/typeck/typeck_type_placeholder_item.rs deleted file mode 100644 index 86c7c52b27166..0000000000000 --- a/src/test/ui/typeck/typeck_type_placeholder_item.rs +++ /dev/null @@ -1,185 +0,0 @@ -#![feature(type_alias_impl_trait)] // Needed for single test `type Y = impl Trait<_>` -// This test checks that it is not possible to enable global type -// inference by using the `_` type placeholder. - -fn test() -> _ { 5 } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - -fn test2() -> (_, _) { (5, 5) } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - -static TEST3: _ = "test"; -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - -static TEST4: _ = 145; -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - -static TEST5: (_, _) = (1, 2); -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - -fn test6(_: _) { } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - -fn test6_b(_: _, _: T) { } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - -fn test6_c(_: _, _: (T, K, L, A, B)) { } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - -fn test7(x: _) { let _x: usize = x; } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - -fn test8(_f: fn() -> _) { } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures -//~| ERROR the type placeholder `_` is not allowed within types on item signatures - -struct Test9; - -impl Test9 { - fn test9(&self) -> _ { () } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - fn test10(&self, _x : _) { } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures -} - -fn test11(x: &usize) -> &_ { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - &x -} - -unsafe fn test12(x: *const usize) -> *const *const _ { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - &x -} - -impl Clone for Test9 { - fn clone(&self) -> _ { Test9 } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - fn clone_from(&mut self, other: _) { *self = Test9; } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures -} - -struct Test10 { - a: _, - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - b: (_, _), -} - -pub fn main() { - static A = 42; - //~^ ERROR missing type for `static` item - static B: _ = 42; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - static C: Option<_> = Some(42); - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - fn fn_test() -> _ { 5 } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - fn fn_test2() -> (_, _) { (5, 5) } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - static FN_TEST3: _ = "test"; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - static FN_TEST4: _ = 145; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - static FN_TEST5: (_, _) = (1, 2); - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - fn fn_test6(_: _) { } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - fn fn_test7(x: _) { let _x: usize = x; } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - fn fn_test8(_f: fn() -> _) { } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - //~| ERROR the type placeholder `_` is not allowed within types on item signatures - - struct FnTest9; - - impl FnTest9 { - fn fn_test9(&self) -> _ { () } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - fn fn_test10(&self, _x : _) { } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - } - - impl Clone for FnTest9 { - fn clone(&self) -> _ { FnTest9 } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - fn clone_from(&mut self, other: _) { *self = FnTest9; } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - } - - struct FnTest10 { - a: _, - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - b: (_, _), - } - - fn fn_test11(_: _) -> (_, _) { panic!() } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - //~| ERROR type annotations needed - - fn fn_test12(x: i32) -> (_, _) { (x, x) } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - - fn fn_test13(x: _) -> (i32, _) { (x, x) } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures -} - -trait T { - fn method_test1(&self, x: _); - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - fn method_test2(&self, x: _) -> _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - fn method_test3(&self) -> _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - fn assoc_fn_test1(x: _); - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - fn assoc_fn_test2(x: _) -> _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - fn assoc_fn_test3() -> _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures -} - -struct BadStruct<_>(_); -//~^ ERROR expected identifier, found reserved identifier `_` -//~| ERROR the type placeholder `_` is not allowed within types on item signatures -trait BadTrait<_> {} -//~^ ERROR expected identifier, found reserved identifier `_` -impl BadTrait<_> for BadStruct<_> {} -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - -fn impl_trait() -> impl BadTrait<_> { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - unimplemented!() -} - -struct BadStruct1<_, _>(_); -//~^ ERROR expected identifier, found reserved identifier `_` -//~| ERROR expected identifier, found reserved identifier `_` -//~| ERROR the name `_` is already used -//~| ERROR the type placeholder `_` is not allowed within types on item signatures -struct BadStruct2<_, T>(_, T); -//~^ ERROR expected identifier, found reserved identifier `_` -//~| ERROR the type placeholder `_` is not allowed within types on item signatures - -type X = Box<_>; -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures - -struct Struct; -trait Trait {} -impl Trait for Struct {} -type Y = impl Trait<_>; -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures -fn foo() -> Y { - Struct -} diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.stderr b/src/test/ui/typeck/typeck_type_placeholder_item.stderr deleted file mode 100644 index f740a9f7f34b1..0000000000000 --- a/src/test/ui/typeck/typeck_type_placeholder_item.stderr +++ /dev/null @@ -1,552 +0,0 @@ -error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:153:18 - | -LL | struct BadStruct<_>(_); - | ^ expected identifier, found reserved identifier - -error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:156:16 - | -LL | trait BadTrait<_> {} - | ^ expected identifier, found reserved identifier - -error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:166:19 - | -LL | struct BadStruct1<_, _>(_); - | ^ expected identifier, found reserved identifier - -error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:166:22 - | -LL | struct BadStruct1<_, _>(_); - | ^ expected identifier, found reserved identifier - -error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:171:19 - | -LL | struct BadStruct2<_, T>(_, T); - | ^ expected identifier, found reserved identifier - -error[E0403]: the name `_` is already used for a generic parameter in this item's generic parameters - --> $DIR/typeck_type_placeholder_item.rs:166:22 - | -LL | struct BadStruct1<_, _>(_); - | - ^ already used - | | - | first use of `_` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:5:14 - | -LL | fn test() -> _ { 5 } - | ^ - | | - | not allowed in type signatures - | help: replace with the correct return type: `i32` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:8:16 - | -LL | fn test2() -> (_, _) { (5, 5) } - | -^--^- - | || | - | || not allowed in type signatures - | |not allowed in type signatures - | help: replace with the correct return type: `(i32, i32)` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:11:15 - | -LL | static TEST3: _ = "test"; - | ^ - | | - | not allowed in type signatures - | help: replace `_` with the correct type: `&'static str` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:14:15 - | -LL | static TEST4: _ = 145; - | ^ - | | - | not allowed in type signatures - | help: replace `_` with the correct type: `i32` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:17:15 - | -LL | static TEST5: (_, _) = (1, 2); - | ^^^^^^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:20:13 - | -LL | fn test6(_: _) { } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn test6(_: T) { } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:23:18 - | -LL | fn test6_b(_: _, _: T) { } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn test6_b(_: K, _: T) { } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:26:30 - | -LL | fn test6_c(_: _, _: (T, K, L, A, B)) { } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn test6_c(_: C, _: (T, K, L, A, B)) { } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:29:13 - | -LL | fn test7(x: _) { let _x: usize = x; } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn test7(x: T) { let _x: usize = x; } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:32:22 - | -LL | fn test8(_f: fn() -> _) { } - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:32:22 - | -LL | fn test8(_f: fn() -> _) { } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn test8(_f: fn() -> T) { } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:46:26 - | -LL | fn test11(x: &usize) -> &_ { - | -^ - | || - | |not allowed in type signatures - | help: replace with the correct return type: `&&usize` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:51:52 - | -LL | unsafe fn test12(x: *const usize) -> *const *const _ { - | --------------^ - | | | - | | not allowed in type signatures - | help: replace with the correct return type: `*const *const usize` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:65:8 - | -LL | a: _, - | ^ not allowed in type signatures -LL | -LL | b: (_, _), - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures - | -help: use type parameters instead - | -LL | struct Test10 { -LL | a: T, -LL | -LL | b: (T, T), - | - -error: missing type for `static` item - --> $DIR/typeck_type_placeholder_item.rs:71:12 - | -LL | static A = 42; - | ^ help: provide a type for the item: `A: i32` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:73:15 - | -LL | static B: _ = 42; - | ^ - | | - | not allowed in type signatures - | help: replace `_` with the correct type: `i32` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:75:15 - | -LL | static C: Option<_> = Some(42); - | ^^^^^^^^^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:78:21 - | -LL | fn fn_test() -> _ { 5 } - | ^ - | | - | not allowed in type signatures - | help: replace with the correct return type: `i32` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:81:23 - | -LL | fn fn_test2() -> (_, _) { (5, 5) } - | -^--^- - | || | - | || not allowed in type signatures - | |not allowed in type signatures - | help: replace with the correct return type: `(i32, i32)` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:84:22 - | -LL | static FN_TEST3: _ = "test"; - | ^ - | | - | not allowed in type signatures - | help: replace `_` with the correct type: `&'static str` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:87:22 - | -LL | static FN_TEST4: _ = 145; - | ^ - | | - | not allowed in type signatures - | help: replace `_` with the correct type: `i32` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:90:22 - | -LL | static FN_TEST5: (_, _) = (1, 2); - | ^^^^^^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:93:20 - | -LL | fn fn_test6(_: _) { } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn fn_test6(_: T) { } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:96:20 - | -LL | fn fn_test7(x: _) { let _x: usize = x; } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn fn_test7(x: T) { let _x: usize = x; } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:99:29 - | -LL | fn fn_test8(_f: fn() -> _) { } - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:99:29 - | -LL | fn fn_test8(_f: fn() -> _) { } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn fn_test8(_f: fn() -> T) { } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:122:12 - | -LL | a: _, - | ^ not allowed in type signatures -LL | -LL | b: (_, _), - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures - | -help: use type parameters instead - | -LL | struct FnTest10 { -LL | a: T, -LL | -LL | b: (T, T), - | - -error[E0282]: type annotations needed - --> $DIR/typeck_type_placeholder_item.rs:127:27 - | -LL | fn fn_test11(_: _) -> (_, _) { panic!() } - | ^^^^^^ cannot infer type - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:127:28 - | -LL | fn fn_test11(_: _) -> (_, _) { panic!() } - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:131:30 - | -LL | fn fn_test12(x: i32) -> (_, _) { (x, x) } - | -^--^- - | || | - | || not allowed in type signatures - | |not allowed in type signatures - | help: replace with the correct return type: `(i32, i32)` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:134:33 - | -LL | fn fn_test13(x: _) -> (i32, _) { (x, x) } - | ------^- - | | | - | | not allowed in type signatures - | help: replace with the correct return type: `(i32, i32)` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:153:21 - | -LL | struct BadStruct<_>(_); - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | struct BadStruct(T); - | ^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:158:15 - | -LL | impl BadTrait<_> for BadStruct<_> {} - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures - | -help: use type parameters instead - | -LL | impl BadTrait for BadStruct {} - | ^^^ ^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:161:34 - | -LL | fn impl_trait() -> impl BadTrait<_> { - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:166:25 - | -LL | struct BadStruct1<_, _>(_); - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | struct BadStruct1(T); - | ^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:171:25 - | -LL | struct BadStruct2<_, T>(_, T); - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | struct BadStruct2(K, T); - | ^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:175:14 - | -LL | type X = Box<_>; - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:42:27 - | -LL | fn test10(&self, _x : _) { } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn test10(&self, _x : T) { } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:139:31 - | -LL | fn method_test1(&self, x: _); - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn method_test1(&self, x: T); - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:141:31 - | -LL | fn method_test2(&self, x: _) -> _; - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures - | -help: use type parameters instead - | -LL | fn method_test2(&self, x: T) -> T; - | ^^^ ^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:143:31 - | -LL | fn method_test3(&self) -> _; - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn method_test3(&self) -> T; - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:145:26 - | -LL | fn assoc_fn_test1(x: _); - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn assoc_fn_test1(x: T); - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:147:26 - | -LL | fn assoc_fn_test2(x: _) -> _; - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures - | -help: use type parameters instead - | -LL | fn assoc_fn_test2(x: T) -> T; - | ^^^ ^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:149:28 - | -LL | fn assoc_fn_test3() -> _; - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn assoc_fn_test3() -> T; - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:60:37 - | -LL | fn clone_from(&mut self, other: _) { *self = Test9; } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn clone_from(&mut self, other: T) { *self = Test9; } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:109:34 - | -LL | fn fn_test10(&self, _x : _) { } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn fn_test10(&self, _x : T) { } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:117:41 - | -LL | fn clone_from(&mut self, other: _) { *self = FnTest9; } - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL | fn clone_from(&mut self, other: T) { *self = FnTest9; } - | ^^^ ^ - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:181:21 - | -LL | type Y = impl Trait<_>; - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:39:24 - | -LL | fn test9(&self) -> _ { () } - | ^ - | | - | not allowed in type signatures - | help: replace with the correct return type: `()` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:57:24 - | -LL | fn clone(&self) -> _ { Test9 } - | ^ - | | - | not allowed in type signatures - | help: replace with the correct return type: `Test9` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:106:31 - | -LL | fn fn_test9(&self) -> _ { () } - | ^ - | | - | not allowed in type signatures - | help: replace with the correct return type: `()` - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:114:28 - | -LL | fn clone(&self) -> _ { FnTest9 } - | ^ - | | - | not allowed in type signatures - | help: replace with the correct return type: `main::FnTest9` - -error: aborting due to 58 previous errors - -Some errors have detailed explanations: E0121, E0282, E0403. -For more information about an error, try `rustc --explain E0121`.