diff options
| author | bors <bors@rust-lang.org> | 2019-07-23 19:50:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-07-23 19:50:46 +0000 |
| commit | a7f28678bbf4e16893bb6a718e427504167a9494 (patch) | |
| tree | 2aa23f2346e84f1de0ce1756217913edccd742f7 /src/test | |
| parent | 299ef86e1f8b3e53154f834115752c719b611fa1 (diff) | |
| parent | c939db7404fdce109ddf8d2fbfceac6ff99b0e26 (diff) | |
| download | rust-a7f28678bbf4e16893bb6a718e427504167a9494.tar.gz rust-a7f28678bbf4e16893bb6a718e427504167a9494.zip | |
Auto merge of #62902 - Mark-Simulacrum:rollup-mxfk0mm, r=Mark-Simulacrum
Rollup of 14 pull requests Successful merges: - #60951 (more specific errors in src/librustc/mir/interpret/error.rs) - #62523 (Delay bug to resolve HRTB ICE) - #62656 (explain how to search in slice without owned data) - #62791 (Handle more cases of typos misinterpreted as type ascription) - #62804 (rustc_typeck: improve diagnostics for _ const/static declarations) - #62808 (Revert "Disable stack probing for gnux32.") - #62817 (Tweak span for variant not found error) - #62842 (Add tests for issue-58887) - #62851 (move unescape module to rustc_lexer) - #62859 (Place::as_place_ref is now Place::as_ref) - #62869 (add rustc_private as a proper language feature gate) - #62880 (normalize use of backticks in compiler messages for librustc_allocator) - #62885 (Change "OSX" to "macOS") - #62889 (Update stage0.txt) Failed merges: r? @ghost
Diffstat (limited to 'src/test')
39 files changed, 368 insertions, 63 deletions
diff --git a/src/test/ui/allocator/two-allocators.rs b/src/test/ui/allocator/two-allocators.rs index 10fb03c3930..0f81fc41823 100644 --- a/src/test/ui/allocator/two-allocators.rs +++ b/src/test/ui/allocator/two-allocators.rs @@ -4,6 +4,6 @@ use std::alloc::System; static A: System = System; #[global_allocator] static B: System = System; -//~^ ERROR: cannot define more than one #[global_allocator] +//~^ ERROR: cannot define more than one `#[global_allocator]` fn main() {} diff --git a/src/test/ui/allocator/two-allocators.stderr b/src/test/ui/allocator/two-allocators.stderr index da247f6c316..6b0c2b2a25d 100644 --- a/src/test/ui/allocator/two-allocators.stderr +++ b/src/test/ui/allocator/two-allocators.stderr @@ -1,4 +1,4 @@ -error: cannot define more than one #[global_allocator] +error: cannot define more than one `#[global_allocator]` --> $DIR/two-allocators.rs:6:1 | LL | static B: System = System; diff --git a/src/test/ui/codemap_tests/bad-format-args.stderr b/src/test/ui/codemap_tests/bad-format-args.stderr index c424eb08a7a..5b01314d8ad 100644 --- a/src/test/ui/codemap_tests/bad-format-args.stderr +++ b/src/test/ui/codemap_tests/bad-format-args.stderr @@ -10,13 +10,13 @@ error: expected token: `,` --> $DIR/bad-format-args.rs:3:16 | LL | format!("" 1); - | ^ + | ^ expected `,` error: expected token: `,` --> $DIR/bad-format-args.rs:4:19 | LL | format!("", 1 1); - | ^ + | ^ expected `,` error: aborting due to 3 previous errors diff --git a/src/test/ui/error-codes/E0121.stderr b/src/test/ui/error-codes/E0121.stderr index 1a16aab6a41..beb8941320b 100644 --- a/src/test/ui/error-codes/E0121.stderr +++ b/src/test/ui/error-codes/E0121.stderr @@ -11,7 +11,10 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa --> $DIR/E0121.rs:3:13 | LL | static BAR: _ = "test"; - | ^ not allowed in type signatures + | ^ + | | + | not allowed in type signatures + | help: replace `_` with the correct type: `&'static str` error: aborting due to 2 previous errors diff --git a/src/test/ui/existential-type/issue-58887.rs b/src/test/ui/existential-type/issue-58887.rs new file mode 100644 index 00000000000..f038648ec21 --- /dev/null +++ b/src/test/ui/existential-type/issue-58887.rs @@ -0,0 +1,23 @@ +#![feature(existential_type)] + +trait UnwrapItemsExt { + type Iter; + fn unwrap_items(self) -> Self::Iter; +} + +impl<I, T, E> UnwrapItemsExt for I +where + I: Iterator<Item = Result<T, E>>, + E: std::fmt::Debug, +{ + existential type Iter: Iterator<Item = T>; + //~^ ERROR: could not find defining uses + + fn unwrap_items(self) -> Self::Iter { + //~^ ERROR: type parameter `T` is part of concrete type + //~| ERROR: type parameter `E` is part of concrete type + self.map(|x| x.unwrap()) + } +} + +fn main() {} diff --git a/src/test/ui/existential-type/issue-58887.stderr b/src/test/ui/existential-type/issue-58887.stderr new file mode 100644 index 00000000000..800f4b7e059 --- /dev/null +++ b/src/test/ui/existential-type/issue-58887.stderr @@ -0,0 +1,30 @@ +error: type parameter `T` is part of concrete type but not used in parameter list for existential type + --> $DIR/issue-58887.rs:16:41 + | +LL | fn unwrap_items(self) -> Self::Iter { + | _________________________________________^ +LL | | +LL | | +LL | | self.map(|x| x.unwrap()) +LL | | } + | |_____^ + +error: type parameter `E` is part of concrete type but not used in parameter list for existential type + --> $DIR/issue-58887.rs:16:41 + | +LL | fn unwrap_items(self) -> Self::Iter { + | _________________________________________^ +LL | | +LL | | +LL | | self.map(|x| x.unwrap()) +LL | | } + | |_____^ + +error: could not find defining uses + --> $DIR/issue-58887.rs:13:5 + | +LL | existential type Iter: Iterator<Item = T>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/feature-gate/rustc-private.rs b/src/test/ui/feature-gate/rustc-private.rs new file mode 100644 index 00000000000..7b8944bb0a0 --- /dev/null +++ b/src/test/ui/feature-gate/rustc-private.rs @@ -0,0 +1,5 @@ +// gate-test-rustc_private + +extern crate libc; //~ ERROR use of unstable library feature 'rustc_private' + +fn main() {} diff --git a/src/test/ui/feature-gate/rustc-private.stderr b/src/test/ui/feature-gate/rustc-private.stderr new file mode 100644 index 00000000000..be320718145 --- /dev/null +++ b/src/test/ui/feature-gate/rustc-private.stderr @@ -0,0 +1,12 @@ +error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? + --> $DIR/rustc-private.rs:3:1 + | +LL | extern crate libc; + | ^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/27812 + = help: add `#![feature(rustc_private)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.rs b/src/test/ui/hrtb/issue-62203-hrtb-ice.rs new file mode 100644 index 00000000000..454d7e5e9cd --- /dev/null +++ b/src/test/ui/hrtb/issue-62203-hrtb-ice.rs @@ -0,0 +1,50 @@ +trait T0<'a, A> { + type O; +} + +struct L<T> { + f: T, +} + +// explicitly named variants of what one would normally denote by the +// unit type `()`. Why do this? So that we can differentiate them in +// the diagnostic output. +struct Unit1; +struct Unit2; +struct Unit3; +struct Unit4; + +impl<'a, A, T> T0<'a, A> for L<T> +where + T: FnMut(A) -> Unit3, +{ + type O = T::Output; +} + +trait T1: for<'r> Ty<'r> { + fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1 + where + F: for<'r> T0<'r, (<Self as Ty<'r>>::V,), O = <B as Ty<'r>>::V>, + { + unimplemented!(); + } +} + +trait Ty<'a> { + type V; +} + +fn main() { + let v = Unit2.m( + //~^ ERROR type mismatch + //~| ERROR type mismatch + L { + f : |x| { drop(x); Unit4 } + }); +} + +impl<'a> Ty<'a> for Unit2 { + type V = &'a u8; +} + +impl T1 for Unit2 {} diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr new file mode 100644 index 00000000000..c2d0e0c2a26 --- /dev/null +++ b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr @@ -0,0 +1,22 @@ +error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (<Unit2 as Ty<'r>>::V,)>>::O == <_ as Ty<'r>>::V` + --> $DIR/issue-62203-hrtb-ice.rs:38:19 + | +LL | let v = Unit2.m( + | ^ expected struct `Unit4`, found associated type + | + = note: expected type `Unit4` + found type `<_ as Ty<'_>>::V` + +error[E0271]: type mismatch resolving `<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39] as std::ops::FnOnce<((&u8,),)>>::Output == Unit3` + --> $DIR/issue-62203-hrtb-ice.rs:38:19 + | +LL | let v = Unit2.m( + | ^ expected struct `Unit4`, found struct `Unit3` + | + = note: expected type `Unit4` + found type `Unit3` + = note: required because of the requirements on the impl of `for<'r> T0<'r, (<Unit2 as Ty<'r>>::V,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/issues/issue-22644.stderr b/src/test/ui/issues/issue-22644.stderr index 4f0dc0a4887..0fe167963c3 100644 --- a/src/test/ui/issues/issue-22644.stderr +++ b/src/test/ui/issues/issue-22644.stderr @@ -87,15 +87,12 @@ error: expected type, found `4` --> $DIR/issue-22644.rs:34:28 | LL | println!("{}", a: &mut 4); - | ^ expecting a type here because of type ascription + | - ^ expected type + | | + | tried to parse a type due to this type ascription | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` -note: this expression expects an ascribed type after the colon - --> $DIR/issue-22644.rs:34:20 - | -LL | println!("{}", a: &mut 4); - | ^ - = help: this might be indicative of a syntax error elsewhere + = note: for more information, see https://github.com/rust-lang/rust/issues/23416 error: aborting due to 9 previous errors diff --git a/src/test/ui/issues/issue-34255-1.stderr b/src/test/ui/issues/issue-34255-1.stderr index 0218a7abeaa..acb093b5142 100644 --- a/src/test/ui/issues/issue-34255-1.stderr +++ b/src/test/ui/issues/issue-34255-1.stderr @@ -2,15 +2,12 @@ error: expected type, found `42` --> $DIR/issue-34255-1.rs:8:24 | LL | Test::Drill(field: 42); - | ^^ expecting a type here because of type ascription + | - ^^ expected type + | | + | tried to parse a type due to this type ascription | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` -note: this expression expects an ascribed type after the colon - --> $DIR/issue-34255-1.rs:8:17 - | -LL | Test::Drill(field: 42); - | ^^^^^ - = help: this might be indicative of a syntax error elsewhere + = note: for more information, see https://github.com/rust-lang/rust/issues/23416 error: aborting due to previous error diff --git a/src/test/ui/issues/issue-39616.stderr b/src/test/ui/issues/issue-39616.stderr index e24ffcdb0d9..75eb55fa50b 100644 --- a/src/test/ui/issues/issue-39616.stderr +++ b/src/test/ui/issues/issue-39616.stderr @@ -2,7 +2,7 @@ error: expected type, found `0` --> $DIR/issue-39616.rs:1:12 | LL | fn foo(a: [0; 1]) {} - | ^ + | ^ expected type error: expected one of `)`, `,`, `->`, `where`, or `{`, found `]` --> $DIR/issue-39616.rs:1:16 diff --git a/src/test/ui/issues/issue-44406.stderr b/src/test/ui/issues/issue-44406.stderr index 14b3b8cc5c8..108542c9b6f 100644 --- a/src/test/ui/issues/issue-44406.stderr +++ b/src/test/ui/issues/issue-44406.stderr @@ -15,7 +15,10 @@ LL | bar(baz: $rest) | - help: try using a semicolon: `;` ... LL | foo!(true); - | ^^^^ expecting a type here because of type ascription + | ^^^^ expected type + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: for more information, see https://github.com/rust-lang/rust/issues/23416 error: aborting due to 2 previous errors diff --git a/src/test/ui/lifetime_starts_expressions.stderr b/src/test/ui/lifetime_starts_expressions.stderr index 84e4c87ebc4..bacba10b55f 100644 --- a/src/test/ui/lifetime_starts_expressions.stderr +++ b/src/test/ui/lifetime_starts_expressions.stderr @@ -12,15 +12,12 @@ error: expected type, found keyword `loop` --> $DIR/lifetime_starts_expressions.rs:6:26 | LL | loop { break 'label: loop { break 'label 42; }; } - | ^^^^ expecting a type here because of type ascription + | - ^^^^ expected type + | | + | tried to parse a type due to this type ascription | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` -note: this expression expects an ascribed type after the colon - --> $DIR/lifetime_starts_expressions.rs:6:12 - | -LL | loop { break 'label: loop { break 'label 42; }; } - | ^^^^^^^^^^^^ - = help: this might be indicative of a syntax error elsewhere + = note: for more information, see https://github.com/rust-lang/rust/issues/23416 error: aborting due to 2 previous errors diff --git a/src/test/ui/macros/missing-comma.stderr b/src/test/ui/macros/missing-comma.stderr index d5b6d86b20f..f96848f8239 100644 --- a/src/test/ui/macros/missing-comma.stderr +++ b/src/test/ui/macros/missing-comma.stderr @@ -2,7 +2,7 @@ error: expected token: `,` --> $DIR/missing-comma.rs:19:19 | LL | println!("{}" a); - | ^ + | ^ expected `,` error: no rules expected the token `b` --> $DIR/missing-comma.rs:21:12 diff --git a/src/test/ui/parser/issue-33262.stderr b/src/test/ui/parser/issue-33262.stderr index c2491df903b..2aff3283935 100644 --- a/src/test/ui/parser/issue-33262.stderr +++ b/src/test/ui/parser/issue-33262.stderr @@ -2,7 +2,7 @@ error: expected type, found `{` --> $DIR/issue-33262.rs:4:22 | LL | for i in 0..a as { } - | ^ + | ^ expected type error: aborting due to previous error diff --git a/src/test/ui/parser/macro/trait-object-macro-matcher.stderr b/src/test/ui/parser/macro/trait-object-macro-matcher.stderr index 19c5c82f82c..f02f60e4bfb 100644 --- a/src/test/ui/parser/macro/trait-object-macro-matcher.stderr +++ b/src/test/ui/parser/macro/trait-object-macro-matcher.stderr @@ -2,7 +2,7 @@ error: expected type, found `'static` --> $DIR/trait-object-macro-matcher.rs:9:8 | LL | m!('static); - | ^^^^^^^ + | ^^^^^^^ expected type error: aborting due to previous error diff --git a/src/test/ui/parser/recover-enum2.stderr b/src/test/ui/parser/recover-enum2.stderr index 9ed2e6f5eb6..2311887a6fb 100644 --- a/src/test/ui/parser/recover-enum2.stderr +++ b/src/test/ui/parser/recover-enum2.stderr @@ -2,7 +2,7 @@ error: expected type, found `{` --> $DIR/recover-enum2.rs:6:18 | LL | abc: {}, - | ^ + | ^ expected type error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `{` --> $DIR/recover-enum2.rs:25:22 diff --git a/src/test/ui/parser/recover-from-bad-variant.stderr b/src/test/ui/parser/recover-from-bad-variant.stderr index d525bd3f4c6..b46d3ca9c23 100644 --- a/src/test/ui/parser/recover-from-bad-variant.stderr +++ b/src/test/ui/parser/recover-from-bad-variant.stderr @@ -2,15 +2,12 @@ error: expected type, found `3` --> $DIR/recover-from-bad-variant.rs:7:26 | LL | let x = Enum::Foo(a: 3, b: 4); - | ^ expecting a type here because of type ascription + | - ^ expected type + | | + | tried to parse a type due to this type ascription | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` -note: this expression expects an ascribed type after the colon - --> $DIR/recover-from-bad-variant.rs:7:23 - | -LL | let x = Enum::Foo(a: 3, b: 4); - | ^ - = help: this might be indicative of a syntax error elsewhere + = note: for more information, see https://github.com/rust-lang/rust/issues/23416 error[E0532]: expected tuple struct/variant, found struct variant `Enum::Foo` --> $DIR/recover-from-bad-variant.rs:10:9 diff --git a/src/test/ui/parser/removed-syntax-mut-vec-ty.stderr b/src/test/ui/parser/removed-syntax-mut-vec-ty.stderr index a759716b5a9..02b518e2516 100644 --- a/src/test/ui/parser/removed-syntax-mut-vec-ty.stderr +++ b/src/test/ui/parser/removed-syntax-mut-vec-ty.stderr @@ -2,7 +2,7 @@ error: expected type, found keyword `mut` --> $DIR/removed-syntax-mut-vec-ty.rs:1:11 | LL | type v = [mut isize]; - | ^^^ + | ^^^ expected type error: aborting due to previous error diff --git a/src/test/ui/parser/removed-syntax-record.stderr b/src/test/ui/parser/removed-syntax-record.stderr index 730d5e2712b..0a1655840b5 100644 --- a/src/test/ui/parser/removed-syntax-record.stderr +++ b/src/test/ui/parser/removed-syntax-record.stderr @@ -2,7 +2,7 @@ error: expected type, found `{` --> $DIR/removed-syntax-record.rs:1:10 | LL | type t = { f: () }; - | ^ + | ^ expected type error: aborting due to previous error diff --git a/src/test/ui/parser/trait-object-lifetime-parens.stderr b/src/test/ui/parser/trait-object-lifetime-parens.stderr index a31b7aea8fe..7ffc26e9ede 100644 --- a/src/test/ui/parser/trait-object-lifetime-parens.stderr +++ b/src/test/ui/parser/trait-object-lifetime-parens.stderr @@ -29,7 +29,7 @@ error: expected type, found `'a` --> $DIR/trait-object-lifetime-parens.rs:9:17 | LL | let _: Box<('a) + Trait>; - | - ^^ + | - ^^ expected type | | | while parsing the type for `_` diff --git a/src/test/ui/suggestions/suggest-variants.stderr b/src/test/ui/suggestions/suggest-variants.stderr index ef0ba70c340..b4338e20554 100644 --- a/src/test/ui/suggestions/suggest-variants.stderr +++ b/src/test/ui/suggestions/suggest-variants.stderr @@ -23,9 +23,7 @@ LL | enum Shape { | ---------- variant `Rombus` not found here ... LL | println!("My shape is {:?}", Shape::Rombus{ size: 5}); - | -------^^^^^^ - | | - | variant not found in `Shape` + | ^^^^^^ variant not found in `Shape` error[E0599]: no variant or associated item named `Squareee` found for type `Shape` in the current scope --> $DIR/suggest-variants.rs:15:12 diff --git a/src/test/ui/suggestions/type-ascription-instead-of-method.stderr b/src/test/ui/suggestions/type-ascription-instead-of-method.stderr index 15ec087b1cc..4a8d2f57d89 100644 --- a/src/test/ui/suggestions/type-ascription-instead-of-method.stderr +++ b/src/test/ui/suggestions/type-ascription-instead-of-method.stderr @@ -2,9 +2,12 @@ error: expected type, found `"foo"` --> $DIR/type-ascription-instead-of-method.rs:2:13 | LL | Box:new("foo".to_string()) - | - ^^^^^ expecting a type here because of type ascription + | - ^^^^^ expected type | | - | help: maybe you meant to write a path separator here: `::` + | help: maybe write a path separator here: `::` + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: for more information, see https://github.com/rust-lang/rust/issues/23416 error: aborting due to previous error diff --git a/src/test/ui/suggestions/type-ascription-instead-of-variant.stderr b/src/test/ui/suggestions/type-ascription-instead-of-variant.stderr index 5719a667a84..7e9a31c06c8 100644 --- a/src/test/ui/suggestions/type-ascription-instead-of-variant.stderr +++ b/src/test/ui/suggestions/type-ascription-instead-of-variant.stderr @@ -2,9 +2,12 @@ error: expected type, found `""` --> $DIR/type-ascription-instead-of-variant.rs:2:25 | LL | let _ = Option:Some(""); - | - ^^ expecting a type here because of type ascription + | - ^^ expected type | | - | help: maybe you meant to write a path separator here: `::` + | help: maybe write a path separator here: `::` + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: for more information, see https://github.com/rust-lang/rust/issues/23416 error: aborting due to previous error diff --git a/src/test/ui/type/ascription/issue-34255-1.rs b/src/test/ui/type/ascription/issue-34255-1.rs new file mode 100644 index 00000000000..c11a248d3c7 --- /dev/null +++ b/src/test/ui/type/ascription/issue-34255-1.rs @@ -0,0 +1,15 @@ +struct Reactor { + input_cells: Vec<usize>, +} + +impl Reactor { + pub fn new() -> Self { + input_cells: Vec::new() + //~^ ERROR cannot find value `input_cells` in this scope + //~| ERROR parenthesized type parameters may only be used with a `Fn` trait + //~| ERROR wrong number of type arguments: expected 1, found 0 + //~| WARNING this was previously accepted by the compiler but is being phased out + } +} + +// This case isn't currently being handled gracefully, including for completeness. diff --git a/src/test/ui/type/ascription/issue-34255-1.stderr b/src/test/ui/type/ascription/issue-34255-1.stderr new file mode 100644 index 00000000000..531455b82b4 --- /dev/null +++ b/src/test/ui/type/ascription/issue-34255-1.stderr @@ -0,0 +1,30 @@ +error[E0425]: cannot find value `input_cells` in this scope + --> $DIR/issue-34255-1.rs:7:9 + | +LL | input_cells: Vec::new() + | ^^^^^^^^^^^ a field by this name exists in `Self` + +error: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-34255-1.rs:7:30 + | +LL | input_cells: Vec::new() + | ^^ + | + = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238> + +error[E0601]: `main` function not found in crate `issue_34255_1` + | + = note: consider adding a `main` function to `$DIR/issue-34255-1.rs` + +error[E0107]: wrong number of type arguments: expected 1, found 0 + --> $DIR/issue-34255-1.rs:7:22 + | +LL | input_cells: Vec::new() + | ^^^^^^^^^^ expected 1 type argument + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0107, E0425, E0601. +For more information about an error, try `rustc --explain E0107`. diff --git a/src/test/ui/type/ascription/issue-47666.rs b/src/test/ui/type/ascription/issue-47666.rs new file mode 100644 index 00000000000..ceb1dd89dae --- /dev/null +++ b/src/test/ui/type/ascription/issue-47666.rs @@ -0,0 +1,5 @@ +fn main() { + let _ = Option:Some(vec![0, 1]); //~ ERROR expected type, found +} + +// This case isn't currently being handled gracefully due to the macro invocation. diff --git a/src/test/ui/type/ascription/issue-47666.stderr b/src/test/ui/type/ascription/issue-47666.stderr new file mode 100644 index 00000000000..7aa899f795c --- /dev/null +++ b/src/test/ui/type/ascription/issue-47666.stderr @@ -0,0 +1,13 @@ +error: expected type, found reserved keyword `box` + --> $DIR/issue-47666.rs:2:25 + | +LL | let _ = Option:Some(vec![0, 1]); + | ^^^^^^^^^^ + | | + | expected type + | in this macro invocation + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/type/ascription/issue-54516.rs b/src/test/ui/type/ascription/issue-54516.rs new file mode 100644 index 00000000000..6d65760e299 --- /dev/null +++ b/src/test/ui/type/ascription/issue-54516.rs @@ -0,0 +1,6 @@ +use std::collections::BTreeMap; + +fn main() { + println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>()); + //~^ ERROR expected token: `,` +} diff --git a/src/test/ui/type/ascription/issue-54516.stderr b/src/test/ui/type/ascription/issue-54516.stderr new file mode 100644 index 00000000000..a846f3bc320 --- /dev/null +++ b/src/test/ui/type/ascription/issue-54516.stderr @@ -0,0 +1,13 @@ +error: expected token: `,` + --> $DIR/issue-54516.rs:4:58 + | +LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>()); + | - ^ expected `,` + | | + | help: maybe write a path separator here: `::` + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: for more information, see https://github.com/rust-lang/rust/issues/23416 + +error: aborting due to previous error + diff --git a/src/test/ui/type/ascription/issue-60933.rs b/src/test/ui/type/ascription/issue-60933.rs new file mode 100644 index 00000000000..8fb06c887bd --- /dev/null +++ b/src/test/ui/type/ascription/issue-60933.rs @@ -0,0 +1,4 @@ +fn main() { + let u: usize = std::mem:size_of::<u32>(); + //~^ ERROR expected one of +} diff --git a/src/test/ui/type/ascription/issue-60933.stderr b/src/test/ui/type/ascription/issue-60933.stderr new file mode 100644 index 00000000000..c2fc7bbcfc8 --- /dev/null +++ b/src/test/ui/type/ascription/issue-60933.stderr @@ -0,0 +1,13 @@ +error: expected one of `!`, `::`, or `;`, found `(` + --> $DIR/issue-60933.rs:2:43 + | +LL | let u: usize = std::mem:size_of::<u32>(); + | - ^ expected one of `!`, `::`, or `;` here + | | + | help: maybe write a path separator here: `::` + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: for more information, see https://github.com/rust-lang/rust/issues/23416 + +error: aborting due to previous error + diff --git a/src/test/ui/type/type-ascription-instead-of-initializer.stderr b/src/test/ui/type/type-ascription-instead-of-initializer.stderr index a22d25697d8..3fe676de59d 100644 --- a/src/test/ui/type/type-ascription-instead-of-initializer.stderr +++ b/src/test/ui/type/type-ascription-instead-of-initializer.stderr @@ -2,7 +2,7 @@ error: expected type, found `10` --> $DIR/type-ascription-instead-of-initializer.rs:2:31 | LL | let x: Vec::with_capacity(10, 20); - | -- ^^ + | -- ^^ expected type | || | |help: use `=` if you meant to assign | while parsing the type for `x` diff --git a/src/test/ui/type/type-ascription-instead-of-statement-end.stderr b/src/test/ui/type/type-ascription-instead-of-statement-end.stderr index 1f8989db814..8fbcb3969a7 100644 --- a/src/test/ui/type/type-ascription-instead-of-statement-end.stderr +++ b/src/test/ui/type/type-ascription-instead-of-statement-end.stderr @@ -4,21 +4,21 @@ error: expected type, found `0` LL | println!("test"): | - help: try using a semicolon: `;` LL | 0; - | ^ expecting a type here because of type ascription + | ^ expected type + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: for more information, see https://github.com/rust-lang/rust/issues/23416 error: expected type, found `0` --> $DIR/type-ascription-instead-of-statement-end.rs:9:23 | LL | println!("test"): 0; - | ^ expecting a type here because of type ascription + | - ^ expected type + | | + | tried to parse a type due to this type ascription | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` -note: this expression expects an ascribed type after the colon - --> $DIR/type-ascription-instead-of-statement-end.rs:9:5 - | -LL | println!("test"): 0; - | ^^^^^^^^^^^^^^^^ - = help: this might be indicative of a syntax error elsewhere + = note: for more information, see https://github.com/rust-lang/rust/issues/23416 error: aborting due to 2 previous errors diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.stderr b/src/test/ui/typeck/typeck_type_placeholder_item.stderr index ddaa5de4d3e..2b4d9966c3d 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item.stderr +++ b/src/test/ui/typeck/typeck_type_placeholder_item.stderr @@ -23,13 +23,19 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa --> $DIR/typeck_type_placeholder_item.rs:11:15 | LL | static TEST3: _ = "test"; - | ^ not allowed in type signatures + | ^ + | | + | 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 + | ^ + | | + | 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:16 @@ -122,13 +128,19 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa --> $DIR/typeck_type_placeholder_item.rs:64:22 | LL | static FN_TEST3: _ = "test"; - | ^ not allowed in type signatures + | ^ + | | + | 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:67:22 | LL | static FN_TEST4: _ = 145; - | ^ not allowed in type signatures + | ^ + | | + | 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:70:23 diff --git a/src/test/ui/typeck/typeck_type_placeholder_item_help.rs b/src/test/ui/typeck/typeck_type_placeholder_item_help.rs index 5f4cb4c1316..905fc35350e 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item_help.rs +++ b/src/test/ui/typeck/typeck_type_placeholder_item_help.rs @@ -4,6 +4,24 @@ fn test1() -> _ { Some(42) } //~^ ERROR the type placeholder `_` is not allowed within types on item signatures +const TEST2: _ = 42u32; +//~^ ERROR the type placeholder `_` is not allowed within types on item signatures + +const TEST3: _ = Some(42); +//~^ ERROR the type placeholder `_` is not allowed within types on item signatures + +trait Test4 { + const TEST4: _ = 42; + //~^ ERROR the type placeholder `_` is not allowed within types on item signatures +} + +struct Test5; + +impl Test5 { + const TEST5: _ = 13; + //~^ ERROR the type placeholder `_` is not allowed within types on item signatures +} + pub fn main() { let _: Option<usize> = test1(); let _: f64 = test1(); diff --git a/src/test/ui/typeck/typeck_type_placeholder_item_help.stderr b/src/test/ui/typeck/typeck_type_placeholder_item_help.stderr index 7fb5549825c..c5b9566290c 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item_help.stderr +++ b/src/test/ui/typeck/typeck_type_placeholder_item_help.stderr @@ -7,6 +7,42 @@ LL | fn test1() -> _ { Some(42) } | not allowed in type signatures | help: replace `_` with the correct return type: `std::option::Option<i32>` -error: aborting due to previous error +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item_help.rs:7:14 + | +LL | const TEST2: _ = 42u32; + | ^ + | | + | not allowed in type signatures + | help: replace `_` with the correct type: `u32` + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item_help.rs:10:14 + | +LL | const TEST3: _ = Some(42); + | ^ + | | + | not allowed in type signatures + | help: replace `_` with the correct type: `std::option::Option<i32>` + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item_help.rs:14:18 + | +LL | const TEST4: _ = 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_help.rs:21:18 + | +LL | const TEST5: _ = 13; + | ^ + | | + | not allowed in type signatures + | help: replace `_` with the correct type: `i32` + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0121`. |
