about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2018-03-01Fix spelling s/casted/cast/Lukas Lueg-1/+1
2018-02-28Rollup merge of #48380 - nikomatsakis:issue-48251-master, r=acrichtoManish Goregaokar-1/+73
Fixes #47311. r? @nrc
2018-02-28Rollup merge of #48359 - jsgf:remap-path-prefix, r=sanxiynManish Goregaokar-1/+1
Fixes #47311. r? @nrc
2018-03-01Support parentheses in patterns under feature gateVadim Petrochenkov-28/+58
Improve recovery for trailing comma after `..`
2018-02-28Auto merge of #48056 - ExpHP:macro-commas, r=dtolnaybors-2/+4
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
2018-02-27Diagnostic tweaks (review)Esteban Küber-17/+11
2018-02-27Add label to primary span in some parse errorsEsteban Küber-21/+64
2018-02-27Detect missing `if` blocksEsteban Küber-8/+27
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.
2018-02-27Provide missing comma in match arm suggestionEsteban Küber-2/+36
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 ```
2018-02-27add lint to detect ignored generic bounds; this subsumes the previous ↵Ralf Jung-0/+19
'generic bounds in type aliases are ignored' warning
2018-02-26Support flag `-Z ui-testing` for tweaking diagnostic output for UI testsVadim Petrochenkov-1/+9
2018-02-26Auto merge of #48082 - jseyfried:improve_struct_field_hygiene, r=petrochenkovbors-1/+1
macros: improve struct constructor field hygiene, fix span bug Fixes #47311. r? @nrc
2018-02-25Fix find_width_of_character_at_span bounds checkRyan Cumming-8/+11
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
2018-02-24Rollup merge of #48490 - petrochenkov:orpat, r=eddybManish Goregaokar-32/+46
Implement multiple patterns with `|` in `if let` and `while let` (RFC 2175) cc https://github.com/rust-lang/rust/issues/48215
2018-02-24Rollup merge of #48481 - Manishearth:dyn-paren, r=petrochenkovManish Goregaokar-5/+9
Allow parentheses in `dyn (Trait)` r? @eddyb @nikomatsakis
2018-02-24Rollup merge of #48441 - petrochenkov:exty, r=estebankManish Goregaokar-1/+1
Fix parsing of extern paths in types and poly-traits Fixes https://github.com/rust-lang/rust/issues/48262
2018-02-24Rollup merge of #48356 - estebank:unsafe-without-braces, r=nikomatsakisManish Goregaokar-0/+2
When encountering invalid token after `unsafe`, mention `{` Fix #37158.
2018-02-24Rollup merge of #48143 - nikomatsakis:termination_trait_in_tests, r=eddybManish Goregaokar-52/+149
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.
2018-02-24Rollup merge of #48084 - cramertj:impl-trait-errors, r=nikomatsakisManish Goregaokar-69/+1
Error on nested impl Trait and path projections from impl Trait cc #34511 r? @nikomatsakis
2018-02-24Implement multiple patterns with `|` in `if let` and `while let`Vadim Petrochenkov-32/+46
2018-02-23parse `dyn (Foo)` as a trait objectManish Goregaokar-5/+9
2018-02-23Rollup merge of #48429 - toidiu:patch-1, r=nikomatsakisManish Goregaokar-1/+1
update tracking issue for nll Point to the new tracing issue for nll For reference https://github.com/rust-lang/rust/issues/44928
2018-02-23Rollup merge of #48083 - ↵Manish Goregaokar-5/+3
jseyfried:improve_tuple_struct_field_access_hygiene, r=petrochenkov Improve tuple struct field access hygiene Fixes #47312 by fixing a span bug. r? @nrc
2018-02-23Auto merge of #47799 - topecongiro:fix-span-of-visibility, r=petrochenkovbors-63/+100
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.
2018-02-22handle `#[bench]` functions betterNiko Matsakis-19/+43
2018-02-22remove tokenstreamNiko Matsakis-1/+0
2018-02-22Implement --remap-path-prefixJeremy Fitzhardinge-1/+1
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.
2018-02-22put the "unit test" logic into libtestNiko Matsakis-36/+24
Also make `std::termination` module public and rename feature. The lib feature needs a different name from the language feature.
2018-02-22begin crate-relative paths with `crate`Niko Matsakis-10/+9
2018-02-22support unit tests with return values that implement `Terminaton`Niko Matsakis-42/+129
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>.
2018-02-23Fix parsing of extern paths in types and poly-traitsVadim Petrochenkov-1/+1
2018-02-22update tracking issue for nlltoidiu-1/+1
Point to the new tracing issue for nll
2018-02-20make `#[unwind]` attribute specify expectations more clearlyNiko Matsakis-1/+73
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.
2018-02-20stage0 cfg cleanupMark Simulacrum-1/+0
2018-02-19When encountering invalid token after `unsafe`, mention `{`Esteban Küber-0/+2
2018-02-18Rollup merge of #48275 - matthiaskrgr:codespell, r=kennytm,varkorGuillaume Gomez-4/+4
fix more typos found by codespell.
2018-02-17Fix span bug.Jeffrey Seyfried-1/+1
2018-02-17fix more typos found by codespell.Matthias Krüger-4/+4
2018-02-18Fix up tests and typosSeiichi Uchida-2/+2
2018-02-18Replace dummy spans with empty spansSeiichi Uchida-13/+13
2018-02-18Change ast::Visibility to Spanned typeSeiichi Uchida-68/+95
2018-02-18Add a span field to Visibility::RestrictedSeiichi Uchida-6/+15
This span covers the whole visibility expression: e.g. `pub (in path)`.
2018-02-18Add a closing parenthesis to the span of Visibility::CrateSeiichi Uchida-2/+3
2018-02-16Remove unneeded string allocationsAlex Crawford-4/+4
2018-02-14Rollup merge of #48167 - Mark-Simulacrum:remove-allocation-codemap, r=estebankkennytm-3/+5
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
2018-02-14Rollup merge of #48154 - estebank:issue-31481, r=nikomatsakiskennytm-5/+16
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.
2018-02-14Rollup merge of #48130 - ollie27:stab, r=Mark-Simulacrumkennytm-1/+1
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.
2018-02-13Make nested impl Trait a hard errorTaylor Cramer-69/+1
2018-02-12Remove allocation from width of character function.Mark Simulacrum-3/+5
2018-02-11Continue parsing function after finding `...` argEsteban Küber-5/+16
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.