Commit Graph

140 Commits

Author SHA1 Message Date
Nicholas Nethercote 2747923c27 Rename Parser::last_span as prev_span.
This is a [breaking-change] for libsyntax.
2016-10-05 08:53:18 +11:00
Mikhail Modin 82639d4f04 fix top level attr spans 2016-09-16 21:44:15 +03:00
Mikhail Modin fb85dd398b fix span for errors E0537, E0535 & E0536 2016-09-10 10:21:13 +03:00
Sergio Benitez 8250a26b5b Implement RFC#1559: allow all literals in attributes. 2016-08-25 13:25:22 -07:00
Aravind Gollakota ff95ba3a8c syntax: Better error message for inner attr following doc comment 2016-07-15 21:02:53 -07:00
Zack M. Davis d37edef9dd prefer if let to match with None => {} arm in some places
This is a spiritual succesor to #34268/8531d581, in which we replaced a
number of matches of None to the unit value with `if let` conditionals
where it was judged that this made for clearer/simpler code (as would be
recommended by Manishearth/rust-clippy's `single_match` lint). The same
rationale applies to matches of None to the empty block.
2016-07-03 16:27:02 -07:00
Jonathan Turner 6ae3502134 Move errors from libsyntax to its own crate 2016-06-23 08:07:35 -04:00
Georg Brandl 72560e1403 parser: show a helpful note on unexpected inner comment
Fixes: #30318.
2016-05-03 17:53:23 +02:00
Niko Matsakis 489a6c95bf replace fileline_{help,note} with {help,note}
The extra filename and line was mainly there to keep the indentation
relative to the main snippet; now that this doesn't include
filename/line-number as a prefix, it is distracted.
2016-05-02 11:49:23 -04:00
Jorge Aparicio 0f02309e4b try! -> ?
Automated conversion using the untry tool [1] and the following command:

```
$ find -name '*.rs' -type f | xargs untry
```

at the root of the Rust repo.

[1]: https://github.com/japaric/untry
2016-03-22 22:01:37 -05:00
Corey Farwell bc2f5e2612 Use associated functions for libsyntax SepSeq constructors. 2016-02-22 23:24:42 -05:00
Oliver 'ker' Schneider 14e09ad468 [breaking-change] don't glob export ast::MetaItem_ 2016-02-11 12:34:48 +01:00
Oliver Schneider 69072c4f5d [breaking-change] don't pub export ast::Lit_ variants 2016-02-11 12:34:48 +01:00
Tshepang Lekhonkhobe bbdef0ce59 rustfmt syntax::parse 2016-01-27 21:45:14 +02:00
Nick Cameron 9023c659af Cut out a bunch of Result and panictry! boilerplate from libsyntax.
[breaking-change] if you use any of the changed functions, you'll need to remove a try! or panictry!
2015-12-31 14:29:02 +13:00
Nick Cameron 95dc7efad0 use structured errors 2015-12-30 14:27:59 +13:00
Eli Friedman e7d3ae606e Make quote plugin use parsing functions which explicitly panic.
Rename parse_* to parse_*_panic, and add parse_attribute_panic.
2015-10-28 14:11:31 -07:00
Eli Friedman de95857129 Don't panic for fatal errors in attribute parsing. 2015-10-27 20:09:10 -07:00
Eli Friedman c141f47c24 Delete unnecessary ParserAttr trait. 2015-10-27 20:09:10 -07:00
Ms2ger b093060c2a Stop re-exporting AttrStyle's variants and rename them. 2015-10-01 18:03:34 +02:00
Vadim Petrochenkov f284cbc7af Cleanup interfaces of Name, SyntaxContext and Ident
Make sure Name, SyntaxContext and Ident are passed by value
Make sure Idents don't serve as keys (or parts of keys) in maps, Ident comparison is not well defined
2015-09-24 23:05:02 +03:00
Phil Dawes b2bcb7229a Work towards a non-panicing parser (libsyntax)
- Functions in parser.rs return PResult<> rather than panicing
- Other functions in libsyntax call panic! explicitly for now if they rely on panicing behaviour.
- 'panictry!' macro added as scaffolding while converting panicing functions.
  (This does the same as 'unwrap()' but is easier to grep for and turn into try!())
- Leaves panicing wrappers for the following functions so that the
  quote_* macros behave the same:
  - parse_expr, parse_item, parse_pat, parse_arm, parse_ty, parse_stmt
2015-04-05 09:52:50 +01:00
Eduard Burtescu 9889aae13e syntax: use lookahead to distinguish inner and outer attributes, instead of passing the latter around. 2015-03-13 11:36:30 +02:00
Ivan Radanov Ivanov 7496539a00 Change span_help calls to fileline_help where appropriate 2015-03-03 15:18:33 +02:00
Niko Matsakis 68e5bb3f2c Remove remaining uses of []. This time I tried to use deref coercions where possible. 2015-02-20 14:08:14 -05:00
P1start 597b4fa984 Tweak some ‘expected…’ error messages
Fixes #21153.
2015-02-02 15:30:35 +13:00
Jorge Aparicio 517f1cc63c use slicing sugar 2015-01-07 17:35:56 -05:00
Alex Crichton 5c3ddcb15d rollup merge of #20481: seanmonstar/fmt-show-string
Conflicts:
	src/compiletest/runtest.rs
	src/libcore/fmt/mod.rs
	src/libfmt_macros/lib.rs
	src/libregex/parse.rs
	src/librustc/middle/cfg/construct.rs
	src/librustc/middle/dataflow.rs
	src/librustc/middle/infer/higher_ranked/mod.rs
	src/librustc/middle/ty.rs
	src/librustc_back/archive.rs
	src/librustc_borrowck/borrowck/fragments.rs
	src/librustc_borrowck/borrowck/gather_loans/mod.rs
	src/librustc_resolve/lib.rs
	src/librustc_trans/back/link.rs
	src/librustc_trans/save/mod.rs
	src/librustc_trans/trans/base.rs
	src/librustc_trans/trans/callee.rs
	src/librustc_trans/trans/common.rs
	src/librustc_trans/trans/consts.rs
	src/librustc_trans/trans/controlflow.rs
	src/librustc_trans/trans/debuginfo.rs
	src/librustc_trans/trans/expr.rs
	src/librustc_trans/trans/monomorphize.rs
	src/librustc_typeck/astconv.rs
	src/librustc_typeck/check/method/mod.rs
	src/librustc_typeck/check/mod.rs
	src/librustc_typeck/check/regionck.rs
	src/librustc_typeck/collect.rs
	src/libsyntax/ext/format.rs
	src/libsyntax/ext/source_util.rs
	src/libsyntax/ext/tt/transcribe.rs
	src/libsyntax/parse/mod.rs
	src/libsyntax/parse/token.rs
	src/test/run-pass/issue-8898.rs
2015-01-06 15:22:24 -08:00
Sean McArthur 44440e5c18 core: split into fmt::Show and fmt::String
fmt::Show is for debugging, and can and should be implemented for
all public types. This trait is used with `{:?}` syntax. There still
exists #[derive(Show)].

fmt::String is for types that faithfully be represented as a String.
Because of this, there is no way to derive fmt::String, all
implementations must be purposeful. It is used by the default format
syntax, `{}`.

This will break most instances of `{}`, since that now requires the type
to impl fmt::String. In most cases, replacing `{}` with `{:?}` is the
correct fix. Types that were being printed specifically for users should
receive a fmt::String implementation to fix this.

Part of #20013

[breaking-change]
2015-01-06 14:49:42 -08:00
Nick Cameron f7ff37e4c5 Replace full slice notation with index calls 2015-01-07 10:46:33 +13:00
Alex Crichton 082bfde412 Fallout of std::str stabilization 2014-12-21 23:31:42 -08:00
Corey Richardson 26f2867c2e rollup merge of #19413: P1start/more-trailing-commas
The only other place I know of that doesn’t allow trailing commas is closure types (#19414), and those are a bit tricky to fix (I suspect it might be impossible without infinite lookahead) so I didn’t implement that in this patch. There are other issues surrounding closure type parsing anyway, in particular #19410.
2014-12-05 10:06:50 -08:00
P1start f5715f7867 Allow trailing commas in array patterns and attributes 2014-11-30 22:28:54 +13:00
P1start 432adc675e Adjust some error messages to start with a lowercase letter and not finish with a full stop 2014-11-30 20:26:53 +13:00
Liigo Zhuang 0a52cc3534 syntax: improve message for misused inner attributes 2014-11-11 08:53:26 +08:00
Brendan Zabarauskas 936d999b52 Use common variants for open and close delimiters
This common representation for delimeters should make pattern matching easier. Having a separate `token::DelimToken` enum also allows us to enforce the invariant that the opening and closing delimiters must be the same in `ast::TtDelimited`, removing the need to ensure matched delimiters when working with token trees.
2014-10-30 09:35:52 +11:00
Brendan Zabarauskas d8b1fa0ae0 Use PascalCase for token variants 2014-10-28 15:55:37 +11:00
Luqman Aden 26e547af5d libsyntax: Remove all uses of {:?}. 2014-10-16 11:15:34 -04:00
Eduard Burtescu ccd8498afb syntax: fix fallout from using ptr::P. 2014-09-14 03:39:36 +03:00
Jonas Hietala 9968ae2554 Adjust the error messages to match the pattern "expected foo, found bar"
Closes #8492
2014-08-24 09:53:01 +02:00
Steven Fackler 52ccab1405 Fix spans for attributes
They used to be one token too long, so you'd see things like
```
rust/rust/test.rs:1:1: 2:2 warning: unused attribute,
rust/rust/test.rs:1 #![foo]
rust/rust/test.rs:2 #![bar]
```
instead of
```
test.rs:1:1: 1:8 warning: unused attribute, #[warn(unused_attribute)] on
by default
test.rs:1 #![foo]
          ^~~~~~~
```
2014-07-11 15:26:26 -07:00
Corey Richardson 092c5078be ast: make Name its own type 2014-07-09 00:49:54 -07:00
Corey Richardson f512779554 lexer: lex WS/COMMENT/SHEBANG rather than skipping
Now, the lexer will categorize every byte in its input according to the
grammar. The parser skips over these while parsing, thus avoiding their
presence in the input to syntax extensions.
2014-07-09 00:06:29 -07:00
Corey Richardson 4989a56448 syntax: doc comments all the things 2014-07-09 00:06:27 -07:00
Richo Healey 12c334a77b std: Rename the ToStr trait to ToString, and to_str to to_string.
[breaking-change]
2014-07-08 13:01:43 -07:00
Alex Crichton 89b0e6e12b Register new snapshots 2014-06-15 23:30:24 -07:00
Alex Crichton ade807c6dc rustc: Obsolete the @ syntax entirely
This removes all remnants of `@` pointers from rustc. Additionally, this removes
the `GC` structure from the prelude as it seems odd exporting an experimental
type in the prelude by default.

Closes #14193
[breaking-change]
2014-06-14 10:45:37 -07:00
Cameron Zwarich 159e27aebb Fix all violations of stronger guarantees for mutable borrows
Fix all violations in the Rust source tree of the stronger guarantee
of a unique access path for mutable borrows as described in #12624.
2014-06-13 20:48:09 -07:00
Alex Crichton cac7a2053a std: Remove i18n/l10n from format!
* The select/plural methods from format strings are removed
* The # character no longer needs to be escaped
* The \-based escapes have been removed
* '{{' is now an escape for '{'
* '}}' is now an escape for '}'

Closes #14810
[breaking-change]
2014-06-11 16:04:24 -07:00
Alex Crichton 53ad426e92 syntax: Move the AST from @T to Gc<T> 2014-06-11 09:11:40 -07:00