Stream: t-compiler/rust-analyzer

Topic: rustwide analysis-stats


Laurențiu (Feb 27 2021 at 15:21, on Zulip):

It might be a fun project to run the RA analysis over a set of popular Rust repost on GitHub to find any crashes/hangs. But we might as wall wait until chalk is tested in rustc

matklad (Feb 27 2021 at 15:22, on Zulip):

rust-craterizer?

detrumi (Feb 27 2021 at 15:24, on Zulip):

We still need to get all rustc tests green for Chalk integration

detrumi (Feb 27 2021 at 15:24, on Zulip):

But after that, yeah that's a good way to find issues

matklad (Feb 27 2021 at 15:35, on Zulip):

Note that a good first step would be not crashing with rust-analyzer analysis-stats --parallel --with-deps . on parity's substrate

matklad (Feb 27 2021 at 15:36, on Zulip):

Currently dies with

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 4', crates/hir_def/src/visibility.rs:170:37
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic_bounds_check
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:69:5
   3: hir_def::visibility::Visibility::max
   4: hir_def::nameres::collector::DefCollector::update_recursive
   5: hir_def::nameres::collector::DefCollector::record_resolved_import
   6: hir_def::nameres::collector::DefCollector::resolve_imports
   7: hir_def::nameres::collector::collect_defs
   8: hir_def::nameres::DefMap::block_def_map_query

(cc @Jonas Schievink [he/him] )

matklad (Feb 27 2021 at 15:36, on Zulip):

(visibility there reminrds me of that bug with macros)

Jonas Schievink [he/him] (Feb 27 2021 at 18:06, on Zulip):

Repro:

fn main() {
    use Tr as _;
    trait Tr {}
}

...except it, again, doesn't happen when making this a test :angry_cat:

Jonas Schievink [he/him] (Feb 27 2021 at 18:08, on Zulip):

it would be neat if we could print query stacks during panic like rustc can

Laurențiu (Feb 27 2021 at 18:13, on Zulip):

That one doesn't panic for me

Jonas Schievink [he/him] (Feb 27 2021 at 18:42, on Zulip):

oh lemme guess, only happens in submodules again

Jonas Schievink [he/him] (Feb 27 2021 at 18:42, on Zulip):

yup

Jonas Schievink [he/him] (Feb 27 2021 at 18:58, on Zulip):

what seems to happen is that the item's visibility gets resolved to the containing module, because we treat the default visibility as pub(self), and self resolves to the containing module

Jonas Schievink [he/him] (Feb 27 2021 at 18:58, on Zulip):

Visibility::max does not handle visibilities from outside the given DefMap (which I think is correct) and panics

Jonas Schievink [he/him] (Mar 04 2021 at 15:46, on Zulip):

The substrate codebase now runs into the chalk recurson limit:

thread '<unnamed>' panicked at 'overflow depth reached', /home/jonas/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-recursive-0.59.0/src/stack.rs:51:13
stack backtrace:
   0: std::panicking::begin_panic
   1: chalk_recursive::stack::Stack::push
   2: <chalk_recursive::recursive::Solver<I> as chalk_recursive::solve::SolveDatabase<I>>::solve_goal
   3: chalk_recursive::fulfill::Fulfill<I,Solver>::prove
   4: chalk_recursive::fulfill::Fulfill<I,Solver>::solve

It then pegs a core for hours while using 50 GB of RAM, it might be stuck in chalk or the type inference code:

(gdb) bt
#0  0x000056188c21f325 in <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch ()
#1  0x000056188c0c4e55 in <DB as hir_ty::db::HirDatabase>::trait_solve::__shim ()
#2  0x000056188ba8d8f9 in <DB as hir_ty::db::HirDatabase>::trait_solve ()
#3  0x000056188c18b705 in hir_ty::infer::InferenceContext::resolve_ty_as_possible::hdcbd7f0297ba5860 ()
#4  0x000056188c082eab in hir_ty::infer::unify::Canonicalized<T>::apply_solution ()
#5  0x000056188c18b925 in hir_ty::infer::InferenceContext::resolve_ty_as_possible::hdcbd7f0297ba5860 ()
#6  0x000056188c082eab in hir_ty::infer::unify::Canonicalized<T>::apply_solution ()
#7  0x000056188c18b925 in hir_ty::infer::InferenceContext::resolve_ty_as_possible::hdcbd7f0297ba5860 ()
#8  0x000056188c082eab in hir_ty::infer::unify::Canonicalized<T>::apply_solution ()
#9  0x000056188c18b925 in hir_ty::infer::InferenceContext::resolve_ty_as_possible::hdcbd7f0297ba5860 ()
#10 0x000056188c082eab in hir_ty::infer::unify::Canonicalized<T>::apply_solution ()
#11 0x000056188c18b925 in hir_ty::infer::InferenceContext::resolve_ty_as_possible::hdcbd7f0297ba5860 ()
#12 0x000056188c082eab in hir_ty::infer::unify::Canonicalized<T>::apply_solution ()
#13 0x000056188c18b925 in hir_ty::infer::InferenceContext::resolve_ty_as_possible::hdcbd7f0297ba5860 ()
#14 0x000056188c082eab in hir_ty::infer::unify::Canonicalized<T>::apply_solution ()
#15 0x000056188c18b925 in hir_ty::infer::InferenceContext::resolve_ty_as_possible::hdcbd7f0297ba5860 ()
#16 0x000056188c082eab in hir_ty::infer::unify::Canonicalized<T>::apply_solution ()
#17 0x000056188c18b925 in hir_ty::infer::InferenceContext::resolve_ty_as_possible::hdcbd7f0297ba5860 ()
#18 0x000056188c1791a7 in hir_ty::infer::path::<impl hir_ty::infer::InferenceContext>::infer_path ()
#19 0x000056188c17af73 in hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner ()
#20 0x000056188c17b653 in hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner ()
#21 0x000056188c179c15 in hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr ()
#22 0x000056188c17e6a1 in hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner ()
matklad (Mar 04 2021 at 15:48, on Zulip):

Should've used "stress testing trait inference" as an example of blockchain application on reddit

Last update: Jul 29 2021 at 10:00UTC