fn primary_location(
    config: &DiagnosticsMapConfig,
    workspace_root: &AbsPath,
    span: &DiagnosticSpan,
    snap: &GlobalStateSnapshot,
) -> lsp_types::Location {
    let span_stack = std::iter::successors(Some(span), |span| Some(&span.expansion.as_ref()?.span));
    for span in span_stack.clone() {
        let abs_path = resolve_path(config, workspace_root, &span.file_name);
        if !is_dummy_macro_file(&span.file_name) && abs_path.starts_with(workspace_root) {
            return location(config, workspace_root, span, snap);
        }
    }

    // Fall back to the outermost macro invocation if no suitable span comes up.
    let last_span = span_stack.last().unwrap();
    location(config, workspace_root, last_span, snap)
}
/// Extracts a suitable "primary" location from a rustc diagnostic.
///
/// This takes locations pointing into the standard library, or generally outside the current
/// workspace into account and tries to avoid those, in case macros are involved.
Extracts a suitable "primary" location from a rustc diagnostic.
This takes locations pointing into the standard library, or generally outside the current
workspace into account and tries to avoid those, in case macros are involved.
Extracts a suitable " primary " location from a rustc diagnostic . This takes locations pointing into the standard library or generally outside the current workspace into account and tries to avoid those in case macros are involved .
fn primary_location(
    config: &DiagnosticsMapConfig,
    workspace_root: &AbsPath,
    span: &DiagnosticSpan,
    snap: &GlobalStateSnapshot,
) -> lsp_types::Location {
    let span_stack = std::iter::successors(Some(span), |span| Some(&span.expansion.as_ref()?.span));
    for span in span_stack.clone() {
        let abs_path = resolve_path(config, workspace_root, &span.file_name);
        if !is_dummy_macro_file(&span.file_name) && abs_path.starts_with(workspace_root) {
            return location(config, workspace_root, span, snap);
        }
    }
    // Fall back to the outermost macro invocation if no suitable span comes up.
    let last_span = span_stack.last().unwrap();
    location(config, workspace_root, last_span, snap)
}
fn primary_location ( config : & DiagnosticsMapConfig , workspace_root : & AbsPath , span : & DiagnosticSpan , snap : & GlobalStateSnapshot , ) -> lsp_types :: Location { let span_stack = std :: iter :: successors ( Some ( span ) , | span | Some ( & span . expansion . as_ref ( ) ? . span ) ) ; for span in span_stack . clone ( ) { let abs_path = resolve_path ( config , workspace_root , & span . file_name ) ; if ! is_dummy_macro_file ( & span . file_name ) && abs_path . starts_with ( workspace_root ) { return location ( config , workspace_root , span , snap ) ; } } // Fall back to the outermost macro invocation if no suitable span comes up. let last_span = span_stack . last ( ) . unwrap ( ) ; location ( config , workspace_root , last_span , snap ) }
Extracts a suitable "primary" location from a rustc diagnostic.
Extracts a suitable " primary " location from a rustc diagnostic .
config
&DiagnosticsMapConfig
workspace_root
&AbsPath
span
&DiagnosticSpan
snap
&GlobalStateSnapshot
config
&DiagnosticsMapConfig
workspace_root
&AbsPath
span
&DiagnosticSpan
snap
&GlobalStateSnapshot