Skip to content

Commit

Permalink
Fix name collision and CI issues (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Juici authored Feb 17, 2024
1 parent 83ef757 commit 2d85c0c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 33 deletions.
5 changes: 2 additions & 3 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::{Attribute, DataEnum, Expr, Fields, Meta, Token};

use crate::span_ext::SpanExt;
use crate::Result;

pub struct Repr {
Expand Down Expand Up @@ -114,10 +113,10 @@ pub fn get_variants(enum_ident: &Ident, data: DataEnum) -> Result<Vec<Variant>>

for v in err_iter {
if !matches!(&v.fields, Fields::Unit) {
diag = diag.span_error(v.fields.span(), "only unit variants are supported");
diag = diag.span_warning(v.fields.span(), "only unit variants are supported");
}
if v.discriminant.is_none() {
diag = diag.span_error(v.span().end(), "missing discriminant");
diag = diag.span_warning(crate::span::end(v.span()), "missing discriminant");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern crate proc_macro;

mod ast;
mod expand;
mod span_ext;
mod span;

use proc_macro::TokenStream;
use proc_macro2_diagnostics::Diagnostic;
Expand Down
12 changes: 12 additions & 0 deletions src/span.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use proc_macro2::Span;

pub fn end(span: Span) -> Span {
#[cfg(proc_macro_span)]
{
Span::from(span.unwrap().end())
}
#[cfg(not(proc_macro_span))]
{
span
}
}
28 changes: 0 additions & 28 deletions src/span_ext.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/ui/missing_discriminant.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ error: enum has variants that are not supported by this trait
5 | pub enum MissingDiscriminant {
| ^^^^^^^^^^^^^^^^^^^
|
error: missing discriminant
warning: missing discriminant
--> tests/ui/missing_discriminant.rs:7:19
|
7 | NoDiscriminant,
Expand Down

0 comments on commit 2d85c0c

Please sign in to comment.