diff options
| author | bors <bors@rust-lang.org> | 2021-09-08 17:26:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-09-08 17:26:17 +0000 |
| commit | 47ae8deb8a35030bdc4e502b03400800864cc264 (patch) | |
| tree | d54ceba095ccad99db82466854201635442cea25 /src/test | |
| parent | c9db3e0fbc84d8409285698486375f080d361ef3 (diff) | |
| parent | 4cb751e1f4ea6b9925e9be8984851f01d0003e30 (diff) | |
Auto merge of #88750 - jackh726:rollup-w57i9fp, r=jackh726
Rollup of 9 pull requests Successful merges: - #86263 (Rustdoc: Report Layout of enum variants) - #88541 (Add regression test for #74400) - #88553 (Improve diagnostics for unary plus operators (#88276)) - #88594 (More symbolic doc aliases) - #88648 (Correct “copies” to “moves” in `<Option<T> as From<T>>::from` doc, and other copyediting) - #88691 (Add a regression test for #88649) - #88694 (Drop 1.56 stabilizations from 1.55 release notes) - #88712 (Fix docs for `uX::checked_next_multiple_of`) - #88726 (Fix typo in `const_generics` replaced with `adt_const_params` note) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/rustdoc/type-layout.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-36499.stderr | 10 | ||||
| -rw-r--r-- | src/test/ui/consts/issue-88649.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr | 30 | ||||
| -rw-r--r-- | src/test/ui/lifetimes/lifetime-errors/issue_74400.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr | 11 | ||||
| -rw-r--r-- | src/test/ui/parser/expr-as-stmt.fixed | 2 | ||||
| -rw-r--r-- | src/test/ui/parser/expr-as-stmt.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/parser/expr-as-stmt.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-88276-unary-plus.fixed | 8 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-88276-unary-plus.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-88276-unary-plus.stderr | 50 |
12 files changed, 168 insertions, 6 deletions
diff --git a/src/test/rustdoc/type-layout.rs b/src/test/rustdoc/type-layout.rs index 272911de681..0868486fa59 100644 --- a/src/test/rustdoc/type-layout.rs +++ b/src/test/rustdoc/type-layout.rs @@ -52,3 +52,21 @@ pub struct Unsized([u8]); // @!has type_layout/trait.MyTrait.html 'Size: ' pub trait MyTrait {} + +// @has type_layout/enum.Variants.html 'Size: ' +// @has - '2 bytes' +// @has - '<code>A</code>: 0 bytes' +// @has - '<code>B</code>: 1 byte' +pub enum Variants { + A, + B(u8), +} + +// @has type_layout/enum.WithNiche.html 'Size: ' +// @has - //p '4 bytes' +// @has - '<code>None</code>: 0 bytes' +// @has - '<code>Some</code>: 4 bytes' +pub enum WithNiche { + None, + Some(std::num::NonZeroU32), +} diff --git a/src/test/ui/associated-types/issue-36499.stderr b/src/test/ui/associated-types/issue-36499.stderr index ff450f60acc..610798d880f 100644 --- a/src/test/ui/associated-types/issue-36499.stderr +++ b/src/test/ui/associated-types/issue-36499.stderr @@ -1,8 +1,14 @@ -error: expected expression, found `+` +error: leading `+` is not supported --> $DIR/issue-36499.rs:4:9 | LL | 2 + +2; - | ^ expected expression + | ^ unexpected `+` + | +help: try removing the `+` + | +LL - 2 + +2; +LL + 2 + 2; + | error: aborting due to previous error diff --git a/src/test/ui/consts/issue-88649.rs b/src/test/ui/consts/issue-88649.rs new file mode 100644 index 00000000000..43e562b5a7d --- /dev/null +++ b/src/test/ui/consts/issue-88649.rs @@ -0,0 +1,18 @@ +// check-pass +#![crate_type = "lib"] + +enum Foo { + Variant1(bool), + Variant2(bool), +} + +const _: () = { + let mut n = 0; + while n < 2 { + match Foo::Variant1(true) { + Foo::Variant1(x) | Foo::Variant2(x) if x => {} + _ => {} + } + n += 1; + } +}; diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr new file mode 100644 index 00000000000..5a1294f948f --- /dev/null +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr @@ -0,0 +1,30 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/issue_74400.rs:12:5 + | +LL | f(data, identity) + | ^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... + +error[E0308]: mismatched types + --> $DIR/issue_74400.rs:12:5 + | +LL | f(data, identity) + | ^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected type `for<'r> Fn<(&'r T,)>` + found type `Fn<(&T,)>` + +error: implementation of `FnOnce` is not general enough + --> $DIR/issue_74400.rs:12:5 + | +LL | f(data, identity) + | ^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | + = note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&'2 T,)>`, for some specific lifetime `'2` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0308, E0310. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs b/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs new file mode 100644 index 00000000000..f83384524f7 --- /dev/null +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs @@ -0,0 +1,13 @@ +//! Regression test for #74400: Type mismatch in function arguments E0631, E0271 are falsely +//! recognized as E0308 mismatched types. + +use std::convert::identity; + +fn main() {} + +fn f<T, S>(data: &[T], key: impl Fn(&T) -> S) { +} + +fn g<T>(data: &[T]) { + f(data, identity) //~ ERROR implementation of `FnOnce` is not general +} diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr b/src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr new file mode 100644 index 00000000000..d972861a2b5 --- /dev/null +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr @@ -0,0 +1,11 @@ +error: implementation of `FnOnce` is not general enough + --> $DIR/issue_74400.rs:12:5 + | +LL | f(data, identity) + | ^ implementation of `FnOnce` is not general enough + | + = note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&'2 T,)>`, for some specific lifetime `'2` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/expr-as-stmt.fixed b/src/test/ui/parser/expr-as-stmt.fixed index c217ab9774f..5f5e25991e0 100644 --- a/src/test/ui/parser/expr-as-stmt.fixed +++ b/src/test/ui/parser/expr-as-stmt.fixed @@ -10,7 +10,7 @@ fn foo() -> i32 { } fn bar() -> i32 { - ({2}) + 2 //~ ERROR expected expression, found `+` + ({2}) + 2 //~ ERROR leading `+` is not supported //~^ ERROR mismatched types } diff --git a/src/test/ui/parser/expr-as-stmt.rs b/src/test/ui/parser/expr-as-stmt.rs index b04025faaec..5428e1c32fe 100644 --- a/src/test/ui/parser/expr-as-stmt.rs +++ b/src/test/ui/parser/expr-as-stmt.rs @@ -10,7 +10,7 @@ fn foo() -> i32 { } fn bar() -> i32 { - {2} + 2 //~ ERROR expected expression, found `+` + {2} + 2 //~ ERROR leading `+` is not supported //~^ ERROR mismatched types } diff --git a/src/test/ui/parser/expr-as-stmt.stderr b/src/test/ui/parser/expr-as-stmt.stderr index ba5cd01abfc..d99e9be0000 100644 --- a/src/test/ui/parser/expr-as-stmt.stderr +++ b/src/test/ui/parser/expr-as-stmt.stderr @@ -9,11 +9,11 @@ help: parentheses are required to parse this as an expression LL | ({2}) + {2} | + + -error: expected expression, found `+` +error: leading `+` is not supported --> $DIR/expr-as-stmt.rs:13:9 | LL | {2} + 2 - | ^ expected expression + | ^ unexpected `+` | help: parentheses are required to parse this as an expression | diff --git a/src/test/ui/parser/issue-88276-unary-plus.fixed b/src/test/ui/parser/issue-88276-unary-plus.fixed new file mode 100644 index 00000000000..25b7c340f60 --- /dev/null +++ b/src/test/ui/parser/issue-88276-unary-plus.fixed @@ -0,0 +1,8 @@ +// run-rustfix +#[allow(unused_parens)] +fn main() { + let _ = 1; //~ ERROR leading `+` is not supported + let _ = (1.0 + 2.0) * 3.0; //~ ERROR leading `+` is not supported + //~| ERROR leading `+` is not supported + let _ = [3, 4+6]; //~ ERROR leading `+` is not supported +} diff --git a/src/test/ui/parser/issue-88276-unary-plus.rs b/src/test/ui/parser/issue-88276-unary-plus.rs new file mode 100644 index 00000000000..11b2e9d6016 --- /dev/null +++ b/src/test/ui/parser/issue-88276-unary-plus.rs @@ -0,0 +1,8 @@ +// run-rustfix +#[allow(unused_parens)] +fn main() { + let _ = +1; //~ ERROR leading `+` is not supported + let _ = (1.0 + +2.0) * +3.0; //~ ERROR leading `+` is not supported + //~| ERROR leading `+` is not supported + let _ = [+3, 4+6]; //~ ERROR leading `+` is not supported +} diff --git a/src/test/ui/parser/issue-88276-unary-plus.stderr b/src/test/ui/parser/issue-88276-unary-plus.stderr new file mode 100644 index 00000000000..b26761729a8 --- /dev/null +++ b/src/test/ui/parser/issue-88276-unary-plus.stderr @@ -0,0 +1,50 @@ +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:4:13 + | +LL | let _ = +1; + | ^ unexpected `+` + | +help: try removing the `+` + | +LL - let _ = +1; +LL + let _ = 1; + | + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:5:20 + | +LL | let _ = (1.0 + +2.0) * +3.0; + | ^ unexpected `+` + | +help: try removing the `+` + | +LL - let _ = (1.0 + +2.0) * +3.0; +LL + let _ = (1.0 + 2.0) * +3.0; + | + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:5:28 + | +LL | let _ = (1.0 + +2.0) * +3.0; + | ^ unexpected `+` + | +help: try removing the `+` + | +LL - let _ = (1.0 + +2.0) * +3.0; +LL + let _ = (1.0 + +2.0) * 3.0; + | + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:7:14 + | +LL | let _ = [+3, 4+6]; + | ^ unexpected `+` + | +help: try removing the `+` + | +LL - let _ = [+3, 4+6]; +LL + let _ = [3, 4+6]; + | + +error: aborting due to 4 previous errors + |
