Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-lang/rust
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f3eb8ce
Choose a base ref
...
head repository: rust-lang/rust
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b7a73c6
Choose a head ref
  • 12 commits
  • 23 files changed
  • 1 contributor

Commits on May 31, 2024

  1. Don't use the word "parse" for lexing operations.

    Lexing converts source text into a token stream. Parsing converts a
    token stream into AST fragments. This commit renames several lexing
    operations that have "parse" in the name. I think these names have been
    subtly confusing me for years.
    
    This is just a `s/parse/lex/` on function names, with one exception:
    `parse_stream_from_source_str` becomes `source_str_to_stream`, to make
    it consistent with the existing `source_file_to_stream`. The commit also
    moves that function's location in the file to be just above
    `source_file_to_stream`.
    
    The commit also cleans up a few comments along the way.
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    116541b View commit details
    Browse the repository at this point in the history
  2. Inline and remove error_malformed_cfg_attr_missing.

    It has a single call site.
    
    This also means `CFG_ATTR_{GRAMMAR_HELP,NOTE_REF}` can be moved into
    `parse_cfg_attr`, now that it's the only function that uses them.
    And the commit removes the line break in the URL.
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    38305b1 View commit details
    Browse the repository at this point in the history
  3. Rename maybe_file_to_stream as maybe_source_file_to_stream.

    Because it takes an `Lrc<SourceFile>`, and for consistency with
    `source_file_to_stream`.
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    fb6f5a9 View commit details
    Browse the repository at this point in the history
  4. Remove stream_to_parser.

    It's a zero-value wrapper of `Parser::new`.
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    9ba87a9 View commit details
    Browse the repository at this point in the history
  5. Improve panictry_buffer!.

    - Convert it from a macro to a function, which is nicer.
    - Rename it as `unwrap_or_emit_fatal`, which is clearer.
    - Fix the comment. In particular, `panictry!` no longer exists.
    - Remove the unnecessary `use` declaration.
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    c342820 View commit details
    Browse the repository at this point in the history
  6. Remove low-value comments.

    The first one is out-of-date -- there are no longer functions expr,
    item, stmt. And I don't know what a "HOF" is.
    
    The second one doesn't really tell you anything.
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    73e7ecb View commit details
    Browse the repository at this point in the history
  7. Rename maybe_source_file_to_parser as `maybe_new_parser_from_source…

    …_file`.
    
    For consistency with `new_parser_from_{file,source_str}` and
    `maybe_new_parser_from_source_str`.
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    dc038fd View commit details
    Browse the repository at this point in the history
  8. Use source_str_to_stream in a test file.

    It does exactly what is required.
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    6e95819 View commit details
    Browse the repository at this point in the history
  9. Inline and remove parse_crate{,_attrs}_from_{file,source_str}.

    All four functions are simple and have a single call site.
    
    This requires making `Parser::parse_inner_attributes` public, which is
    no big deal.
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    aef3300 View commit details
    Browse the repository at this point in the history
  10. Reorder source_str_to_stream arguments.

    It's the only one of these functions where `psess` isn't the first
    argument.
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    2b9f414 View commit details
    Browse the repository at this point in the history
  11. Inline and remove source_file_to_stream.

    It has a single call site.
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    3b61803 View commit details
    Browse the repository at this point in the history
  12. Make top-level rustc_parse functions fallible.

    Currently we have an awkward mix of fallible and infallible functions:
    ```
           new_parser_from_source_str
     maybe_new_parser_from_source_str
           new_parser_from_file
    (maybe_new_parser_from_file)        // missing
          (new_parser_from_source_file) // missing
     maybe_new_parser_from_source_file
           source_str_to_stream
     maybe_source_file_to_stream
    ```
    We could add the two missing functions, but instead this commit removes
    of all the infallible ones and renames the fallible ones leaving us with
    these which are all fallible:
    ```
    new_parser_from_source_str
    new_parser_from_file
    new_parser_from_source_file
    source_str_to_stream
    source_file_to_stream
    ```
    This requires making `unwrap_or_emit_fatal` public so callers of
    formerly infallible functions can still work.
    
    This does make some of the call sites slightly more verbose, but I think
    it's worth it for the simpler API. Also, there are two `catch_unwind`
    calls and one `catch_fatal_errors` call in this diff that become
    removable thanks this change. (I will do that in a follow-up PR.)
    nnethercote committed May 31, 2024
    Configuration menu
    Copy the full SHA
    b7a73c6 View commit details
    Browse the repository at this point in the history
Loading