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

function import get replaced by a module import #18347

Open
wiiznokes opened this issue Oct 19, 2024 · 2 comments
Open

function import get replaced by a module import #18347

wiiznokes opened this issue Oct 19, 2024 · 2 comments
Assignees
Labels
C-bug Category: bug

Comments

@wiiznokes
Copy link

wiiznokes commented Oct 19, 2024

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

0.3.2146-standalone

rustc version: (eg. output of rustc -V)

rustc 1.84.0-nightly (3ed6e3cc6 2024-10-17)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)

VSCode

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

code snippet to reproduce:

#[doc(inline)]
pub use tooltip::{tooltip, Tooltip};
pub mod tooltip {
    use crate::Element;
    use std::borrow::Cow;

    pub use iced::widget::tooltip::Position;

    pub type Tooltip<'a, Message> =
        iced::widget::Tooltip<'a, Message, crate::Theme, crate::Renderer>;

    pub fn tooltip<'a, Message>(
        content: impl Into<Element<'a, Message>>,
        tooltip: impl Into<Element<'a, Message>>,
        position: Position,
    ) -> Tooltip<'a, Message> {
        let xxs = crate::theme::active().cosmic().space_xxs();

        Tooltip::new(content, tooltip, position)
            .class(crate::theme::Container::Tooltip)
            .padding(xxs)
            .gap(1)
    }
}

This code is from libcosmic.

My current import is:

use cosmic::{
    iced::{Color, Length},
    iced_widget::{pick_list, toggler},
    prelude::CollectionWidget,
    widget::{
        button, column, container, dropdown, horizontal_space, row,
        segmented_button::Entity, settings::section, text, text_input, tooltip, tooltip::Position,
        Row,
    },
    Element,
};

When I import stmg from libcosmic, let's say mouse_arena, this is what imported:

use cosmic::{
    iced::{Color, Length},
    iced_widget::{pick_list, toggler},
    prelude::CollectionWidget,
    widget::{
        button, column, container, dropdown, horizontal_space, mouse_area, row, segmented_button::Entity, settings::section, text, text_input, tooltip::{self, Position}, Row
    },
    Element,
};

Notice the tooltip::{self, Position}. This cause this error: error[E0423]: expected function, found module tooltip``

@wiiznokes wiiznokes added the C-bug Category: bug label Oct 19, 2024
@rwakulszowa
Copy link

I can take a look at this. @rustbot claim

@rwakulszowa
Copy link

A simpler repro

  1. Start with this
// main.rs
use lsp_test::foo;

fn main() {
    println!("{:}", foo());
}
// lib.rs
pub fn foo() -> u32 {
    44
}

pub mod foo {
    pub fn bar() -> u32 {
        88
    }
}

Compiles and works fine.

  1. Call bar in main.
// main.rs
use lsp_test::foo::{self, bar};  // auto imported

fn main() {
    println!("{:} {:}", foo(), bar());
}

// expected function, found module foo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants