about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2018-01-15Point at unused arguments for format stringEsteban Küber-29/+34
Avoid overlapping spans by only pointing at the arguments that are not being used in the argument string. Enable libsyntax to have diagnostics with multiple primary spans by accepting `Into<MultiSpan>` instead of `Span`.
2018-01-15Move `ExprPrecedence` to `libsyntax/util/parser.rs`Esteban Küber-135/+127
2018-01-15Reexport -> re-export in prose and documentation commentsCarol (Nichols || Goulding)-2/+2
2018-01-15Reexport -> re-export in error messagesCarol (Nichols || Goulding)-1/+1
2018-01-15Use single source of truth for expr precedenceEsteban Küber-62/+182
Introduce a new unified type that holds the expression precedence for both AST and HIR nodes.
2018-01-15Add error code for unstable feature errorsGuillaume Gomez-1/+36
2018-01-14Auto merge of #46455 - petrochenkov:pimpl, r=nikomatsakisbors-167/+156
syntax: Rewrite parsing of impls Properly parse impls for the never type `!` Recover from missing `for` in `impl Trait for Type` Prohibit inherent default impls and default impls of auto traits (https://github.com/rust-lang/rust/issues/37653#issuecomment-348687794, https://github.com/rust-lang/rust/issues/37653#issuecomment-348688785) Change wording in more diagnostics to use "auto traits" Fix some spans in diagnostics Some other minor code cleanups in the parser Disambiguate generics and qualified paths in impls (parse `impl <Type as Trait>::AssocTy { ... }`) Replace the future-compatibility hack from https://github.com/rust-lang/rust/pull/38268 with actually parsing generic parameters Add a test for https://github.com/rust-lang/rust/issues/46438
2018-01-14syntax: Disambiguate generics and qualified pathsVadim Petrochenkov-15/+33
2018-01-14syntax: Rewrite parsing of implsVadim Petrochenkov-154/+125
Properly parse impls for the never type `!` Recover from missing `for` in `impl Trait for Type` Prohibit inherent default impls and default impls of auto traits Change wording in more diagnostics to use "auto traits" Some minor code cleanups in the parser
2018-01-14Auto merge of #47274 - Manishearth:rustdoc-span, r=QuietMisdreavusbors-1/+35
Use correct line offsets for doctests Not yet tested. This doesn't handle char positions. It could if I collected a map of char offsets and lines, but this is a bit more work and requires hooking into the parser much more (unsure if it's possible). r? @QuietMisdreavus (fixes #45868)
2018-01-13Auto merge of #47416 - petrochenkov:remove-impl-for-dot-dot, r=petrochenkovbors-80/+39
Remove `impl Foo for .. {}` in favor `auto trait Foo {}` Rebase of https://github.com/rust-lang/rust/pull/46480 with restored parsing support.
2018-01-13Re-add support for `impl Trait for ..` to the parserVadim Petrochenkov-1/+5
2018-01-13Address review.leonardo.yvens-4/+4
2018-01-13Parse `auto trait` inside fns.leonardo.yvens-12/+16
Also refactored parsing auto traits.
2018-01-13Remove `impl Foo for ..` in favor of `auto trait Foo`leonardo.yvens-69/+20
No longer parse it. Remove AutoTrait variant from AST and HIR. Remove backwards compatibility lint. Remove coherence checks, they make no sense for the new syntax. Remove from rustdoc.
2018-01-13Auto merge of #47251 - rkruppe:rm-simd-attr, r=eddybbors-10/+2
Remove deprecated unstable attribute #[simd] The `#[simd]` attribute has been deprecated since c8b6d5b23cc8b2d43ece9f06252c7e98280fb8e5 back in 2015. Any nightly crates using it have had ample time to switch to `#[repr(simd)]`, and if they didn't they're likely broken by now anyway. r? @eddyb
2018-01-13Auto merge of #47242 - estebank:issue-15980, r=petrochenkovbors-11/+42
`struct` pattern parsing and diagnostic tweaks - Recover from struct parse error on match and point out missing match body. - Point at struct when finding non-identifier while parsing its fields. - Add label to "expected identifier, found {}" error. Fix #15980.
2018-01-13Auto merge of #46461 - zackmdavis:elemental_method_suggestion_jamboree, ↵bors-0/+7
r=estebank type error method suggestions use whitelisted identity-like conversions ![method_jamboree_summit](https://user-images.githubusercontent.com/1076988/33523646-e5c43184-d7c0-11e7-98e5-1bff426ade86.png) Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings: firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are pretty and good for RLS and friends. Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2018-01-13Rollup merge of #47343 - goffrie:master, r=jseyfriedkennytm-6/+24
Glued tokens can themselves be joint. When gluing two tokens, the second of which is joint, the result should also be joint. This fixes an issue with joining three `Dot` tokens to make a `DotDotDot` - the intermediate `DotDot` would not be joint and therefore we would not attempt to glue the last `Dot` token, yielding `.. .` instead of `...`. r? @jseyfried
2018-01-13Rollup merge of #47298 - cramertj:path-as-modrs, r=nikomatsakiskennytm-4/+8
Treat #[path] files as mod.rs files Fixes https://github.com/rust-lang/rust/issues/46936, cc @briansmith, @SergioBenitez, @nikomatsakis. This (insta-stable) change treats files included via `#[path = "bla.rs"] mod foo;` as though they were `mod.rs` files. Namely, it allows them to include `mod` statements and looks for the child modules in sibling directories, rather than in relative `modname/childmodule.rs` files as happens for non-`mod.rs` files. This change makes the `non_modrs_mods` feature backwards compatible with the existing usage in https://github.com/briansmith/ring, several versions of which are currently broken in beta. If we decide to merge, this change should be backported to beta. cc https://github.com/rust-lang/rust/issues/37872 r? @jseyfried
2018-01-10Glued tokens can themselves be joint.Geoffry Song-6/+24
When gluing two tokens, the second of which is joint, the result should also be joint. This fixes an issue with joining three `Dot` tokens to make a `DotDotDot` - the intermediate `DotDot` would not be joint and therefore we would not attempt to glue the last `Dot` token, yielding `.. .` instead of `...`.
2018-01-10Use correct line offsets for doctests (fixes #45868)Manish Goregaokar-1/+35
2018-01-09Treat #[path] files as mod.rs filesTaylor Cramer-4/+8
2018-01-09Rollup merge of #47256 - rkruppe:misc-cleanup, r=eddybkennytm-3/+2
Rename ReprExtern to ReprC … and similarily rename a few other field and locals that mentioned "extern repr".
2018-01-09Rollup merge of #47210 - ↵kennytm-1/+1
zackmdavis:the_3rd_of_2_hardest_problems_in_computer_science, r=QuietMisdreavus fix the doc-comment-decoration-trimming edge-case rustdoc ICE This `horizontal_trim` function strips the leading whitespace from doc-comments that have a left-asterisk-margin: ``` /** * You know what I mean— * * comments like this! */ ``` The index of the column of asterisks is `i`, and if trimming is deemed possible, we slice each line from `i+1` to the end of the line. But if, in particular, `i` was 0 _and_ there was an empty line (as in the example given in the reporting issue), we ended up panicking trying to slice an empty string from 0+1 (== 1). Let's tighten our check to say that we can't trim when `i` is even the same as the length of the line, not just when it's greater. (Any such cases would panic trying to slice `line` from `line.len()+1`.) Resolves #47197.
2018-01-08Auto merge of #47232 - keatinge:master, r=petrochenkovbors-2/+14
Add help message for incorrect pattern syntax When I was getting started with rust I often made the mistake of using `||` instead of `|` to match multiple patterns and spent a long time staring at my code wondering what was wrong. for example: ``` fn main() { let x = 1; match x { 1 || 2 => println!("1 or 2"), _ => println!("Something else"), } } ``` If you compile this with current rustc you will see ``` error: expected one of `...`, `..=`, `..`, `=>`, `if`, or `|`, found `||` --> test.rs:5:11 | 5 | 1 || 2 => println!("1 or 2"), | -^^ unexpected token | | | expected one of `...`, `..=`, `..`, `=>`, `if`, or `|` here error: aborting due to previous error ``` With my proposed change it will show: ``` error: unexpected token `||` after pattern --> test.rs:5:11 | 5 | 1 || 2 => println!("1 or 2"), | ^^ | = help: did you mean to use `|` to specify multiple patterns instead? error: aborting due to previous error ```
2018-01-07`struct` pattern parsing and diagnostic tweaksEsteban Küber-11/+42
- Recover from struct parse error on match and point out missing match body. - Point at struct when finding non-identifier while parsing its fields. - Add label to "expected identifier, found {}" error.
2018-01-07Rename ReprExtern to ReprC, and similarily rename a few other fields and ↵Robin Kruppe-3/+2
locals that mentioned "extern repr"
2018-01-07Try to fix a perf regression by updating logMalo Jaffré-1/+1
Upgrade `log` to `0.4` in multiple crates.
2018-01-07Remove deprecated unstable attribute `#[simd]`Robin Kruppe-10/+2
The `#[simd]` attribute has been deprecated since c8b6d5b23cc8b2d43ece9f06252c7e98280fb8e5 back in 2015. Any nightly crates using it have had ample time to switch to `#[repr(simd)]`, and if they didn't they're likely broken by now anyway.
2018-01-06type error method suggestions use whitelisted identity-like conversionsZack M. Davis-0/+7
Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings. Firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are preferred (because they're pretty, but also for RLS and friends). Also also, we make the E0055 autoderef recursion limit error use the one-time-diagnostics set, because we can potentially hit the limit a lot during probing. (Without this, test/ui/did_you_mean/recursion_limit_deref.rs would report "aborting due to 51 errors"). Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2018-01-07Auto merge of #47156 - petrochenkov:extpath, r=nikomatsakisbors-4/+18
Support `extern` in paths Implement the primary alternative to https://github.com/rust-lang/rust/pull/46613 + https://github.com/rust-lang/rust/pull/45771, achieving the same effect without requiring changes to other imports. Both need to be experimentally evaluated before making further progress. The PR also adds docs for all these related features into the unstable book. cc https://github.com/rust-lang/rust/issues/44660 r? @nikomatsakis
2018-01-06Fix tidy errorkeatinge-2/+5
2018-01-06Use span_suggestion instead of span_err_helpkeatinge-3/+3
2018-01-06wherein careful doc-decoration arithmetic proves quite the ICE-breakerZack M. Davis-1/+1
This `horizontal_trim` function strips the leading whitespace from doc-comments that have a left-asterisk-margin: /** * You know what I mean— * * comments like this! */ The index of the column of asterisks is `i`, and if trimming is deemed possible, we slice each line from `i+1` to the end of the line. But if, in particular, `i` was 0 _and_ there was an empty line (as in the example given in the reporting issue), we ended up panicking trying to slice an empty string from 0+1 (== 1). Let's tighten our check to say that we can't trim when `i` is even the same as the length of the line, not just when it's greater. (Any such cases would panic trying to slice `line` from `line.len()+1`.) Resolves #47197.
2018-01-07Rollup merge of #47170 - eddyb:us-vs-usize, r=nikomatsakiskennytm-15/+15
rustc: use {U,I}size instead of {U,I}s shorthands. `Us`/`Is` come from a time when `us` and `is` were the literal suffixes that are now `usize` / `isize`. r? @nikomatsakis
2018-01-06fix stylekeatinge-4/+2
2018-01-06Emit non-fatal error insteadkeatinge-8/+10
2018-01-06fix capitalizationkeatinge-2/+2
2018-01-06Add help message for incorrect pattern syntaxkeatinge-1/+10
2018-01-04rustc: Don't use relative paths for extended errorsAlex Crichton-5/+7
These no longer work now that Cargo changes the cwd of rustc while it's running. Instead use an absolute path that's set by rustbuild.
2018-01-04rustc: use {U,I}size instead of {U,I}s shorthands.Eduard-Mihai Burtescu-15/+15
2018-01-03Support `extern` in pathsVadim Petrochenkov-4/+18
2018-01-01Fix docs for future pulldown migrationMalo Jaffré-5/+7
2018-01-01Auto merge of #46895 - ricochet1k:macro-lifetimes, r=jseyfriedbors-21/+69
Allow lifetimes in macros This is a resurrection of PR #41927 which was a resurrection of #33135, which is intended to fix #34303. In short, this allows macros_rules! to use :lifetime as a matcher to match 'lifetimes. Still to do: - [x] Feature gate
2017-12-30in which leading zeroes on tuple-struct accesses are abjuredZack M. Davis-3/+12
Resolves #47073.
2017-12-30refactor lifetime out of is_lifetimeMatt Peterson-19/+20
2017-12-28CleanupMatt Peterson-5/+5
2017-12-28Add feature gate macro_lifetime_matcherMatt Peterson-2/+20
2017-12-28CleanupMatt Peterson-4/+3