diff options
| author | Phlosioneer <mattmdrr2@gmail.com> | 2018-03-11 10:03:23 -0400 |
|---|---|---|
| committer | Phlosioneer <mattmdrr2@gmail.com> | 2018-03-11 10:03:23 -0400 |
| commit | c033c6e47c1a84e2902c75a1b5ec161362f34f18 (patch) | |
| tree | 38ee60e3d76445b079ba71d32bcd9c0fdfbc7927 /src/libsyntax_ext | |
| parent | 1733a61141d125beb45587dd89d54cd4a01cdd5a (diff) | |
| download | rust-c033c6e47c1a84e2902c75a1b5ec161362f34f18.tar.gz rust-c033c6e47c1a84e2902c75a1b5ec161362f34f18.zip | |
Fix hygene issue when deriving Debug
The code for several of the core traits doesn't use hygenic macros. This isn't a problem, except for the Debug trait, which is the only one that uses a variable, named "builder". Variables can't share names with unit structs, so attempting to [derive(Debug)] on any type while a unit struct with the name "builder" was in scope would result in an error. This commit just changes the name of the variable to "__debug_trait_builder", because I couldn't figure out how to get a list of all unit structs in-scope from within the derive expansion function. If someone wants to have a unit struct with the exact name "__debug_trait_builder", they'll just have to do it without a [derive(Debug)].
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/deriving/debug.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 82fc09fca69..7b23de582a7 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -70,7 +70,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<E // We want to make sure we have the ctxt set so that we can use unstable methods let span = span.with_ctxt(cx.backtrace()); let name = cx.expr_lit(span, ast::LitKind::Str(ident.name, ast::StrStyle::Cooked)); - let builder = Ident::from_str("builder"); + let builder = Ident::from_str("__debug_trait_builder"); let builder_expr = cx.expr_ident(span, builder.clone()); let fmt = substr.nonself_args[0].clone(); |
