idanarye / rust-typed-builder

Compile-time type-checked builder derive
https://crates.io/crates/typed-builder
Apache License 2.0
908 stars 52 forks source link

Use absolute paths in generated code #56

Closed Veetaha closed 3 years ago

Veetaha commented 3 years ago

I've stumbled with the problem where I use TypedBuilder in a file that uses declares or imports a custom module named core:

use typed_builder::TypedBuilder;
use rusoto_core as core;

#[derive(TypedBuilder)]
struct StaticCreds {
    // ...
}

and since the generated code references some types from Rust's standard core crate like here: https://github.com/idanarye/rust-typed-builder/blob/69d6aac815eda708557414b62fad9e02c4e3f452/src/struct_info.rs#L280

this gives compile errors, because the core symbol currently in scope is rusoto_core.

The solution would be to qualify all references in generated code to be absolute paths:

impl ::core::Into<#arg_type>