Commit Graph

1676 Commits

Author SHA1 Message Date
Huon Wilson 661598cef0 Use the correct span for out-of-range int literals.
This corrects the error message to point at the literal, not the next
token.

Closes #17123.
2014-11-13 13:43:01 +11:00
Huon Wilson 26282ac337 Add more "help: ..."'s to the parser.
Adds a method for printing a fatal error and also a help message to the
parser and uses this in a variety of places to improve error messages.

Closes #12213.
2014-11-13 13:43:00 +11:00
Huon Wilson e621e3216b Add error message specific to \<carriage return>.
This can crop-up with a misconfigured editor or an unexpected
interaction between version control and certain operating systems.

Closes #11669.
2014-11-13 13:43:00 +11:00
Niko Matsakis 091dc6e98a Purge the old once_fns, which are not coming back 2014-11-07 15:51:30 -05:00
Niko Matsakis 244231720d Update parser with for syntax 2014-11-07 15:51:30 -05:00
bors 0b48001c28 auto merge of #17830 : pczarn/rust/interp_tt, r=pnkfelix
Closes #14197

Removes the `matchers` nonterminal.

If you're using `$foo:matchers` in a macro, write `$foo:tt` instead.

[breaking-change]
2014-11-07 15:26:26 +00:00
Piotr Czarnecki 00676c8ea2 Add ast::SequenceRepetition 2014-11-07 10:21:57 +01:00
Niko Matsakis d0fa4c6239 Remove the unboxed closure |:| notation from types and trait references completely. 2014-11-06 06:48:24 -05:00
Niko Matsakis 221edbae38 Support parenthesized paths Foo(A,B) -> C that expand to Foo<(A,B),C>. These paths also bind anonymous regions (or will, once HRTB is fully working).
Fixes #18423.
2014-11-06 06:48:23 -05:00
Niko Matsakis 4e352892c8 Restructure parsing of paths, which is quite tortured 2014-11-06 06:48:23 -05:00
Piotr Czarnecki 6f30a4ee6c Remove Matchers 2014-11-05 23:06:01 +01:00
Piotr Czarnecki 38ce6d9eac Use TokenTrees in lhs of macros 2014-11-05 23:06:01 +01:00
Eduard Burtescu 56dbf3d122 Register snapshots. 2014-11-05 12:55:58 +02:00
Patrick Walton e8d6031c71 libsyntax: Forbid escapes in the inclusive range \x80-\xff in
Unicode characters and strings.

Use `\u0080`-`\u00ff` instead. ASCII/byte literals are unaffected.

This PR introduces a new function, `escape_default`, into the ASCII
module. This was necessary for the pretty printer to continue to
function.

RFC #326.

Closes #18062.

[breaking-change]
2014-11-04 14:58:11 -08:00
Alex Crichton 2659b2e885 rollup merge of #18562 : nick29581/dxr-1 2014-11-03 15:55:59 -08:00
Alex Crichton eb793616dc rollup merge of #18506 : nikomatsakis/assoc-type-bounds 2014-11-03 15:55:58 -08:00
Alex Crichton 3aaee490d3 rollup merge of #18318 : arielb1/transmute-cleanup 2014-11-03 15:29:08 -08:00
Niko Matsakis 319d778ed3 Restructure AST so that the associated type definition carries
bounds like any other "type parameter".
2014-11-03 17:41:00 -05:00
Ariel Ben-Yehuda fbb90c3458 Clean-up transmutes in libsyntax 2014-11-03 22:07:43 +02:00
Nick Cameron 3ceb0112ef Ignore whitespace tokens when re-computing spans in save_analysis 2014-11-03 17:52:00 +13:00
P1start 5bf9ef2122 Convert some notes to help messages
Closes #18126.
2014-11-02 16:12:23 +13:00
Alex Crichton 6fcba8826f Test fixes and rebase conflicts 2014-10-30 17:37:56 -07:00
Alex Crichton 5d6241ddaf rollup merge of #18430 : bjz/token
Conflicts:
	src/libsyntax/parse/parser.rs
2014-10-30 17:37:41 -07:00
Alex Crichton 00975e041d rollup merge of #18398 : aturon/lint-conventions-2
Conflicts:
	src/libcollections/slice.rs
	src/libcore/failure.rs
	src/libsyntax/parse/token.rs
	src/test/debuginfo/basic-types-mut-globals.rs
	src/test/debuginfo/simple-struct.rs
	src/test/debuginfo/trait-pointers.rs
2014-10-30 17:37:22 -07:00
P1start 14398f2929 Add a message for when a . follows a macro invocation 2014-10-30 19:51:16 +13:00
P1start fb00015246 Improve the error message for parenthesised box expressions
Closes #15386.
2014-10-30 17:12:22 +13:00
Brendan Zabarauskas 98a4770a98 Formatting fixes 2014-10-30 09:35:53 +11:00
Brendan Zabarauskas 1ab50f3600 Remove Token::get_close_delimiter
We can simplify these usages due to the new delimiter representation. `Parser::expect_open_delim` has been added for convenience.
2014-10-30 09:35:53 +11: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
Steve Klabnik 7828c3dd28 Rename fail! to panic!
https://github.com/rust-lang/rfcs/pull/221

The current terminology of "task failure" often causes problems when
writing or speaking about code. You often want to talk about the
possibility of an operation that returns a Result "failing", but cannot
because of the ambiguity with task failure. Instead, you have to speak
of "the failing case" or "when the operation does not succeed" or other
circumlocutions.

Likewise, we use a "Failure" header in rustdoc to describe when
operations may fail the task, but it would often be helpful to separate
out a section describing the "Err-producing" case.

We have been steadily moving away from task failure and toward Result as
an error-handling mechanism, so we should optimize our terminology
accordingly: Result-producing functions should be easy to describe.

To update your code, rename any call to `fail!` to `panic!` instead.
Assuming you have not created your own macro named `panic!`, this
will work on UNIX based systems:

    grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g'

You can of course also do this by hand.

[breaking-change]
2014-10-29 11:43:07 -04:00
Aaron Turon e0ad0fcb95 Update code with new lint names 2014-10-28 08:54:21 -07:00
Brendan Zabarauskas 665ad9c175 Move token-to-string functions into print::pprust 2014-10-28 15:55:38 +11:00
Brendan Zabarauskas cd049591a2 Use an enum rather than a bool in token::Ident 2014-10-28 15:55:37 +11:00
Brendan Zabarauskas fcb78d65f2 Convert some token functions into methods 2014-10-28 15:55:37 +11:00
Brendan Zabarauskas d8b1fa0ae0 Use PascalCase for token variants 2014-10-28 15:55:37 +11:00
Brendan Zabarauskas 6598d33bd0 Update parse::test::string_to_tts_1 test 2014-10-26 11:20:32 +11:00
Brendan Zabarauskas 94d6eee335 Add a KleeneOp enum for clarity 2014-10-26 09:53:30 +11:00
Brendan Zabarauskas 34dacb80ce Reduce the size of the TokenTree 2014-10-26 09:53:30 +11:00
Brendan Zabarauskas dfb4163f83 Use standard capitalisation for TokenTree variants 2014-10-26 09:53:30 +11:00
Brendan Zabarauskas ec3f0201e7 Rename TokenTree variants for clarity
This should be clearer, and fits in better with the `TTNonterminal` variant.

Renames:

- `TTTok` -> `TTToken`
- `TTDelim` -> `TTDelimited`
- `TTSeq` -> `TTSequence`
2014-10-26 09:53:29 +11:00
Brendan Zabarauskas 971d776aa5 Add Span and separate open/close delims to TTDelim
This came up when working [on the gl-rs generator extension](https://github.com/bjz/gl-rs/blob/990383de801bd2e233159d5be07c9b5622827620/src/gl_generator/lib.rs#L135-L146).

The new definition of  `TTDelim` adds an associated `Span` that covers the whole token tree and enforces the invariant that a delimited sequence of token trees must have an opening and closing delimiter.

A `get_span` method has also been added to `TokenTree` type to make it easier to implement better error messages for syntax extensions.
2014-10-26 09:53:29 +11:00
P1start ead6c4b9d4 Add a lint for not using field pattern shorthands
Closes #17792.
2014-10-24 15:44:18 +13:00
bors 7088c45ef4 auto merge of #18141 : phildawes/rust/master, r=brson
Hello! I noticed spans are wrong for the PatIdents of self args. (I use spans a lot in racer)
2014-10-22 07:07:09 +00:00
Alex Crichton 9d5d97b55d Remove a large amount of deprecated functionality
Spring cleaning is here! In the Fall! This commit removes quite a large amount
of deprecated functionality from the standard libraries. I tried to ensure that
only old deprecated functionality was removed.

This is removing lots and lots of deprecated features, so this is a breaking
change. Please consult the deprecation messages of the deleted code to see how
to migrate code forward if it still needs migration.

[breaking-change]
2014-10-19 12:59:40 -07:00
Phil Dawes 9c7865fa6f Parser: Fix spans of explicit self arg idents 2014-10-18 16:05:26 +01:00
bors 4694b99102 auto merge of #16855 : P1start/rust/help-messages, r=brson
This adds ‘help’ diagnostic messages to rustc. This is used for anything that provides help to the user, particularly the `--explain` messages that were previously integrated into the relevant error message.

They look like this:

```
match.rs:10:13: 10:14 error: unreachable pattern [E0001]
match.rs:10             1 => {},
                        ^
match.rs:3:1: 3:38 note: in expansion of foo!
match.rs:7:5: 20:2 note: expansion site
match.rs:10:13: 10:14 help: pass `--explain E0001` to see a detailed explanation
```

(`help` is coloured cyan.) Adding these errors on a separate line stops the lines from being too long, as discussed in #16619.
2014-10-17 20:32:22 +00:00
Luqman Aden 26e547af5d libsyntax: Remove all uses of {:?}. 2014-10-16 11:15:34 -04:00
bors c7e0724274 auto merge of #17733 : jgallagher/rust/while-let, r=alexcrichton
This is *heavily* based on `if let` (#17634) by @jakub- and @kballard

This should close #17687
2014-10-13 19:37:40 +00:00
bors a6e0c76ef4 auto merge of #17757 : gamazeps/rust/issue17709, r=alexcrichton
I did not put the crate name in the error note, if that's necessary I'll look into it.

Closes #17709
2014-10-13 02:47:37 +00:00
Jakub Wieczorek 403cd40e6a Remove virtual structs from the language 2014-10-11 19:42:26 +02:00