Repository: casey/just
File: src/parser.rs (Rust)

Code before:
            self.presume_keyword(Keyword::Export)?;
            items.push(Item::Assignment(self.parse_assignment(true)?));
          }
          Some(Keyword::Set)
            if self.next_are(&[Identifier, Identifier, ColonEquals])
              || self.next_are(&[Identifier, Identifier, Comment, Eof])
              || self.next_are(&[Identifier, Identifier, Comment, Eol])
              || self.next_are(&[Identifier, Identifier, Eof])
              || self.next_are(&[Identifier, Identifier, Eol]) =>
          {
            items.push(Item::Set(self.parse_set()?));
          }
          _ => {
            if self.next_are(&[Identifier, ColonEquals]) {
              items.push(Item::Assignment(self.parse_assignment(false)?));
            } else {
              let doc = pop_doc_comment(&mut items, eol_since_last_comment);
              items.push(Item::Recipe(self.parse_recipe(doc, false, false)?));
            }
          }
        }
      } else if self.accepted(At)? {
        let doc = pop_doc_comment(&mut items, eol_since_last_comment);
        items.push(Item::Recipe(self.parse_recipe(doc, true, false)?));
      } else if self.accepted(BracketL)? {
        self.parse_attribute_name()?;
        self.expect(BracketR)?;
        self.expect_eol()?;
        let quiet = self.accepted(At)?;
        let doc = pop_doc_comment(&mut items, eol_since_last_comment);
        items.push(Item::Recipe(self.parse_recipe(doc, quiet, true)?));
      } else {
        return Err(self.unexpected_token()?);
      }
    }

    if self.next == self.tokens.len() {
      Ok(Ast {
        warnings: Vec::new(),
        items,
      })
    } else {
      Err(self.internal_error(format!(
        "Parse completed with {} unparsed tokens",
        self.tokens.len() - self.next,
      ))?)
    }
  }

  /// Parse an alias, e.g `alias name := target`
  fn parse_alias(&mut self) -> CompileResult<'src, Alias<'src, Name<'src>>> {

Review comment (suggestion):
This works, but it's a bit unclear what's going on. I'd do something like:

```rust
let Attribute::NoExitMessage = self.parse_atribute_name()?;
```

This makes it clear what's going on, and it will turn into a compile error when we add another variant.

Code after:
            self.presume_keyword(Keyword::Export)?;
            items.push(Item::Assignment(self.parse_assignment(true)?));
          }
          Some(Keyword::Set)
            if self.next_are(&[Identifier, Identifier, ColonEquals])
              || self.next_are(&[Identifier, Identifier, Comment, Eof])
              || self.next_are(&[Identifier, Identifier, Comment, Eol])
              || self.next_are(&[Identifier, Identifier, Eof])
              || self.next_are(&[Identifier, Identifier, Eol]) =>
          {
            items.push(Item::Set(self.parse_set()?));
          }
          _ => {
            if self.next_are(&[Identifier, ColonEquals]) {
              items.push(Item::Assignment(self.parse_assignment(false)?));
            } else {
              let doc = pop_doc_comment(&mut items, eol_since_last_comment);
              items.push(Item::Recipe(self.parse_recipe(doc, false, false)?));
            }
          }
        }
      } else if self.accepted(At)? {
        let doc = pop_doc_comment(&mut items, eol_since_last_comment);
        items.push(Item::Recipe(self.parse_recipe(doc, true, false)?));
      } else if self.accepted(BracketL)? {
        let Attribute::NoExitMessage = self.parse_attribute_name()?;
        self.expect(BracketR)?;
        self.expect_eol()?;
        let quiet = self.accepted(At)?;
        let doc = pop_doc_comment(&mut items, eol_since_last_comment);
        items.push(Item::Recipe(self.parse_recipe(doc, quiet, true)?));
      } else {
        return Err(self.unexpected_token()?);
      }
    }

    if self.next == self.tokens.len() {
      Ok(Ast {
        warnings: Vec::new(),
        items,
      })
    } else {
      Err(self.internal_error(format!(
        "Parse completed with {} unparsed tokens",
        self.tokens.len() - self.next,
      ))?)
    }
  }

  /// Parse an alias, e.g `alias name := target`
  fn parse_alias(&mut self) -> CompileResult<'src, Alias<'src, Name<'src>>> {