Skip to content

Change active cfg's dynamically #6117

@tweksteen

Description

@tweksteen

I am raising this issue following the conversation on wg-rls-2.0 (topic "Support for #[cfg(test)]").

The test cfg option is currently added unconditionally when loading the source of a crate. A similar approach is usually followed for project using the rust-project.json model.

It is a standard pattern for mocking library to use the attribute: #[cfg(not(test))]. Because of this, the name resolution (i.e. go to definition) will jump to the mocked value instead of the original one.

For the rust-project.json-based model, it is possible to declare the crate with and without the configuration enabled. We should support the configuration selection, as provided by the client, to use one or the other crate. We may use the initializationOptions during the initialize request to provide rust-analyzer with the information on which configuration should be enabled.

@woody77 @Nashenas88 @flodiebold Did I miss anything from the conversation? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-configconfigurationE-unknownIt's unclear if the issue is E-hard or E-easy without digging inS-unactionableIssue requires feedback, design decisions or is blocked on other work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions