-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Comparing changes
Open a pull request
base repository: rust-lang/rust
base: f3eb8ce
head repository: rust-lang/rust
compare: b7a73c6
- 12 commits
- 23 files changed
- 1 contributor
Commits on May 31, 2024
-
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.
Configuration menu - View commit details
-
Copy full SHA for 116541b - Browse repository at this point
Copy the full SHA 116541bView commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 38305b1 - Browse repository at this point
Copy the full SHA 38305b1View commit details -
Rename
maybe_file_to_stream
asmaybe_source_file_to_stream
.Because it takes an `Lrc<SourceFile>`, and for consistency with `source_file_to_stream`.
Configuration menu - View commit details
-
Copy full SHA for fb6f5a9 - Browse repository at this point
Copy the full SHA fb6f5a9View commit details -
It's a zero-value wrapper of `Parser::new`.
Configuration menu - View commit details
-
Copy full SHA for 9ba87a9 - Browse repository at this point
Copy the full SHA 9ba87a9View commit details -
- 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.
Configuration menu - View commit details
-
Copy full SHA for c342820 - Browse repository at this point
Copy the full SHA c342820View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 73e7ecb - Browse repository at this point
Copy the full SHA 73e7ecbView commit details -
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`.
Configuration menu - View commit details
-
Copy full SHA for dc038fd - Browse repository at this point
Copy the full SHA dc038fdView commit details -
Use
source_str_to_stream
in a test file.It does exactly what is required.
Configuration menu - View commit details
-
Copy full SHA for 6e95819 - Browse repository at this point
Copy the full SHA 6e95819View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for aef3300 - Browse repository at this point
Copy the full SHA aef3300View commit details -
Reorder
source_str_to_stream
arguments.It's the only one of these functions where `psess` isn't the first argument.
Configuration menu - View commit details
-
Copy full SHA for 2b9f414 - Browse repository at this point
Copy the full SHA 2b9f414View commit details -
Inline and remove
source_file_to_stream
.It has a single call site.
Configuration menu - View commit details
-
Copy full SHA for 3b61803 - Browse repository at this point
Copy the full SHA 3b61803View commit details -
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.)
Configuration menu - View commit details
-
Copy full SHA for b7a73c6 - Browse repository at this point
Copy the full SHA b7a73c6View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff f3eb8ce...b7a73c6