Skip to content

Commit

Permalink
Adjust Literal constructor argument names to match those in libproc_m…
Browse files Browse the repository at this point in the history
…acro
  • Loading branch information
dtolnay committed Apr 14, 2024
1 parent 26d1d3f commit 45730bc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,10 +1007,10 @@ impl Literal {
Literal::_new(s)
}

pub fn string(t: &str) -> Literal {
let mut repr = String::with_capacity(t.len() + 2);
pub fn string(string: &str) -> Literal {
let mut repr = String::with_capacity(string.len() + 2);
repr.push('"');
let mut chars = t.chars();
let mut chars = string.chars();
while let Some(ch) = chars.next() {
if ch == '\0' {
repr.push_str(
Expand All @@ -1035,14 +1035,14 @@ impl Literal {
Literal::_new(repr)
}

pub fn character(t: char) -> Literal {
pub fn character(ch: char) -> Literal {
let mut repr = String::new();
repr.push('\'');
if t == '"' {
if ch == '"' {
// escape_debug turns this into '\"' which is unnecessary.
repr.push(t);
repr.push(ch);
} else {
repr.extend(t.escape_debug());
repr.extend(ch.escape_debug());
}
repr.push('\'');
Literal::_new(repr)
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,8 @@ impl Literal {
}

/// Byte string literal.
pub fn byte_string(s: &[u8]) -> Literal {
Literal::_new(imp::Literal::byte_string(s))
pub fn byte_string(bytes: &[u8]) -> Literal {
Literal::_new(imp::Literal::byte_string(bytes))
}

/// Returns the span encompassing this literal.
Expand Down
12 changes: 6 additions & 6 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,19 +846,19 @@ impl Literal {
}
}

pub fn string(t: &str) -> Literal {
pub fn string(string: &str) -> Literal {
if inside_proc_macro() {
Literal::Compiler(proc_macro::Literal::string(t))
Literal::Compiler(proc_macro::Literal::string(string))
} else {
Literal::Fallback(fallback::Literal::string(t))
Literal::Fallback(fallback::Literal::string(string))
}
}

pub fn character(t: char) -> Literal {
pub fn character(ch: char) -> Literal {
if inside_proc_macro() {
Literal::Compiler(proc_macro::Literal::character(t))
Literal::Compiler(proc_macro::Literal::character(ch))
} else {
Literal::Fallback(fallback::Literal::character(t))
Literal::Fallback(fallback::Literal::character(ch))
}
}

Expand Down

0 comments on commit 45730bc

Please sign in to comment.