I have the following project and get an unexpected compiler error. Inside the function foo in src/lib.rs, the generic type of Vec::new() cannot be inferred.
I do not get the compiler error if I do one of:
- remove the call to
#[::bug_macro::bug_macro]in src/lib.rs. Note that this macro does not do to any ast-transformations - remove the call to
json::parsein bug-macro/src/lib.rs. Note that this is an implementation detail of a private function that is never called - I use the
bug_macrodirectly from thebug-macro-codegencrate, even if it contains a call tojson::parse.
Have I uncovered some compiler error?
I tried to minify the error and got following 3-crate Project:
Cargo.toml
[package]
name = "bug"
version = "0.1.0"
edition = "2018"
[dependencies]
bug-macro = {path = "bug-macro"}
src/lib.rs
#[::bug_macro::bug_macro]
pub fn bar() {}
pub fn foo() {
let sum = Vec::new();
b"" == &sum[..];
}
bug-macro/Cargo.toml
[package]
name = "bug-macro"
version = "0.2.0"
edition = "2018"
[dependencies]
bug-macro-codegen = { path = "../bug-macro-codegen" }
json = "0.11"
bug-macro/src/lib.rs
pub use bug_macro_codegen::bug_macro;
fn jkl() {json::parse("");}
bug-macro-codegen/Cargo.toml:
[package]
name = "bug-macro-codegen"
version = "0.2.0"
edition = "2018"
[lib]
proc_macro = true
bug-macro-codegen/src/lib.rs
extern crate proc_macro;
#[proc_macro_attribute]
pub fn bug_macro(
_attr: proc_macro::TokenStream,
input: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
input
}