Skip to content

Commit 9b2246c

Browse files
author
dutchmartin
committed
Process CR and simplyly the PR
1 parent e9a2a9b commit 9b2246c

File tree

3 files changed

+29
-91
lines changed

3 files changed

+29
-91
lines changed

procedural-masquerade/lib.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -244,33 +244,33 @@ macro_rules! define_invoke_proc_macro {
244244
#[doc(hidden)]
245245
#[macro_export]
246246
macro_rules! $macro_name {
247-
($proc_macro_name: ident ! $paren: tt) => {
248-
#[derive($proc_macro_name)]
249-
#[allow(unused)]
250-
enum ProceduralMasqueradeDummyType {
251-
// The magic happens here.
252-
//
253-
// We use an `enum` with an explicit discriminant
254-
// because that is the only case where a type definition
255-
// can contain a (const) expression.
256-
//
257-
// `(0, "foo").0` evalutes to 0, with the `"foo"` part ignored.
258-
//
259-
// By the time the `#[proc_macro_derive]` function
260-
// implementing `#[derive($proc_macro_name)]` is called,
261-
// `$paren` has already been replaced with the input of this inner macro,
262-
// but `stringify!` has not been expanded yet.
263-
//
264-
// This how arbitrary tokens can be inserted
265-
// in the input to the `#[proc_macro_derive]` function.
266-
//
267-
// Later, `stringify!(...)` is expanded into a string literal
268-
// which is then ignored.
269-
// Using `stringify!` enables passing arbitrary tokens
270-
// rather than only what can be parsed as a const expression.
271-
Input = (0, stringify! $paren ).0
272-
}
273-
}
274-
}
247+
($proc_macro_name: ident ! $paren: tt) => {
248+
#[derive($proc_macro_name)]
249+
#[allow(unused)]
250+
enum ProceduralMasqueradeDummyType {
251+
// The magic happens here.
252+
//
253+
// We use an `enum` with an explicit discriminant
254+
// because that is the only case where a type definition
255+
// can contain a (const) expression.
256+
//
257+
// `(0, "foo").0` evalutes to 0, with the `"foo"` part ignored.
258+
//
259+
// By the time the `#[proc_macro_derive]` function
260+
// implementing `#[derive($proc_macro_name)]` is called,
261+
// `$paren` has already been replaced with the input of this inner macro,
262+
// but `stringify!` has not been expanded yet.
263+
//
264+
// This how arbitrary tokens can be inserted
265+
// in the input to the `#[proc_macro_derive]` function.
266+
//
267+
// Later, `stringify!(...)` is expanded into a string literal
268+
// which is then ignored.
269+
// Using `stringify!` enables passing arbitrary tokens
270+
// rather than only what can be parsed as a const expression.
271+
Input = (0, stringify! $paren ).0
272+
}
273+
}
274+
}
275275
};
276276
}

src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'i> BasicParseErrorKind<'i> {
5959
fn description(&self) -> String {
6060
match self {
6161
BasicParseErrorKind::UnexpectedToken(token) => {
62-
format!("Unexpected token: '{}'", token.description())
62+
format!("Unexpected token: {:?}", token)
6363
}
6464
BasicParseErrorKind::EndOfInput => "End of input".to_owned(),
6565
BasicParseErrorKind::AtRuleInvalid(message) => format!("Invalid @ rule: {}", message),

src/tokenizer.rs

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -191,68 +191,6 @@ impl<'a> Token<'a> {
191191
BadUrl(_) | BadString(_) | CloseParenthesis | CloseSquareBracket | CloseCurlyBracket
192192
)
193193
}
194-
195-
pub(crate) fn description(&self) -> String {
196-
match self {
197-
Ident(name) => format!("A ident token '{}'", name),
198-
AtKeyword(value) => format!("The value '{}' does not include the `@` marker", value),
199-
Hash(value) => format!("The value '{}' does not include the `#` marker", value),
200-
IDHash(value) => format!(
201-
"The value '{}' does not include the `#` marker, but has a valid ID selector",
202-
value
203-
),
204-
QuotedString(value) => format!("The value '{}' does not include the quotes", value),
205-
UnquotedUrl(value) => format!(
206-
"The value '{}' does not include the `url(` `)` markers.",
207-
value
208-
),
209-
Delim(character) => format!("'{}'", character),
210-
Number {
211-
has_sign, value, ..
212-
} => {
213-
let sign = if has_sign.clone() { '-' } else { '+' };
214-
format!("{}{}", sign, value.to_string())
215-
}
216-
Percentage {
217-
has_sign,
218-
unit_value,
219-
..
220-
} => {
221-
let sign = if has_sign.clone() { '-' } else { '+' };
222-
format!("{}{}%", sign, unit_value.to_string())
223-
}
224-
Dimension {
225-
has_sign,
226-
value,
227-
unit,
228-
..
229-
} => {
230-
let sign = if has_sign.clone() { '-' } else { '+' };
231-
format!("{}{} {}", sign, value.to_string(), unit)
232-
}
233-
WhiteSpace(whitespace) => format!("whitespace: '{}'", whitespace),
234-
Comment(comment) => format!("The comment: '{}'", comment),
235-
Colon => String::from(":"),
236-
Semicolon => String::from(";"),
237-
Comma => String::from(","),
238-
IncludeMatch => String::from("~="),
239-
DashMatch => String::from("|="),
240-
PrefixMatch => String::from("^="),
241-
SuffixMatch => String::from("$="),
242-
SubstringMatch => String::from("*="),
243-
CDO => String::from("<!--"),
244-
CDC => String::from("-->"),
245-
Function(name) => format!("The value ({}) does not include the `(` marker", name),
246-
ParenthesisBlock => String::from("("),
247-
SquareBracketBlock => String::from("["),
248-
CurlyBracketBlock => String::from("{"),
249-
BadUrl(url) => format!("Bad url: '{}'", url),
250-
BadString(string) => format!("Bad string: '{}'", string),
251-
CloseParenthesis => "Unclosed parenthesis".to_owned(),
252-
CloseSquareBracket => "Unclosed square bracket".to_owned(),
253-
CloseCurlyBracket => "Unclosed curly bracket".to_owned(),
254-
}
255-
}
256194
}
257195

258196
#[derive(Clone)]

0 commit comments

Comments
 (0)