about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2017-04-03Fix bug parsing `#[derive]` macro invocations.Jeffrey Seyfried-1/+22
2017-04-03Merge branch 'master' into issue-40006Esteban Küber-1663/+672
2017-04-02Introduce `TyErr` independent from `TyInfer`Esteban Küber-3/+31
Add a `TyErr` type to represent unknown types in places where parse errors have happened, while still able to build the AST. Initially only used to represent incorrectly written fn arguments and avoid "expected X parameters, found Y" errors when called with the appropriate amount of parameters. We cannot use `TyInfer` for this as `_` is not allowed as a valid argument type. Example output: ```rust error: expected one of `:` or `@`, found `,` --> file.rs:12:9 | 12 | fn bar(x, y: usize) {} | ^ error[E0061]: this function takes 2 parameters but 3 parameters were supplied --> file.rs:19:9 | 12 | fn bar(x, y) {} | --------------- defined here ... 19 | bar(1, 2, 3); | ^^^^^^^ expected 2 parameters ```
2017-04-01rustc: Stabilize the `#![windows_subsystem]` attributeAlex Crichton-9/+3
This commit stabilizes the `#![windows_subsystem]` attribute which is a conservative exposure of the `/SUBSYSTEM` linker flag on Widnows platforms. This is useful for creating applications as well as console programs. Closes #37499
2017-03-31Auto merge of #40620 - laumann:slash-in-diagnostics-path, r=BurntSushibors-4/+5
Replace hardcoded forward slash with path::MAIN_SEPARATOR Fixes #40149
2017-03-30port the match code to use `CoerceMany`Niko Matsakis-0/+1
`match { }` now (correctly?) indicates divergence, which results in more unreachable warnings. We also avoid fallback to `!` if there is just one arm (see new test: `match-unresolved-one-arm.rs`).
2017-03-30Replace hardcoded forward slash with path::MAIN_SEPARATORThomas Jespersen-4/+5
Fixes #40149
2017-03-30Improve `Path` spans.Jeffrey Seyfried-67/+95
2017-03-29Refactor how spans are combined in the parser.Jeffrey Seyfried-399/+337
2017-03-29Merge `ExpnId` and `SyntaxContext`.Jeffrey Seyfried-868/+163
2017-03-29Remove code in `syntax::codemap`.Jeffrey Seyfried-185/+0
2017-03-29Move `syntax::ext::hygiene` to `syntax_pos::hygiene`.Jeffrey Seyfried-134/+15
2017-03-27Fix unittestsEsteban Küber-1/+1
2017-03-27Simplify error outputEsteban Küber-11/+6
2017-03-27Rollup merge of #40813 - jseyfried:fix_expansion_regression, r=nrcAlex Crichton-1/+1
macros: fix ICE on some nested macro definitions Fixes #40770. r? @nrc
2017-03-27Fix various useless derefs and slicingsOliver Schneider-10/+9
2017-03-27allow `InternedString` to be compared to `str` directlyOliver Schneider-4/+40
2017-03-26Auto merge of #40347 - alexcrichton:rm-liblog, r=brsonbors-1/+1
Remove internal liblog This commit deletes the internal liblog in favor of the implementation that lives on crates.io. Similarly it's also setting a convention for adding crates to the compiler. The main restriction right now is that we want compiler implementation details to be unreachable from normal Rust code (e.g. requires a feature), and by default everything in the sysroot is reachable via `extern crate`. The proposal here is to require that crates pulled in have these lines in their `src/lib.rs`: #![cfg_attr(rustbuild, feature(staged_api, rustc_private))] #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))] This'll mean that by default they're not using these attributes but when compiled as part of the compiler they do a few things: * Mark themselves as entirely unstable via the `staged_api` feature and the `#![unstable]` attribute. * Allow usage of other unstable crates via `feature(rustc_private)` which is required if the crate relies on any other crates to compile (other than std).
2017-03-25Improve wording and spans for unexpected tokenEsteban Küber-6/+19
* Point at where the token was expected instead of the last token successfuly parsed. * Only show `unexpected token` if the next char and the unexpected token don't have the same span. * Change some cfail and pfail tests to ui test. * Don't show all possible tokens in span label if they are more than 6.
2017-03-24Point at last valid token on failed `expect_one_of`Esteban Küber-14/+14
```rust error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)` --> $DIR/token-error-correct-3.rs:29:9 | 25 | foo() | - expected one of `.`, `;`, `?`, `}`, or an operator after this ... 29 | } else { | ^ unexpected token ```
2017-03-24Identify missing item category in `impl`sEsteban Küber-15/+47
```rust struct S; impl S { pub hello_method(&self) { println!("Hello"); } } fn main() { S.hello_method(); } ``` ```rust error: can't qualify macro invocation with `pub` --> file.rs:3:4 | 3 | pub hello_method(&self) { | ^^^- - expected `!` here for a macro invocation | | | did you mean to write `fn` here for a method declaration? | = help: try adjusting the macro to put `pub` inside the invocation ```
2017-03-25Fix ICE with nested macros in certain situations.Jeffrey Seyfried-1/+1
2017-03-23Remove internal liblogAlex Crichton-1/+1
This commit deletes the internal liblog in favor of the implementation that lives on crates.io. Similarly it's also setting a convention for adding crates to the compiler. The main restriction right now is that we want compiler implementation details to be unreachable from normal Rust code (e.g. requires a feature), and by default everything in the sysroot is reachable via `extern crate`. The proposal here is to require that crates pulled in have these lines in their `src/lib.rs`: #![cfg_attr(rustbuild, feature(staged_api, rustc_private))] #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))] This'll mean that by default they're not using these attributes but when compiled as part of the compiler they do a few things: * Mark themselves as entirely unstable via the `staged_api` feature and the `#![unstable]` attribute. * Allow usage of other unstable crates via `feature(rustc_private)` which is required if the crate relies on any other crates to compile (other than std).
2017-03-23Rollup merge of #40627 - estebank:pub-restricted, r=petrochenkovCorey Farwell-26/+38
Add diagnostic for incorrect `pub (restriction)` Given the following statement ```rust pub (a) fn afn() {} ``` Provide the following diagnostic: ```rust error: incorrect restriction in `pub` --> file.rs:15:1 | 15 | pub (a) fn afn() {} | ^^^ | = help: some valid visibility restrictions are: `pub(crate)`: visible only on the current crate `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path help: to make this visible only to module `a`, add `in` before the path: | pub (in a) fn afn() {} ``` Follow up to #40340, fix #40599, cc #32409.
2017-03-22Add diagnostic for incorrect `pub (restriction)`Esteban Küber-26/+38
Given the following statement ```rust pub (a) fn afn() {} ``` Provide the following diagnostic: ```rust error: incorrect restriction in `pub` --> file.rs:15:1 | 15 | pub (a) fn afn() {} | ^^^^^^^ | = help: some valid visibility restrictions are: `pub(crate)`: visible only on the current crate `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path help: to make this visible only to module `a`, add `in` before the path: | pub (in a) fn afn() {} ``` Remove cruft from old `pub(path)` syntax.
2017-03-22Introduce HirId, a replacement for NodeId after lowering to HIR.Michael Woerister-11/+3
HirId has a more stable representation than NodeId, meaning that modifications to one item don't influence (part of) the IDs within other items. The other part is a DefIndex for which there already is a way of stable hashing and persistence. This commit introduces the HirId type and generates a HirId for every NodeId during HIR lowering, but the resulting values are not yet used anywhere, except in consistency checks.
2017-03-22Implement indexed_vec::Idx for ast::NodeIdMichael Woerister-0/+11
2017-03-21Refactor parsing of trait object typesVadim Petrochenkov-246/+220
2017-03-20Rollup merge of #40556 - cramertj:stabilize-pub-restricted, r=petrochenkovCorey Farwell-14/+3
Stabilize pub(restricted) Fix https://github.com/rust-lang/rust/issues/32409
2017-03-19Rollup merge of #40532 - jseyfried:improve_tokenstream_quoter, r=nrcCorey Farwell-0/+6
macros: improve the `TokenStream` quoter This PR - renames the `TokenStream` quoter from `qquote!` to `quote!`, - uses `$` instead of `unquote` (e.g. `let toks: TokenStream = ...; quote!([$toks])`), - allows unquoting `Token`s as well as `TokenTree`s and `TokenStream`s (fixes #39746), and - to preserve syntactic space, requires that `$` be followed by - a single identifier to unquote, or - another `$` to produce a literal `$`. r? @nrc
2017-03-19Rollup merge of #40589 - topecongiro:floating-point-literal, r=nagisaCorey Farwell-1/+1
Parse 0e+10 as a valid floating-point literal Fixes issue #40408.
2017-03-19Rollup merge of #40441 - tschottdorf:promotable-rfc, r=eddybCorey Farwell-0/+3
Add feature gate for rvalue-static-promotion Probably needs more tests (which ones?) and there may be other things that need to be done. Also not sure whether the version that introduces the flag is really `1.15.1`. See https://github.com/rust-lang/rfcs/pull/1414. Updates #38865.
2017-03-19Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrcbors-350/+691
`TokenStream`-based attributes, paths in attribute and derive macro invocations This PR - refactors `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`. - supports macro invocation paths for attribute procedural macros. - e.g. `#[::foo::attr_macro] struct S;`, `#[cfg_attr(all(), foo::attr_macro)] struct S;` - supports macro invocation paths for derive procedural macros. - e.g. `#[derive(foo::Bar, super::Baz)] struct S;` - supports arbitrary tokens as arguments to attribute procedural macros. - e.g. `#[foo::attr_macro arbitrary + tokens] struct S;` - supports using arbitrary tokens in "inert attributes" with derive procedural macros. - e.g. `#[derive(Foo)] struct S(#[inert arbitrary + tokens] i32);` where `#[proc_macro_derive(Foo, attributes(inert))]` r? @nrc
2017-03-18Parse 0e+10 as a valid floating-point literaltopecongiro-1/+1
Fixes issue #40408.
2017-03-15Stabilize pub(restricted)Taylor Cramer-14/+3
2017-03-15Improve the `TokenStream` quoter.Jeffrey Seyfried-0/+6
2017-03-14Point out correct turbofish usage on `Foo<Bar<Baz>>`Esteban Küber-1/+4
Whenever we parse a chain of binary operations, as long as the first operation is `<` and the subsequent operations are either `>` or `<`, present the following diagnostic help: use `::<...>` instead of `<...>` if you meant to specify type arguments This will lead to spurious recommendations on situations like `2 < 3 < 4` but should be clear from context that the help doesn't apply in that case.
2017-03-14Add feature toggle for rvalue-static-promotion RFCTobias Schottdorf-0/+3
See https://github.com/rust-lang/rfcs/pull/1414. Updates #38865.
2017-03-14Auto merge of #39921 - cramertj:add-catch-to-ast, r=nikomatsakisbors-1/+47
Add catch {} to AST Part of #39849. Builds on #39864.
2017-03-14Liberalize attributes.Jeffrey Seyfried-120/+187
2017-03-14Refactor `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`.Jeffrey Seyfried-229/+504
2017-03-14Cleanup.Jeffrey Seyfried-12/+11
2017-03-12Rollup merge of #40369 - petrochenkov:segspan, r=eddybCorey Farwell-35/+52
Give spans to individual path segments in AST And use these spans in path resolution diagnostics. The spans are spans of identifiers in segments, not whole segments. I'm not sure what spans are more useful in general, but identifier spans are a better fit for resolve errors. HIR still doesn't have spans. Fixes https://github.com/rust-lang/rust/pull/38927#discussion_r95336667 https://github.com/rust-lang/rust/pull/38890#issuecomment-271731008 r? @nrc @eddyb
2017-03-12Auto merge of #40340 - petrochenkov:restricted, r=nikomatsakisbors-32/+40
Update syntax for `pub(restricted)` Update the syntax before stabilization. cc https://github.com/rust-lang/rust/issues/32409 r? @nikomatsakis
2017-03-11Temporarily prefix catch block with do keywordTaylor Cramer-14/+7
2017-03-11Add catch expr to AST and disallow catch as a struct nameTaylor Cramer-1/+54
2017-03-11Auto merge of #40220 - jseyfried:ast_macro_def, r=nrcbors-156/+89
syntax: add `ast::ItemKind::MacroDef`, simplify hygiene info This PR - adds a new variant `MacroDef` to `ast::ItemKind` for `macro_rules!` and eventually `macro` items, - [breaking-change] forbids macro defs without a name (`macro_rules! { () => {} }` compiles today), - removes `ast::MacroDef`, and - no longer uses `Mark` and `Invocation` to identify and characterize macro definitions. - We used to apply (at least) two `Mark`s to an expanded identifier's `SyntaxContext` -- the definition mark(s) and the expansion mark(s). We now only apply the latter. r? @nrc
2017-03-10Give spans to individual path segments in ASTVadim Petrochenkov-35/+52
2017-03-10Update syntax for `pub(restricted)`Vadim Petrochenkov-32/+40
2017-03-10Expect macro defs in save-analysis and add expn info to spans for attr proc ↵Nick Cameron-1/+13
macros