diff options
| author | bors <bors@rust-lang.org> | 2022-06-06 08:02:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-06 08:02:38 +0000 |
| commit | e70c60d34b9783a2fd3171d88d248c2e0ec8ecdd (patch) | |
| tree | 5408b1ac29becada73eddc0d75196e5b1e66d289 /src/test | |
| parent | 6609c6734de4df43e24d7672f8ae8786ecc8047e (diff) | |
| parent | 1258fa9d9be2811497c03235cd3db60aad6a9763 (diff) | |
| download | rust-e70c60d34b9783a2fd3171d88d248c2e0ec8ecdd.tar.gz rust-e70c60d34b9783a2fd3171d88d248c2e0ec8ecdd.zip | |
Auto merge of #97783 - matthiaskrgr:rollup-14t9htt, r=matthiaskrgr
Rollup of 7 pull requests
Successful merges:
- #90905 (Add empty impl blocks if they have documentation)
- #97683 (Fail gracefully when encountering an HRTB in APIT. )
- #97721 (Do `suggest_await_before_try` with infer variables in self, and clean up binders)
- #97752 (typo: `-Zcodegen-backend=llvm -Cpasses=list` should work now)
- #97759 (Suggest adding `{}` for `'label: non_block_expr`)
- #97764 (use strict provenance APIs)
- #97765 (Restore a test that was intended to test `as` cast to ptr)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/rustdoc/empty-impl-block.rs | 20 | ||||
| -rw-r--r-- | src/test/ui/cast/casts-issue-46365.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/universal_wrong_hrtb.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/universal_wrong_hrtb.stderr | 14 | ||||
| -rw-r--r-- | src/test/ui/parser/labeled-no-colon-expr.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/parser/recover-labeled-non-block-expr.fixed | 27 | ||||
| -rw-r--r-- | src/test/ui/parser/recover-labeled-non-block-expr.rs | 26 | ||||
| -rw-r--r-- | src/test/ui/parser/recover-labeled-non-block-expr.stderr | 80 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-97704.fixed | 19 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-97704.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-97704.stderr | 15 |
11 files changed, 223 insertions, 14 deletions
diff --git a/src/test/rustdoc/empty-impl-block.rs b/src/test/rustdoc/empty-impl-block.rs new file mode 100644 index 00000000000..6a2a254f63a --- /dev/null +++ b/src/test/rustdoc/empty-impl-block.rs @@ -0,0 +1,20 @@ +#![crate_name = "foo"] + +// @has 'foo/struct.Foo.html' +pub struct Foo; + +// @has - '//*[@class="docblock"]' 'Hello empty impl block!' +// @has - '//*[@class="item-info"]' 'This impl block contains no items.' +/// Hello empty impl block! +impl Foo {} +// We ensure that this empty impl block without doc isn't rendered. +// @count - '//*[@class="impl has-srclink"]' 'impl Foo' 1 +impl Foo {} + +// Just to ensure that empty trait impl blocks are rendered. +pub struct Another; +pub trait Bar {} + +// @has 'foo/struct.Another.html' +// @has - '//h3[@class="code-header in-band"]' 'impl Bar for Another' +impl Bar for Another {} diff --git a/src/test/ui/cast/casts-issue-46365.rs b/src/test/ui/cast/casts-issue-46365.rs index a2205b718c1..50aa1a856a7 100644 --- a/src/test/ui/cast/casts-issue-46365.rs +++ b/src/test/ui/cast/casts-issue-46365.rs @@ -3,5 +3,6 @@ struct Lorem { } fn main() { - let _foo: *mut Lorem = core::ptr::NonNull::dangling().as_ptr(); // no error here + // Testing `as` casts, so deliberately not using `ptr::null`. + let _foo: *mut Lorem = 0 as *mut _; // no error here } diff --git a/src/test/ui/impl-trait/universal_wrong_hrtb.rs b/src/test/ui/impl-trait/universal_wrong_hrtb.rs new file mode 100644 index 00000000000..b9551c2ceb0 --- /dev/null +++ b/src/test/ui/impl-trait/universal_wrong_hrtb.rs @@ -0,0 +1,8 @@ +trait Trait<'a> { + type Assoc; +} + +fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {} +//~^ ERROR `impl Trait` can only mention lifetimes bound at the fn or impl level + +fn main() {} diff --git a/src/test/ui/impl-trait/universal_wrong_hrtb.stderr b/src/test/ui/impl-trait/universal_wrong_hrtb.stderr new file mode 100644 index 00000000000..37eb8dfa1a1 --- /dev/null +++ b/src/test/ui/impl-trait/universal_wrong_hrtb.stderr @@ -0,0 +1,14 @@ +error: `impl Trait` can only mention lifetimes bound at the fn or impl level + --> $DIR/universal_wrong_hrtb.rs:5:73 + | +LL | fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {} + | ^^ + | +note: lifetime declared here + --> $DIR/universal_wrong_hrtb.rs:5:39 + | +LL | fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {} + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/labeled-no-colon-expr.stderr b/src/test/ui/parser/labeled-no-colon-expr.stderr index 26884dc5d74..5c9597c440c 100644 --- a/src/test/ui/parser/labeled-no-colon-expr.stderr +++ b/src/test/ui/parser/labeled-no-colon-expr.stderr @@ -47,6 +47,12 @@ error: expected `while`, `for`, `loop` or `{` after a label | LL | 'l4 0; | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: consider removing the label + | +LL - 'l4 0; +LL + 0; + | error: labeled expression must be followed by `:` --> $DIR/labeled-no-colon-expr.rs:8:9 diff --git a/src/test/ui/parser/recover-labeled-non-block-expr.fixed b/src/test/ui/parser/recover-labeled-non-block-expr.fixed new file mode 100644 index 00000000000..fe546a71971 --- /dev/null +++ b/src/test/ui/parser/recover-labeled-non-block-expr.fixed @@ -0,0 +1,27 @@ +// run-rustfix +#![feature(label_break_value)] +fn main() { + let _ = 1 + 1; //~ ERROR expected `while`, `for`, `loop` or `{` after a label + + match () { () => {}, }; //~ ERROR expected `while`, `for`, `loop` or `{` after a label + 'label: { match () { () => break 'label, } }; //~ ERROR expected `while`, `for`, `loop` or `{` after a label + #[allow(unused_labels)] + 'label: { match () { () => 'lp: loop { break 'lp 0 }, } }; //~ ERROR expected `while`, `for`, `loop` or `{` after a label + + let x = 1; + let _i = 'label: { match x { //~ ERROR expected `while`, `for`, `loop` or `{` after a label + 0 => 42, + 1 if false => break 'label 17, + 1 => { + if true { + break 'label 13 + } else { + break 'label 0; + } + } + _ => 1, + } }; + + let other = 3; + let _val = 'label: { (1, if other == 3 { break 'label (2, 3) } else { other }) }; //~ ERROR expected `while`, `for`, `loop` or `{` after a label +} diff --git a/src/test/ui/parser/recover-labeled-non-block-expr.rs b/src/test/ui/parser/recover-labeled-non-block-expr.rs index be92170acf0..35862e2eef9 100644 --- a/src/test/ui/parser/recover-labeled-non-block-expr.rs +++ b/src/test/ui/parser/recover-labeled-non-block-expr.rs @@ -1,5 +1,27 @@ +// run-rustfix +#![feature(label_break_value)] fn main() { - 'label: 1 + 1; //~ ERROR expected `while`, `for`, `loop` or `{` after a label + let _ = 'label: 1 + 1; //~ ERROR expected `while`, `for`, `loop` or `{` after a label - let _recovery_witness: () = 0; //~ ERROR mismatched types + 'label: match () { () => {}, }; //~ ERROR expected `while`, `for`, `loop` or `{` after a label + 'label: match () { () => break 'label, }; //~ ERROR expected `while`, `for`, `loop` or `{` after a label + #[allow(unused_labels)] + 'label: match () { () => 'lp: loop { break 'lp 0 }, }; //~ ERROR expected `while`, `for`, `loop` or `{` after a label + + let x = 1; + let _i = 'label: match x { //~ ERROR expected `while`, `for`, `loop` or `{` after a label + 0 => 42, + 1 if false => break 'label 17, + 1 => { + if true { + break 'label 13 + } else { + break 'label 0; + } + } + _ => 1, + }; + + let other = 3; + let _val = 'label: (1, if other == 3 { break 'label (2, 3) } else { other }); //~ ERROR expected `while`, `for`, `loop` or `{` after a label } diff --git a/src/test/ui/parser/recover-labeled-non-block-expr.stderr b/src/test/ui/parser/recover-labeled-non-block-expr.stderr index 771a915288c..767389c4808 100644 --- a/src/test/ui/parser/recover-labeled-non-block-expr.stderr +++ b/src/test/ui/parser/recover-labeled-non-block-expr.stderr @@ -1,17 +1,75 @@ error: expected `while`, `for`, `loop` or `{` after a label - --> $DIR/recover-labeled-non-block-expr.rs:2:13 + --> $DIR/recover-labeled-non-block-expr.rs:4:21 | -LL | 'label: 1 + 1; - | ^ expected `while`, `for`, `loop` or `{` after a label +LL | let _ = 'label: 1 + 1; + | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: consider removing the label + | +LL - let _ = 'label: 1 + 1; +LL + let _ = 1 + 1; + | + +error: expected `while`, `for`, `loop` or `{` after a label + --> $DIR/recover-labeled-non-block-expr.rs:6:13 + | +LL | 'label: match () { () => {}, }; + | ^^^^^ expected `while`, `for`, `loop` or `{` after a label + | +help: consider removing the label + | +LL - 'label: match () { () => {}, }; +LL + match () { () => {}, }; + | -error[E0308]: mismatched types - --> $DIR/recover-labeled-non-block-expr.rs:4:33 +error: expected `while`, `for`, `loop` or `{` after a label + --> $DIR/recover-labeled-non-block-expr.rs:7:13 + | +LL | 'label: match () { () => break 'label, }; + | ^^^^^ expected `while`, `for`, `loop` or `{` after a label + | +help: consider enclosing expression in a block + | +LL | 'label: { match () { () => break 'label, } }; + | + + + +error: expected `while`, `for`, `loop` or `{` after a label + --> $DIR/recover-labeled-non-block-expr.rs:9:13 + | +LL | 'label: match () { () => 'lp: loop { break 'lp 0 }, }; + | ^^^^^ expected `while`, `for`, `loop` or `{` after a label + | +help: consider enclosing expression in a block + | +LL | 'label: { match () { () => 'lp: loop { break 'lp 0 }, } }; + | + + + +error: expected `while`, `for`, `loop` or `{` after a label + --> $DIR/recover-labeled-non-block-expr.rs:12:22 + | +LL | let _i = 'label: match x { + | ^^^^^ expected `while`, `for`, `loop` or `{` after a label + | +help: consider enclosing expression in a block + | +LL ~ let _i = 'label: { match x { +LL | 0 => 42, +LL | 1 if false => break 'label 17, +LL | 1 => { +LL | if true { +LL | break 'label 13 + ... + +error: expected `while`, `for`, `loop` or `{` after a label + --> $DIR/recover-labeled-non-block-expr.rs:26:24 + | +LL | let _val = 'label: (1, if other == 3 { break 'label (2, 3) } else { other }); + | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: consider enclosing expression in a block | -LL | let _recovery_witness: () = 0; - | -- ^ expected `()`, found integer - | | - | expected due to this +LL | let _val = 'label: { (1, if other == 3 { break 'label (2, 3) } else { other }) }; + | + + -error: aborting due to 2 previous errors +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/suggestions/issue-97704.fixed b/src/test/ui/suggestions/issue-97704.fixed new file mode 100644 index 00000000000..c42bdfff5f9 --- /dev/null +++ b/src/test/ui/suggestions/issue-97704.fixed @@ -0,0 +1,19 @@ +// edition:2021 +// run-rustfix + +#![allow(unused)] + +use std::future::Future; + +async fn foo() -> Result<(), i32> { + func(async { Ok::<_, i32>(()) }).await?; + //~^ ERROR the `?` operator can only be applied to values that implement `Try` + + Ok(()) +} + +async fn func<T>(fut: impl Future<Output = T>) -> T { + fut.await +} + +fn main() {} diff --git a/src/test/ui/suggestions/issue-97704.rs b/src/test/ui/suggestions/issue-97704.rs new file mode 100644 index 00000000000..5dfee6cac60 --- /dev/null +++ b/src/test/ui/suggestions/issue-97704.rs @@ -0,0 +1,19 @@ +// edition:2021 +// run-rustfix + +#![allow(unused)] + +use std::future::Future; + +async fn foo() -> Result<(), i32> { + func(async { Ok::<_, i32>(()) })?; + //~^ ERROR the `?` operator can only be applied to values that implement `Try` + + Ok(()) +} + +async fn func<T>(fut: impl Future<Output = T>) -> T { + fut.await +} + +fn main() {} diff --git a/src/test/ui/suggestions/issue-97704.stderr b/src/test/ui/suggestions/issue-97704.stderr new file mode 100644 index 00000000000..ca017be45ac --- /dev/null +++ b/src/test/ui/suggestions/issue-97704.stderr @@ -0,0 +1,15 @@ +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/issue-97704.rs:9:5 + | +LL | func(async { Ok::<_, i32>(()) })?; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `?` operator cannot be applied to type `impl Future<Output = Result<(), i32>>` + | + = help: the trait `Try` is not implemented for `impl Future<Output = Result<(), i32>>` +help: consider `await`ing on the `Future` + | +LL | func(async { Ok::<_, i32>(()) }).await?; + | ++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
