Change:
RLS cannot build my project, which uses gstreamer. Compiling it normally with rustc works fine. Affected project for reference: I launched RLS manually with
Probably unearthed by
cc
Recompiled everything with , same issue.
works fine.
I’m sure it’s what - it’s an unearthed bug when you pass -Zsave-analysis, hence why it crashes only when using RLS.
I have the same error when using rust nightly and directly or indirectly referencing the crate. The project builds fine but crashes. Steps to reproduce: Create a new project Add to the Run Downgrading to and makes the error go away.
pre-triage: not sure what priority to assign to this. Probably P-high but I want to discuss with team. Leaving I-nominated unprioritized for now.
triage: P-high. Cc (can you take point on this?)
Yup, assigning to myself, shouldn’t be hard to fix
What assistance from others, if any, could help you resolve this issue?
Minimal reproducer (based on petgraph ICE):
Is anyone else available you can offload this bug to?
visiting for triage. Assigning to self to remember to look into this later
So I have a fix that does not ICE but doesn't seem to actually 'fix' the behaviour. The problem is that we can't nest typeck tables for because it doesn't have one because it doesn't have a body; however we hit the assertion when trying to resolve member type when resolving a qualified path using because the DefId paths don't properly match. The fix that I have is not to try to nest when a given NodeId doesn't have associated typecktables but instead use an empty table approach (e.g. used in privacy code). This means we don't hit the assertion but IIUC we can't properly resolve a qualified path this way. I think long-term the solution would be to traverse HIR directly rather than doing so using AST (that's another case where we have a mismatch of nested DefIds for which we can't get typeck tables to properly resolve a ). I'll submit the PR with the fix later today.

Discussion:
F: FnOnce(&mut Self), { let item_def_id = self.tcx.hir().local_def_id_from_node_id(item_id); <del> if self.tcx.has_typeck_tables(item_def_id) { let tables = self.tcx.typeck_tables_of(item_def_id); let old_tables = self.save_ctxt.tables; self.save_ctxt.tables = tables; f(self); self.save_ctxt.tables = old_tables; </del> <ins> let tables = if self.tcx.has_typeck_tables(item_def_id) { self.tcx.typeck_tables_of(item_def_id) </ins> } else { <del> f(self); } </del> <ins> self.save_ctxt.empty_tables }; let old_tables = self.save_ctxt.tables; self.save_ctxt.tables = tables; f(self); self.save_ctxt.tables = old_tables; </ins> } fn span_from_span(&self, span: Span) -> SpanData {

); } <del> for field in def.fields() { self.process_struct_field_def(field, item.id); self.visit_ty(&field.ty); } </del> <ins> self.nest_tables(item.id, |v| { for field in def.fields() { v.process_struct_field_def(field, item.id); v.visit_ty(&field.ty); } </ins> <del> self.process_generic_params(ty_params, &qualname, item.id); </del> <ins> v.process_generic_params(ty_params, &qualname, item.id); }); </ins> } fn process_enum(

pub struct SaveContext<'l, 'tcx> { tcx: TyCtxt<'tcx>, tables: &'l ty::TypeckTables<'tcx>, <ins> /// Used as a fallback when nesting the typeck tables during item processing /// (if these are not available for that item, e.g. don't own a body) empty_tables: &'l ty::TypeckTables<'tcx>, </ins> access_levels: &'l AccessLevels, span_utils: SpanUtils<'tcx>, config: Config,

let save_ctxt = SaveContext { tcx, tables: &ty::TypeckTables::empty(None), <ins> empty_tables: &ty::TypeckTables::empty(None), </ins> access_levels: &access_levels, span_utils: SpanUtils::new(&tcx.sess), config: find_config(config),

<ins> // check-pass // compile-flags: -Zsave-analysis trait Trait { type Assoc; } fn main() { struct Data<T: Trait> { x: T::Assoc, } } </ins>