diff options
| author | bors <bors@rust-lang.org> | 2023-08-02 23:04:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-02 23:04:27 +0000 |
| commit | 736ef39a84cafc879818781094c897bfbb0bf7bc (patch) | |
| tree | 745d6a92a3660c7f9b1d4f6f0815ee2683ce07ca /tests | |
| parent | 8131b9774ebcb6c162fcac71545a13543ec369e7 (diff) | |
| parent | ac25636a8f1efa40d368eaec363b01b748e193a1 (diff) | |
| download | rust-736ef39a84cafc879818781094c897bfbb0bf7bc.tar.gz rust-736ef39a84cafc879818781094c897bfbb0bf7bc.zip | |
Auto merge of #107254 - chenyukang:yukang/fix-107113-wrong-sugg-in-macro, r=estebank
Avoid wrong code suggesting for attribute macro Fixes #107113 r? `@estebank`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/coercion/coerce-block-tail-83783.fixed | 13 | ||||
| -rw-r--r-- | tests/ui/coercion/coerce-block-tail-83783.rs | 2 | ||||
| -rw-r--r-- | tests/ui/coercion/coerce-block-tail-83783.stderr | 4 | ||||
| -rw-r--r-- | tests/ui/proc-macro/auxiliary/issue-107113.rs | 13 | ||||
| -rw-r--r-- | tests/ui/proc-macro/issue-107113-wrap.rs | 8 | ||||
| -rw-r--r-- | tests/ui/proc-macro/issue-107113-wrap.stderr | 16 |
6 files changed, 55 insertions, 1 deletions
diff --git a/tests/ui/coercion/coerce-block-tail-83783.fixed b/tests/ui/coercion/coerce-block-tail-83783.fixed new file mode 100644 index 00000000000..0df0a64ac96 --- /dev/null +++ b/tests/ui/coercion/coerce-block-tail-83783.fixed @@ -0,0 +1,13 @@ +// run-rustfix +// edition:2018 +fn _consume_reference<T: ?Sized>(_: &T) {} + +async fn _foo() { + _consume_reference::<i32>(&Box::new(7_i32)); + _consume_reference::<i32>(&*async { Box::new(7_i32) }.await); + //~^ ERROR mismatched types + _consume_reference::<[i32]>(&vec![7_i32]); + _consume_reference::<[i32]>(&async { vec![7_i32] }.await); +} + +fn main() { } diff --git a/tests/ui/coercion/coerce-block-tail-83783.rs b/tests/ui/coercion/coerce-block-tail-83783.rs index 18c8ae3bbba..ee6036b4d67 100644 --- a/tests/ui/coercion/coerce-block-tail-83783.rs +++ b/tests/ui/coercion/coerce-block-tail-83783.rs @@ -1,4 +1,4 @@ -// check-fail +// run-rustfix // edition:2018 fn _consume_reference<T: ?Sized>(_: &T) {} diff --git a/tests/ui/coercion/coerce-block-tail-83783.stderr b/tests/ui/coercion/coerce-block-tail-83783.stderr index d556d013bb5..da3c387773f 100644 --- a/tests/ui/coercion/coerce-block-tail-83783.stderr +++ b/tests/ui/coercion/coerce-block-tail-83783.stderr @@ -6,6 +6,10 @@ LL | _consume_reference::<i32>(&async { Box::new(7_i32) }.await); | = note: expected type `i32` found struct `Box<i32>` +help: consider unboxing the value + | +LL | _consume_reference::<i32>(&*async { Box::new(7_i32) }.await); + | + error: aborting due to previous error diff --git a/tests/ui/proc-macro/auxiliary/issue-107113.rs b/tests/ui/proc-macro/auxiliary/issue-107113.rs new file mode 100644 index 00000000000..b27d3fd2fbd --- /dev/null +++ b/tests/ui/proc-macro/auxiliary/issue-107113.rs @@ -0,0 +1,13 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn main(_: TokenStream, item: TokenStream) -> TokenStream { + "fn main() -> std::io::Result<()> { () } ".parse().unwrap() +} diff --git a/tests/ui/proc-macro/issue-107113-wrap.rs b/tests/ui/proc-macro/issue-107113-wrap.rs new file mode 100644 index 00000000000..bc5b44963f7 --- /dev/null +++ b/tests/ui/proc-macro/issue-107113-wrap.rs @@ -0,0 +1,8 @@ +// edition:2021 +// aux-build:issue-107113.rs + +#[macro_use] +extern crate issue_107113; + +#[issue_107113::main] //~ ERROR mismatched types [E0308] +async fn main() -> std::io::Result<()> {} diff --git a/tests/ui/proc-macro/issue-107113-wrap.stderr b/tests/ui/proc-macro/issue-107113-wrap.stderr new file mode 100644 index 00000000000..4122253d22f --- /dev/null +++ b/tests/ui/proc-macro/issue-107113-wrap.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/issue-107113-wrap.rs:7:1 + | +LL | #[issue_107113::main] + | ^^^^^^^^^^^^^^^^^^^^^ + | | + | expected `Result<(), Error>`, found `()` + | expected `Result<(), std::io::Error>` because of return type + | + = note: expected enum `Result<(), std::io::Error>` + found unit type `()` + = note: this error originates in the attribute macro `issue_107113::main` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. |
