idanarye/rust-typed-builder

Use absolute paths in generated code

Closed this issue · 0 comments

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:

(quote!(impl core::convert::Into<#arg_type>), quote!(#field_name.into()))

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>