| Age | Commit message (Collapse) | Author | Lines |
|
|
|
Fixes #47311.
r? @nrc
|
|
Fixes #47311.
r? @nrc
|
|
Improve recovery for trailing comma after `..`
|
|
Comprehensively support trailing commas in std/core macros
I carefully organized the changes into four commits:
* Test cases
* Fixes for `macro_rules!` macros
* Fixes for builtin macros
* Docs for builtins
**I can easily scale this back to just the first two commits for now if such is desired.**
### Breaking (?) changes
* This fixes #48042, which is a breaking change that I hope people can agree is just a bugfix for an extremely dark corner case.
* To fix five of the builtins, this changes `syntax::ext::base::get_single_str_from_tts` to accept a trailing comma, and revises the documentation so that this aspect is not surprising. **I made this change under the (hopefully correct) understanding that `libsyntax` is private rustc implementation detail.** After reviewing all call sites (which were, you guessed it, *precisely those five macros*), I believe the revised semantics are closer to the intended spirit of the function.
### Changes which may require concensus
Up until now, it could be argued that some or all the following macros did not conceptually take a comma-separated list, because they only took one argument:
* **`cfg(unix,)`** (most notable since cfg! is unique in taking a meta tag)
* **`include{,_bytes,_str}("file.rs",)`** (in item form this might be written as "`include!{"file.rs",}`" which is even slightly more odd)
* **`compile_error("message",);`**
* **`option_env!("PATH",)`**
* **`try!(Ok(()),)`**
So I think these particular changes may require some sort of consensus. **All of the fixes for builtins are included this list, so if we want to defer these decisions to later then I can scale this PR back to just the first two commits.**
### Other notes/general requests for comment
* Do we have a big checklist somewhere of "things to do when adding macros?" My hope is for `run-pass/macro-comma-support.rs` to remain comprehensive.
* Originally I wanted the tests to also comprehensively forbid double trailing commas. However, this didn't work out too well: [see this gist and the giant FIXME in it](https://gist.github.com/ExpHP/6fc40e82f3d73267c4e590a9a94966f1#file-compile-fail_macro-comma-support-rs-L33-L50)
* I did not touch `select!`. It appears to me to be a complete mess, and its trailing comma mishaps are only the tip of the iceberg.
* There are [some compile-fail test cases](https://github.com/ExpHP/rust/blob/5fa97c35da2f0ee/src/test/compile-fail/macro-comma-behavior.rs#L49-L52) that didn't seem to work (rustc emits errors, but compile-fail doesn't acknowledge them), so they are disabled. Any clues? (Possibly related: These happen to be precisely the set of errors which are tagged by rustc as "this error originates in a macro outside of the current crate".)
---
Fixes #48042
Closes #46241
|
|
|
|
|
|
When unnecessarily using a fat arrow after an if condition, suggest the
removal of it.
When finding an if statement with no block, point at the `if` keyword to
provide more context.
|
|
When finding:
```rust
match &Some(3) {
&None => 1
&Some(2) => { 3 }
_ => 2
}
```
provide the following diagnostic:
```
error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
--> $DIR/missing-comma-in-match.rs:15:18
|
X | &None => 1
| -- - help: missing comma
| |
| while parsing the match arm starting here
X | &Some(2) => { 3 }
| ^^ expected one of `,`, `.`, `?`, `}`, or an operator here
```
|
|
'generic bounds in type aliases are ignored' warning
|
|
|
|
macros: improve struct constructor field hygiene, fix span bug
Fixes #47311.
r? @nrc
|
|
Commit 0bd96671f0 added bounds checking of our current target byte
position to prevent infinite loops. Unfortunately it was comparing the
file-relative `target` versus the global relative `file_start_pos` and
`file_end_pos`.
The result is failing to detect multibyte characters unless their
file-relative offset fit within their global offset. This causes other
parts of the compiler to generate spans pointing to the middle of a
multibyte character which will ultimately panic in
`bytepos_to_file_charpos`.
Fix by comparing the `target` to the total file size when moving forward
and doing checked subtraction when moving backwards. This should
preserve the intent of the bounds check while removing the offset
confusion.
Fixes #48508
|
|
Implement multiple patterns with `|` in `if let` and `while let` (RFC 2175)
cc https://github.com/rust-lang/rust/issues/48215
|
|
Allow parentheses in `dyn (Trait)`
r? @eddyb @nikomatsakis
|
|
Fix parsing of extern paths in types and poly-traits
Fixes https://github.com/rust-lang/rust/issues/48262
|
|
When encountering invalid token after `unsafe`, mention `{`
Fix #37158.
|
|
Termination trait in tests
Support the `Termination` trait in unit tests (cc https://github.com/rust-lang/rust/issues/43301)
Also, a drive-by fix for #47075.
This is joint work with @bkchr.
|
|
Error on nested impl Trait and path projections from impl Trait
cc #34511
r? @nikomatsakis
|
|
|
|
|
|
update tracking issue for nll
Point to the new tracing issue for nll
For reference https://github.com/rust-lang/rust/issues/44928
|
|
jseyfried:improve_tuple_struct_field_access_hygiene, r=petrochenkov
Improve tuple struct field access hygiene
Fixes #47312 by fixing a span bug.
r? @nrc
|
|
Fix span of visibility
This PR
1. adds a closing parenthesis to the span of `Visibility::Crate` (e.g. `pub(crate)`). The current span only covers `pub(crate`.
2. adds a `span` field to `Visibility::Restricted`. This span covers the entire visibility expression (e.g. `pub (in self)`). Currently all we can have is a span for `Path`.
This PR is motivated by the bug found in rustfmt (https://github.com/rust-lang-nursery/rustfmt/issues/2398).
The first change is a strict improvement IMHO. The second change may not be desirable, as it adds a field which is currently not used by the compiler.
|
|
|
|
|
|
Remove experimental -Zremap-path-prefix-from/to, and replace it with
the stabilized --remap-path-prefix=from=to variant.
This is an implementation for issue of #41555.
|
|
Also make `std::termination` module public and rename feature.
The lib feature needs a different name from the language feature.
|
|
|
|
Extend `Termination` trait with a method to determine what happens
with a unit test.
This commit incorporates work by Bastian Köcher <git@kchr.de>.
|
|
|
|
Point to the new tracing issue for nll
|
|
You can now choose between the following:
- `#[unwind(allowed)]`
- `#[unwind(aborts)]`
Per rust-lang/rust#48251, the default is `#[unwind(allowed)]`, though
I think we should change this eventually.
|
|
|
|
|
|
fix more typos found by codespell.
|
|
|
|
|
|
|
|
|
|
|
|
This span covers the whole visibility expression: e.g. `pub (in path)`.
|
|
|
|
|
|
Remove allocation from width of character function.
Locally this seems to eliminate the problem or at least resolve most of the
issue.
Fixes #48153.
r? @estebank
|
|
Continue parsing function after finding `...` arg
When encountering a variadic argument in a function definition that
doesn't accept it, if immediately after there's a closing paren,
continue parsing as normal. Otherwise keep current behavior of emitting
error and stopping.
Fix #31481.
|
|
Correct a few stability attributes
* `core_float_bits`, `duration_core`, `path_component_asref`, and `repr_align` were stabalized in 1.25.0 not 1.24.0.
* Impls for `NonNull` involving unstable things should remain unstable.
* `Duration` should remain stable since 1.3.0 so it appears correctly in the `std` docs.
* `cursor_mut_vec` is an impl on only stable things so should be marked stable.
|
|
|
|
|
|
When encountering a variadic argument in a function definition that
doesn't accept it, if immediately after there's a closing paren,
continue parsing as normal. Otherwise keep current behavior of emitting
error and stopping.
|