Intellij-rust: Invalid duplicated name for function

Created on 19 Sep 2019  路  3Comments  路  Source: intellij-rust/intellij-rust

Environment

  • IntelliJ Rust plugin version: 0.2.105.2133-192
  • Rust toolchain version: 1.35.0
  • IDE name and version: CLion 2019.2.2
  • Operating system: Windows 10

Problem description

The plugin wrongly detects a duplicate function name. (A value named raw_match_pattern_endian has already been defined in this module [E0428]) when using conditional compilation.

Steps to reproduce

#[cfg(target_endian = "little")]
const fn raw_match_pattern_endian(original: u64) -> u64 {
    original
}

#[cfg(target_endian = "big")]
const fn raw_match_pattern_endian(original: u64) -> u64 {
    (original & 0xff) << 56 | (original & 0xff00) << 40 | (original & 0xff0000) << 24 | (original & 0xff000000) << 8 | (original & 0xff00000000) >> 8 | (original & 0xff0000000000) >> 24 | (original & 0xff000000000000) >> 40 | (original & 0xff00000000000000) >> 56
}
bug cfg code insight

Most helpful comment

@parkercouch Cargo features aren't supported yet (we're working on it). For more information, see https://github.com/intellij-rust/intellij-rust/pull/4488.

However, the original issue about target_endian seems to be fixed now:
Screenshot 2019-10-23 at 21 53 25

All 3 comments

Was also wondering about it as well, what if I have custom #[cfg(some_stuff)] and #[cfg(not(some_stuff))] next to it (which is quite a common pattern for conditionally compiled libraries). Currently the plugin reports duplicate function name.

I'm also getting this when dealing with type aliases that are conditional to the selected feature.
(Not sure if this is the right place to post this)

IntelliJ Rust plugin version: 0.2.106.2135-191
Rust toolchain version: 1.39.0
IDE name and version: CLion 2019.1.4
Operating system: macOS Catalina 10.15

/// The connection type (MySQL database).
#[cfg(feature = "mysql")]
pub type Connection = diesel::mysql::MysqlConnection;

/// The connection type (SQLite database).
#[cfg(feature = "sqlite")]
pub type Connection = diesel::sqlite::SqliteConnection;

/// The connection type (PostgreSQL database).
#[cfg(feature = "postgres")]
pub type Connection = diesel::pg::PgConnection;

@parkercouch Cargo features aren't supported yet (we're working on it). For more information, see https://github.com/intellij-rust/intellij-rust/pull/4488.

However, the original issue about target_endian seems to be fixed now:
Screenshot 2019-10-23 at 21 53 25

Was this page helpful?
0 / 5 - 0 ratings