Skip to content
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

Fn field with GAT breaks rust analyzer #13734

Closed
xmakro opened this issue Dec 6, 2022 · 0 comments · Fixed by #13742
Closed

Fn field with GAT breaks rust analyzer #13734

xmakro opened this issue Dec 6, 2022 · 0 comments · Fixed by #13742
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@xmakro
Copy link

xmakro commented Dec 6, 2022

rust-analyzer version: 0.4.1310-standalone
rustc version: rustc 1.65.0 (897e37553 2022-11-02)

Rust analyzer error message: Request textDocument/inlayHint failed.

Minimal repro:

pub trait Foo {
    type Data<A>;
}

pub struct Bar<B: Foo, A> {
    pub my_fun: Box<dyn Fn(&B::Data<A>)>,
}

impl<B: Foo, A> Bar<B, A> {
    fn run_fun(&mut self, data: &B::Data<A>) {
        (self.my_fun)(data);
    }
}

The code builds successfully with cargo build,

but rust analyzer crashes with the following log:

Panic context:
> 
version: 0.4.1310-standalone
request: textDocument/codeAction CodeActionParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/mnt/c/Users/mnlkr/Documents/GitHub/rax/src/example.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 105,
            character: 50,
        },
        end: Position {
            line: 105,
            character: 50,
        },
    },
    context: CodeActionContext {
        diagnostics: [],
        only: None,
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

thread 'Worker' panicked at 'unexpected free variable with depth `^0.1` with outer binder ^2', /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.88.0/src/fold.rs:154:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
   2: chalk_ir::fold::FallibleTypeFolder::try_fold_free_var_ty
   3: <chalk_ir::Ty<I> as chalk_ir::fold::TypeSuperFoldable<I>>::try_super_fold_with
   4: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::GenericArg<I>>::try_fold_with
   5: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   6: <hir_ty::interner::Interner as chalk_ir::interner::Interner>::intern_substitution
   7: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
   8: <chalk_ir::Ty<I> as chalk_ir::fold::TypeSuperFoldable<I>>::try_super_fold_with
   9: <chalk_ir::Ty<I> as chalk_ir::fold::TypeSuperFoldable<I>>::try_super_fold_with
  10: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::GenericArg<I>>::try_fold_with
  11: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  12: <hir_ty::interner::Interner as chalk_ir::interner::Interner>::intern_substitution
  13: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
  14: <chalk_ir::Ty<I> as chalk_ir::fold::TypeSuperFoldable<I>>::try_super_fold_with
  15: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::GenericArg<I>>::try_fold_with
  16: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  17: <hir_ty::interner::Interner as chalk_ir::interner::Interner>::intern_substitution
  18: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
  19: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::WhereClause<I>>::try_fold_with
  20: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Binders<T>>::try_fold_with
  21: <chalk_ir::cast::Casted<IT,U> as core::iter::traits::iterator::Iterator>::next
  22: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  23: core::iter::adapters::try_process
  24: <chalk_ir::Ty<I> as chalk_ir::fold::TypeSuperFoldable<I>>::try_super_fold_with
  25: chalk_solve::infer::unify::Unifier<I>::relate_var_ty
  26: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  27: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_tys
  28: chalk_ir::zip::Zipper::zip_substs
  29: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  30: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_tys
  31: chalk_solve::infer::unify::Unifier<I>::relate
  32: chalk_solve::infer::unify::<impl chalk_solve::infer::InferenceTable<I>>::relate
  33: hir_ty::infer::unify::InferenceTable::fudge_inference
  34: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::expected_inputs_for_expected_output
  35: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  36: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  37: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  38: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  39: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  40: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  41: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  42: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  43: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  44: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  45: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  46: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  47: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  48: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  49: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  50: hir_ty::infer::infer_query
  51: salsa::runtime::Runtime::execute_query_implementation
  52: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  53: salsa::derived::slot::Slot<Q,MP>::read
  54: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  55: <DB as hir_ty::db::HirDatabase>::infer_query::__shim
  56: <DB as hir_ty::db::HirDatabase>::infer_query
  57: hir_ty::db::infer_wait
  58: <DB as hir_ty::db::HirDatabase>::infer
  59: hir::DefWithBody::diagnostics
  60: hir::Module::diagnostics
  61: ide_diagnostics::diagnostics
  62: std::panicking::try
  63: ide::Analysis::assists_with_fixes
  64: rust_analyzer::handlers::handle_code_action
  65: std::panicking::try
  66: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@xmakro xmakro changed the title Calling Fn member functions that use GAT breaks rust analyzer Fn member functions with GAT breaks rust analyzer Dec 6, 2022
@xmakro xmakro changed the title Fn member functions with GAT breaks rust analyzer Fn member function with GAT breaks rust analyzer Dec 6, 2022
@xmakro xmakro changed the title Fn member function with GAT breaks rust analyzer Fn field with GAT breaks rust analyzer Dec 6, 2022
@lnicola lnicola added A-ty type system / type inference / traits / method resolution C-bug Category: bug labels Dec 6, 2022
@bors bors closed this as completed in 518e39b Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants