about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2017-11-03Detect `=` -> `:` typo in let bindingsEsteban Küber-44/+88
When encountering a let binding type error, attempt to parse as initializer instead. If successful, it is likely just a typo: ```rust fn main() { let x: Vec::with_capacity(10); } ``` ``` error: expected type, found `10` --> file.rs:3:31 | 3 | let x: Vec::with_capacity(10, 20); | -- ^^ | || | |help: did you mean assign here?: `=` | while parsing the type for `x` ```
2017-11-03Copy `AsciiExt` methods to `str` directlyLukas Kalbertodt-1/+0
This is done in order to deprecate AsciiExt eventually. Note that this commit contains a bunch of `cfg(stage0)` statements. This is due to a new compiler feature this commit depends on: the `slice_u8` lang item. Once this lang item is available in the stage0 compiler, all those cfg flags (and more) can be removed.
2017-11-03Added feature gate for RFC 2008.David Wood-0/+9
2017-11-03Auto merge of #45247 - leodasvacas:implement-auto-trait-syntax, r=nikomatsakisbors-24/+71
[Syntax] Implement auto trait syntax Implements `auto trait Send {}` as a substitute for `trait Send {} impl Send for .. {}`. See the [internals thread](https://internals.rust-lang.org/t/pre-rfc-renaming-oibits-and-changing-their-declaration-syntax/3086) for motivation. Part of #13231. The first commit is just a rename moving from "default trait" to "auto trait". The rest is parser->AST->HIR work and making it the same as the current syntax for everything below HIR. It's under the `optin_builtin_traits` feature gate. When can we remove the old syntax? Do we need to wait for a new `stage0`? We also need to formally decide for the new form (even if the keyword is not settled yet). Observations: - If you `auto trait Auto {}` and then `impl Auto for .. {}` that's accepted even if it's redundant. - The new syntax is simpler internally which will allow for a net removal of code, for example well-formedness checks are effectively moved to the parser. - Rustfmt and clippy are broken, need to fix those. - Rustdoc just ignores it for now. ping @petrochenkov @nikomatsakis
2017-11-03Fix unsafe auto trait pretty print.leonardo.yvens-1/+1
It was being printed wrong as auto unsafe trait
2017-11-03Parse auto traits the same as traits.leonardo.yvens-49/+32
This moves the well formedness checks to the AST validation pass. Tests were adjusted. The auto keyword should be back-compat now.
2017-11-03Add tests for `auto trait`, fix parsing bugleonardo.yvens-32/+32
Now we can do the well formedness checks in the parser, yay!
2017-11-03Feature gate `auto trait` and ignore it in rustdocleonardo.yvens-0/+6
2017-11-03add `auto` keyword, parse `auto trait`, lower to HIRleonardo.yvens-7/+65
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[Syntax Breaking] Rename DefaultImpl to AutoImplleonardo.yvens-11/+11
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-03Refactor internal suggestion APIOliver Schneider-4/+4
2017-11-03Pretty print json in ui testsOliver Schneider-6/+16
2017-11-03Remove outdated documentationOliver Schneider-6/+2
2017-11-03Display spans correctly when there are non-half-width charactersWonwoo Choi-2/+41
2017-11-02Make the difference between lint codes and error codes explicitOliver Schneider-13/+60
2017-11-01Remove the redundant span_label.laurent-1/+0
2017-11-01Auto merge of #45472 - michaelwoerister:incr-comp-caching-base, r=nikomatsakisbors-0/+37
incr.comp.: Implement compiler diagnostic persistence. This PR implements storing and loading diagnostics that the compiler generates and thus allows for emitting warnings during incremental compilation without actually re-evaluating the thing the warning originally came from. It also lays some groundwork for storing and loading type information and MIR in the incr. comp. cache. ~~It is still work in progress:~~ - ~~There's still some documentation to be added.~~ - ~~The way anonymous queries are handled might lead to duplicated emissions of warnings. Not sure if there is a better way or how frequent such duplication would be in practice.~~ Diagnostic message duplication is addressed separately in #45519. r? @nikomatsakis
2017-11-01Preserve original formatting.laurent-4/+1
2017-11-01Remove the parser snapshot hack.laurent-40/+16
2017-11-01Rollup merge of #45644 - zackmdavis:edit_disallowed_inner_attr_note, r=estebankkennytm-5/+4
edit and fix bad spacing of inner-attribute-not-allowed note This multiline string literal was missing a backslash, leaving an awkward newline and 35 spaces in the middle of the message. But while we're here, the existing message seems kind of long in comparison to similar notes: to cut it down, we excise the mentions of doc comments, which seems sensible because we know that this erroneous attribute is not a doc comment (notice the `is_sugared_doc: false` at the end of the function; if it had been a doc comment, that error would get set in the `token::DocComment` match branch of `parse_outer_attributes`).
2017-11-01Rollup merge of #45579 - ↵kennytm-1/+3
leodasvacas:document-that-call-can-be-adt-constructor, r=estebank Document that call expressions also represent ADT constructors. This is a rather obscure part of the language.
2017-10-31Formatting tweak.laurent-2/+1
2017-10-31Add some missing spaces.laurent-1/+1
2017-10-31Fix spans and error messages.laurent-13/+6
2017-10-30edit and fix bad spacing of inner-attribute-not-allowed noteZack M. Davis-5/+4
This multiline string literal was missing a backslash, leaving an awkward newline and 35 spaces in the middle of the message. But while we're here, the existing message seems kind of long in comparison to similar notes: to cut it down, we excise the mentions of doc comments, which seems sensible because we know that this erroneous attribute is not a doc comment (notice the `is_sugared_doc: false` at the end of the function; if it had been a doc comment, that error would get set in the `token::DocComment` match branch of `parse_outer_attributes`).
2017-10-30Add a nicer error message for missing in for loop, fixes #40782.laurent-6/+48
2017-10-28Auto merge of #45489 - oli-obk:json_diagnostics, r=petrochenkovbors-17/+9
Fix a quadradic duplication in json for multi-suggestions r? @petrochenkov
2017-10-28Auto merge of #44295 - plietar:extern-types, r=arielb1bors-8/+55
Implement RFC 1861: Extern types A few notes : - Type parameters are not supported. This was an unresolved question from the RFC. It is not clear how useful this feature is, and how variance should be treated. This can be added in a future PR. - `size_of_val` / `align_of_val` can be called with extern types, and respectively return 0 and 1. This differs from the RFC, which specified that they should panic, but after discussion with @eddyb on IRC this seems like a better solution. If/when a `DynSized` trait is added, this will be disallowed statically. - Auto traits are not implemented by default, since the contents of extern types is unknown. This means extern types are `!Sync`, `!Send` and `!Freeze`. This seems like the correct behaviour to me. Manual `unsafe impl Sync for Foo` is still possible. - This PR allows extern type to be used as the tail of a struct, as described by the RFC : ```rust extern { type OpaqueTail; } #[repr(C)] struct FfiStruct { data: u8, more_data: u32, tail: OpaqueTail, } ``` However this is undesirable, as the alignment of `tail` is unknown (the current PR assumes an alignment of 1). Unfortunately we can't prevent it in the general case as the tail could be a type parameter : ```rust #[repr(C)] struct FfiStruct<T: ?Sized> { data: u8, more_data: u32, tail: T, } ``` Adding a `DynSized` trait would solve this as well, by requiring tail fields to be bound by it. - Despite being unsized, pointers to extern types are thin and can be casted from/to integers. However it is not possible to write a `null<T>() -> *const T` function which works with extern types, as I've explained here : https://github.com/rust-lang/rust/issues/43467#issuecomment-321678621 - Trait objects cannot be built from extern types. I intend to support it eventually, although how this interacts with `DynSized`/`size_of_val` is still unclear. - The definition of `c_void` is unmodified
2017-10-28Auto merge of #45503 - thombles:tk/i44339-v5, r=petrochenkovbors-1/+27
Improve diagnostics when list of tokens has incorrect separators Make `parse_seq_to_before_tokens` more resilient to error conditions. Where possible it is better if it can consume up to the final bracket before returning. This change improves the diagnostics in a couple of situations: ``` struct S(pub () ()); // omitted separator use std::{foo. bar}; // used a similar but wrong separator ``` Fixes #44339 r? @petrochenkov
2017-10-27Implement RFC 1861: Extern typesPaul Lietar-8/+55
2017-10-27Document that call expressions also represent ADT constructors.leonardo.yvens-1/+3
This is a rather obscure part of the language.
2017-10-26Auto merge of #45464 - sinkuu:ice_44851, r=jseyfriedbors-1/+30
Visit attribute tokens in `DefCollector` and `BuildReducedGraphVisitor` Fixes #44851.
2017-10-26Add FIXMEsinkuu-0/+1
2017-10-25Auto merge of #44636 - GuillaumeGomez:little-error-msg, r=michaelwoeristerbors-2/+5
Add short error message-format Fixes #42653.
2017-10-25incr.comp.: Implement query diagnostic persistence.Michael Woerister-0/+37
2017-10-24Reduce the repetition in json error outputOliver Schneider-17/+9
2017-10-25Improve recovery after unexpected tokens parsing sequenceThomas Karpiniec-1/+27
2017-10-24Auto merge of #45401 - zackmdavis:crate_shorthand_visibility_modifier, ↵bors-4/+31
r=nikomatsakis `crate` shorthand visibility modifier cc #45388. r? @nikomatsakis
2017-10-24Auto merge of #44766 - sunjay:lift_generics, r=nikomatsakisbors-32/+38
Move Generics from MethodSig to TraitItem and ImplItem As part of `rust-impl-period/WG-compiler-traits`, we want to "lift" `Generics` from `MethodSig` into `TraitItem` and `ImplItem`. This is in preparation for adding associated type generics. (https://github.com/rust-lang/rust/issues/44265#issuecomment-331172238) Currently this change is only made in the AST. In the future, it may also impact the HIR. (Still discussing) To understand this PR, it's probably best to start from the changes to `ast.rs` and then work your way to the other files to understand the far reaching effects of this change. r? @nikomatsakis
2017-10-23Fix #44851 by visiting tokens in `DefCollector` and `BuildReducedGraphVisitor`sinkuu-1/+29
2017-10-22`crate` shorthand visibility modifierZack M. Davis-4/+31
With regrets, this breaks rustfmt and rls. This is in the matter of #45388.
2017-10-20Add short message-formatGuillaume Gomez-2/+5
2017-10-19Auto merge of #45232 - zackmdavis:moar_lint_suggestions, r=estebankbors-0/+11
code suggestions for non-shorthand field pattern, no-mangle lints continuing in the spirit of #44942 ![moar_lint_suggestions](https://user-images.githubusercontent.com/1076988/31485011-3b20cc80-aee7-11e7-993d-81267ab77732.png) r? @estebank
2017-10-17Removed Generics from FnKind::ItemFn in libsyntaxSunjay Varma-6/+6
2017-10-17Fixed tidy errorsSunjay Varma-2/+4
2017-10-17Lifting Generics from MethodSig to TraitItem and ImplItem since we want to ↵Sunjay Varma-26/+30
support generics in each variant of TraitItem and ImplItem
2017-10-16code suggestion for non-shorthand field patterns lintZack M. Davis-0/+11
We also edit the lint description to clarify that this is different from the struct field init shorthand.
2017-10-15don't issue "expected statement after outer attr." after inner attr.Zack M. Davis-2/+2
While an inner attribute here is in fact erroneous, that error ("inner attribute is not permitted in this context") successfully gets set earlier; this further admonition is nonsensical. Resolves #45296.
2017-10-14Implement `dyn Trait` syntaxVadim Petrochenkov-32/+67
2017-10-13Rollup merge of #45178 - Badel2:comma-after-struct, r=petrochenkovkennytm-0/+11
Better error message for comma after base struct #41834 This adds a better error for commas after the base struct: ``` let foo = Foo { one: 111, ..Foo::default(), // This comma is a syntax error }; ``` The current error is a generic `expected one of ...` which isn't beginner-friendly. My error looks like this: ``` error: cannot use a comma after the base struct --> tmp/example.rs:26:9 | 26 | ..Foo::default(), | ^^^^^^^^^^^^^^^^- help: remove this comma | = note: the base struct expansion must always be the last field ``` I even added a note for people who don't know why this isn't allowed.