Skip to content

Can't figure out that two #[cfg(... type parameters are disjoint #10016

@bes

Description

@bes

Environment

  • IntelliJ Rust plugin version: 0.4.186.5143-223
  • Rust toolchain version: rustc 1.66.0 (69f9c33d7 2022-12-12)
  • IDE name and version: CLion 2022.3.1 Build #CL-223.8214.51, built on December 20, 2022
  • Operating system: macOS

Problem description

IntelliJ Rust Can't figure out that two #[cfg(... type parameters are disjoint.

Steps to reproduce

Enter this code into CLion:

use std::marker::PhantomData;

pub trait A {
    fn args<
        #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] T: Send + 'static,
        #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] T,
    >(&self, phantom: PhantomData<T>);
}

#[derive(Debug)]
struct B;

impl A for B {
    fn args<T: Send + 'static>(&self, _phantom: PhantomData<T>) {
        println!("Foo!");
    }
}

fn main() {
    let b = B;
    b.args::<String>(PhantomData::default());
    println!("{:?}", b);
}

CLion will complain that we have error E0049, when infact we have not:

Screenshot 2023-01-20 at 16 52 51

Cargo check is clean:

% cargo check
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s

Cargo clippy is clean:

% cargo clippy
    Checking m3u8-hang v0.1.0 (/Users/bes/repos/github/m3u8-hang)
    Finished dev [unoptimized + debuginfo] target(s) in 1.20s

Compiling and running is clean:

% cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.39s
     Running `target/debug/m3u8-hang`
Foo!
B

Metadata

Metadata

Assignees

Labels

bugduplicateIssue duplicates another onesubsystem::cfgIssues related to conditional compilation (processing of `cfg` attributes)subsystem::highlightingIssues related to code highlighting

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions