Skip to content

Panic when analyzing &fn(&dyn Trait) #13838

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
sandyberko opened this issue Dec 24, 2022 · 0 comments · Fixed by #13840
Closed

Panic when analyzing &fn(&dyn Trait) #13838

sandyberko opened this issue Dec 24, 2022 · 0 comments · Fixed by #13840
Labels
A-ty type system / type inference / traits / method resolution Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug

Comments

@sandyberko
Copy link

rust-analyzer panics when encountering a reference to a function pointer that has a &dyn parameter.
I'm using VS Code on Windows.

Reproduction repo:
https://github.com/sandyberko/ra-repro.git

rust-analyzer version: rust-analyzer 0.3.1325-standalone (9ed1829 2022-12-17)

rustc version: rustc 1.66.0 (69f9c33d7 2022-12-12)

relevant settings: N/A

Code:

trait Trait {}
fn foo(x: &fn(&dyn Trait)) {}

Error:

thread 'Worker' panicked at 'unexpected free variable with depth `^0.0` with outer binder ^0', C:\Users\runneradmin\.cargo\registry\src\gb.xjqchip.workers.dev-1ecc6299db9ec823\chalk-ir-0.88.0\src\fold.rs:454:13
Log

Panic context:
> 
version: 0.3.1325-standalone (9ed1829f1 2022-12-17)
request: textDocument/semanticTokens/full SemanticTokensParams {
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "[redacted]/ra-repro/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
}

thread 'Worker' panicked at 'unexpected free variable with depth `^0.0` with outer binder ^0', C:\Users\runneradmin\.cargo\registry\src\gb.xjqchip.workers.dev-1ecc6299db9ec823\chalk-ir-0.88.0\src\fold.rs:454:13
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library\std\src\panicking.rs:575
   1: core::panicking::panic_fmt
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library\core\src\panicking.rs:65
   2: chalk_solve::infer::instantiate::<impl chalk_solve::infer::InferenceTable<I>>::instantiate_binders_existentially
   3: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   4: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::DynTy<I>>::try_fold_with
   5: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   6: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   7: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   8: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
   9: chalk_ir::fold::TypeSuperFoldable::super_fold_with
  10: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  11: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
  12: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::WhereClause<I>>::try_fold_with
  13: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::DomainGoal<I>>::try_fold_with
  14: chalk_ir::fold::TypeSuperFoldable::super_fold_with
  15: chalk_solve::infer::canonicalize::<impl chalk_solve::infer::InferenceTable<I>>::canonicalize
  16: hir_ty::infer::unify::InferenceTable::canonicalize
  17: hir_ty::infer::unify::InferenceTable::register_obligation_in_env
  18: hir_ty::infer::unify::InferenceTable::normalize_projection_ty
  19: <DB as hir_ty::db::HirDatabase>::normalize_projection
  20: hir_ty::callable_sig_from_fnonce
  21: hir::Type::as_callable
  22: ide::syntax_highlighting::highlight::name_like
  23: ide::syntax_highlighting::highlight::name_like
  24: ide::syntax_highlighting::highlight
  25: ide::syntax_highlighting::highlight
  26: std::panicking::try
  27: rust_analyzer::handlers::handle_semantic_tokens_full
  28: std::panicking::try
  29: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 20:17:15] Request textDocument/semanticTokens/full failed.
  Message: request handler panicked: unexpected free variable with depth `^0.0` with outer binder ^0
  Code: -32603 

@flodiebold flodiebold added A-ty type system / type inference / traits / method resolution Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug labels Dec 24, 2022
@bors bors closed this as completed in 74ae2dd Dec 25, 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 Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants