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

save-analysis: Get path def from parent in case there's no def for the path itself. #57474

Merged
merged 1 commit into from
Jan 13, 2019

Commits on Jan 9, 2019

  1. save-analysis: Get path def from parent in case there's no def for th…

    …e path itself.
    
    This fixes rust-lang#57462.
    
    The relevant part from the hir type collector is:
    
    ```
    DEBUG 2019-01-09T15:42:58Z: rustc::hir::map::collector: hir_map: NodeId(32) => Entry { parent: NodeId(33), dep_node: 4294967040, node: Expr(expr(32: <Foo>::new)) }
    DEBUG 2019-01-09T15:42:58Z: rustc::hir::map::collector: hir_map: NodeId(48) => Entry { parent: NodeId(32), dep_node: 4294967040, node: Ty(type(Foo)) }
    DEBUG 2019-01-09T15:42:58Z: rustc::hir::map::collector: hir_map: NodeId(30) => Entry { parent: NodeId(48), dep_node: 4294967040, node: PathSegment(PathSegment { ident: Foo#0, id: Some(NodeId(30)), def: Some(Err), args: None, infer_types: true }) }
    DEBUG 2019-01-09T15:42:58Z: rustc::hir::map::collector: hir_map: NodeId(31) => Entry { parent: NodeId(32), dep_node: 4294967040, node: PathSegment(PathSegment { ident: new#0, id: Some(NodeId(31)), def: Some(Err), args: None, infer_types: true }) }
    ```
    
    We have the right ID when looking for NodeId(31) and try with NodeId(32) (which
    is the right thing to look for) from get_path_data, but not for the segments
    that we write from `write_sub_paths_truncated`.
    
    Basically `process_path` takes an id which is always the parent, and that we
    fall back to in `get_path_data()`, so we get the right result for the last path
    segment, but not for the other segments that get written to from
    `write_sub_paths_truncated`.
    
    I think we can stop passing the explicit id around to `get_path_data` now, will
    consider sending that as a followup.
    emilio committed Jan 9, 2019
    Configuration menu
    Copy the full SHA
    c47ed14 View commit details
    Browse the repository at this point in the history