Skip to content

Commit

Permalink
Rename internal Ident::new -> Ident::new_checked
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Nov 26, 2023
1 parent 8059195 commit ea2cd7f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ pub(crate) struct Ident {
}

impl Ident {
pub fn new(string: &str, span: Span) -> Self {
pub fn new_checked(string: &str, span: Span) -> Self {
validate_ident(string);
Ident::new_unchecked(string, span)
}
Expand All @@ -768,7 +768,7 @@ impl Ident {
}
}

pub fn new_raw(string: &str, span: Span) -> Self {
pub fn new_raw_checked(string: &str, span: Span) -> Self {
validate_ident_raw(string);
Ident::new_raw_unchecked(string, span)
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ impl Ident {
/// style="padding-left:0;">::&lt;Ident&gt;</code>
/// rather than `Ident::new`.
pub fn new(string: &str, span: Span) -> Self {
Ident::_new(imp::Ident::new(string, span.inner))
Ident::_new(imp::Ident::new_checked(string, span.inner))
}

/// Same as `Ident::new`, but creates a raw identifier (`r#ident`). The
Expand All @@ -960,7 +960,7 @@ impl Ident {
/// segments (e.g. `self`, `super`) are not supported, and will cause a
/// panic.
pub fn new_raw(string: &str, span: Span) -> Self {
Ident::_new(imp::Ident::new_raw(string, span.inner))
Ident::_new(imp::Ident::new_raw_checked(string, span.inner))
}

/// Returns the span of this `Ident`.
Expand Down
8 changes: 4 additions & 4 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,21 +639,21 @@ pub(crate) enum Ident {
}

impl Ident {
pub fn new(string: &str, span: Span) -> Self {
pub fn new_checked(string: &str, span: Span) -> Self {
match span {
Span::Compiler(s) => Ident::Compiler(proc_macro::Ident::new(string, s)),
Span::Fallback(s) => Ident::Fallback(fallback::Ident::new(string, s)),
Span::Fallback(s) => Ident::Fallback(fallback::Ident::new_checked(string, s)),
}
}

pub fn new_unchecked(string: &str, span: fallback::Span) -> Self {
Ident::Fallback(fallback::Ident::new_unchecked(string, span))
}

pub fn new_raw(string: &str, span: Span) -> Self {
pub fn new_raw_checked(string: &str, span: Span) -> Self {
match span {
Span::Compiler(s) => Ident::Compiler(proc_macro::Ident::new_raw(string, s)),
Span::Fallback(s) => Ident::Fallback(fallback::Ident::new_raw(string, s)),
Span::Fallback(s) => Ident::Fallback(fallback::Ident::new_raw_checked(string, s)),
}
}

Expand Down

0 comments on commit ea2cd7f

Please sign in to comment.