Skip to content

Commit ad45ac1

Browse files
authored
Merge pull request #174 from nikomatsakis/underscore-impls
use underscore impls where we can
2 parents 7ce7522 + d25bf61 commit ad45ac1

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

crates/formality-macros/src/cast.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use synstructure::VariantInfo;
66

77
use crate::attrs::has_isa_attr;
88

9-
pub(crate) fn upcast_impls(s: synstructure::Structure) -> Vec<TokenStream> {
9+
pub(crate) fn upcast_impls(mut s: synstructure::Structure) -> Vec<TokenStream> {
10+
s.underscore_const(true);
11+
1012
let num_variants = s.variants().len();
1113
s.variants()
1214
.iter()
@@ -74,7 +76,9 @@ fn upcast_to_variant(s: &synstructure::Structure, v: &VariantInfo) -> TokenStrea
7476
})
7577
}
7678

77-
pub(crate) fn downcast_impls(s: synstructure::Structure) -> Vec<TokenStream> {
79+
pub(crate) fn downcast_impls(mut s: synstructure::Structure) -> Vec<TokenStream> {
80+
s.underscore_const(true);
81+
7882
let num_variants = s.variants().len();
7983
s.variants()
8084
.iter()

crates/formality-macros/src/debug.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ use crate::{
1313
/// Derive the `Parse` impl, using an optional grammar supplied "from the outside".
1414
/// This is used by the `#[term(G)]` macro, which supplies the grammar `G`.
1515
pub(crate) fn derive_debug_with_spec(
16-
s: synstructure::Structure,
16+
mut s: synstructure::Structure,
1717
external_spec: Option<&FormalitySpec>,
1818
) -> TokenStream {
19+
s.underscore_const(true);
20+
1921
if let syn::Data::Union(v) = &s.ast().data {
2022
return syn::Error::new(v.union_token.span, "unions are not supported")
2123
.into_compile_error();

crates/formality-macros/src/parse.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ use crate::{
1515
/// Derive the `Parse` impl, using an optional grammar supplied "from the outside".
1616
/// This is used by the `#[term(G)]` macro, which supplies the grammar `G`.
1717
pub(crate) fn derive_parse_with_spec(
18-
s: synstructure::Structure,
18+
mut s: synstructure::Structure,
1919
external_spec: Option<&FormalitySpec>,
2020
) -> syn::Result<TokenStream> {
21+
s.underscore_const(true);
22+
2123
if let syn::Data::Union(v) = &s.ast().data {
2224
return Err(syn::Error::new(
2325
v.union_token.span,

0 commit comments

Comments
 (0)