Closed
Description
The following code fails to compile:
#[async_trait]
pub trait AsCleanJson {
pub async fn clean_json<T: DeserializeOwned>(self) -> Result<T>;
}
However, after observing start of the stacktrace I see the following message: pub not permitted here because it's implied
,
after removing it, this code compiles fine:
#[async_trait]
pub trait AsCleanJson {
async fn clean_json<T: DeserializeOwned>(self) -> Result<T>;
}
The depencencies used:
anyhow = "1.0.68"
async-trait = "0.1.61"
reqwest = "0.11.13"
serde = { version = "1.0.152", features = ["serde_derive"] }
Here's the stacktrace:
error[E0449]: unnecessary visibility qualifier
--> src/deserialization.rs:8:5
|
8 | pub async fn clean_json<T: DeserializeOwned>(self) -> Result<T>;
| ^^^ `pub` not permitted here because it's implied
error[E0706]: functions in traits cannot be declared `async`
--> src/deserialization.rs:8:5
|
8 | pub async fn clean_json<T: DeserializeOwned>(self) -> Result<T>;
| ^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
error[E0195]: lifetime parameters or bounds on method `clean_json` do not match the trait declaration
--> src/deserialization.rs:13:24
|
8 | pub async fn clean_json<T: DeserializeOwned>(self) -> Result<T>;
| --------------------- lifetimes in impl do not match this method in trait
...
13 | async fn clean_json<T: DeserializeOwned>(self) -> Result<T> {
| ^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait
error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:726:9: type parameter `T/#1` (T/1) out of range when substituting, substs=[_]
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/compiler/rustc_errors/src/lib.rs:1519:9
stack backtrace:
0: 0x7f3f40a204d0 - std::backtrace_rs::backtrace::libunwind::trace::h1d00f3fcf4cb5ac4
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x7f3f40a204d0 - std::backtrace_rs::backtrace::trace_unsynchronized::h920a6ff332484ee2
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f3f40a204d0 - std::sys_common::backtrace::_print_fmt::hd7323920c925af6d
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:65:5
3: 0x7f3f40a204d0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3155a8c966b4beb5
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f3f3cbc898e - core::fmt::write::h062c617411b691df
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/fmt/mod.rs:1209:17
5: 0x7f3f40a14285 - std::io::Write::write_fmt::hb61fdf1275c61e1c
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/io/mod.rs:1682:15
6: 0x7f3f40a20295 - std::sys_common::backtrace::_print::hd1b4d9664ab500e0
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:47:5
7: 0x7f3f40a20295 - std::sys_common::backtrace::print::hca896ae22beb06cb
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:34:9
8: 0x7f3f40a225ef - std::panicking::default_hook::{{closure}}::h0b5eeed5cf36ab5f
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:267:22
9: 0x7f3f40a2232a - std::panicking::default_hook::h8932b573145a321b
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:286:9
10: 0x7f3f3fce5824 - <rustc_driver[a4af459bb9807b28]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[7004993c4fa7d925]::ops::function::FnOnce<(&core[7004993c4fa7d925]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
11: 0x7f3f40a22dd9 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hbb63890df2a28e48
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/alloc/src/boxed.rs:2001:9
12: 0x7f3f40a22dd9 - std::panicking::rust_panic_with_hook::h4b1447a24e3e94f8
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:692:13
13: 0x7f3f4010ec11 - std[c44ab7e3d3d4e36a]::panicking::begin_panic::<rustc_errors[25ac01a7cd1ad6e4]::ExplicitBug>::{closure#0}
14: 0x7f3f4010e776 - std[c44ab7e3d3d4e36a]::sys_common::backtrace::__rust_end_short_backtrace::<std[c44ab7e3d3d4e36a]::panicking::begin_panic<rustc_errors[25ac01a7cd1ad6e4]::ExplicitBug>::{closure#0}, !>
15: 0x7f3f40176c26 - std[c44ab7e3d3d4e36a]::panicking::begin_panic::<rustc_errors[25ac01a7cd1ad6e4]::ExplicitBug>
16: 0x7f3f4010e766 - std[c44ab7e3d3d4e36a]::panic::panic_any::<rustc_errors[25ac01a7cd1ad6e4]::ExplicitBug>
17: 0x7f3f4010d65d - <rustc_errors[25ac01a7cd1ad6e4]::HandlerInner>::bug::<&alloc[3b3f0114a095882a]::string::String>
18: 0x7f3f4010d0d0 - <rustc_errors[25ac01a7cd1ad6e4]::Handler>::bug::<&alloc[3b3f0114a095882a]::string::String>
19: 0x7f3f401d947d - rustc_middle[e3d6ddb3c6f8799a]::ty::context::tls::with_context_opt::<rustc_middle[e3d6ddb3c6f8799a]::ty::context::tls::with_opt<rustc_middle[e3d6ddb3c6f8799a]::util::bug::opt_span_bug_fmt<rustc_span[bc5b46e63c35e1c0]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
20: 0x7f3f401db636 - rustc_middle[e3d6ddb3c6f8799a]::util::bug::opt_span_bug_fmt::<rustc_span[bc5b46e63c35e1c0]::span_encoding::Span>
21: 0x7f3f3df65043 - rustc_middle[e3d6ddb3c6f8799a]::util::bug::bug_fmt
22: 0x7f3f401c1e32 - <rustc_middle[e3d6ddb3c6f8799a]::ty::subst::SubstFolder>::type_param_out_of_range
23: 0x7f3f3dd34885 - <rustc_middle[e3d6ddb3c6f8799a]::ty::subst::SubstFolder as rustc_middle[e3d6ddb3c6f8799a]::ty::fold::FallibleTypeFolder>::try_fold_ty
24: 0x7f3f3ddc3f84 - <rustc_middle[e3d6ddb3c6f8799a]::ty::generics::GenericPredicates>::instantiate_into
25: 0x7f3f3ddc3c7f - <rustc_middle[e3d6ddb3c6f8799a]::ty::generics::GenericPredicates>::instantiate
26: 0x7f3f3e4dc9e5 - rustc_trait_selection[572e1522d08a21fc]::traits::project::opt_normalize_projection_type
27: 0x7f3f3e4c8c1e - <rustc_trait_selection[572e1522d08a21fc]::traits::project::AssocTypeNormalizer as rustc_middle[e3d6ddb3c6f8799a]::ty::fold::TypeFolder>::fold_ty
28: 0x7f3f3e4985b9 - <&rustc_middle[e3d6ddb3c6f8799a]::ty::list::List<rustc_middle[e3d6ddb3c6f8799a]::ty::Ty> as rustc_middle[e3d6ddb3c6f8799a]::ty::fold::TypeFoldable>::try_fold_with::<rustc_trait_selection[572e1522d08a21fc]::traits::project::AssocTypeNormalizer>
29: 0x7f3f3e497b4e - <rustc_infer[c21feda1ece992cd]::infer::InferCtxt as rustc_trait_selection[572e1522d08a21fc]::infer::InferCtxtExt>::partially_normalize_associated_types_in::<(rustc_middle[e3d6ddb3c6f8799a]::ty::sty::FnSig, rustc_middle[e3d6ddb3c6f8799a]::ty::InstantiatedPredicates)>
30: 0x7f3f3e299c44 - <rustc_hir_typeck[be3388c9a0d8ddb6]::method::confirm::ConfirmContext>::confirm
31: 0x7f3f3e25da5a - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::lookup_method
32: 0x7f3f3e23b448 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
33: 0x7f3f3df0d7cc - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_argument_types
34: 0x7f3f3e28b535 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_call
35: 0x7f3f3e23ac00 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
36: 0x7f3f3e2a364f - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_match::{closure#0}
37: 0x7f3f3e23d1da - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
38: 0x7f3f3df0d7cc - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_argument_types
39: 0x7f3f3e28b535 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_call
40: 0x7f3f3e23ac00 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
41: 0x7f3f3e2a364f - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_match::{closure#0}
42: 0x7f3f3e23d1da - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
43: 0x7f3f3e27e682 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_decl
44: 0x7f3f3e27b6fa - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_block_with_expected
45: 0x7f3f3e23b376 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
46: 0x7f3f3ec53546 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_return_expr
47: 0x7f3f3ec50eda - rustc_hir_typeck[be3388c9a0d8ddb6]::check::check_fn
48: 0x7f3f3e2da586 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_expr_closure
49: 0x7f3f3e23f0c9 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
50: 0x7f3f3df0d7cc - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_argument_types
51: 0x7f3f3e28b535 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_call
52: 0x7f3f3e23ac00 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
53: 0x7f3f3e27e682 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_decl
54: 0x7f3f3e27b6fa - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_block_with_expected
55: 0x7f3f3e23b376 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
56: 0x7f3f3ec53546 - <rustc_hir_typeck[be3388c9a0d8ddb6]::fn_ctxt::FnCtxt>::check_return_expr
57: 0x7f3f3ec50eda - rustc_hir_typeck[be3388c9a0d8ddb6]::check::check_fn
58: 0x7f3f3ec3c643 - rustc_hir_typeck[be3388c9a0d8ddb6]::typeck
59: 0x7f3f3e190163 - <rustc_query_system[dc96433844bf4855]::dep_graph::graph::DepGraph<rustc_middle[e3d6ddb3c6f8799a]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[e3d6ddb3c6f8799a]::ty::context::TyCtxt, rustc_span[bc5b46e63c35e1c0]::def_id::LocalDefId, &rustc_middle[e3d6ddb3c6f8799a]::ty::context::TypeckResults>
60: 0x7f3f3e188311 - rustc_query_system[dc96433844bf4855]::query::plumbing::try_execute_query::<rustc_query_impl[2c7253b64d5debaa]::plumbing::QueryCtxt, rustc_query_system[dc96433844bf4855]::query::caches::DefaultCache<rustc_span[bc5b46e63c35e1c0]::def_id::LocalDefId, &rustc_middle[e3d6ddb3c6f8799a]::ty::context::TypeckResults>>
61: 0x7f3f3f4f69d8 - rustc_data_structures[e4382d39faf37387]::sync::par_for_each_in::<&[rustc_span[bc5b46e63c35e1c0]::def_id::LocalDefId], <rustc_middle[e3d6ddb3c6f8799a]::hir::map::Map>::par_body_owners<rustc_hir_typeck[be3388c9a0d8ddb6]::typeck_item_bodies::{closure#0}>::{closure#0}>
62: 0x7f3f3f4f66b3 - rustc_hir_typeck[be3388c9a0d8ddb6]::typeck_item_bodies
63: 0x7f3f3f3f03d9 - <rustc_query_system[dc96433844bf4855]::dep_graph::graph::DepGraph<rustc_middle[e3d6ddb3c6f8799a]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[e3d6ddb3c6f8799a]::ty::context::TyCtxt, (), ()>
64: 0x7f3f3f3ef37d - rustc_query_system[dc96433844bf4855]::query::plumbing::try_execute_query::<rustc_query_impl[2c7253b64d5debaa]::plumbing::QueryCtxt, rustc_query_system[dc96433844bf4855]::query::caches::DefaultCache<(), ()>>
65: 0x7f3f3f3eed07 - rustc_query_system[dc96433844bf4855]::query::plumbing::get_query::<rustc_query_impl[2c7253b64d5debaa]::queries::typeck_item_bodies, rustc_query_impl[2c7253b64d5debaa]::plumbing::QueryCtxt>
66: 0x7f3f3e0ffb5a - <rustc_session[d7fba84d2e88e76]::session::Session>::time::<(), rustc_hir_analysis[59acc8331deb892c]::check_crate::{closure#7}>
67: 0x7f3f3e0fed1b - rustc_hir_analysis[59acc8331deb892c]::check_crate
68: 0x7f3f3e0fe94b - rustc_interface[3232fd3fb3a640fd]::passes::analysis
69: 0x7f3f3f54cd8e - <rustc_query_system[dc96433844bf4855]::dep_graph::graph::DepGraph<rustc_middle[e3d6ddb3c6f8799a]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[e3d6ddb3c6f8799a]::ty::context::TyCtxt, (), core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>>
70: 0x7f3f3f54c104 - rustc_query_system[dc96433844bf4855]::query::plumbing::try_execute_query::<rustc_query_impl[2c7253b64d5debaa]::plumbing::QueryCtxt, rustc_query_system[dc96433844bf4855]::query::caches::DefaultCache<(), core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>>>
71: 0x7f3f3f54bb87 - rustc_query_system[dc96433844bf4855]::query::plumbing::get_query::<rustc_query_impl[2c7253b64d5debaa]::queries::analysis, rustc_query_impl[2c7253b64d5debaa]::plumbing::QueryCtxt>
72: 0x7f3f3f08c27d - <rustc_interface[3232fd3fb3a640fd]::passes::QueryContext>::enter::<rustc_driver[a4af459bb9807b28]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>>
73: 0x7f3f3f08872f - <rustc_interface[3232fd3fb3a640fd]::interface::Compiler>::enter::<rustc_driver[a4af459bb9807b28]::run_compiler::{closure#1}::{closure#2}, core[7004993c4fa7d925]::result::Result<core[7004993c4fa7d925]::option::Option<rustc_interface[3232fd3fb3a640fd]::queries::Linker>, rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>>
74: 0x7f3f3f080272 - rustc_span[bc5b46e63c35e1c0]::with_source_map::<core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>, rustc_interface[3232fd3fb3a640fd]::interface::run_compiler<core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>, rustc_driver[a4af459bb9807b28]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
75: 0x7f3f3f07fd69 - <scoped_tls[51b8cb41e419758d]::ScopedKey<rustc_span[bc5b46e63c35e1c0]::SessionGlobals>>::set::<rustc_interface[3232fd3fb3a640fd]::interface::run_compiler<core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>, rustc_driver[a4af459bb9807b28]::run_compiler::{closure#1}>::{closure#0}, core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>>
76: 0x7f3f3f07f378 - std[c44ab7e3d3d4e36a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3232fd3fb3a640fd]::util::run_in_thread_pool_with_globals<rustc_interface[3232fd3fb3a640fd]::interface::run_compiler<core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>, rustc_driver[a4af459bb9807b28]::run_compiler::{closure#1}>::{closure#0}, core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>>
77: 0x7f3f3f07f09c - <<std[c44ab7e3d3d4e36a]::thread::Builder>::spawn_unchecked_<rustc_interface[3232fd3fb3a640fd]::util::run_in_thread_pool_with_globals<rustc_interface[3232fd3fb3a640fd]::interface::run_compiler<core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>, rustc_driver[a4af459bb9807b28]::run_compiler::{closure#1}>::{closure#0}, core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7004993c4fa7d925]::result::Result<(), rustc_errors[25ac01a7cd1ad6e4]::ErrorGuaranteed>>::{closure#1} as core[7004993c4fa7d925]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
78: 0x7f3f40a29d53 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6202d10b0224e7b0
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/alloc/src/boxed.rs:1987:9
79: 0x7f3f40a29d53 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4dbea73c9cec160b
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/alloc/src/boxed.rs:1987:9
80: 0x7f3f40a29d53 - std::sys::unix::thread::Thread::new::thread_start::h0a2f4c32ba2f2278
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys/unix/thread.rs:108:17
81: 0x7f3f3c8eb8fd - <unknown>
82: 0x7f3f3c96da60 - <unknown>
83: 0x0 - <unknown>
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.66.1 (90743e729 2023-01-10) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
Some errors have detailed explanations: E0195, E0449, E0706.
For more information about an error, try `rustc --explain E0195`.
Metadata
Metadata
Assignees
Labels
Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.