about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-07-20 07:03:54 +0000
committerbors <bors@rust-lang.org>2022-07-20 07:03:54 +0000
commit748cb1f01d623f2afd0d8b84fda7e2c8f7a11c7b (patch)
tree9acf078061e8970bf2cf81193a29f9e09ce1b400 /src
parent03d488b48af9f66b91e9400387f781b82411fa82 (diff)
parentd7a65a55584368500314384e526378d50c60bdd1 (diff)
downloadrust-748cb1f01d623f2afd0d8b84fda7e2c8f7a11c7b.tar.gz
rust-748cb1f01d623f2afd0d8b84fda7e2c8f7a11c7b.zip
Auto merge of #99493 - Dylan-DPC:rollup-lli4gcx, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #98784 (Suggest returning local on "expected `ty`, found `()`" due to expr-less block)
 - #98916 (Windows: Use `FindFirstFileW` for getting the metadata of locked system files)
 - #99433 (Erase regions before comparing signatures of foreign fns.)
 - #99452 (int_macros was only using to_xe_bytes_doc and not from_xe_bytes_doc)
 - #99481 (Add regression test for #71547)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/async-await/async-block-control-flow-static-semantics.stderr18
-rw-r--r--src/test/ui/const-generics/issues/issue-71547.rs18
-rw-r--r--src/test/ui/foreign/issue-99276-same-type-lifetimes.rs24
-rw-r--r--src/test/ui/liveness/liveness-forgot-ret.stderr5
-rw-r--r--src/test/ui/parser/issues/issue-33413.stderr5
-rw-r--r--src/test/ui/suggestions/return-bindings-multi.rs9
-rw-r--r--src/test/ui/suggestions/return-bindings-multi.stderr34
-rw-r--r--src/test/ui/suggestions/return-bindings.fixed23
-rw-r--r--src/test/ui/suggestions/return-bindings.rs21
-rw-r--r--src/test/ui/suggestions/return-bindings.stderr48
10 files changed, 196 insertions, 9 deletions
diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr
index e5887689690..ada6e357aea 100644
--- a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr
+++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr
@@ -18,6 +18,14 @@ LL | |             break 0u8;
 LL | |         };
    | |_________- enclosing `async` block
 
+error[E0271]: type mismatch resolving `<impl Future<Output = u8> as Future>::Output == ()`
+  --> $DIR/async-block-control-flow-static-semantics.rs:26:39
+   |
+LL |     let _: &dyn Future<Output = ()> = &block;
+   |                                       ^^^^^^ expected `()`, found `u8`
+   |
+   = note: required for the cast from `impl Future<Output = u8>` to the object type `dyn Future<Output = ()>`
+
 error[E0308]: mismatched types
   --> $DIR/async-block-control-flow-static-semantics.rs:21:58
    |
@@ -32,7 +40,7 @@ LL | | }
    | |_^ expected `u8`, found `()`
 
 error[E0271]: type mismatch resolving `<impl Future<Output = u8> as Future>::Output == ()`
-  --> $DIR/async-block-control-flow-static-semantics.rs:26:39
+  --> $DIR/async-block-control-flow-static-semantics.rs:17:39
    |
 LL |     let _: &dyn Future<Output = ()> = &block;
    |                                       ^^^^^^ expected `()`, found `u8`
@@ -47,14 +55,6 @@ LL | fn return_targets_async_block_not_fn() -> u8 {
    |    |
    |    implicitly returns `()` as its body has no tail or `return` expression
 
-error[E0271]: type mismatch resolving `<impl Future<Output = u8> as Future>::Output == ()`
-  --> $DIR/async-block-control-flow-static-semantics.rs:17:39
-   |
-LL |     let _: &dyn Future<Output = ()> = &block;
-   |                                       ^^^^^^ expected `()`, found `u8`
-   |
-   = note: required for the cast from `impl Future<Output = u8>` to the object type `dyn Future<Output = ()>`
-
 error[E0308]: mismatched types
   --> $DIR/async-block-control-flow-static-semantics.rs:47:44
    |
diff --git a/src/test/ui/const-generics/issues/issue-71547.rs b/src/test/ui/const-generics/issues/issue-71547.rs
new file mode 100644
index 00000000000..60776a1a985
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-71547.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+#![feature(adt_const_params)]
+#![allow(incomplete_features)]
+
+pub trait GetType<const N: &'static str> {
+    type Ty;
+    fn get(&self) -> &Self::Ty;
+}
+
+pub fn get_val<T>(value: &T) -> &T::Ty
+where
+    T: GetType<"hello">,
+{
+    value.get()
+}
+
+fn main() {}
diff --git a/src/test/ui/foreign/issue-99276-same-type-lifetimes.rs b/src/test/ui/foreign/issue-99276-same-type-lifetimes.rs
new file mode 100644
index 00000000000..fce603c801f
--- /dev/null
+++ b/src/test/ui/foreign/issue-99276-same-type-lifetimes.rs
@@ -0,0 +1,24 @@
+// Check that we do not ICE when structurally comparing types with lifetimes present.
+// check-pass
+
+pub struct Record<'a> {
+    pub args: &'a [(usize, &'a str)],
+}
+
+mod a {
+    extern "Rust" {
+        fn foo<'a, 'b>(record: &'a super::Record<'b>);
+
+        fn bar<'a, 'b>(record: &'a super::Record<'b>);
+    }
+}
+
+mod b {
+    extern "Rust" {
+        fn foo<'a, 'b>(record: &'a super::Record<'b>);
+
+        fn bar<'a, 'b>(record: &'a super::Record<'b>);
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/liveness/liveness-forgot-ret.stderr b/src/test/ui/liveness/liveness-forgot-ret.stderr
index 95070322bdd..ddbdbdb0fd0 100644
--- a/src/test/ui/liveness/liveness-forgot-ret.stderr
+++ b/src/test/ui/liveness/liveness-forgot-ret.stderr
@@ -5,6 +5,11 @@ LL | fn f(a: isize) -> isize { if god_exists(a) { return 5; }; }
    |    -              ^^^^^ expected `isize`, found `()`
    |    |
    |    implicitly returns `()` as its body has no tail or `return` expression
+   |
+help: consider returning the local binding `a`
+   |
+LL | fn f(a: isize) -> isize { if god_exists(a) { return 5; }; a }
+   |                                                           +
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/parser/issues/issue-33413.stderr b/src/test/ui/parser/issues/issue-33413.stderr
index ac320f095a2..b7250f3b0b5 100644
--- a/src/test/ui/parser/issues/issue-33413.stderr
+++ b/src/test/ui/parser/issues/issue-33413.stderr
@@ -11,6 +11,11 @@ LL |     fn f(*, a: u8) -> u8 {}
    |        -              ^^ expected `u8`, found `()`
    |        |
    |        implicitly returns `()` as its body has no tail or `return` expression
+   |
+help: consider returning the local binding `a`
+   |
+LL |     fn f(*, a: u8) -> u8 { a }
+   |                            +
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/suggestions/return-bindings-multi.rs b/src/test/ui/suggestions/return-bindings-multi.rs
new file mode 100644
index 00000000000..8c3bd641e97
--- /dev/null
+++ b/src/test/ui/suggestions/return-bindings-multi.rs
@@ -0,0 +1,9 @@
+fn a(i: i32) -> i32 {
+    //~^ ERROR mismatched types
+    let j = 2i32;
+}
+
+fn b(i: i32, j: i32) -> i32 {}
+//~^ ERROR mismatched types
+
+fn main() {}
diff --git a/src/test/ui/suggestions/return-bindings-multi.stderr b/src/test/ui/suggestions/return-bindings-multi.stderr
new file mode 100644
index 00000000000..738e3f2f4be
--- /dev/null
+++ b/src/test/ui/suggestions/return-bindings-multi.stderr
@@ -0,0 +1,34 @@
+error[E0308]: mismatched types
+  --> $DIR/return-bindings-multi.rs:1:17
+   |
+LL | fn a(i: i32) -> i32 {
+   |    -            ^^^ expected `i32`, found `()`
+   |    |
+   |    implicitly returns `()` as its body has no tail or `return` expression
+   |
+note: consider returning one of these bindings
+  --> $DIR/return-bindings-multi.rs:1:6
+   |
+LL | fn a(i: i32) -> i32 {
+   |      ^
+LL |
+LL |     let j = 2i32;
+   |         ^
+
+error[E0308]: mismatched types
+  --> $DIR/return-bindings-multi.rs:6:25
+   |
+LL | fn b(i: i32, j: i32) -> i32 {}
+   |    -                    ^^^ expected `i32`, found `()`
+   |    |
+   |    implicitly returns `()` as its body has no tail or `return` expression
+   |
+note: consider returning one of these bindings
+  --> $DIR/return-bindings-multi.rs:6:6
+   |
+LL | fn b(i: i32, j: i32) -> i32 {}
+   |      ^       ^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/return-bindings.fixed b/src/test/ui/suggestions/return-bindings.fixed
new file mode 100644
index 00000000000..4fabc411abc
--- /dev/null
+++ b/src/test/ui/suggestions/return-bindings.fixed
@@ -0,0 +1,23 @@
+// run-rustfix
+
+#![allow(unused)]
+
+fn a(i: i32) -> i32 { i }
+//~^ ERROR mismatched types
+
+fn b(opt_str: Option<String>) {
+    let s: String = if let Some(s) = opt_str {
+        s
+    //~^ ERROR mismatched types
+    } else {
+        String::new()
+    };
+}
+
+fn c() -> Option<i32> {
+    //~^ ERROR mismatched types
+    let x = Some(1);
+    x
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/return-bindings.rs b/src/test/ui/suggestions/return-bindings.rs
new file mode 100644
index 00000000000..d05b4ba27d6
--- /dev/null
+++ b/src/test/ui/suggestions/return-bindings.rs
@@ -0,0 +1,21 @@
+// run-rustfix
+
+#![allow(unused)]
+
+fn a(i: i32) -> i32 {}
+//~^ ERROR mismatched types
+
+fn b(opt_str: Option<String>) {
+    let s: String = if let Some(s) = opt_str {
+        //~^ ERROR mismatched types
+    } else {
+        String::new()
+    };
+}
+
+fn c() -> Option<i32> {
+    //~^ ERROR mismatched types
+    let x = Some(1);
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/return-bindings.stderr b/src/test/ui/suggestions/return-bindings.stderr
new file mode 100644
index 00000000000..e5d49255005
--- /dev/null
+++ b/src/test/ui/suggestions/return-bindings.stderr
@@ -0,0 +1,48 @@
+error[E0308]: mismatched types
+  --> $DIR/return-bindings.rs:5:17
+   |
+LL | fn a(i: i32) -> i32 {}
+   |    -            ^^^ expected `i32`, found `()`
+   |    |
+   |    implicitly returns `()` as its body has no tail or `return` expression
+   |
+help: consider returning the local binding `i`
+   |
+LL | fn a(i: i32) -> i32 { i }
+   |                       +
+
+error[E0308]: mismatched types
+  --> $DIR/return-bindings.rs:9:46
+   |
+LL |       let s: String = if let Some(s) = opt_str {
+   |  ______________________________________________^
+LL | |
+LL | |     } else {
+   | |_____^ expected struct `String`, found `()`
+   |
+help: consider returning the local binding `s`
+   |
+LL ~     let s: String = if let Some(s) = opt_str {
+LL +         s
+LL ~
+   |
+
+error[E0308]: mismatched types
+  --> $DIR/return-bindings.rs:16:11
+   |
+LL | fn c() -> Option<i32> {
+   |    -      ^^^^^^^^^^^ expected enum `Option`, found `()`
+   |    |
+   |    implicitly returns `()` as its body has no tail or `return` expression
+   |
+   = note:   expected enum `Option<i32>`
+           found unit type `()`
+help: consider returning the local binding `x`
+   |
+LL ~     let x = Some(1);
+LL +     x
+   |
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.