-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Importing suggestion can add use-statement in between attribute and struct #3237
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
Comments
Oh, that massive To be more presize, Thank you for the report, I'll try to look at it this week, if nobody does this before. |
@Nashenas88 , I think we're missing some bits of the information here. and get the import placed on the top of the file: This sentence sounds a bit suspicious:
Are you sure that you're using rust-analyzer functionality to import the struct? No words about "possible candidates", "modules", no "use" word either. |
Could it have been suggested by rustc? |
The message looks exactly as if it was, but rustc does not add imports, does it? I'm rebuilding RA on Linux just in case the platfor has to do something with the bug. |
Rustc can give suggestions for unresolved idents. I think they are marked as machine applicable. @Nashenas88 do you have the RLS extension installed in addition to rust-analyzer? |
I was able to get the compiler message with the same words (when fixed my set up to a proper one: moved the code into a foo.rs and added a proc macro And I don't have rls installed, so maybe that's the case indeed. |
I'm going to close this since the issue seems not to be related to RA and we've got no extra details to think otherwise or to continue the investigation. Feel free to comment in case something new appears on the topic. |
@bjorn3 @SomeoneToIgnore I don't have RLS installed, only Rust Analyzer. The error does indeed come from the compiler itself, since when compiling from the terminal, I get this output:
Does something in RA try to apply rustc suggestions? I did used to have RLS installed, but I would be surprised if uninstalling it left context menu actions around. The only other extensions I have that might apply are ones limited to cargo and crates.io, but to my understanding those are for Cargo.toml file only. |
To clarify, the only extension I have that I expect to work on rust source code is rust-analyzer. |
Rust-analyzer does provide actions for machine-applicable fixes from rustc. I'm not sure if this is an upstream bug or an off-by-one on our line count. Could you attach the output of |
Here's the result of that command: {"reason":"compiler-artifact","package_id":"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["custom-build"],"crate_types":["bin"],"name":"build-script-build","src_path":"/home/pfaria/.cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/proc-macro2-1.0.8/build.rs","edition":"2018","doctest":false},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["default","proc-macro"],"filenames":["/home/pfaria/projects/coi/target/debug/build/proc-macro2-d1957ceb72a583e6/build-script-build"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["lib"],"crate_types":["lib"],"name":"unicode-xid","src_path":"/home/pfaria/.cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/unicode-xid-0.2.0/src/lib.rs","edition":"2015","doctest":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["default"],"filenames":["/home/pfaria/projects/coi/target/debug/deps/libunicode_xid-cfcbecc30409d14b.rlib","/home/pfaria/projects/coi/target/debug/deps/libunicode_xid-cfcbecc30409d14b.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["custom-build"],"crate_types":["bin"],"name":"build-script-build","src_path":"/home/pfaria/.cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/syn-1.0.14/build.rs","edition":"2018","doctest":false},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["clone-impls","default","derive","full","parsing","printing","proc-macro","quote"],"filenames":["/home/pfaria/projects/coi/target/debug/build/syn-2cb6d520c72b2228/build-script-build"],"executable":null,"fresh":true}
{"reason":"build-script-executed","package_id":"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)","linked_libs":[],"linked_paths":[],"cfgs":["use_proc_macro","wrap_proc_macro"],"env":[],"out_dir":"/home/pfaria/projects/coi/target/debug/build/proc-macro2-80ebaef47242d8b8/out"}
{"reason":"compiler-artifact","package_id":"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["lib"],"crate_types":["lib"],"name":"proc-macro2","src_path":"/home/pfaria/.cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/proc-macro2-1.0.8/src/lib.rs","edition":"2018","doctest":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["default","proc-macro"],"filenames":["/home/pfaria/projects/coi/target/debug/deps/libproc_macro2-58630165de29d27e.rlib","/home/pfaria/projects/coi/target/debug/deps/libproc_macro2-58630165de29d27e.rmeta"],"executable":null,"fresh":true}
{"reason":"build-script-executed","package_id":"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)","linked_libs":[],"linked_paths":[],"cfgs":["syn_disable_nightly_tests"],"env":[],"out_dir":"/home/pfaria/projects/coi/target/debug/build/syn-67e46b59d7d47e2a/out"}
{"reason":"compiler-artifact","package_id":"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["lib"],"crate_types":["lib"],"name":"quote","src_path":"/home/pfaria/.cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/quote-1.0.2/src/lib.rs","edition":"2018","doctest":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["default","proc-macro"],"filenames":["/home/pfaria/projects/coi/target/debug/deps/libquote-08e6bc44c5e16ed2.rlib","/home/pfaria/projects/coi/target/debug/deps/libquote-08e6bc44c5e16ed2.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["lib"],"crate_types":["lib"],"name":"syn","src_path":"/home/pfaria/.cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/syn-1.0.14/src/lib.rs","edition":"2018","doctest":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["clone-impls","default","derive","full","parsing","printing","proc-macro","quote"],"filenames":["/home/pfaria/projects/coi/target/debug/deps/libsyn-156e2a52d741215a.rlib","/home/pfaria/projects/coi/target/debug/deps/libsyn-156e2a52d741215a.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"thiserror-impl 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["proc-macro"],"crate_types":["proc-macro"],"name":"thiserror-impl","src_path":"/home/pfaria/.cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/thiserror-impl-1.0.10/src/lib.rs","edition":"2018","doctest":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/home/pfaria/projects/coi/target/debug/deps/libthiserror_impl-98c0fd2b98e96fb5.so"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"thiserror 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["lib"],"crate_types":["lib"],"name":"thiserror","src_path":"/home/pfaria/.cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/thiserror-1.0.10/src/lib.rs","edition":"2018","doctest":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/home/pfaria/projects/coi/target/debug/deps/libthiserror-d0c7d80784654e8f.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-message","package_id":"coi-derive 0.8.0 (path+file:///home/pfaria/projects/coi/coi-derive)","target":{"kind":["proc-macro"],"crate_types":["proc-macro"],"name":"coi-derive","src_path":"/home/pfaria/projects/coi/coi-derive/src/lib.rs","edition":"2018","doctest":true},"message":{"rendered":"error[E0412]: cannot find type `Ident` in this scope\n --> coi-derive/src/symbol.rs:15:28\n |\n15 | impl PartialEq<Symbol> for Ident {\n | ^^^^^ not found in this scope\n |\nhelp: possible candidates are found in other modules, you can import them into scope\n |\n6 | use proc_macro2::Ident;\n |\n6 | use proc_macro::Ident;\n |\n6 | use proc_macro::bridge::server::Ident;\n |\n6 | use quote::__rt::Ident;\n |\n and 1 other candidate\n\n","children":[{"children":[],"code":null,"level":"help","message":"possible candidates are found in other modules, you can import them into scope","rendered":null,"spans":[{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use proc_macro2::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use proc_macro::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use proc_macro::bridge::server::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use quote::__rt::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use syn::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]}]}],"code":{"code":"E0412","explanation":"The type name used is not in scope.\n\nErroneous code examples:\n\n```compile_fail,E0412\nimpl Something {} // error: type name `Something` is not in scope\n\n// or:\n\ntrait Foo {\n fn bar(N); // error: type name `N` is not in scope\n}\n\n// or:\n\nfn foo(x: T) {} // type name `T` is not in scope\n```\n\nTo fix this error, please verify you didn't misspell the type name, you did\ndeclare it or imported it into the scope. Examples:\n\n```\nstruct Something;\n\nimpl Something {} // ok!\n\n// or:\n\ntrait Foo {\n type N;\n\n fn bar(_: Self::N); // ok!\n}\n\n// or:\n\nfn foo<T>(x: T) {} // ok!\n```\n\nAnother case that causes this error is when a type is imported into a parent\nmodule. To fix this, you can follow the suggestion and use File directly or\n`use super::File;` which will import the types from the parent namespace. An\nexample that causes this error is below:\n\n```compile_fail,E0412\nuse std::fs::File;\n\nmod foo {\n fn some_function(f: File) {}\n}\n```\n\n```\nuse std::fs::File;\n\nmod foo {\n // either\n use super::File;\n // or\n // use std::fs::File;\n fn foo(f: File) {}\n}\n# fn main() {} // don't insert it for us; that'll break imports\n```\n"},"level":"error","message":"cannot find type `Ident` in this scope","spans":[{"byte_end":432,"byte_start":427,"column_end":33,"column_start":28,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":"not found in this scope","line_end":15,"line_start":15,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":33,"highlight_start":28,"text":"impl PartialEq<Symbol> for Ident {"}]}]}}
{"reason":"compiler-message","package_id":"coi-derive 0.8.0 (path+file:///home/pfaria/projects/coi/coi-derive)","target":{"kind":["proc-macro"],"crate_types":["proc-macro"],"name":"coi-derive","src_path":"/home/pfaria/projects/coi/coi-derive/src/lib.rs","edition":"2018","doctest":true},"message":{"rendered":"error[E0412]: cannot find type `Ident` in this scope\n --> coi-derive/src/symbol.rs:21:36\n |\n21 | impl<'a> PartialEq<Symbol> for &'a Ident {\n | ^^^^^ not found in this scope\n |\nhelp: possible candidates are found in other modules, you can import them into scope\n |\n6 | use proc_macro2::Ident;\n |\n6 | use proc_macro::Ident;\n |\n6 | use proc_macro::bridge::server::Ident;\n |\n6 | use quote::__rt::Ident;\n |\n and 1 other candidate\n\n","children":[{"children":[],"code":null,"level":"help","message":"possible candidates are found in other modules, you can import them into scope","rendered":null,"spans":[{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use proc_macro2::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use proc_macro::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use proc_macro::bridge::server::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use quote::__rt::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use syn::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]}]}],"code":{"code":"E0412","explanation":"The type name used is not in scope.\n\nErroneous code examples:\n\n```compile_fail,E0412\nimpl Something {} // error: type name `Something` is not in scope\n\n// or:\n\ntrait Foo {\n fn bar(N); // error: type name `N` is not in scope\n}\n\n// or:\n\nfn foo(x: T) {} // type name `T` is not in scope\n```\n\nTo fix this error, please verify you didn't misspell the type name, you did\ndeclare it or imported it into the scope. Examples:\n\n```\nstruct Something;\n\nimpl Something {} // ok!\n\n// or:\n\ntrait Foo {\n type N;\n\n fn bar(_: Self::N); // ok!\n}\n\n// or:\n\nfn foo<T>(x: T) {} // ok!\n```\n\nAnother case that causes this error is when a type is imported into a parent\nmodule. To fix this, you can follow the suggestion and use File directly or\n`use super::File;` which will import the types from the parent namespace. An\nexample that causes this error is below:\n\n```compile_fail,E0412\nuse std::fs::File;\n\nmod foo {\n fn some_function(f: File) {}\n}\n```\n\n```\nuse std::fs::File;\n\nmod foo {\n // either\n use super::File;\n // or\n // use std::fs::File;\n fn foo(f: File) {}\n}\n# fn main() {} // don't insert it for us; that'll break imports\n```\n"},"level":"error","message":"cannot find type `Ident` in this scope","spans":[{"byte_end":547,"byte_start":542,"column_end":41,"column_start":36,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":"not found in this scope","line_end":21,"line_start":21,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":41,"highlight_start":36,"text":"impl<'a> PartialEq<Symbol> for &'a Ident {"}]}]}}
{"reason":"compiler-message","package_id":"coi-derive 0.8.0 (path+file:///home/pfaria/projects/coi/coi-derive)","target":{"kind":["proc-macro"],"crate_types":["proc-macro"],"name":"coi-derive","src_path":"/home/pfaria/projects/coi/coi-derive/src/lib.rs","edition":"2018","doctest":true},"message":{"rendered":"error[E0412]: cannot find type `Ident` in this scope\n --> coi-derive/src/symbol.rs:46:38\n |\n46 | pub(crate) fn as_ident(&self) -> Ident {\n | ^^^^^ not found in this scope\n |\nhelp: possible candidates are found in other modules, you can import them into scope\n |\n6 | use proc_macro2::Ident;\n |\n6 | use proc_macro::Ident;\n |\n6 | use proc_macro::bridge::server::Ident;\n |\n6 | use quote::__rt::Ident;\n |\n and 1 other candidate\n\n","children":[{"children":[],"code":null,"level":"help","message":"possible candidates are found in other modules, you can import them into scope","rendered":null,"spans":[{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use proc_macro2::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use proc_macro::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use proc_macro::bridge::server::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use quote::__rt::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]},{"byte_end":113,"byte_start":113,"column_end":1,"column_start":1,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":null,"line_end":6,"line_start":6,"suggested_replacement":"use syn::Ident;\n\n","suggestion_applicability":"Unspecified","text":[{"highlight_end":1,"highlight_start":1,"text":"pub struct Symbol(&'static str);"}]}]}],"code":{"code":"E0412","explanation":"The type name used is not in scope.\n\nErroneous code examples:\n\n```compile_fail,E0412\nimpl Something {} // error: type name `Something` is not in scope\n\n// or:\n\ntrait Foo {\n fn bar(N); // error: type name `N` is not in scope\n}\n\n// or:\n\nfn foo(x: T) {} // type name `T` is not in scope\n```\n\nTo fix this error, please verify you didn't misspell the type name, you did\ndeclare it or imported it into the scope. Examples:\n\n```\nstruct Something;\n\nimpl Something {} // ok!\n\n// or:\n\ntrait Foo {\n type N;\n\n fn bar(_: Self::N); // ok!\n}\n\n// or:\n\nfn foo<T>(x: T) {} // ok!\n```\n\nAnother case that causes this error is when a type is imported into a parent\nmodule. To fix this, you can follow the suggestion and use File directly or\n`use super::File;` which will import the types from the parent namespace. An\nexample that causes this error is below:\n\n```compile_fail,E0412\nuse std::fs::File;\n\nmod foo {\n fn some_function(f: File) {}\n}\n```\n\n```\nuse std::fs::File;\n\nmod foo {\n // either\n use super::File;\n // or\n // use std::fs::File;\n fn foo(f: File) {}\n}\n# fn main() {} // don't insert it for us; that'll break imports\n```\n"},"level":"error","message":"cannot find type `Ident` in this scope","spans":[{"byte_end":1080,"byte_start":1075,"column_end":43,"column_start":38,"expansion":null,"file_name":"coi-derive/src/symbol.rs","is_primary":true,"label":"not found in this scope","line_end":46,"line_start":46,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":43,"highlight_start":38,"text":" pub(crate) fn as_ident(&self) -> Ident {"}]}]}}
{"reason":"compiler-message","package_id":"coi-derive 0.8.0 (path+file:///home/pfaria/projects/coi/coi-derive)","target":{"kind":["proc-macro"],"crate_types":["proc-macro"],"name":"coi-derive","src_path":"/home/pfaria/projects/coi/coi-derive/src/lib.rs","edition":"2018","doctest":true},"message":{"rendered":"error: aborting due to 3 previous errors\n\n","children":[],"code":null,"level":"error","message":"aborting due to 3 previous errors","spans":[]}}
{"reason":"compiler-message","package_id":"coi-derive 0.8.0 (path+file:///home/pfaria/projects/coi/coi-derive)","target":{"kind":["proc-macro"],"crate_types":["proc-macro"],"name":"coi-derive","src_path":"/home/pfaria/projects/coi/coi-derive/src/lib.rs","edition":"2018","doctest":true},"message":{"rendered":"For more information about this error, try `rustc --explain E0412`.\n","children":[],"code":null,"level":"failure-note","message":"For more information about this error, try `rustc --explain E0412`.","spans":[]}} |
Also, when hovering over the underlined |
I can try working on a minimized version of this sometime tonight, or if I don't get to it, then tomorrow morning. |
Could you share the first 10 or so lines of |
The first fix in that picture is a rustc suggestion. |
@lnicola Right, and the cargo-watch functionality provides those when they're machine applicable, but I'm not sure if we're converting the line offset wrong, or whether rustc is providing the wrong line, or something completely different :) |
I can reproduce it with just #[derive(Copy, Clone)]
pub struct Symbol(&'static str);
pub const CRATE: Symbol = Symbol("crate");
pub const PROVIDES: Symbol = Symbol("provides");
pub const WITH: Symbol = Symbol("with");
impl PartialEq<Symbol> for Ident {} in extern crate proc_macro;
mod foo; in and [package]
name = "proc-macro-test"
version = "0.1.0"
[lib]
proc-macro = true in With the |
For this case,
The culprit is in one of the spans:
Should we create an issue for |
This is likely a rustc bug, not a cargo bug. |
I file a bug in the rust repo, so no need to track this here anymore. |
I'm working on a proc-macro crate, and I was trying to import the use statement for Ident (on line 8 below):
In vs code, I hit
Ctrl+.
to bring up the suggestions, where I selected "possible candidates are found in other modules, you can import them into scope: 'use proc_macro2::Ident;\n\n'". This generates the following:The
use proc_macro2::Ident;
line is inserted between the attribute and the struct, causing the attribute to now apply to the use statement. This should obviously be corrected to:Versions:
rust-analyzer: commit eab80cd
vs code: 1.42.1
uname -a:
Linux pop-os 5.3.0-7625-generic #27~1576774560~19.10~f432cd8-Ubuntu SMP Thu Dec 19 20:35:37 UTC x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: