diff options
| author | bors <bors@rust-lang.org> | 2022-07-19 13:49:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-07-19 13:49:56 +0000 |
| commit | a289cfcfb32593c63d75f113547f63ffe2dde285 (patch) | |
| tree | a54aeb4086ab0399fd43dcb0724f0eb26deb91c9 /src | |
| parent | 8bd12e8cca3f28f302b9cc0f1f47bb64bd1f98fd (diff) | |
| parent | e6904fc5b24a10e97d0a32908f49886e52e73990 (diff) | |
| download | rust-a289cfcfb32593c63d75f113547f63ffe2dde285.tar.gz rust-a289cfcfb32593c63d75f113547f63ffe2dde285.zip | |
Auto merge of #99462 - matthiaskrgr:rollup-ihhwaru, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #98028 (Add E0790 as more specific variant of E0283) - #99384 (use body's param-env when checking if type needs drop) - #99401 (Avoid `Symbol` to `&str` conversions) - #99419 (Stabilize `core::task::ready!`) - #99435 (Revert "Stabilize $$ in Rust 1.63.0") - #99438 (Improve suggestions for `NonZeroT` <- `T` coercion error) - #99441 (Update mdbook) - #99453 (:arrow_up: rust-analyzer) - #99457 (use `par_for_each_in` in `par_body_owners` and `collect_crate_mono_items`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
28 files changed, 426 insertions, 92 deletions
diff --git a/src/test/ui/associated-consts/issue-63496.rs b/src/test/ui/associated-consts/issue-63496.rs index f9f663af5e2..67ef4e74cf2 100644 --- a/src/test/ui/associated-consts/issue-63496.rs +++ b/src/test/ui/associated-consts/issue-63496.rs @@ -2,8 +2,8 @@ trait A { const C: usize; fn f() -> ([u8; A::C], [u8; A::C]); - //~^ ERROR: type annotations needed - //~| ERROR: type annotations needed + //~^ ERROR: E0790 + //~| ERROR: E0790 } fn main() {} diff --git a/src/test/ui/associated-consts/issue-63496.stderr b/src/test/ui/associated-consts/issue-63496.stderr index db39fd762c3..f2a4e01adea 100644 --- a/src/test/ui/associated-consts/issue-63496.stderr +++ b/src/test/ui/associated-consts/issue-63496.stderr @@ -1,27 +1,21 @@ -error[E0283]: type annotations needed +error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type --> $DIR/issue-63496.rs:4:21 | +LL | const C: usize; + | --------------- `A::C` defined here +LL | LL | fn f() -> ([u8; A::C], [u8; A::C]); - | ^^^^ - | | - | cannot infer type - | help: use the fully qualified path to an implementation: `<Type as A>::C` - | - = note: cannot satisfy `_: A` - = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` + | ^^^^ cannot refer to the associated constant of trait -error[E0283]: type annotations needed +error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type --> $DIR/issue-63496.rs:4:33 | +LL | const C: usize; + | --------------- `A::C` defined here +LL | LL | fn f() -> ([u8; A::C], [u8; A::C]); - | ^^^^ - | | - | cannot infer type - | help: use the fully qualified path to an implementation: `<Type as A>::C` - | - = note: cannot satisfy `_: A` - = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` + | ^^^^ cannot refer to the associated constant of trait error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0790`. diff --git a/src/test/ui/associated-item/issue-48027.rs b/src/test/ui/associated-item/issue-48027.rs index c9b4ccd3e8a..d2b51184c99 100644 --- a/src/test/ui/associated-item/issue-48027.rs +++ b/src/test/ui/associated-item/issue-48027.rs @@ -1,6 +1,6 @@ trait Bar { const X: usize; - fn return_n(&self) -> [u8; Bar::X]; //~ ERROR: type annotations needed + fn return_n(&self) -> [u8; Bar::X]; //~ ERROR: E0790 } impl dyn Bar {} //~ ERROR: the trait `Bar` cannot be made into an object diff --git a/src/test/ui/associated-item/issue-48027.stderr b/src/test/ui/associated-item/issue-48027.stderr index 5487af1a835..45ea419336b 100644 --- a/src/test/ui/associated-item/issue-48027.stderr +++ b/src/test/ui/associated-item/issue-48027.stderr @@ -13,19 +13,15 @@ LL | const X: usize; | ^ ...because it contains this associated `const` = help: consider moving `X` to another trait -error[E0283]: type annotations needed +error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type --> $DIR/issue-48027.rs:3:32 | +LL | const X: usize; + | --------------- `Bar::X` defined here LL | fn return_n(&self) -> [u8; Bar::X]; - | ^^^^^^ - | | - | cannot infer type - | help: use the fully qualified path to an implementation: `<Type as Bar>::X` - | - = note: cannot satisfy `_: Bar` - = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` + | ^^^^^^ cannot refer to the associated constant of trait error: aborting due to 2 previous errors -Some errors have detailed explanations: E0038, E0283. +Some errors have detailed explanations: E0038, E0790. For more information about an error, try `rustc --explain E0038`. diff --git a/src/test/ui/associated-types/associated-types-unconstrained.rs b/src/test/ui/associated-types/associated-types-unconstrained.rs index b97d4af184f..2fb27bf3cd1 100644 --- a/src/test/ui/associated-types/associated-types-unconstrained.rs +++ b/src/test/ui/associated-types/associated-types-unconstrained.rs @@ -12,5 +12,5 @@ impl Foo for isize { pub fn main() { let x: isize = Foo::bar(); - //~^ ERROR type annotations needed + //~^ ERROR E0790 } diff --git a/src/test/ui/associated-types/associated-types-unconstrained.stderr b/src/test/ui/associated-types/associated-types-unconstrained.stderr index 60ec23cf655..e51a8f3bd1a 100644 --- a/src/test/ui/associated-types/associated-types-unconstrained.stderr +++ b/src/test/ui/associated-types/associated-types-unconstrained.stderr @@ -1,11 +1,12 @@ -error[E0283]: type annotations needed +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/associated-types-unconstrained.rs:14:20 | +LL | fn bar() -> isize; + | ------------------ `Foo::bar` defined here +... LL | let x: isize = Foo::bar(); - | ^^^^^^^^ cannot infer type - | - = note: cannot satisfy `_: Foo` + | ^^^^^^^^ cannot call associated function of trait error: aborting due to previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0790`. diff --git a/src/test/ui/error-codes/E0283.rs b/src/test/ui/error-codes/E0283.rs index 4d7c2f2396d..0643af4b7e8 100644 --- a/src/test/ui/error-codes/E0283.rs +++ b/src/test/ui/error-codes/E0283.rs @@ -27,7 +27,7 @@ impl Generator for AnotherImpl { } fn main() { - let cont: u32 = Generator::create(); //~ ERROR E0283 + let cont: u32 = Generator::create(); //~ ERROR E0790 } fn buzz() { diff --git a/src/test/ui/error-codes/E0283.stderr b/src/test/ui/error-codes/E0283.stderr index a107160d11a..90a28874ead 100644 --- a/src/test/ui/error-codes/E0283.stderr +++ b/src/test/ui/error-codes/E0283.stderr @@ -1,10 +1,16 @@ -error[E0283]: type annotations needed +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/E0283.rs:30:21 | +LL | fn create() -> u32; + | ------------------- `Generator::create` defined here +... LL | let cont: u32 = Generator::create(); - | ^^^^^^^^^^^^^^^^^ cannot infer type + | ^^^^^^^^^^^^^^^^^ cannot call associated function of trait + | +help: use a fully-qualified path to a specific available implementation (2 found) | - = note: cannot satisfy `_: Generator` +LL | let cont: u32 = <::Impl as Generator>::create(); + | ++++++++++ + error[E0283]: type annotations needed --> $DIR/E0283.rs:35:24 @@ -27,4 +33,5 @@ LL | let bar = <Impl as Into<T>>::into(foo_impl) * 1u32; error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0283`. +Some errors have detailed explanations: E0283, E0790. +For more information about an error, try `rustc --explain E0283`. diff --git a/src/test/ui/error-codes/E0790.rs b/src/test/ui/error-codes/E0790.rs new file mode 100644 index 00000000000..d99006d2df7 --- /dev/null +++ b/src/test/ui/error-codes/E0790.rs @@ -0,0 +1,53 @@ +mod inner { + pub trait MyTrait { + const MY_ASSOC_CONST: (); + + fn my_fn(); + } + + pub struct MyStruct; + + impl MyTrait for MyStruct { + const MY_ASSOC_CONST: () = (); + + fn my_fn() {} + } + + fn call() { + MyTrait::my_fn(); //~ ERROR E0790 + } + + fn use_const() { + let _ = MyTrait::MY_ASSOC_CONST; //~ ERROR E0790 + } +} + +fn call_inner() { + inner::MyTrait::my_fn(); //~ ERROR E0790 +} + +fn use_const_inner() { + let _ = inner::MyTrait::MY_ASSOC_CONST; //~ ERROR E0790 +} + +trait MyTrait2 { + fn my_fn(); +} + +struct Impl1; + +impl MyTrait2 for Impl1 { + fn my_fn() {} +} + +struct Impl2; + +impl MyTrait2 for Impl2 { + fn my_fn() {} +} + +fn call_multiple_impls() { + MyTrait2::my_fn(); //~ ERROR E0790 +} + +fn main() {} diff --git a/src/test/ui/error-codes/E0790.stderr b/src/test/ui/error-codes/E0790.stderr new file mode 100644 index 00000000000..6e173a9682a --- /dev/null +++ b/src/test/ui/error-codes/E0790.stderr @@ -0,0 +1,73 @@ +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type + --> $DIR/E0790.rs:17:9 + | +LL | fn my_fn(); + | ----------- `MyTrait::my_fn` defined here +... +LL | MyTrait::my_fn(); + | ^^^^^^^^^^^^^^ cannot call associated function of trait + | +help: use the fully-qualified path to the only available implementation + | +LL | <::inner::MyStruct as MyTrait>::my_fn(); + | +++++++++++++++++++++ + + +error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type + --> $DIR/E0790.rs:21:17 + | +LL | const MY_ASSOC_CONST: (); + | ------------------------- `MyTrait::MY_ASSOC_CONST` defined here +... +LL | let _ = MyTrait::MY_ASSOC_CONST; + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot refer to the associated constant of trait + | +help: use the fully-qualified path to the only available implementation + | +LL | let _ = <::inner::MyStruct as MyTrait>::MY_ASSOC_CONST; + | +++++++++++++++++++++ + + +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type + --> $DIR/E0790.rs:26:5 + | +LL | fn my_fn(); + | ----------- `MyTrait::my_fn` defined here +... +LL | inner::MyTrait::my_fn(); + | ^^^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait + | +help: use the fully-qualified path to the only available implementation + | +LL | inner::<::inner::MyStruct as MyTrait>::my_fn(); + | +++++++++++++++++++++ + + +error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type + --> $DIR/E0790.rs:30:13 + | +LL | const MY_ASSOC_CONST: (); + | ------------------------- `MyTrait::MY_ASSOC_CONST` defined here +... +LL | let _ = inner::MyTrait::MY_ASSOC_CONST; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot refer to the associated constant of trait + | +help: use the fully-qualified path to the only available implementation + | +LL | let _ = inner::<::inner::MyStruct as MyTrait>::MY_ASSOC_CONST; + | +++++++++++++++++++++ + + +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type + --> $DIR/E0790.rs:50:5 + | +LL | fn my_fn(); + | ----------- `MyTrait2::my_fn` defined here +... +LL | MyTrait2::my_fn(); + | ^^^^^^^^^^^^^^^ cannot call associated function of trait + | +help: use a fully-qualified path to a specific available implementation (2 found) + | +LL | <::Impl1 as MyTrait2>::my_fn(); + | +++++++++++ + + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0790`. diff --git a/src/test/ui/issues/issue-54954.rs b/src/test/ui/issues/issue-54954.rs index ddd39141541..d4e1df22770 100644 --- a/src/test/ui/issues/issue-54954.rs +++ b/src/test/ui/issues/issue-54954.rs @@ -1,5 +1,5 @@ const ARR_LEN: usize = Tt::const_val::<[i8; 123]>(); -//~^ ERROR type annotations needed +//~^ ERROR E0790 trait Tt { const fn const_val<T: Sized>() -> usize { diff --git a/src/test/ui/issues/issue-54954.stderr b/src/test/ui/issues/issue-54954.stderr index 6e8d3cac9a7..668985c2b59 100644 --- a/src/test/ui/issues/issue-54954.stderr +++ b/src/test/ui/issues/issue-54954.stderr @@ -4,13 +4,17 @@ error[E0379]: functions in traits cannot be declared const LL | const fn const_val<T: Sized>() -> usize { | ^^^^^ functions in traits cannot be const -error[E0283]: type annotations needed +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/issue-54954.rs:1:24 | -LL | const ARR_LEN: usize = Tt::const_val::<[i8; 123]>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type - | - = note: cannot satisfy `_: Tt` +LL | const ARR_LEN: usize = Tt::const_val::<[i8; 123]>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait +... +LL | / const fn const_val<T: Sized>() -> usize { +LL | | +LL | | core::mem::size_of::<T>() +LL | | } + | |_____- `Tt::const_val` defined here error[E0080]: evaluation of constant value failed --> $DIR/issue-54954.rs:11:15 @@ -26,5 +30,5 @@ LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] { error: aborting due to 4 previous errors -Some errors have detailed explanations: E0080, E0283, E0379. +Some errors have detailed explanations: E0080, E0379, E0790. For more information about an error, try `rustc --explain E0080`. diff --git a/src/test/ui/issues/issue-58022.rs b/src/test/ui/issues/issue-58022.rs index e4b9b3b53a6..2a8a1eaa6d3 100644 --- a/src/test/ui/issues/issue-58022.rs +++ b/src/test/ui/issues/issue-58022.rs @@ -2,7 +2,7 @@ pub trait Foo: Sized { const SIZE: usize; fn new(slice: &[u8; Foo::SIZE]) -> Self; - //~^ ERROR: type annotations needed + //~^ ERROR: E0790 } pub struct Bar<T: ?Sized>(T); diff --git a/src/test/ui/issues/issue-58022.stderr b/src/test/ui/issues/issue-58022.stderr index 0128b70e216..6d24209ad3c 100644 --- a/src/test/ui/issues/issue-58022.stderr +++ b/src/test/ui/issues/issue-58022.stderr @@ -4,19 +4,16 @@ error[E0423]: expected function, tuple struct or tuple variant, found trait `Foo LL | Foo(Box::new(*slice)) | ^^^ not a function, tuple struct or tuple variant -error[E0283]: type annotations needed +error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type --> $DIR/issue-58022.rs:4:25 | +LL | const SIZE: usize; + | ------------------ `Foo::SIZE` defined here +LL | LL | fn new(slice: &[u8; Foo::SIZE]) -> Self; - | ^^^^^^^^^ - | | - | cannot infer type - | help: use the fully qualified path to an implementation: `<Type as Foo>::SIZE` - | - = note: cannot satisfy `_: Foo` - = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` + | ^^^^^^^^^ cannot refer to the associated constant of trait error: aborting due to 2 previous errors -Some errors have detailed explanations: E0283, E0423. -For more information about an error, try `rustc --explain E0283`. +Some errors have detailed explanations: E0423, E0790. +For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/allowed-features.rs b/src/test/ui/macros/rfc-3086-metavar-expr/allowed-features.rs deleted file mode 100644 index c248c46f52c..00000000000 --- a/src/test/ui/macros/rfc-3086-metavar-expr/allowed-features.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass - -macro_rules! dollar_dollar { - () => { - macro_rules! bar { - ( $$( $$any:tt )* ) => { $$( $$any )* }; - } - }; -} - -fn main() { -} diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/required-features.rs b/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs index cce3e578aea..b4fef11f1e2 100644 --- a/src/test/ui/macros/rfc-3086-metavar-expr/required-features.rs +++ b/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs @@ -5,6 +5,18 @@ macro_rules! count { }; } +macro_rules! dollar_dollar { + () => { + macro_rules! bar { + ( $$( $$any:tt )* ) => { $$( $$any )* }; + //~^ ERROR meta-variable expressions are unstable + //~| ERROR meta-variable expressions are unstable + //~| ERROR meta-variable expressions are unstable + //~| ERROR meta-variable expressions are unstable + } + }; +} + macro_rules! index { ( $( $e:stmt ),* ) => { $( ${ignore(e)} ${index()} )* diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/required-features.stderr b/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.stderr index 5efd3b10442..ecf598b104d 100644 --- a/src/test/ui/macros/rfc-3086-metavar-expr/required-features.stderr +++ b/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.stderr @@ -1,5 +1,5 @@ error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:3:10 + --> $DIR/required-feature.rs:3:10 | LL | ${ count(e) } | ^^^^^^^^^^^^ @@ -8,7 +8,43 @@ LL | ${ count(e) } = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:10:13 + --> $DIR/required-feature.rs:11:16 + | +LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; + | ^ + | + = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information + = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable + +error[E0658]: meta-variable expressions are unstable + --> $DIR/required-feature.rs:11:20 + | +LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; + | ^ + | + = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information + = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable + +error[E0658]: meta-variable expressions are unstable + --> $DIR/required-feature.rs:11:39 + | +LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; + | ^ + | + = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information + = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable + +error[E0658]: meta-variable expressions are unstable + --> $DIR/required-feature.rs:11:43 + | +LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; + | ^ + | + = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information + = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable + +error[E0658]: meta-variable expressions are unstable + --> $DIR/required-feature.rs:22:13 | LL | $( ${ignore(e)} ${index()} )* | ^^^^^^^^^^^ @@ -17,7 +53,7 @@ LL | $( ${ignore(e)} ${index()} )* = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:10:26 + --> $DIR/required-feature.rs:22:26 | LL | $( ${ignore(e)} ${index()} )* | ^^^^^^^^^ @@ -26,7 +62,7 @@ LL | $( ${ignore(e)} ${index()} )* = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:18:19 + --> $DIR/required-feature.rs:30:19 | LL | 0 $( + 1 ${ignore(i)} )* | ^^^^^^^^^^^ @@ -35,7 +71,7 @@ LL | 0 $( + 1 ${ignore(i)} )* = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:25:13 + --> $DIR/required-feature.rs:37:13 | LL | $( ${ignore(e)} ${length()} )* | ^^^^^^^^^^^ @@ -44,7 +80,7 @@ LL | $( ${ignore(e)} ${length()} )* = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:25:26 + --> $DIR/required-feature.rs:37:26 | LL | $( ${ignore(e)} ${length()} )* | ^^^^^^^^^^ @@ -52,6 +88,6 @@ LL | $( ${ignore(e)} ${length()} )* = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable -error: aborting due to 6 previous errors +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/mismatched_types/non_zero_assigned_something.rs b/src/test/ui/mismatched_types/non_zero_assigned_something.rs new file mode 100644 index 00000000000..d2adbe01c18 --- /dev/null +++ b/src/test/ui/mismatched_types/non_zero_assigned_something.rs @@ -0,0 +1,9 @@ +fn main() { + let _: std::num::NonZeroU64 = 1; + //~^ ERROR mismatched types + //~| HELP consider calling `NonZeroU64::new` + + let _: Option<std::num::NonZeroU64> = 1; + //~^ ERROR mismatched types + //~| HELP consider calling `NonZeroU64::new` +} diff --git a/src/test/ui/mismatched_types/non_zero_assigned_something.stderr b/src/test/ui/mismatched_types/non_zero_assigned_something.stderr new file mode 100644 index 00000000000..d4b2c902f9b --- /dev/null +++ b/src/test/ui/mismatched_types/non_zero_assigned_something.stderr @@ -0,0 +1,31 @@ +error[E0308]: mismatched types + --> $DIR/non_zero_assigned_something.rs:2:35 + | +LL | let _: std::num::NonZeroU64 = 1; + | -------------------- ^ expected struct `NonZeroU64`, found integer + | | + | expected due to this + | +help: consider calling `NonZeroU64::new` + | +LL | let _: std::num::NonZeroU64 = NonZeroU64::new(1).unwrap(); + | ++++++++++++++++ ++++++++++ + +error[E0308]: mismatched types + --> $DIR/non_zero_assigned_something.rs:6:43 + | +LL | let _: Option<std::num::NonZeroU64> = 1; + | ---------------------------- ^ expected enum `Option`, found integer + | | + | expected due to this + | + = note: expected enum `Option<NonZeroU64>` + found type `{integer}` +help: consider calling `NonZeroU64::new` + | +LL | let _: Option<std::num::NonZeroU64> = NonZeroU64::new(1); + | ++++++++++++++++ + + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/mismatched_types/wrap-suggestion-privacy.rs b/src/test/ui/mismatched_types/wrap-suggestion-privacy.rs new file mode 100644 index 00000000000..63cb1a12991 --- /dev/null +++ b/src/test/ui/mismatched_types/wrap-suggestion-privacy.rs @@ -0,0 +1,24 @@ +mod inner { + pub struct Wrapper<T>(T); +} + +fn needs_wrapper(t: inner::Wrapper<i32>) {} +fn needs_wrapping(t: std::num::Wrapping<i32>) {} +fn needs_ready(t: std::future::Ready<i32>) {} + +fn main() { + // Suggest wrapping expression because type is local + // and its privacy can be easily changed + needs_wrapper(0); + //~^ ERROR mismatched types + //~| HELP try wrapping the expression in `inner::Wrapper` + + // Suggest wrapping expression because field is accessible + needs_wrapping(0); + //~^ ERROR mismatched types + //~| HELP try wrapping the expression in `std::num::Wrapping` + + // Do not suggest wrapping expression + needs_ready(Some(0)); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/mismatched_types/wrap-suggestion-privacy.stderr b/src/test/ui/mismatched_types/wrap-suggestion-privacy.stderr new file mode 100644 index 00000000000..e8eb8d263ec --- /dev/null +++ b/src/test/ui/mismatched_types/wrap-suggestion-privacy.stderr @@ -0,0 +1,59 @@ +error[E0308]: mismatched types + --> $DIR/wrap-suggestion-privacy.rs:12:19 + | +LL | needs_wrapper(0); + | ------------- ^ expected struct `Wrapper`, found integer + | | + | arguments to this function are incorrect + | + = note: expected struct `Wrapper<i32>` + found type `{integer}` +note: function defined here + --> $DIR/wrap-suggestion-privacy.rs:5:4 + | +LL | fn needs_wrapper(t: inner::Wrapper<i32>) {} + | ^^^^^^^^^^^^^ ---------------------- +help: try wrapping the expression in `inner::Wrapper` (its field is private, but it's local to this crate and its privacy can be changed) + | +LL | needs_wrapper(inner::Wrapper(0)); + | +++++++++++++++ + + +error[E0308]: mismatched types + --> $DIR/wrap-suggestion-privacy.rs:17:20 + | +LL | needs_wrapping(0); + | -------------- ^ expected struct `Wrapping`, found integer + | | + | arguments to this function are incorrect + | + = note: expected struct `Wrapping<i32>` + found type `{integer}` +note: function defined here + --> $DIR/wrap-suggestion-privacy.rs:6:4 + | +LL | fn needs_wrapping(t: std::num::Wrapping<i32>) {} + | ^^^^^^^^^^^^^^ -------------------------- +help: try wrapping the expression in `std::num::Wrapping` + | +LL | needs_wrapping(std::num::Wrapping(0)); + | +++++++++++++++++++ + + +error[E0308]: mismatched types + --> $DIR/wrap-suggestion-privacy.rs:22:17 + | +LL | needs_ready(Some(0)); + | ----------- ^^^^^^^ expected struct `std::future::Ready`, found enum `Option` + | | + | arguments to this function are incorrect + | + = note: expected struct `std::future::Ready<i32>` + found enum `Option<{integer}>` +note: function defined here + --> $DIR/wrap-suggestion-privacy.rs:7:4 + | +LL | fn needs_ready(t: std::future::Ready<i32>) {} + | ^^^^^^^^^^^ -------------------------- + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/privacy/privacy2.stderr b/src/test/ui/privacy/privacy2.stderr index c2a33ce1f59..882f314655d 100644 --- a/src/test/ui/privacy/privacy2.stderr +++ b/src/test/ui/privacy/privacy2.stderr @@ -23,7 +23,13 @@ LL | pub fn foo() {} error: requires `sized` lang_item -error: aborting due to 3 previous errors +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: aborting due to 6 previous errors Some errors have detailed explanations: E0432, E0603. For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/privacy/privacy3.stderr b/src/test/ui/privacy/privacy3.stderr index 22c1e48b07d..42ce456d962 100644 --- a/src/test/ui/privacy/privacy3.stderr +++ b/src/test/ui/privacy/privacy3.stderr @@ -6,6 +6,12 @@ LL | use bar::gpriv; error: requires `sized` lang_item -error: aborting due to 2 previous errors +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/traits/static-method-generic-inference.rs b/src/test/ui/traits/static-method-generic-inference.rs index 759416d1901..f4e94c4f786 100644 --- a/src/test/ui/traits/static-method-generic-inference.rs +++ b/src/test/ui/traits/static-method-generic-inference.rs @@ -22,7 +22,7 @@ mod base { pub fn foo() { let _f: base::Foo = base::HasNew::new(); - //~^ ERROR type annotations needed + //~^ ERROR E0790 } fn main() { } diff --git a/src/test/ui/traits/static-method-generic-inference.stderr b/src/test/ui/traits/static-method-generic-inference.stderr index 1a0bcf00a67..f1b8f23ecc7 100644 --- a/src/test/ui/traits/static-method-generic-inference.stderr +++ b/src/test/ui/traits/static-method-generic-inference.stderr @@ -1,11 +1,17 @@ -error[E0283]: type annotations needed +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/static-method-generic-inference.rs:24:25 | +LL | fn new() -> T; + | -------------- `HasNew::new` defined here +... LL | let _f: base::Foo = base::HasNew::new(); - | ^^^^^^^^^^^^^^^^^ cannot infer type + | ^^^^^^^^^^^^^^^^^ cannot call associated function of trait | - = note: cannot satisfy `_: HasNew<Foo>` +help: use the fully-qualified path to the only available implementation + | +LL | let _f: base::Foo = base::<::base::Foo as HasNew>::new(); + | +++++++++++++++ + error: aborting due to previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0790`. diff --git a/src/test/ui/type_length_limit.stderr b/src/test/ui/type_length_limit.stderr index a2ddffff997..1508b84c1b6 100644 --- a/src/test/ui/type_length_limit.stderr +++ b/src/test/ui/type_length_limit.stderr @@ -7,5 +7,14 @@ LL | pub fn drop<T>(_x: T) {} = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit/type_length_limit.long-type.txt' = help: consider adding a `#![type_length_limit="8"]` attribute to your crate -error: aborting due to previous error +error: reached the type-length limit while instantiating `<[closure@std::rt::lang_start<()...e<()>>::call_once - shim(vtable)` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + | +LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit/type_length_limit.long-type.txt' + = help: consider adding a `#![type_length_limit="8"]` attribute to your crate + +error: aborting due to 2 previous errors diff --git a/src/test/ui/union/issue-99375.rs b/src/test/ui/union/issue-99375.rs new file mode 100644 index 00000000000..175018a7d71 --- /dev/null +++ b/src/test/ui/union/issue-99375.rs @@ -0,0 +1,21 @@ +// check-pass + +union URes<R: Copy> { + uninit: (), + init: R, +} + +struct Params<F, R: Copy> { + function: F, + result: URes<R>, +} + +unsafe extern "C" fn do_call<F, R>(params: *mut Params<F, R>) +where + R: Copy, + F: Fn() -> R, +{ + (*params).result.init = ((*params).function)(); +} + +fn main() {} diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer -Subproject 5342f47f4276641ddb5f0a5e08fb307742d6cdc +Subproject 897a7ec4b826f85ec1626870e73449070113809 |
