Skip to content

unexpected panic unexpected ambiguity at 'try_normalize_generic_arg_after_erasing_regions' query #10009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gmoshkin opened this issue Dec 1, 2022 · 5 comments · Fixed by #10403
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@gmoshkin
Copy link

gmoshkin commented Dec 1, 2022

I'm running cargo clippy (Clippy version: clippy 0.1.65 (897e375 2022-11-02)) on my library and it panics.

The message is something like:
error: internal compiler error: compiler/rustc_trait_selection/src/traits/query/normalize.rs:258:21: unexpected ambiguity: Canonical { .. } (see bellow for more details)

Reproduce

Here's a link to my project and the commit on which clippy panics:
https://git.picodata.io/picodata/picodata/tarantool-module/-/commit/d417c97904ac614b577478df0b6aaaa5174a22c2

Simply do:

git clone https://git.picodata.io/picodata/picodata/tarantool-module.git
cd tarantool-module
git checkout d417c97904ac614b577478df0b6aaaa5174a22c2
cargo clippy

You'll get this:

    Updating crates.io index
   Compiling tlua-derive v0.1.3 (/home/gmoshkin/code/pd/tm3/tlua-derive)
   Compiling tarantool-proc v0.1.2 (/home/gmoshkin/code/pd/tm3/tarantool-proc)
    Checking tlua v0.6.3 (/home/gmoshkin/code/pd/tm3/tlua)
    Checking tarantool v0.6.4 (/home/gmoshkin/code/pd/tm3/tarantool)
    Checking easy v0.1.0 (/home/gmoshkin/code/pd/tm3/examples/easy)
    Checking harder v0.1.0 (/home/gmoshkin/code/pd/tm3/examples/harder)
    Checking read v0.1.0 (/home/gmoshkin/code/pd/tm3/examples/read)
    Checking tarantool-module-test-runner v0.1.0 (/home/gmoshkin/code/pd/tm3/tests)
    Checking hardest v0.1.0 (/home/gmoshkin/code/pd/tm3/examples/hardest)
    Checking write v0.1.0 (/home/gmoshkin/code/pd/tm3/examples/write)
warning: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_names`
 --> tests/src/lib.rs:2:10
  |
2 | #![allow(clippy::blacklisted_name)]
  |          ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_names`
  |
  = note: `#[warn(renamed_and_removed_lints)]` on by default

warning: deref which would be done by auto-deref
  --> tests/src/bench_bulk_insert.rs:59:31
   |
59 |                         text: &*text.borrow(),
   |                               ^^^^^^^^^^^^^^^ help: try this: `&text.borrow()`
   |
   = note: `#[warn(clippy::explicit_auto_deref)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref

error: internal compiler error: compiler/rustc_trait_selection/src/traits/query/normalize.rs:258:21: unexpected ambiguity: Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing, constness: NotConst }, value: ProjectionTy { substs: [tarantool::tlua::Function<fn() -> std::result::Result<i32, &str>, (), std::result::Result<i32, &str>>], item_def_id: DefId(33:1837 ~ tlua[df0d]::PushInto::Err) } } } Canonical { max_universe: U1, variables: [CanonicalVarInfo { kind: Region(U1) }, CanonicalVarInfo { kind: PlaceholderRegion(Placeholder { universe: U1, name: BrNamed(DefId(33:3158 ~ tlua[df0d]::functions_write::{impl#75}::'p), 'p) }) }, CanonicalVarInfo { kind: Region(U1) }], value: QueryResponse { var_values: CanonicalVarValues { var_values: [] }, region_constraints: QueryRegionConstraints { outlives: [(Binder(OutlivesPredicate(ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrAnon(0) }), ReLateBound(DebruijnIndex(1), BoundRegion { var: 1, kind: BrAnon(1) })), []), BoringNoLocation), (Binder(OutlivesPredicate(ReLateBound(DebruijnIndex(1), BoundRegion { var: 2, kind: BrAnon(2) }), ReErased), []), BoringNoLocation), (Binder(OutlivesPredicate(ReLateBound(DebruijnIndex(1), BoundRegion { var: 1, kind: BrAnon(1) }), ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrAnon(0) })), []), BoringNoLocation), (Binder(OutlivesPredicate(ReErased, ReLateBound(DebruijnIndex(1), BoundRegion { var: 2, kind: BrAnon(2) })), []), BoringNoLocation), (Binder(OutlivesPredicate(fn() -> std::result::Result<i32, &str>, ReStatic), []), BoringNoLocation), (Binder(OutlivesPredicate(std::result::Result<i32, &str>, ReStatic), []), BoringNoLocation)], member_constraints: [] }, certainty: Ambiguous, opaque_types: [], value: NormalizationResult { normalized_ty: tarantool::tlua::Void } } }

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/897e37553bba8b42751c67658967889d11ecd120/compiler/rustc_errors/src/lib.rs:1462:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::bug::<&alloc::string::String>
   3: <rustc_errors::Handler>::bug::<&alloc::string::String>
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
   5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   6: rustc_middle::util::bug::bug_fmt
   7: <rustc_trait_selection::traits::query::normalize::QueryNormalizer as rustc_middle::ty::fold::FallibleTypeFolder>::try_fold_ty
   8: <rustc_infer::infer::InferCtxtBuilder>::enter::<core::result::Result<rustc_middle::ty::subst::GenericArg, rustc_middle::traits::query::NoSolution>, rustc_traits::normalize_erasing_regions::try_normalize_after_erasing_regions<rustc_middle::ty::subst::GenericArg>::{closure#0}>
   9: <rustc_traits::normalize_erasing_regions::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::subst::GenericArg>)>>::call_once
  10: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::subst::GenericArg>, core::result::Result<rustc_middle::ty::subst::GenericArg, rustc_middle::traits::query::NoSolution>>
  11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::subst::GenericArg>, core::result::Result<rustc_middle::ty::subst::GenericArg, rustc_middle::traits::query::NoSolution>>>
  12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_normalize_generic_arg_after_erasing_regions
  13: <rustc_middle::ty::normalize_erasing_regions::TryNormalizeAfterErasingRegionsFolder as rustc_middle::ty::fold::FallibleTypeFolder>::try_fold_ty
  14: clippy_lints::dereference::needless_borrow_impl_arg_position
  15: <&mut clippy_lints::dereference::walk_parents::{closure#0} as core::ops::function::FnMut<(rustc_hir::hir::Node, rustc_hir::hir_id::HirId)>>::call_mut
  16: clippy_utils::walk_to_expr_usage::<clippy_lints::dereference::Position, &mut clippy_lints::dereference::walk_parents::{closure#0}>
  17: <clippy_lints::dereference::Dereferencing as rustc_lint::passes::LateLintPass>::check_expr
  18: <rustc_lint::early::EarlyLintPassObjects as rustc_lint::passes::EarlyLintPass>::check_generic_arg
  19: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_expr
  20: rustc_hir::intravisit::walk_expr::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
  21: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_expr
  22: rustc_hir::intravisit::walk_block::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
  23: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_block
  24: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_expr
  25: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_body
  26: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_fn
  27: rustc_hir::intravisit::walk_item::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
  28: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_item
  29: rustc_hir::intravisit::walk_mod::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
  30: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_item
  31: rustc_hir::intravisit::walk_mod::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
  32: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_item
  33: rustc_hir::intravisit::walk_mod::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
  34: rustc_lint::late::late_lint_pass_crate::<rustc_lint::late::LateLintPassObjects>
  35: rustc_lint::late::late_lint_crate::<rustc_lint::BuiltinCombinedLateLintPass>
  36: <rustc_session::session::Session>::time::<(), rustc_lint::late::check_crate<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
  37: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}>
  38: <core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#5}::{closure#1}> as core::ops::function::FnOnce<()>>::call_once
  39: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#5}>
  40: rustc_interface::passes::analysis
  41: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_mi
ddle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  42: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  43: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  44: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  45: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  46: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new

note: Clippy version: clippy 0.1.65 (897e375 2022-11-02)

query stack during panic:
#0 [try_normalize_generic_arg_after_erasing_regions] normalizing `tlua::PushInto::Err`
#1 [analysis] running analysis passes on this crate
end of query stack
warning: `tarantool-module-test-runner` (lib) generated 2 warnings
error: could not compile `tarantool-module-test-runner`; 2 warnings emitted

Can't add any more context at this point

@gmoshkin gmoshkin changed the title unexpected panic at 'try_normalize_generic_arg_after_erasing_regions' query unexpected panic unexpected ambiguity at 'try_normalize_generic_arg_after_erasing_regions' query Dec 1, 2022
@Alexendoo Alexendoo added the I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 1, 2022
@e-ivkov
Copy link

e-ivkov commented Dec 4, 2022

In 1.64 and earlier versions cargo clippy seems to work fine on this tarantool-module commit. This panic starts only on 1.65

@e-ivkov
Copy link

e-ivkov commented Dec 4, 2022

Also interestingly it doesn't panic if we give it cargo clippy --tests flag

@gmoshkin
Copy link
Author

gmoshkin commented Dec 5, 2022

@smoelius yes, the panic goes away for me if I remove the & on line https://git.picodata.io/picodata/picodata/tarantool-module/-/blob/d417c97904ac614b577478df0b6aaaa5174a22c2/tests/src/tlua/functions_write.rs#L68
like this:

     let f: function![() -> Result<i32, &'static str>] = function0(always_fails);
-    lua.set("always_fails", &f);
+    lua.set("always_fails", f);

Thus changing the deduced generic argument to the Lua::set function

But what I noticed is that it also goes aways if I change the signature of Lua::set (defined at https://git.picodata.io/picodata/picodata/tarantool-module/-/blob/d417c97904ac614b577478df0b6aaaa5174a22c2/tlua/src/lib.rs#L1281) in a seemingly unrelated way:

-    pub fn set<'lua, I, V, E>(&'lua self, index: I, value: V)
+    pub fn set<'lua, I, V>(&'lua self, index: I, value: V)
     where
         I: Borrow<str>,
-        V: PushOneInto<&'lua Self, Err = E>,
-        E: Into<Void>,
+        V: PushOneInto<&'lua Self>,
+        <V as PushInto<&'lua Self>>::Err: Into<Void>,

Not sure if this is of any help

@matthiaskrgr
Copy link
Member

Getting the same ICE when running clippy on the git-repository gitoxide crate :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants