Commit Graph

1210 Commits

Author SHA1 Message Date
Alex Crichton
98b375483c Rollup merge of #47502 - petrochenkov:label, r=eddyb
AST/HIR: Add a separate structure for labels
2018-01-25 12:48:49 -06:00
John Kåre Alsaker
ccf0d8399e Adds support for immovable generators. Move checking of invalid borrows across suspension points to borrowck. Fixes #44197, #45259 and #45093. 2018-01-23 05:10:38 +01:00
Vadim Petrochenkov
2d56abfbeb AST/HIR: Add a separate structure for labels 2018-01-22 23:13:12 +03:00
Esteban Küber
afe8d13a66 Use single source of truth for expr precedence
Introduce a new unified type that holds the expression precedence for
both AST and HIR nodes.
2018-01-15 02:02:37 -08:00
leonardo.yvens
f93183adb4 Remove impl Foo for .. in favor of auto trait Foo
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-13 18:48:00 +03:00
Michael Hewson
03a51019a4 Resurrecting #33135
Started rebasing @sgrif's PR #33135 off of current master. (Well, actually merging it into a new branch based off current master.)

The following files still need to be fixed or at least reviewed:

- `src/libsyntax/ext/tt/macro_parser.rs`: calls `Parser::parse_lifetime`, which doesn't exist anymore
- `src/libsyntax/parse/parser.rs`: @sgrif added an error message to `Parser::parse_lifetime`. Code has since been refactored, so I just took it out for now.
- `src/libsyntax/ext/tt/transcribe.rs`: This code has been refactored bigtime. Not sure whether @sgrif's changes here are still necessary. Took it out for this commit.
2017-12-28 11:32:05 -05:00
Jonas Platte
78493ed21a Add GenericParam, refactor Generics in ast, hir, rustdoc
The Generics now contain one Vec of an enum for the generic parameters,
rather than two separate Vec's for lifetime and type parameters.

Additionally, places that previously used Vec<LifetimeDef> now use
Vec<GenericParam> instead.
2017-12-21 13:38:10 +01:00
Vadim Petrochenkov
7a95e716c7 Fix whitespacing issues in pretty-printing of bounds 2017-12-20 00:23:18 +03:00
Alex Burka
d4a28268cc add trait aliases to AST 2017-12-14 12:56:26 -05:00
Oliver Schneider
d732da813b
Use PathBuf instead of String where applicable 2017-12-14 11:22:08 +01:00
Jeffrey Seyfried
85d19b3335 Improve pretty printing $crate:: paths. 2017-12-12 22:32:19 -08:00
Pietro Albini
91ba8b42fc
Implement RFC 2128 (use_nested_groups)
This commit adds support for nested groups inside `use` declarations,
such as `use foo::{bar, sub::{baz::Foo, *}};`.
2017-11-30 13:10:26 +01:00
bors
d5ff0e6422 Auto merge of #45773 - Badel2:dotdoteq, r=petrochenkov
Add error for `...` in expressions

Follow-up to https://github.com/rust-lang/rust/pull/44709
Tracking issue: https://github.com/rust-lang/rust/issues/28237

* Using `...` in expressions was a warning, now it's an error
* The error message suggests using `..` or `..=` instead, and explains the difference
* Updated remaining occurrences of `...` to `..=`

r? petrochenkov
2017-11-10 01:40:21 +00:00
kennytm
0d53ecd0c7
Rollup merge of #45784 - harpocrates:fix/print-parens-cast-lt, r=kennytm
Pretty print parens around casts on the LHS of `<`/`<<`

When pretty printing a cast expression occuring on the LHS of a `<` or `<<` expression, we should add parens around the cast. Otherwise, the `<`/`<<` gets interpreted as the beginning of the generics for the type on the RHS of the cast.

Consider:

    $ cat parens_cast.rs
    macro_rules! negative {
        ($e:expr) => { $e < 0 }
    }

    fn main() {
        negative!(1 as i32);
    }

Before this PR, the output of the following is not valid Rust:

    $ rustc -Z unstable-options --pretty=expanded parens_cast.rs
    #![feature(prelude_import)]
    #![no_std]
    #[prelude_import]
    use std::prelude::v1::*;
    #[macro_use]
    extern crate std as std;
    macro_rules! negative(( $ e : expr ) => { $ e < 0 });

    fn main() { 1 as i32 < 0; }

After this PR, the output of the following is valid Rust:

    $ rustc -Z unstable-options --pretty=expanded parens_cast.rs
    #![feature(prelude_import)]
    #![no_std]
    #[prelude_import]
    use std::prelude::v1::*;
    #[macro_use]
    extern crate std as std;
    macro_rules! negative(( $ e : expr ) => { $ e < 0 });

    fn main() { (1 as i32) < 0; }

I've gone through several README/wiki style documents but I'm still not sure where to test this though. I'm not even sure if this sort of thing is tested...
2017-11-07 22:40:20 +08:00
Badel2
4bd6be9dc6 Inclusive range updated to ..= syntax 2017-11-06 13:43:59 +01:00
Alec Theriault
45a0aa4b4d Pretty print parens around casts on the LHS of '<'
When pretty printing a cast expression occuring on the LHS of a '<'
or '<<' expression, we should add parens around the cast. Otherwise,
the '<'/'<<' gets interpreted as the beginning of the generics for
the type on the RHS of the cast.
2017-11-05 09:45:06 -08:00
leonardo.yvens
5190abb941 Fix unsafe auto trait pretty print.
It was being printed wrong as auto unsafe trait
2017-11-03 16:13:23 -02:00
leonardo.yvens
1f4b630899 add auto keyword, parse auto trait, lower to HIR
Adds an `IsAuto` field to `ItemTrait` which flags if the trait was
declared as an `auto trait`.

Auto traits cannot have generics nor super traits.
2017-11-03 16:13:20 -02:00
leonardo.yvens
06506bb751 [Syntax Breaking] Rename DefaultImpl to AutoImpl
DefaultImpl is a highly confusing name for what we now call auto impls,
as in `impl Send for ..`. The name auto impl is not formally decided
but for sanity anything is better than `DefaultImpl` which refers
neither to `default impl` nor to `impl Default`.
2017-11-03 16:13:20 -02:00
Paul Lietar
77f7e85d7f Implement RFC 1861: Extern types 2017-10-27 23:01:34 +02:00
bors
fbc3642ef1 Auto merge of #45401 - zackmdavis:crate_shorthand_visibility_modifier, r=nikomatsakis
`crate` shorthand visibility modifier

cc #45388.

r? @nikomatsakis
2017-10-24 12:24:16 +00:00
Zack M. Davis
214b0f2293 crate shorthand visibility modifier
With regrets, this breaks rustfmt and rls.

This is in the matter of #45388.
2017-10-22 23:58:13 -07:00
Sunjay Varma
f61394f0bd Lifting Generics from MethodSig to TraitItem and ImplItem since we want to support generics in each variant of TraitItem and ImplItem 2017-10-17 22:14:14 -04:00
Vadim Petrochenkov
e6115af4bd Implement dyn Trait syntax 2017-10-14 12:51:13 +03:00
Badel2
7aabf57278 Add information about the syntax used in ranges
... or ..=
2017-09-22 22:05:18 +02:00
Alex Burka
e64efc91f4 Add support for ..= syntax
Add ..= to the parser

Add ..= to libproc_macro

Add ..= to ICH

Highlight ..= in rustdoc

Update impl Debug for RangeInclusive to ..=

Replace `...` to `..=` in range docs

Make the dotdoteq warning point to the ...

Add warning for ... in expressions

Updated more tests to the ..= syntax

Updated even more tests to the ..= syntax

Updated the inclusive_range entry in unstable book
2017-09-22 22:05:18 +02:00
Stuart Pernsteiner
b79dada453 pprust: fix parenthesization of exprs 2017-09-06 10:26:51 -04:00
Vadim Petrochenkov
3da868dcb6 Make fields of Span private 2017-08-30 01:38:54 +03:00
Alex Crichton
1210ebff43 Merge remote-tracking branch 'origin/master' into gen 2017-08-16 10:03:47 -07:00
Zack M. Davis
1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Alex Crichton
c25ddf21f1 Merge remote-tracking branch 'origin/master' into gen 2017-08-09 11:44:21 -07:00
topecongiro
6375b77ebb Add Span to ast::WhereClause 2017-07-29 00:43:35 +09:00
Alex Crichton
09a5d319ab Remove support for gen arg 2017-07-28 15:46:26 +02:00
John Kåre Alsaker
05fcef0b3e Fix printing 2017-07-28 15:46:24 +02:00
John Kåre Alsaker
d861982ca6 Generator literal support 2017-07-28 15:46:23 +02:00
Mark Simulacrum
0343136805 Make a few functions non-public 2017-07-11 12:09:25 -06:00
Mark Simulacrum
16b486ce6e Refactor cur_cmnt_and_lit away.
The literal index was increased in only next_lit, so it isn't
necessary: code now uses an iterator. The cur_cmnt field is also moved
to be increased in print_comment instead of after each call to
print_comment.
2017-07-11 12:09:25 -06:00
Mark Simulacrum
bac4bb9613 Refactor methods onto Printer struct.
No (intentional) changes to behavior. This is intended to avoid the
anti-pattern of having to import individual methods throughout code.
2017-07-11 12:09:19 -06:00
Vadim Petrochenkov
287de2595a Store all generic arguments for method calls in AST 2017-07-10 00:20:25 +03:00
Alex Crichton
fd95db25b3 Merge remote-tracking branch 'origin/master' into proc_macro_api 2017-07-05 08:42:13 -07:00
Vadim Petrochenkov
e03948ef3e Make $crate a keyword 2017-06-29 15:19:52 +03:00
Jeffrey Seyfried
7d493bdd2a Add LazyTokenStream. 2017-06-26 02:06:31 +00:00
Jeffrey Seyfried
d4488b7df9 Simplify hygiene::Mark application, and
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-26 02:05:45 +00:00
kennytm
4711982314
Removed as many "```ignore" as possible.
Replaced by adding extra imports, adding hidden code (`# ...`), modifying
examples to be runnable (sorry Homura), specifying non-Rust code, and
converting to should_panic, no_run, or compile_fail.

Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-23 15:31:53 +08:00
Nick Cameron
600237fa19 Add a sig module to save-analysis
Generates signatures for use in Rustdoc and similar tools.
2017-06-12 14:14:23 +12:00
Jeffrey Seyfried
7fdc1fb2e4 Hygienize lifetimes. 2017-05-25 05:52:09 +00:00
Jeffrey Seyfried
9c6430b325 Refactor out ast::MacroDef. 2017-05-25 05:47:25 +00:00
Andre Bogus
282b40249e (hopefully) fix pprust error 2017-05-16 09:21:30 +02:00
Andre Bogus
958c67d9c8 adressed comments by @kennytm and @petrochenkov 2017-05-15 23:56:09 +02:00
Andre Bogus
a9c163ebe9 Fix some clippy warnings in libsyntax
This is mostly removing stray ampersands, needless returns and lifetimes.
2017-05-12 20:05:39 +02:00