Skip to content

Reduce redundant path validation for attributes #4251

@carolynzech

Description

@carolynzech

Proposed change: Refactor path handling for contracts and stubs to check for resolution errors once at the start of codegen; then maintain state about resolved functions and paths.

Motivation:
#4249 has interpret_for_contract_attribute and interpret_stub_verified_attribute do the exact same path resolution logic that we already did in check_attributes. But we abort if check_attributes errors:

tcx.dcx().abort_if_errors();

I'm envisioning that we do the resolution once in check_attributes, abort if there's an error, and then again in the beginning of codegen, this time leveraging the fact that we know there won't be errors to store the FnResolution only. Then codegen could pass around these resolutions as state (perhaps in the CodegenUnit), rather than redoing path resolution every time we want to refer to the path in the attribute.

i.e. parse, don't validate!

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    [C] InternalTracks some internal work. I.e.: Users should not be affected.[I] Refactoring / Clean UpRefactoring or cleaning up of existing code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions