Skip to content

Unreasonable "consider importing" suggestions #84081

Closed

Description

@porglezomp

I made a typo text -> test and got a very strange suggestion.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1fdd70937900d5a5443d66f0c200ada6

use std::{fs, io::Read};

fn foo() {
    let mut f = fs::File::new("hello");
    let mut text = String::new();
    f.read_to_string(&mut test).unwrap();
}

The current output is:

Standard Error

   Compiling playground v0.0.1 (/playground)

error[E0423]: expected value, found attribute macro `test`
 --> src/lib.rs:6:27
  |
6 |     f.read_to_string(&mut test).unwrap();
  |                           ^^^^
  |
help: a local variable with a similar name exists
  |
6 |     f.read_to_string(&mut text).unwrap();
  |                           ^^^^
help: consider importing one of these items instead
  |
1 | use crate::fs::io::sys::ext::net::raw_fd::sys_common::backtrace::backtrace_rs::symbolize::gimli::mystd::detect::bit::test;
  |
1 | use crate::fs::io::sys::ext::net::raw_fd::sys_common::backtrace::backtrace_rs::symbolize::gimli::mystd::detect::cache::test;
  |

The import suggestions here are kind of nonsense.
(They are only suggested if fs is imported.)
It seems like "consider importing one of these items instead" shouldn't suggest private items, at the very least in the case of external crates.

(For the current crate, maybe you wanted one of your own items to be available, but those should still probably be called out as being private items?)

Activity

  1. added
    A-diagnostics
    T-compiler
    on Apr 11, 2021
  2. added
    A-resolve
    on Apr 11, 2021
  3. added a commit that references this issue on Apr 17, 2021
    511dc3f
  4. added a commit that references this issue on Apr 17, 2021
    42e5621
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsA-resolveT-compiler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions