Skip to content

Auto-importing puts import into a feature-gated import block. #6925

@jcdyer

Description

@jcdyer

The following code depends on bson = {version = "1.1", features = ["decimal128"]}.

#[cfg(feature = "decimal128")]
use bson::decimal128::Decimal128;

use bson::{
    doc,
    Bson,
};

fn demonstrator() -> Vec<u8> {
    let js = Bson::JavaScriptCodeWithScope(JavaScriptCodeWithScope {
        code: String::from("console.log('a bug?', x);"),
        scope: doc! {"x": 42},
    });
    let doc = doc!{ "js": js };
    let mut out = Vec::new();
    doc.to_writer(&mut out);
    out
}

The identifier "JavaScriptCodeWithScope" can be used as bson::JavaScriptCodeWithScope, but when I do ctrl-., and opt to perform the import, it places the import within the feature-gated import block. In theory that could be the correct action, and I'm not sure how smart RA could be about this, but I think importing into the non-cfg-gated block is a better choice in the absence of a specific reason to choose one or the other.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-completionautocompletionE-has-instructionsIssue has some instructions and pointers to code to get startedS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions