zargony / atom-language-rust

Rust language support in Atom - LOOKING FOR MAINTAINER, see #144
MIT License
116 stars 33 forks source link

Support attributes in function definitions (parameter attributes) #148

Open peterhuene opened 4 years ago

peterhuene commented 4 years ago

Now that Rust 1.39.0 supports attributes on parameters, the grammar should be updated to allow attributes when parsing function definitions.

Example:

#[attr(foo = "bar")]
fn foo(#[attr(foo = "bar")] p: u32) {
    println!("hi");
}

Notice that "bar" is not highlighted as a string, which is an included pattern in the attribute grammar.

Additionally, parsing breaks when the attribute string has characters that are interpreted as Rust tokens:

#[attr(foo = "bar")]
fn foo(#[attr(foo = "{")] p: u32) {
  println!("hi");
}

Note that here { is being matched as the opening bracket of the function, causing the closing " to be matched as the start of a string (the remainder of the function is considered to be in the string).