about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2018-03-08Note the future epoch for epoch lintsManish Goregaokar-6/+8
2018-03-08Make it possible to ungate features by epochManish Goregaokar-6/+19
2018-03-08Allow mentioning an optional epoch on featuresManish Goregaokar-185/+186
2018-03-08Move epochs to libsyntaxManish Goregaokar-0/+69
2018-03-08Add codemap functions to retrieve the source before a given spanBasile Desloges-3/+63
2018-03-08in which parentheses are suggested for should-have-been-tuple-patternsZack M. Davis-5/+39
Programmers used to working in some other languages (such as Python or Go) might expect to be able to destructure values with comma-separated identifiers but no parentheses on the left side of an assignment. Previously, the first name in such code would get parsed as a single-indentifier pattern—recognizing, for example, the `let a` in `let a, b = (1, 2);`—whereupon we would have a fatal syntax error on seeing an unexpected comma rather than the expected semicolon (all the way nearer to the end of `parse_full_stmt`). Instead, let's look for that comma when parsing the pattern, and if we see it, momentarily make-believe that we're parsing the remaining elements in a tuple pattern, so that we can suggest wrapping it all in parentheses. We need to do this in a separate wrapper method called on the top-level pattern (or `|`-patterns) in a `let` statement, `for` loop, `if`- or `while let` expression, or match arm rather than within `parse_pat` itself, because `parse_pat` gets called recursively to parse the sub-patterns within a tuple pattern. Resolves #48492.
2018-03-08Rollup merge of #48808 - Zoxc:reg-diag, r=michaelwoeristerManish Goregaokar-20/+12
Move REGISTERED_DIAGNOSTICS to a ParseSess field r? @michaelwoerister
2018-03-08Stabilize const_indexing featureOliver Schneider-3/+2
2018-03-08Move REGISTERED_DIAGNOSTICS to a ParseSess fieldJohn Kåre Alsaker-20/+12
2018-03-07check stability of macro invocationsAustin Bonander-17/+56
2018-03-06Add `inline` to `TransFnAttrs`Wesley Wiser-114/+1
Part of #47320
2018-03-06note a FIXMERalf Jung-0/+1
2018-03-06make bounds on higher-kinded lifetimes a hard error in ast_validationRalf Jung-12/+2
Also move the check for not having type parameters into ast_validation. I was not sure what to do with compile-fail/issue-23046.rs: The issue looks like maybe the bounds actually played a role in triggering the ICE, but that seems unlikely given that the compiler seems to entirely ignore them. However, I couldn't find a testcase without the bounds, so I figured the best I could do is to just remove the bounds and make sure at least that keeps working.
2018-03-06Rollup merge of #48546 - GuillaumeGomez:raw-string-error-note, r=estebankkennytm-8/+25
Raw string error note Fixes #48395. I think this note should be helpful enough to solve the issue.
2018-03-06Rollup merge of #48403 - lukaslueg:casted, r=steveklabnikkennytm-1/+1
Fix spelling s/casted/cast/ r? @GuillaumeGomez
2018-03-05Turn features() into a query.Michael Woerister-17/+22
2018-03-04Add note for unterminated raw string errorGuillaume Gomez-8/+25
2018-03-03rust: Import LLD for linking wasm objectsAlex Crichton-8/+0
This commit imports the LLD project from LLVM to serve as the default linker for the `wasm32-unknown-unknown` target. The `binaryen` submoule is consequently removed along with "binaryen linker" support in rustc. Moving to LLD brings with it a number of benefits for wasm code: * LLD is itself an actual linker, so there's no need to compile all wasm code with LTO any more. As a result builds should be *much* speedier as LTO is no longer forcibly enabled for all builds of the wasm target. * LLD is quickly becoming an "official solution" for linking wasm code together. This, I believe at least, is intended to be the main supported linker for native code and wasm moving forward. Picking up support early on should help ensure that we can help LLD identify bugs and otherwise prove that it works great for all our use cases! * Improvements to the wasm toolchain are currently primarily focused around LLVM and LLD (from what I can tell at least), so it's in general much better to be on this bandwagon for bugfixes and new features. * Historical "hacks" like `wasm-gc` will soon no longer be necessary, LLD will [natively implement][gc] `--gc-sections` (better than `wasm-gc`!) which means a postprocessor is no longer needed to show off Rust's "small wasm binary size". LLD is added in a pretty standard way to rustc right now. A new rustbuild target was defined for building LLD, and this is executed when a compiler's sysroot is being assembled. LLD is compiled against the LLVM that we've got in tree, which means we're currently on the `release_60` branch, but this may get upgraded in the near future! LLD is placed into rustc's sysroot in a `bin` directory. This is similar to where `gcc.exe` can be found on Windows. This directory is automatically added to `PATH` whenever rustc executes the linker, allowing us to define a `WasmLd` linker which implements the interface that `wasm-ld`, LLD's frontend, expects. Like Emscripten the LLD target is currently only enabled for Tier 1 platforms, notably OSX/Windows/Linux, and will need to be installed manually for compiling to wasm on other platforms. LLD is by default turned off in rustbuild, and requires a `config.toml` option to be enabled to turn it on. Finally the unstable `#![wasm_import_memory]` attribute was also removed as LLD has a native option for controlling this. [gc]: https://reviews.llvm.org/D42511
2018-03-02Rollup merge of #48338 - estebank:match-missing-comma, r=petrochenkovManish Goregaokar-31/+121
Fixes #47311. r? @nrc
2018-03-02Replace Rc with Lrc for shared dataJohn Kåre Alsaker-91/+91
2018-03-01Rollup merge of #48522 - ↵Manish Goregaokar-8/+11
etaoins:fix-find-width-of-character-at-span-bounds-check, r=estebank Fix find_width_of_character_at_span bounds check 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 `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. cc @davidtwco Fixes #48508
2018-03-01Rollup merge of #48500 - petrochenkov:parpat, r=nikomatsakisManish Goregaokar-28/+58
Support parentheses in patterns under feature gate This is a prerequisite for any other extensions to pattern syntax - `|` with multiple patterns, type ascription, `..PAT` in slice patterns. Closes https://github.com/rust-lang/rfcs/issues/554
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.