diff options
| author | bors <bors@rust-lang.org> | 2020-10-27 01:36:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-10-27 01:36:12 +0000 |
| commit | 28f03ac4c08fc7ec62428d0b914e1510ce7ee2cb (patch) | |
| tree | c3f0b0308ea3548fd1319b0721d9d90b4f17d0d3 /src/test | |
| parent | a4d30a7b490065f0aa56f58e508a11546445aea9 (diff) | |
| parent | 4236d27c9bb0af5cbdfaaa840b211827c65fb1ee (diff) | |
| download | rust-28f03ac4c08fc7ec62428d0b914e1510ce7ee2cb.tar.gz rust-28f03ac4c08fc7ec62428d0b914e1510ce7ee2cb.zip | |
Auto merge of #78421 - JohnTitor:rollup-bq2d7fo, r=JohnTitor
Rollup of 16 pull requests Successful merges: - #76635 (Add [T]::as_chunks(_mut)) - #77703 (add system-llvm-libunwind config option) - #78219 (Prefer to use `print_def_path`) - #78298 (Add test for bad NLL higher-ranked subtype) - #78332 (Update description for error E0308) - #78342 (Use check-pass in single-use-lifetime ui tests) - #78347 (Add lexicographical comparison doc) - #78348 (Make some functions private that don't have to be public) - #78349 (Use its own `TypeckResults` to avoid ICE) - #78375 (Use ? in core/std macros) - #78377 (Fix typo in debug statement) - #78388 (Add some regression tests) - #78394 (fix(docs): typo in BufWriter documentation) - #78396 (Add compiler support for LLVM's x86_64 ERMSB feature) - #78405 (Fix typo in lint description) - #78412 (Improve formatting of hash collections docs) Failed merges: r? `@ghost`
Diffstat (limited to 'src/test')
19 files changed, 329 insertions, 136 deletions
diff --git a/src/test/ui/impl-trait/bound-normalization-pass.stderr b/src/test/ui/impl-trait/bound-normalization-pass.default.stderr index afc181a906a..ef3cb740112 100644 --- a/src/test/ui/impl-trait/bound-normalization-pass.stderr +++ b/src/test/ui/impl-trait/bound-normalization-pass.default.stderr @@ -1,5 +1,5 @@ warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/bound-normalization-pass.rs:5:12 + --> $DIR/bound-normalization-pass.rs:8:12 | LL | #![feature(impl_trait_in_bindings)] | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/impl-trait/bound-normalization-pass.rs b/src/test/ui/impl-trait/bound-normalization-pass.rs index fff17667fda..3e6884ef10f 100644 --- a/src/test/ui/impl-trait/bound-normalization-pass.rs +++ b/src/test/ui/impl-trait/bound-normalization-pass.rs @@ -1,5 +1,8 @@ // check-pass // edition:2018 +// revisions: default sa +//[sa] compile-flags: -Z save-analysis +//-^ To make this the regression test for #75962. #![feature(type_alias_impl_trait)] #![feature(impl_trait_in_bindings)] diff --git a/src/test/ui/impl-trait/bound-normalization-pass.sa.stderr b/src/test/ui/impl-trait/bound-normalization-pass.sa.stderr new file mode 100644 index 00000000000..ef3cb740112 --- /dev/null +++ b/src/test/ui/impl-trait/bound-normalization-pass.sa.stderr @@ -0,0 +1,11 @@ +warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/bound-normalization-pass.rs:8:12 + | +LL | #![feature(impl_trait_in_bindings)] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information + +warning: 1 warning emitted + diff --git a/src/test/ui/issues/issue-75763.rs b/src/test/ui/issues/issue-75763.rs new file mode 100644 index 00000000000..2fd9f9a60de --- /dev/null +++ b/src/test/ui/issues/issue-75763.rs @@ -0,0 +1,15 @@ +// build-pass + +#![allow(incomplete_features)] +#![feature(const_generics)] + +struct Bug<const S: &'static str>; + +fn main() { + let b: Bug::<{ + unsafe { + // FIXME(const_generics): Decide on how to deal with invalid values as const params. + std::mem::transmute::<&[u8], &str>(&[0xC0, 0xC1, 0xF5]) + } + }>; +} diff --git a/src/test/ui/issues/issue-76179.rs b/src/test/ui/issues/issue-76179.rs new file mode 100644 index 00000000000..0e086968b90 --- /dev/null +++ b/src/test/ui/issues/issue-76179.rs @@ -0,0 +1,19 @@ +// check-pass + +#![feature(associated_type_defaults)] + +use std::io::Read; + +trait View { + type Deserializers: Deserializer<Item = Self::RequestParams>; + type RequestParams = DefaultRequestParams; +} + +struct DefaultRequestParams; + +trait Deserializer { + type Item; + fn deserialize(r: impl Read) -> Self::Item; +} + +fn main() {} diff --git a/src/test/ui/json-bom-plus-crlf-multifile.stderr b/src/test/ui/json-bom-plus-crlf-multifile.stderr index b222334eda9..da8849a8284 100644 --- a/src/test/ui/json-bom-plus-crlf-multifile.stderr +++ b/src/test/ui/json-bom-plus-crlf-multifile.stderr @@ -1,81 +1,113 @@ {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. -Erroneous code example: +Erroneous code examples: ```compile_fail,E0308 -let x: i32 = \"I am not a number!\"; -// ~~~ ~~~~~~~~~~~~~~~~~~~~ -// | | -// | initializing expression; -// | compiler infers type `&str` -// | -// type `i32` assigned to variable `x` +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this ``` -This error occurs when the compiler is unable to infer the concrete type of a -variable. It can occur in several cases, the most common being a mismatch -between two types: the type the author explicitly assigned, and the type the -compiler inferred. +This error occurs when an expression was used in a place where the compiler +expected an expression of a different type. It can occur in several cases, the +most common being when calling a function and passing an argument which has a +different type than the matching type in the function declaration. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":612,"byte_end":618,"line_start":17,"line_end":17,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:17:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. -Erroneous code example: +Erroneous code examples: ```compile_fail,E0308 -let x: i32 = \"I am not a number!\"; -// ~~~ ~~~~~~~~~~~~~~~~~~~~ -// | | -// | initializing expression; -// | compiler infers type `&str` -// | -// type `i32` assigned to variable `x` +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this ``` -This error occurs when the compiler is unable to infer the concrete type of a -variable. It can occur in several cases, the most common being a mismatch -between two types: the type the author explicitly assigned, and the type the -compiler inferred. +This error occurs when an expression was used in a place where the compiler +expected an expression of a different type. It can occur in several cases, the +most common being when calling a function and passing an argument which has a +different type than the matching type in the function declaration. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":672,"byte_end":678,"line_start":19,"line_end":19,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:19:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. -Erroneous code example: +Erroneous code examples: ```compile_fail,E0308 -let x: i32 = \"I am not a number!\"; -// ~~~ ~~~~~~~~~~~~~~~~~~~~ -// | | -// | initializing expression; -// | compiler infers type `&str` -// | -// type `i32` assigned to variable `x` +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this ``` -This error occurs when the compiler is unable to infer the concrete type of a -variable. It can occur in several cases, the most common being a mismatch -between two types: the type the author explicitly assigned, and the type the -compiler inferred. +This error occurs when an expression was used in a place where the compiler +expected an expression of a different type. It can occur in several cases, the +most common being when calling a function and passing an argument which has a +different type than the matching type in the function declaration. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":735,"byte_end":741,"line_start":22,"line_end":22,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String =","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:23:1: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. -Erroneous code example: +Erroneous code examples: ```compile_fail,E0308 -let x: i32 = \"I am not a number!\"; -// ~~~ ~~~~~~~~~~~~~~~~~~~~ -// | | -// | initializing expression; -// | compiler infers type `&str` -// | -// type `i32` assigned to variable `x` +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this ``` -This error occurs when the compiler is unable to infer the concrete type of a -variable. It can occur in several cases, the most common being a mismatch -between two types: the type the author explicitly assigned, and the type the -compiler inferred. +This error occurs when an expression was used in a place where the compiler +expected an expression of a different type. It can occur in several cases, the +most common being when calling a function and passing an argument which has a +different type than the matching type in the function declaration. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":801,"byte_end":809,"line_start":25,"line_end":26,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `String`, found `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":792,"byte_end":798,"line_start":25,"line_end":25,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = (","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:25:22: error[E0308]: mismatched types "} {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors diff --git a/src/test/ui/json-bom-plus-crlf.stderr b/src/test/ui/json-bom-plus-crlf.stderr index 6041366dbd8..811206f9aa0 100644 --- a/src/test/ui/json-bom-plus-crlf.stderr +++ b/src/test/ui/json-bom-plus-crlf.stderr @@ -1,81 +1,113 @@ {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. -Erroneous code example: +Erroneous code examples: ```compile_fail,E0308 -let x: i32 = \"I am not a number!\"; -// ~~~ ~~~~~~~~~~~~~~~~~~~~ -// | | -// | initializing expression; -// | compiler infers type `&str` -// | -// type `i32` assigned to variable `x` +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this ``` -This error occurs when the compiler is unable to infer the concrete type of a -variable. It can occur in several cases, the most common being a mismatch -between two types: the type the author explicitly assigned, and the type the -compiler inferred. +This error occurs when an expression was used in a place where the compiler +expected an expression of a different type. It can occur in several cases, the +most common being when calling a function and passing an argument which has a +different type than the matching type in the function declaration. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":606,"byte_end":607,"line_start":16,"line_end":16,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":597,"byte_end":603,"line_start":16,"line_end":16,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":606,"byte_end":607,"line_start":16,"line_end":16,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:16:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. -Erroneous code example: +Erroneous code examples: ```compile_fail,E0308 -let x: i32 = \"I am not a number!\"; -// ~~~ ~~~~~~~~~~~~~~~~~~~~ -// | | -// | initializing expression; -// | compiler infers type `&str` -// | -// type `i32` assigned to variable `x` +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this ``` -This error occurs when the compiler is unable to infer the concrete type of a -variable. It can occur in several cases, the most common being a mismatch -between two types: the type the author explicitly assigned, and the type the -compiler inferred. +This error occurs when an expression was used in a place where the compiler +expected an expression of a different type. It can occur in several cases, the +most common being when calling a function and passing an argument which has a +different type than the matching type in the function declaration. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":666,"byte_end":667,"line_start":18,"line_end":18,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":657,"byte_end":663,"line_start":18,"line_end":18,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":666,"byte_end":667,"line_start":18,"line_end":18,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:18:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. -Erroneous code example: +Erroneous code examples: ```compile_fail,E0308 -let x: i32 = \"I am not a number!\"; -// ~~~ ~~~~~~~~~~~~~~~~~~~~ -// | | -// | initializing expression; -// | compiler infers type `&str` -// | -// type `i32` assigned to variable `x` +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this ``` -This error occurs when the compiler is unable to infer the concrete type of a -variable. It can occur in several cases, the most common being a mismatch -between two types: the type the author explicitly assigned, and the type the -compiler inferred. +This error occurs when an expression was used in a place where the compiler +expected an expression of a different type. It can occur in several cases, the +most common being when calling a function and passing an argument which has a +different type than the matching type in the function declaration. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":730,"byte_end":731,"line_start":22,"line_end":22,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":720,"byte_end":726,"line_start":21,"line_end":21,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String =","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":730,"byte_end":731,"line_start":22,"line_end":22,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:22:1: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. -Erroneous code example: +Erroneous code examples: ```compile_fail,E0308 -let x: i32 = \"I am not a number!\"; -// ~~~ ~~~~~~~~~~~~~~~~~~~~ -// | | -// | initializing expression; -// | compiler infers type `&str` -// | -// type `i32` assigned to variable `x` +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this ``` -This error occurs when the compiler is unable to infer the concrete type of a -variable. It can occur in several cases, the most common being a mismatch -between two types: the type the author explicitly assigned, and the type the -compiler inferred. +This error occurs when an expression was used in a place where the compiler +expected an expression of a different type. It can occur in several cases, the +most common being when calling a function and passing an argument which has a +different type than the matching type in the function declaration. "},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":786,"byte_end":794,"line_start":24,"line_end":25,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `String`, found `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":777,"byte_end":783,"line_start":24,"line_end":24,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = (","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf.rs:24:22: error[E0308]: mismatched types "} {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors diff --git a/src/test/ui/nll/issue-57642-higher-ranked-subtype.rs b/src/test/ui/nll/issue-57642-higher-ranked-subtype.rs new file mode 100644 index 00000000000..36c54628317 --- /dev/null +++ b/src/test/ui/nll/issue-57642-higher-ranked-subtype.rs @@ -0,0 +1,41 @@ +// Regression test for issue #57642 +// Tests that we reject a bad higher-ranked subtype +// with `#![feature(nll)]` + +#![feature(nll)] + +trait X { + type G; + fn make_g() -> Self::G; +} + +impl<'a> X for fn(&'a ()) { + type G = &'a (); + + fn make_g() -> Self::G { + &() + } +} + +trait Y { + type F; + fn make_f() -> Self::F; +} + +impl<T> Y for fn(T) { + type F = fn(T); + + fn make_f() -> Self::F { + |_| {} + } +} + +fn higher_ranked_region_has_lost_its_binder() { + let x = <fn (&())>::make_g(); //~ ERROR no function +} + +fn magical() { + let x = <fn (&())>::make_f(); //~ ERROR no function +} + +fn main() {} diff --git a/src/test/ui/nll/issue-57642-higher-ranked-subtype.stderr b/src/test/ui/nll/issue-57642-higher-ranked-subtype.stderr new file mode 100644 index 00000000000..f6909819342 --- /dev/null +++ b/src/test/ui/nll/issue-57642-higher-ranked-subtype.stderr @@ -0,0 +1,31 @@ +error[E0599]: no function or associated item named `make_g` found for fn pointer `for<'r> fn(&'r ())` in the current scope + --> $DIR/issue-57642-higher-ranked-subtype.rs:34:25 + | +LL | let x = <fn (&())>::make_g(); + | ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())` + | + = note: the method `make_g` exists but the following trait bounds were not satisfied: + `for<'r> fn(&'r ()): X` + = help: items from traits can only be used if the trait is implemented and in scope +note: `X` defines an item `make_g`, perhaps you need to implement it + --> $DIR/issue-57642-higher-ranked-subtype.rs:7:1 + | +LL | trait X { + | ^^^^^^^ + +error[E0599]: no function or associated item named `make_f` found for fn pointer `for<'r> fn(&'r ())` in the current scope + --> $DIR/issue-57642-higher-ranked-subtype.rs:38:25 + | +LL | let x = <fn (&())>::make_f(); + | ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())` + | + = help: items from traits can only be used if the trait is implemented and in scope +note: `Y` defines an item `make_f`, perhaps you need to implement it + --> $DIR/issue-57642-higher-ranked-subtype.rs:20:1 + | +LL | trait Y { + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/parser/issue-62894.stderr b/src/test/ui/parser/issue-62894.stderr index 93d43bda32d..cf3727c9d57 100644 --- a/src/test/ui/parser/issue-62894.stderr +++ b/src/test/ui/parser/issue-62894.stderr @@ -45,7 +45,7 @@ LL | fn main() {} | ::: $SRC_DIR/core/src/macros/mod.rs:LL:COL | -LL | ($left:expr, $right:expr) => ({ +LL | ($left:expr, $right:expr $(,)?) => ({ | ---------- while parsing argument for this `expr` macro fragment error: aborting due to 4 previous errors diff --git a/src/test/ui/single-use-lifetime/one-use-in-fn-return.rs b/src/test/ui/single-use-lifetime/one-use-in-fn-return.rs index d9d7e66d0ca..7b7ff08da7c 100644 --- a/src/test/ui/single-use-lifetime/one-use-in-fn-return.rs +++ b/src/test/ui/single-use-lifetime/one-use-in-fn-return.rs @@ -5,11 +5,12 @@ // (Normally, using `'static` would be preferred, but there are // times when that is not what you want.) -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![deny(single_use_lifetimes)] -fn b<'a>() -> &'a u32 { // OK: used only in return type +// OK: used only in return type +fn b<'a>() -> &'a u32 { &22 } diff --git a/src/test/ui/single-use-lifetime/one-use-in-struct.rs b/src/test/ui/single-use-lifetime/one-use-in-struct.rs index 7285324ef63..9082aa68ed2 100644 --- a/src/test/ui/single-use-lifetime/one-use-in-struct.rs +++ b/src/test/ui/single-use-lifetime/one-use-in-struct.rs @@ -2,27 +2,26 @@ // even when they are only used once (since to not use a named // lifetime is illegal!) // -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![deny(single_use_lifetimes)] #![allow(dead_code)] #![allow(unused_variables)] struct Foo<'f> { - data: &'f u32 + data: &'f u32, } enum Bar<'f> { - Data(&'f u32) + Data(&'f u32), } -trait Baz<'f> { } +trait Baz<'f> {} // `Derive`d impls shouldn't trigger a warning, either (Issue #53738). - #[derive(Debug)] struct Quux<'a> { priors: &'a u32, } -fn main() { } +fn main() {} diff --git a/src/test/ui/single-use-lifetime/two-uses-in-fn-argument-and-return.rs b/src/test/ui/single-use-lifetime/two-uses-in-fn-argument-and-return.rs index 8efe806b6e6..f80f3f63c66 100644 --- a/src/test/ui/single-use-lifetime/two-uses-in-fn-argument-and-return.rs +++ b/src/test/ui/single-use-lifetime/two-uses-in-fn-argument-and-return.rs @@ -1,14 +1,15 @@ // Test that we DO NOT warn when lifetime name is used in // both the argument and return. // -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![deny(single_use_lifetimes)] #![allow(dead_code)] #![allow(unused_variables)] -fn c<'a>(x: &'a u32) -> &'a u32 { // OK: used twice +// OK: used twice +fn c<'a>(x: &'a u32) -> &'a u32 { &22 } -fn main() { } +fn main() {} diff --git a/src/test/ui/single-use-lifetime/two-uses-in-fn-arguments.rs b/src/test/ui/single-use-lifetime/two-uses-in-fn-arguments.rs index 09b01d8b05b..51724ebf898 100644 --- a/src/test/ui/single-use-lifetime/two-uses-in-fn-arguments.rs +++ b/src/test/ui/single-use-lifetime/two-uses-in-fn-arguments.rs @@ -1,16 +1,16 @@ // Test that we DO NOT warn when lifetime name is used multiple // arguments, or more than once in a single argument. // -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![deny(single_use_lifetimes)] #![allow(dead_code)] #![allow(unused_variables)] -fn c<'a>(x: &'a u32, y: &'a u32) { // OK: used twice -} +// OK: used twice +fn c<'a>(x: &'a u32, y: &'a u32) {} -fn d<'a>(x: (&'a u32, &'a u32)) { // OK: used twice -} +// OK: used twice +fn d<'a>(x: (&'a u32, &'a u32)) {} -fn main() { } +fn main() {} diff --git a/src/test/ui/single-use-lifetime/two-uses-in-inherent-impl-header.rs b/src/test/ui/single-use-lifetime/two-uses-in-inherent-impl-header.rs index eb85a148e60..125a395db3b 100644 --- a/src/test/ui/single-use-lifetime/two-uses-in-inherent-impl-header.rs +++ b/src/test/ui/single-use-lifetime/two-uses-in-inherent-impl-header.rs @@ -1,18 +1,17 @@ // Test that we DO NOT warn for a lifetime used twice in an impl. // -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![deny(single_use_lifetimes)] #![allow(dead_code)] #![allow(unused_variables)] struct Foo<'f> { - data: &'f u32 + data: &'f u32, } impl<'f> Foo<'f> { - fn inherent_a(&self, data: &'f u32) { - } + fn inherent_a(&self, data: &'f u32) {} } -fn main() { } +fn main() {} diff --git a/src/test/ui/single-use-lifetime/two-uses-in-trait-impl.rs b/src/test/ui/single-use-lifetime/two-uses-in-trait-impl.rs index fd8c899f4fa..16431a39fd0 100644 --- a/src/test/ui/single-use-lifetime/two-uses-in-trait-impl.rs +++ b/src/test/ui/single-use-lifetime/two-uses-in-trait-impl.rs @@ -1,14 +1,14 @@ // Test that we DO NOT warn for a lifetime on an impl used in both // header and in an associated type. // -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![deny(single_use_lifetimes)] #![allow(dead_code)] #![allow(unused_variables)] struct Foo<'f> { - data: &'f u32 + data: &'f u32, } impl<'f> Iterator for Foo<'f> { @@ -19,4 +19,4 @@ impl<'f> Iterator for Foo<'f> { } } -fn main() { } +fn main() {} diff --git a/src/test/ui/target-feature/gate.rs b/src/test/ui/target-feature/gate.rs index e4b78c76e16..164830fecee 100644 --- a/src/test/ui/target-feature/gate.rs +++ b/src/test/ui/target-feature/gate.rs @@ -26,6 +26,7 @@ // gate-test-rtm_target_feature // gate-test-f16c_target_feature // gate-test-riscv_target_feature +// gate-test-ermsb_target_feature #[target_feature(enable = "avx512bw")] //~^ ERROR: currently unstable diff --git a/src/test/ui/target-feature/gate.stderr b/src/test/ui/target-feature/gate.stderr index 2384a00aa47..2d6abcc0a01 100644 --- a/src/test/ui/target-feature/gate.stderr +++ b/src/test/ui/target-feature/gate.stderr @@ -1,5 +1,5 @@ error[E0658]: the target feature `avx512bw` is currently unstable - --> $DIR/gate.rs:30:18 + --> $DIR/gate.rs:31:18 | LL | #[target_feature(enable = "avx512bw")] | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/terminal-width/flag-json.stderr b/src/test/ui/terminal-width/flag-json.stderr index 29730ccdd4e..93c246cb3f5 100644 --- a/src/test/ui/terminal-width/flag-json.stderr +++ b/src/test/ui/terminal-width/flag-json.stderr @@ -1,21 +1,29 @@ {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type. -Erroneous code example: +Erroneous code examples: ```compile_fail,E0308 -let x: i32 = \"I am not a number!\"; -// ~~~ ~~~~~~~~~~~~~~~~~~~~ -// | | -// | initializing expression; -// | compiler infers type `&str` -// | -// type `i32` assigned to variable `x` +fn plus_one(x: i32) -> i32 { + x + 1 +} + +plus_one(\"Not a number\"); +// ^^^^^^^^^^^^^^ expected `i32`, found `&str` + +if \"Not a bool\" { +// ^^^^^^^^^^^^ expected `bool`, found `&str` +} + +let x: f32 = \"Not a float\"; +// --- ^^^^^^^^^^^^^ expected `f32`, found `&str` +// | +// expected due to this ``` -This error occurs when the compiler is unable to infer the concrete type of a -variable. It can occur in several cases, the most common being a mismatch -between two types: the type the author explicitly assigned, and the type the -compiler inferred. +This error occurs when an expression was used in a place where the compiler +expected an expression of a different type. It can occur in several cases, the +most common being when calling a function and passing an argument which has a +different type than the matching type in the function declaration. "},"level":"error","spans":[{"file_name":"$DIR/flag-json.rs","byte_start":244,"byte_end":246,"line_start":7,"line_end":7,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":" let _: () = 42;","highlight_start":17,"highlight_end":19}],"label":"expected `()`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/flag-json.rs","byte_start":239,"byte_end":241,"line_start":7,"line_end":7,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":" let _: () = 42;","highlight_start":12,"highlight_end":14}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types --> $DIR/flag-json.rs:7:17 | |
