diff --git a/Cargo.toml b/Cargo.toml index aa5a37f..e40e71c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,9 @@ serde_json = "1.0" termcolor = "1.0.4" basic-toml = "0.1" +[dev-dependencies] +automod = "1.0" + [lib] doc-scrape-examples = false diff --git a/src/lib.rs b/src/lib.rs index d99e034..2348a8f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -219,6 +219,7 @@ clippy::let_underscore_untyped, // https://github.com/rust-lang/rust-clippy/issues/10410 clippy::manual_assert, clippy::manual_range_contains, + clippy::module_inception, clippy::module_name_repetitions, clippy::must_use_candidate, clippy::needless_pass_by_value, diff --git a/src/tests.rs b/src/tests.rs index 204ab06..812c8a6 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,10 +1,5 @@ -use crate::directory::Directory; -use crate::run::PathDependency; -use std::path::Path; - macro_rules! test_normalize { ( - $name:ident $(DIR=$dir:literal)? $(WORKSPACE=$workspace:literal)? $(INPUT=$input:literal)? @@ -13,20 +8,20 @@ macro_rules! test_normalize { $expected:literal ) => { #[test] - fn $name() { - let context = super::Context { + fn test() { + let context = crate::normalize::Context { krate: "trybuild000", - input_file: Path::new({ "tests/ui/error.rs" $(; $input)? }), - source_dir: &Directory::new({ "/git/trybuild/test_suite" $(; $dir)? }), - workspace: &Directory::new({ "/git/trybuild" $(; $workspace)? }), - target_dir: &Directory::new({ "/git/trybuild/target" $(; $target)? }), - path_dependencies: &[PathDependency { + input_file: std::path::Path::new({ "tests/ui/error.rs" $(; $input)? }), + source_dir: &crate::directory::Directory::new({ "/git/trybuild/test_suite" $(; $dir)? }), + workspace: &crate::directory::Directory::new({ "/git/trybuild" $(; $workspace)? }), + target_dir: &crate::directory::Directory::new({ "/git/trybuild/target" $(; $target)? }), + path_dependencies: &[crate::run::PathDependency { name: String::from("diesel"), - normalized_path: Directory::new("/home/user/documents/rust/diesel/diesel"), + normalized_path: crate::directory::Directory::new("/home/user/documents/rust/diesel/diesel"), }], }; let original = $original; - let variations = super::diagnostics(original, context); + let variations = crate::normalize::diagnostics(original, context); let preferred = variations.preferred(); let expected = $expected; if preferred != expected { @@ -36,466 +31,6 @@ macro_rules! test_normalize { }; } -test_normalize! {test_basic " -error: `self` parameter is only allowed in associated functions - --> /git/trybuild/test_suite/tests/ui/error.rs:11:23 - | -11 | async fn bad_endpoint(self) -> Result, HttpError> { - | ^^^^ not semantically valid as function parameter - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0401`. -error: could not compile `trybuild-tests`. - -To learn more, run the command again with --verbose. -" " -error: `self` parameter is only allowed in associated functions - --> tests/ui/error.rs:11:23 - | -11 | async fn bad_endpoint(self) -> Result, HttpError> { - | ^^^^ not semantically valid as function parameter -"} - -test_normalize! {test_dir_backslash " -error[E0277]: the trait bound `QueryParams: serde::de::Deserialize<'de>` is not satisfied - --> \\git\\trybuild\\test_suite\\tests\\ui\\error.rs:22:61 -" " -error[E0277]: the trait bound `QueryParams: serde::de::Deserialize<'de>` is not satisfied - --> tests/ui/error.rs:22:61 -"} - -test_normalize! {test_rust_lib - INPUT="tests/ui/not-repeatable.rs" -" -error[E0599]: no method named `quote_into_iter` found for struct `std::net::Ipv4Addr` in the current scope - --> /git/trybuild/test_suite/tests/ui/not-repeatable.rs:6:13 - | -6 | let _ = quote! { #(#ip)* }; - | ^^^^^^^^^^^^^^^^^^ method not found in `std::net::Ipv4Addr` - | - ::: /rustlib/src/rust/src/libstd/net/ip.rs:83:1 - ::: /rustlib/src/rust/library/std/src/net/ip.rs:83:1 - | -83 | pub struct Ipv4Addr { - | ------------------- - | | - | doesn't satisfy `std::net::Ipv4Addr: quote::to_tokens::ToTokens` -" " -error[E0599]: no method named `quote_into_iter` found for struct `std::net::Ipv4Addr` in the current scope - --> tests/ui/not-repeatable.rs:6:13 - | -6 | let _ = quote! { #(#ip)* }; - | ^^^^^^^^^^^^^^^^^^ method not found in `std::net::Ipv4Addr` - | - ::: $RUST/src/libstd/net/ip.rs - ::: $RUST/std/src/net/ip.rs - | - | pub struct Ipv4Addr { - | ------------------- - | | - | doesn't satisfy `std::net::Ipv4Addr: quote::to_tokens::ToTokens` -"} - -test_normalize! {test_rust_lib_with_githash " -error[E0599]: the method `to_cxx_exception` exists for reference `&NonError`, but its trait bounds were not satisfied - --> tests/ui/result_no_display.rs:4:19 - | -4 | fn f() -> Result<()>; - | ^^^^^^^^^^ method cannot be called on `&NonError` due to unsatisfied trait bounds -... -8 | pub struct NonError; - | ------------------- doesn't satisfy `NonError: std::fmt::Display` - | - = note: the following trait bounds were not satisfied: - `NonError: std::fmt::Display` - which is required by `&NonError: ToCxxExceptionDefault` -note: the trait `std::fmt::Display` must be implemented - --> /rustc/c5c7d2b37780dac1092e75f12ab97dd56c30861d/library/core/src/fmt/mod.rs:786:1 - | - | pub trait Display { - | ^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `::cxx::map_rust_error_to_cxx_exception` (in Nightly builds, run with -Z macro-backtrace for more info) -" " -error[E0599]: the method `to_cxx_exception` exists for reference `&NonError`, but its trait bounds were not satisfied - --> tests/ui/result_no_display.rs:4:19 - | -4 | fn f() -> Result<()>; - | ^^^^^^^^^^ method cannot be called on `&NonError` due to unsatisfied trait bounds -... -8 | pub struct NonError; - | ------------------- doesn't satisfy `NonError: std::fmt::Display` - | - = note: the following trait bounds were not satisfied: - `NonError: std::fmt::Display` - which is required by `&NonError: ToCxxExceptionDefault` -note: the trait `std::fmt::Display` must be implemented - --> $RUST/core/src/fmt/mod.rs - | - | pub trait Display { - | ^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `::cxx::map_rust_error_to_cxx_exception` (in Nightly builds, run with -Z macro-backtrace for more info) -"} - -test_normalize! {test_type_dir_backslash - INPUT="tests/ui/compile-fail-3.rs" -" -error[E0277]: `*mut _` cannot be shared between threads safely - --> /git/trybuild/test_suite/tests/ui/compile-fail-3.rs:7:5 - | -7 | thread::spawn(|| { - | ^^^^^^^^^^^^^ `*mut _` cannot be shared between threads safely - | - = help: the trait `std::marker::Sync` is not implemented for `*mut _` - = note: required because of the requirements on the impl of `std::marker::Send` for `&*mut _` - = note: required because it appears within the type `[closure@/git/trybuild/test_suite/ui/compile-fail-3.rs:7:19: 9:6 x:&*mut _]` -" " -error[E0277]: `*mut _` cannot be shared between threads safely - --> tests/ui/compile-fail-3.rs:7:5 - | -7 | thread::spawn(|| { - | ^^^^^^^^^^^^^ `*mut _` cannot be shared between threads safely - | - = help: the trait `std::marker::Sync` is not implemented for `*mut _` - = note: required because of the requirements on the impl of `std::marker::Send` for `&*mut _` - = note: required because it appears within the type `[closure@$DIR/ui/compile-fail-3.rs:7:19: 9:6 x:&*mut _]` -"} - -test_normalize! {test_strip_path_dependencies " -error[E0277]: the trait bound `diesel::query_builder::SelectStatement>>>>: diesel::query_builder::IntoUpdateTarget` is not satisfied - --> $DIR/update_requires_valid_where_clause.rs:21:12 - | -21 | update(users::table.filter(posts::id.eq(1))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `diesel::query_builder::IntoUpdateTarget` is not implemented for `diesel::query_builder::SelectStatement>>>>` - | - ::: /home/user/documents/rust/diesel/diesel/src/query_builder/functions.rs:78:18 - | -78 | pub fn update(source: T) -> UpdateStatement { - | ---------------- required by this bound in `diesel::update` - | - = help: the following implementations were found: - as diesel::query_builder::IntoUpdateTarget> -" " -error[E0277]: the trait bound `diesel::query_builder::SelectStatement>>>>: diesel::query_builder::IntoUpdateTarget` is not satisfied - --> $DIR/update_requires_valid_where_clause.rs:21:12 - | -21 | update(users::table.filter(posts::id.eq(1))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `diesel::query_builder::IntoUpdateTarget` is not implemented for `diesel::query_builder::SelectStatement>>>>` - | - ::: $DIESEL/src/query_builder/functions.rs - | - | pub fn update(source: T) -> UpdateStatement { - | ---------------- required by this bound in `diesel::update` - | - = help: the following implementations were found: - as diesel::query_builder::IntoUpdateTarget> -"} - -test_normalize! {test_cargo_registry " -error[E0277]: the trait bound `Thread: serde::de::Deserialize<'_>` is not satisfied - --> src/main.rs:2:36 - | -2 | let _ = serde_json::from_str::(\"???\"); - | ^^^^^^^^^^^^^^^^^^^ the trait `serde::de::Deserialize<'_>` is not implemented for `Thread` - | - ::: /home/ferris/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.64/src/de.rs:2584:8 - | -2584 | T: de::Deserialize<'a>, - | ------------------- required by this bound in `serde_json::from_str` - -For more information about this error, try `rustc --explain E0277`. -error: could not compile `testing` due to previous error -" " -error[E0277]: the trait bound `Thread: serde::de::Deserialize<'_>` is not satisfied - --> src/main.rs:2:36 - | -2 | let _ = serde_json::from_str::(\"???\"); - | ^^^^^^^^^^^^^^^^^^^ the trait `serde::de::Deserialize<'_>` is not implemented for `Thread` - | - ::: $CARGO/serde_json-1.0.64/src/de.rs - | - | T: de::Deserialize<'a>, - | ------------------- required by this bound in `serde_json::from_str` -"} - -test_normalize! {test_cargo_registry_sparse " -error[E0308]: mismatched types - --> tests/compile-fail/surface_source_interval_badarg.rs:7:25 - | -5 | let mut df = hydroflow_syntax! { - | __________________- -6 | | // Should be a `Duration`. -7 | | source_interval(5) -> for_each(std::mem::drop); - | | ^ expected `Duration`, found integer -8 | | }; - | |_____- arguments to this function are incorrect - | -note: function defined here - --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.26.0/src/time/interval.rs:74:8 - | -74 | pub fn interval(period: Duration) -> Interval { - | ^^^^^^^^ -" " -error[E0308]: mismatched types - --> tests/compile-fail/surface_source_interval_badarg.rs:7:25 - | -5 | let mut df = hydroflow_syntax! { - | __________________- -6 | | // Should be a `Duration`. -7 | | source_interval(5) -> for_each(std::mem::drop); - | | ^ expected `Duration`, found integer -8 | | }; - | |_____- arguments to this function are incorrect - | -note: function defined here - --> $CARGO/tokio-1.26.0/src/time/interval.rs - | - | pub fn interval(period: Duration) -> Interval { - | ^^^^^^^^ -"} - -test_normalize! {test_traits_must_be_implemented " -error[E0599]: the method `anyhow_kind` exists for reference `&Error`, but its trait bounds were not satisfied - --> src/main.rs:7:13 - | -4 | struct Error; - | ------------- - | | - | doesn't satisfy `Error: Into` - | doesn't satisfy `Error: anyhow::private::kind::TraitKind` - | doesn't satisfy `Error: std::fmt::Display` -... -7 | let _ = anyhow!(Error); - | ^^^^^^^^^^^^^^ method cannot be called on `&Error` due to unsatisfied trait bounds - | - = note: the following trait bounds were not satisfied: - `Error: Into` - which is required by `Error: anyhow::private::kind::TraitKind` - `Error: std::fmt::Display` - which is required by `&Error: anyhow::private::kind::AdhocKind` - `&Error: Into` - which is required by `&Error: anyhow::private::kind::TraitKind` -note: the following traits must be implemented - --> /rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:274:1 - | -274 | / pub trait Into: Sized { -275 | | /// Performs the conversion. -276 | | #[stable(feature = \"rust1\", since = \"1.0.0\")] -277 | | fn into(self) -> T; -278 | | } - | |_^ - | - ::: /rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:715:1 - | -715 | / pub trait Display { -716 | | /// Formats the value using the given formatter. -717 | | /// -718 | | /// # Examples -... | -738 | | fn fmt(&self, f: &mut Formatter<'_>) -> Result; -739 | | } - | |_^ - = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info) -" " -error[E0599]: the method `anyhow_kind` exists for reference `&Error`, but its trait bounds were not satisfied - --> src/main.rs:7:13 - | -4 | struct Error; - | ------------- - | | - | doesn't satisfy `Error: Into` - | doesn't satisfy `Error: anyhow::private::kind::TraitKind` - | doesn't satisfy `Error: std::fmt::Display` -... -7 | let _ = anyhow!(Error); - | ^^^^^^^^^^^^^^ method cannot be called on `&Error` due to unsatisfied trait bounds - | - = note: the following trait bounds were not satisfied: - `Error: Into` - which is required by `Error: anyhow::private::kind::TraitKind` - `Error: std::fmt::Display` - which is required by `&Error: anyhow::private::kind::AdhocKind` - `&Error: Into` - which is required by `&Error: anyhow::private::kind::TraitKind` -note: the following traits must be implemented - --> $RUST/core/src/convert/mod.rs - | - | / pub trait Into: Sized { - | | /// Performs the conversion. - | | #[stable(feature = \"rust1\", since = \"1.0.0\")] - | | fn into(self) -> T; - | | } - | |_^ - | - ::: $RUST/core/src/fmt/mod.rs - | - | / pub trait Display { - | | /// Formats the value using the given formatter. - | | /// - | | /// # Examples -... | - | | fn fmt(&self, f: &mut Formatter<'_>) -> Result; - | | } - | |_^ - = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info) -"} - -test_normalize! {test_pyo3_url - DIR="/pyo3" - WORKSPACE="/pyo3" -" -error: `async fn` is not yet supported for Python functions. - -Additional crates such as `pyo3-asyncio` can be used to integrate async Rust and Python. For more information, see https://github.com/PyO3/pyo3/issues/1632 - --> tests/ui/invalid_pyfunctions.rs:10:1 - | -10 | async fn async_function() {} - | ^^^^^ -" " -error: `async fn` is not yet supported for Python functions. - -Additional crates such as `pyo3-asyncio` can be used to integrate async Rust and Python. For more information, see https://github.com/PyO3/pyo3/issues/1632 - --> tests/ui/invalid_pyfunctions.rs:10:1 - | -10 | async fn async_function() {} - | ^^^^^ -"} - -test_normalize! {test_dropshot_required_by - DIR="/git/dropshot/dropshot" - WORKSPACE="/git/dropshot" - INPUT="tests/fail/bad_endpoint4.rs" -" -error[E0277]: the trait bound `QueryParams: schemars::JsonSchema` is not satisfied - --> /git/dropshot/dropshot/tests/fail/bad_endpoint4.rs:24:14 - | -24 | _params: Query, - | ^^^^^^^^^^^^^^^^^^ the trait `schemars::JsonSchema` is not implemented for `QueryParams` - | -note: required by a bound in `dropshot::Query` - --> /git/dropshot/dropshot/src/handler.rs:547:48 - | -547 | pub struct Query { - | ^^^^^^^^^^ required by this bound in `dropshot::Query` -" " -error[E0277]: the trait bound `QueryParams: schemars::JsonSchema` is not satisfied - --> tests/fail/bad_endpoint4.rs:24:14 - | -24 | _params: Query, - | ^^^^^^^^^^^^^^^^^^ the trait `schemars::JsonSchema` is not implemented for `QueryParams` - | -note: required by a bound in `dropshot::Query` - --> src/handler.rs - | - | pub struct Query { - | ^^^^^^^^^^ required by this bound in `dropshot::Query` -"} - -test_normalize! {test_uniffi_out_dir - DIR="/git/uniffi-rs/fixtures/uitests" - WORKSPACE="/git/uniffi-rs" - TARGET="/git/uniffi-rs/target" -" -error[E0277]: the trait bound `Arc: FfiConverter` is not satisfied - --> /git/uniffi-rs/target/debug/build/uniffi_uitests-1a51d46aecb559a7/out/counter.uniffi.rs:160:19 - | -160 | match as uniffi::FfiConverter>::try_lift(ptr) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FfiConverter` is not implemented for `Arc` - | - = help: the following implementations were found: - as FfiConverter> - = note: required by `try_lift` -" " -error[E0277]: the trait bound `Arc: FfiConverter` is not satisfied - --> $OUT_DIR[uniffi_uitests]/counter.uniffi.rs - | - | match as uniffi::FfiConverter>::try_lift(ptr) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FfiConverter` is not implemented for `Arc` - | - = help: the following implementations were found: - as FfiConverter> - = note: required by `try_lift` -"} - -test_normalize! {test_proc_macro_panic - DIR="D:\\repro" - INPUT="tests\\ui\\nonzero_fail.rs" -" -error[E0080]: evaluation of constant value failed - --> D:\\repro\\tests\\ui\\nonzero_fail.rs:7:10 - | -7 | #[derive(NonZeroRepr)] - | ^^^^^^^^^^^ the evaluated program panicked at 'expected non-zero discriminant expression', D:\\repro\\tests\\ui\\nonzero_fail.rs:7:10 -" " -error[E0080]: evaluation of constant value failed - --> tests/ui/nonzero_fail.rs:7:10 - | -7 | #[derive(NonZeroRepr)] - | ^^^^^^^^^^^ the evaluated program panicked at 'expected non-zero discriminant expression', $DIR/tests/ui/nonzero_fail.rs:7:10 -"} - -test_normalize! {test_and_n_others " -error[E0277]: no implementation for `u8 >> &str` - --> src/main.rs:2:20 - | -2 | let _x = 42_u8 >> \"bar\"; - | ^^ no implementation for `u8 >> &str` - | - = help: the trait `Shr<&str>` is not implemented for `u8` - = help: the following other types implement trait `Shr`: - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - and 568 others -" " -error[E0277]: no implementation for `u8 >> &str` - --> src/main.rs:2:20 - | -2 | let _x = 42_u8 >> \"bar\"; - | ^^ no implementation for `u8 >> &str` - | - = help: the trait `Shr<&str>` is not implemented for `u8` - = help: the following other types implement trait `Shr`: - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - and $N others -"} - -test_normalize! {test_long_file_names " -error: reached the recursion limit while instantiating `test::>>>>>` - --> src/main.rs:18:11 - | -18 | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: `test` defined here - --> src/main.rs:16:1 - | -16 | fn test (n:isize, i:isize, first:T, second:T) ->isize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the full type name has been written to `/playground/target/debug/deps/playground-c53df771d95c66fb.c7a39e8d0dd9c781.long-type-16688711729771999621.txt` - the full type name has been written to `/playground/target/debug/deps/playground-c53df771d95c66fb.c7a39e8d0dd9c781.long-type-16688711729771999621.txt` -" " -error: reached the recursion limit while instantiating `test::>>>>>` - --> src/main.rs:18:11 - | -18 | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: `test` defined here - --> src/main.rs:16:1 - | -16 | fn test (n:isize, i:isize, first:T, second:T) ->isize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -"} +mod tests { + automod::dir!("src/tests"); +} diff --git a/src/tests/and-n-others.rs b/src/tests/and-n-others.rs new file mode 100644 index 0000000..f1a7cf8 --- /dev/null +++ b/src/tests/and-n-others.rs @@ -0,0 +1,37 @@ +test_normalize! {" +error[E0277]: no implementation for `u8 >> &str` + --> src/main.rs:2:20 + | +2 | let _x = 42_u8 >> \"bar\"; + | ^^ no implementation for `u8 >> &str` + | + = help: the trait `Shr<&str>` is not implemented for `u8` + = help: the following other types implement trait `Shr`: + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + and 568 others +" " +error[E0277]: no implementation for `u8 >> &str` + --> src/main.rs:2:20 + | +2 | let _x = 42_u8 >> \"bar\"; + | ^^ no implementation for `u8 >> &str` + | + = help: the trait `Shr<&str>` is not implemented for `u8` + = help: the following other types implement trait `Shr`: + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + and $N others +"} diff --git a/src/tests/basic.rs b/src/tests/basic.rs new file mode 100644 index 0000000..12f3e93 --- /dev/null +++ b/src/tests/basic.rs @@ -0,0 +1,20 @@ +test_normalize! {" +error: `self` parameter is only allowed in associated functions + --> /git/trybuild/test_suite/tests/ui/error.rs:11:23 + | +11 | async fn bad_endpoint(self) -> Result, HttpError> { + | ^^^^ not semantically valid as function parameter + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0401`. +error: could not compile `trybuild-tests`. + +To learn more, run the command again with --verbose. +" " +error: `self` parameter is only allowed in associated functions + --> tests/ui/error.rs:11:23 + | +11 | async fn bad_endpoint(self) -> Result, HttpError> { + | ^^^^ not semantically valid as function parameter +"} diff --git a/src/tests/cargo-registry-sparse.rs b/src/tests/cargo-registry-sparse.rs new file mode 100644 index 0000000..037d633 --- /dev/null +++ b/src/tests/cargo-registry-sparse.rs @@ -0,0 +1,35 @@ +test_normalize! {" +error[E0308]: mismatched types + --> tests/compile-fail/surface_source_interval_badarg.rs:7:25 + | +5 | let mut df = hydroflow_syntax! { + | __________________- +6 | | // Should be a `Duration`. +7 | | source_interval(5) -> for_each(std::mem::drop); + | | ^ expected `Duration`, found integer +8 | | }; + | |_____- arguments to this function are incorrect + | +note: function defined here + --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.26.0/src/time/interval.rs:74:8 + | +74 | pub fn interval(period: Duration) -> Interval { + | ^^^^^^^^ +" " +error[E0308]: mismatched types + --> tests/compile-fail/surface_source_interval_badarg.rs:7:25 + | +5 | let mut df = hydroflow_syntax! { + | __________________- +6 | | // Should be a `Duration`. +7 | | source_interval(5) -> for_each(std::mem::drop); + | | ^ expected `Duration`, found integer +8 | | }; + | |_____- arguments to this function are incorrect + | +note: function defined here + --> $CARGO/tokio-1.26.0/src/time/interval.rs + | + | pub fn interval(period: Duration) -> Interval { + | ^^^^^^^^ +"} diff --git a/src/tests/cargo-registry.rs b/src/tests/cargo-registry.rs new file mode 100644 index 0000000..f975182 --- /dev/null +++ b/src/tests/cargo-registry.rs @@ -0,0 +1,26 @@ +test_normalize! {" +error[E0277]: the trait bound `Thread: serde::de::Deserialize<'_>` is not satisfied + --> src/main.rs:2:36 + | +2 | let _ = serde_json::from_str::(\"???\"); + | ^^^^^^^^^^^^^^^^^^^ the trait `serde::de::Deserialize<'_>` is not implemented for `Thread` + | + ::: /home/ferris/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.64/src/de.rs:2584:8 + | +2584 | T: de::Deserialize<'a>, + | ------------------- required by this bound in `serde_json::from_str` + +For more information about this error, try `rustc --explain E0277`. +error: could not compile `testing` due to previous error +" " +error[E0277]: the trait bound `Thread: serde::de::Deserialize<'_>` is not satisfied + --> src/main.rs:2:36 + | +2 | let _ = serde_json::from_str::(\"???\"); + | ^^^^^^^^^^^^^^^^^^^ the trait `serde::de::Deserialize<'_>` is not implemented for `Thread` + | + ::: $CARGO/serde_json-1.0.64/src/de.rs + | + | T: de::Deserialize<'a>, + | ------------------- required by this bound in `serde_json::from_str` +"} diff --git a/src/tests/dir-backslash.rs b/src/tests/dir-backslash.rs new file mode 100644 index 0000000..b9ae62d --- /dev/null +++ b/src/tests/dir-backslash.rs @@ -0,0 +1,7 @@ +test_normalize! {" +error[E0277]: the trait bound `QueryParams: serde::de::Deserialize<'de>` is not satisfied + --> \\git\\trybuild\\test_suite\\tests\\ui\\error.rs:22:61 +" " +error[E0277]: the trait bound `QueryParams: serde::de::Deserialize<'de>` is not satisfied + --> tests/ui/error.rs:22:61 +"} diff --git a/src/tests/dropshot-required-by.rs b/src/tests/dropshot-required-by.rs new file mode 100644 index 0000000..0ff0cac --- /dev/null +++ b/src/tests/dropshot-required-by.rs @@ -0,0 +1,29 @@ +test_normalize! { + DIR="/git/dropshot/dropshot" + WORKSPACE="/git/dropshot" + INPUT="tests/fail/bad_endpoint4.rs" +" +error[E0277]: the trait bound `QueryParams: schemars::JsonSchema` is not satisfied + --> /git/dropshot/dropshot/tests/fail/bad_endpoint4.rs:24:14 + | +24 | _params: Query, + | ^^^^^^^^^^^^^^^^^^ the trait `schemars::JsonSchema` is not implemented for `QueryParams` + | +note: required by a bound in `dropshot::Query` + --> /git/dropshot/dropshot/src/handler.rs:547:48 + | +547 | pub struct Query { + | ^^^^^^^^^^ required by this bound in `dropshot::Query` +" " +error[E0277]: the trait bound `QueryParams: schemars::JsonSchema` is not satisfied + --> tests/fail/bad_endpoint4.rs:24:14 + | +24 | _params: Query, + | ^^^^^^^^^^^^^^^^^^ the trait `schemars::JsonSchema` is not implemented for `QueryParams` + | +note: required by a bound in `dropshot::Query` + --> src/handler.rs + | + | pub struct Query { + | ^^^^^^^^^^ required by this bound in `dropshot::Query` +"} diff --git a/src/tests/long-file-names.rs b/src/tests/long-file-names.rs new file mode 100644 index 0000000..175e8f2 --- /dev/null +++ b/src/tests/long-file-names.rs @@ -0,0 +1,27 @@ +test_normalize! {" +error: reached the recursion limit while instantiating `test::>>>>>` + --> src/main.rs:18:11 + | +18 | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `test` defined here + --> src/main.rs:16:1 + | +16 | fn test (n:isize, i:isize, first:T, second:T) ->isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the full type name has been written to `/playground/target/debug/deps/playground-c53df771d95c66fb.c7a39e8d0dd9c781.long-type-16688711729771999621.txt` + the full type name has been written to `/playground/target/debug/deps/playground-c53df771d95c66fb.c7a39e8d0dd9c781.long-type-16688711729771999621.txt` +" " +error: reached the recursion limit while instantiating `test::>>>>>` + --> src/main.rs:18:11 + | +18 | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `test` defined here + --> src/main.rs:16:1 + | +16 | fn test (n:isize, i:isize, first:T, second:T) ->isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +"} diff --git a/src/tests/proc-macro-panic.rs b/src/tests/proc-macro-panic.rs new file mode 100644 index 0000000..a4340f1 --- /dev/null +++ b/src/tests/proc-macro-panic.rs @@ -0,0 +1,16 @@ +test_normalize! { + DIR="D:\\repro" + INPUT="tests\\ui\\nonzero_fail.rs" +" +error[E0080]: evaluation of constant value failed + --> D:\\repro\\tests\\ui\\nonzero_fail.rs:7:10 + | +7 | #[derive(NonZeroRepr)] + | ^^^^^^^^^^^ the evaluated program panicked at 'expected non-zero discriminant expression', D:\\repro\\tests\\ui\\nonzero_fail.rs:7:10 +" " +error[E0080]: evaluation of constant value failed + --> tests/ui/nonzero_fail.rs:7:10 + | +7 | #[derive(NonZeroRepr)] + | ^^^^^^^^^^^ the evaluated program panicked at 'expected non-zero discriminant expression', $DIR/tests/ui/nonzero_fail.rs:7:10 +"} diff --git a/src/tests/py03-url.rs b/src/tests/py03-url.rs new file mode 100644 index 0000000..866c575 --- /dev/null +++ b/src/tests/py03-url.rs @@ -0,0 +1,20 @@ +test_normalize! { + DIR="/pyo3" + WORKSPACE="/pyo3" +" +error: `async fn` is not yet supported for Python functions. + +Additional crates such as `pyo3-asyncio` can be used to integrate async Rust and Python. For more information, see https://github.com/PyO3/pyo3/issues/1632 + --> tests/ui/invalid_pyfunctions.rs:10:1 + | +10 | async fn async_function() {} + | ^^^^^ +" " +error: `async fn` is not yet supported for Python functions. + +Additional crates such as `pyo3-asyncio` can be used to integrate async Rust and Python. For more information, see https://github.com/PyO3/pyo3/issues/1632 + --> tests/ui/invalid_pyfunctions.rs:10:1 + | +10 | async fn async_function() {} + | ^^^^^ +"} diff --git a/src/tests/rust-lib-with-githash.rs b/src/tests/rust-lib-with-githash.rs new file mode 100644 index 0000000..221ebaa --- /dev/null +++ b/src/tests/rust-lib-with-githash.rs @@ -0,0 +1,39 @@ +test_normalize! {" +error[E0599]: the method `to_cxx_exception` exists for reference `&NonError`, but its trait bounds were not satisfied + --> tests/ui/result_no_display.rs:4:19 + | +4 | fn f() -> Result<()>; + | ^^^^^^^^^^ method cannot be called on `&NonError` due to unsatisfied trait bounds +... +8 | pub struct NonError; + | ------------------- doesn't satisfy `NonError: std::fmt::Display` + | + = note: the following trait bounds were not satisfied: + `NonError: std::fmt::Display` + which is required by `&NonError: ToCxxExceptionDefault` +note: the trait `std::fmt::Display` must be implemented + --> /rustc/c5c7d2b37780dac1092e75f12ab97dd56c30861d/library/core/src/fmt/mod.rs:786:1 + | + | pub trait Display { + | ^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `::cxx::map_rust_error_to_cxx_exception` (in Nightly builds, run with -Z macro-backtrace for more info) +" " +error[E0599]: the method `to_cxx_exception` exists for reference `&NonError`, but its trait bounds were not satisfied + --> tests/ui/result_no_display.rs:4:19 + | +4 | fn f() -> Result<()>; + | ^^^^^^^^^^ method cannot be called on `&NonError` due to unsatisfied trait bounds +... +8 | pub struct NonError; + | ------------------- doesn't satisfy `NonError: std::fmt::Display` + | + = note: the following trait bounds were not satisfied: + `NonError: std::fmt::Display` + which is required by `&NonError: ToCxxExceptionDefault` +note: the trait `std::fmt::Display` must be implemented + --> $RUST/core/src/fmt/mod.rs + | + | pub trait Display { + | ^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `::cxx::map_rust_error_to_cxx_exception` (in Nightly builds, run with -Z macro-backtrace for more info) +"} diff --git a/src/tests/rust-lib.rs b/src/tests/rust-lib.rs new file mode 100644 index 0000000..b71a05d --- /dev/null +++ b/src/tests/rust-lib.rs @@ -0,0 +1,31 @@ +test_normalize! { + INPUT="tests/ui/not-repeatable.rs" +" +error[E0599]: no method named `quote_into_iter` found for struct `std::net::Ipv4Addr` in the current scope + --> /git/trybuild/test_suite/tests/ui/not-repeatable.rs:6:13 + | +6 | let _ = quote! { #(#ip)* }; + | ^^^^^^^^^^^^^^^^^^ method not found in `std::net::Ipv4Addr` + | + ::: /rustlib/src/rust/src/libstd/net/ip.rs:83:1 + ::: /rustlib/src/rust/library/std/src/net/ip.rs:83:1 + | +83 | pub struct Ipv4Addr { + | ------------------- + | | + | doesn't satisfy `std::net::Ipv4Addr: quote::to_tokens::ToTokens` +" " +error[E0599]: no method named `quote_into_iter` found for struct `std::net::Ipv4Addr` in the current scope + --> tests/ui/not-repeatable.rs:6:13 + | +6 | let _ = quote! { #(#ip)* }; + | ^^^^^^^^^^^^^^^^^^ method not found in `std::net::Ipv4Addr` + | + ::: $RUST/src/libstd/net/ip.rs + ::: $RUST/std/src/net/ip.rs + | + | pub struct Ipv4Addr { + | ------------------- + | | + | doesn't satisfy `std::net::Ipv4Addr: quote::to_tokens::ToTokens` +"} diff --git a/src/tests/strip-path-dependencies.rs b/src/tests/strip-path-dependencies.rs new file mode 100644 index 0000000..1c55c6b --- /dev/null +++ b/src/tests/strip-path-dependencies.rs @@ -0,0 +1,29 @@ +test_normalize! {" +error[E0277]: the trait bound `diesel::query_builder::SelectStatement>>>>: diesel::query_builder::IntoUpdateTarget` is not satisfied + --> $DIR/update_requires_valid_where_clause.rs:21:12 + | +21 | update(users::table.filter(posts::id.eq(1))); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `diesel::query_builder::IntoUpdateTarget` is not implemented for `diesel::query_builder::SelectStatement>>>>` + | + ::: /home/user/documents/rust/diesel/diesel/src/query_builder/functions.rs:78:18 + | +78 | pub fn update(source: T) -> UpdateStatement { + | ---------------- required by this bound in `diesel::update` + | + = help: the following implementations were found: + as diesel::query_builder::IntoUpdateTarget> +" " +error[E0277]: the trait bound `diesel::query_builder::SelectStatement>>>>: diesel::query_builder::IntoUpdateTarget` is not satisfied + --> $DIR/update_requires_valid_where_clause.rs:21:12 + | +21 | update(users::table.filter(posts::id.eq(1))); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `diesel::query_builder::IntoUpdateTarget` is not implemented for `diesel::query_builder::SelectStatement>>>>` + | + ::: $DIESEL/src/query_builder/functions.rs + | + | pub fn update(source: T) -> UpdateStatement { + | ---------------- required by this bound in `diesel::update` + | + = help: the following implementations were found: + as diesel::query_builder::IntoUpdateTarget> +"} diff --git a/src/tests/traits-must-be-implemented.rs b/src/tests/traits-must-be-implemented.rs new file mode 100644 index 0000000..29d7d8d --- /dev/null +++ b/src/tests/traits-must-be-implemented.rs @@ -0,0 +1,85 @@ +test_normalize! {" +error[E0599]: the method `anyhow_kind` exists for reference `&Error`, but its trait bounds were not satisfied + --> src/main.rs:7:13 + | +4 | struct Error; + | ------------- + | | + | doesn't satisfy `Error: Into` + | doesn't satisfy `Error: anyhow::private::kind::TraitKind` + | doesn't satisfy `Error: std::fmt::Display` +... +7 | let _ = anyhow!(Error); + | ^^^^^^^^^^^^^^ method cannot be called on `&Error` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `Error: Into` + which is required by `Error: anyhow::private::kind::TraitKind` + `Error: std::fmt::Display` + which is required by `&Error: anyhow::private::kind::AdhocKind` + `&Error: Into` + which is required by `&Error: anyhow::private::kind::TraitKind` +note: the following traits must be implemented + --> /rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:274:1 + | +274 | / pub trait Into: Sized { +275 | | /// Performs the conversion. +276 | | #[stable(feature = \"rust1\", since = \"1.0.0\")] +277 | | fn into(self) -> T; +278 | | } + | |_^ + | + ::: /rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:715:1 + | +715 | / pub trait Display { +716 | | /// Formats the value using the given formatter. +717 | | /// +718 | | /// # Examples +... | +738 | | fn fmt(&self, f: &mut Formatter<'_>) -> Result; +739 | | } + | |_^ + = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info) +" " +error[E0599]: the method `anyhow_kind` exists for reference `&Error`, but its trait bounds were not satisfied + --> src/main.rs:7:13 + | +4 | struct Error; + | ------------- + | | + | doesn't satisfy `Error: Into` + | doesn't satisfy `Error: anyhow::private::kind::TraitKind` + | doesn't satisfy `Error: std::fmt::Display` +... +7 | let _ = anyhow!(Error); + | ^^^^^^^^^^^^^^ method cannot be called on `&Error` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `Error: Into` + which is required by `Error: anyhow::private::kind::TraitKind` + `Error: std::fmt::Display` + which is required by `&Error: anyhow::private::kind::AdhocKind` + `&Error: Into` + which is required by `&Error: anyhow::private::kind::TraitKind` +note: the following traits must be implemented + --> $RUST/core/src/convert/mod.rs + | + | / pub trait Into: Sized { + | | /// Performs the conversion. + | | #[stable(feature = \"rust1\", since = \"1.0.0\")] + | | fn into(self) -> T; + | | } + | |_^ + | + ::: $RUST/core/src/fmt/mod.rs + | + | / pub trait Display { + | | /// Formats the value using the given formatter. + | | /// + | | /// # Examples +... | + | | fn fmt(&self, f: &mut Formatter<'_>) -> Result; + | | } + | |_^ + = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info) +"} diff --git a/src/tests/type-dir-backslash.rs b/src/tests/type-dir-backslash.rs new file mode 100644 index 0000000..fe07582 --- /dev/null +++ b/src/tests/type-dir-backslash.rs @@ -0,0 +1,23 @@ +test_normalize! { + INPUT="tests/ui/compile-fail-3.rs" +" +error[E0277]: `*mut _` cannot be shared between threads safely + --> /git/trybuild/test_suite/tests/ui/compile-fail-3.rs:7:5 + | +7 | thread::spawn(|| { + | ^^^^^^^^^^^^^ `*mut _` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `*mut _` + = note: required because of the requirements on the impl of `std::marker::Send` for `&*mut _` + = note: required because it appears within the type `[closure@/git/trybuild/test_suite/ui/compile-fail-3.rs:7:19: 9:6 x:&*mut _]` +" " +error[E0277]: `*mut _` cannot be shared between threads safely + --> tests/ui/compile-fail-3.rs:7:5 + | +7 | thread::spawn(|| { + | ^^^^^^^^^^^^^ `*mut _` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `*mut _` + = note: required because of the requirements on the impl of `std::marker::Send` for `&*mut _` + = note: required because it appears within the type `[closure@$DIR/ui/compile-fail-3.rs:7:19: 9:6 x:&*mut _]` +"} diff --git a/src/tests/uniffi-out-dir.rs b/src/tests/uniffi-out-dir.rs new file mode 100644 index 0000000..7143195 --- /dev/null +++ b/src/tests/uniffi-out-dir.rs @@ -0,0 +1,25 @@ +test_normalize! { + DIR="/git/uniffi-rs/fixtures/uitests" + WORKSPACE="/git/uniffi-rs" + TARGET="/git/uniffi-rs/target" +" +error[E0277]: the trait bound `Arc: FfiConverter` is not satisfied + --> /git/uniffi-rs/target/debug/build/uniffi_uitests-1a51d46aecb559a7/out/counter.uniffi.rs:160:19 + | +160 | match as uniffi::FfiConverter>::try_lift(ptr) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FfiConverter` is not implemented for `Arc` + | + = help: the following implementations were found: + as FfiConverter> + = note: required by `try_lift` +" " +error[E0277]: the trait bound `Arc: FfiConverter` is not satisfied + --> $OUT_DIR[uniffi_uitests]/counter.uniffi.rs + | + | match as uniffi::FfiConverter>::try_lift(ptr) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FfiConverter` is not implemented for `Arc` + | + = help: the following implementations were found: + as FfiConverter> + = note: required by `try_lift` +"}