about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2016-08-28Rollup merge of #35480 - KiChjang:e0379-bonus, r=nikomatsakisJeffrey Seyfried-23/+41
Move E0379 check from typeck to ast validation Part of #35233. Extension of #35338, #35364. Fixes #35404.
2016-08-28Rollup merge of #35618 - jseyfried:ast_view_path_refactor, r=eddybJeffrey Seyfried-74/+28
Refactor `PathListItem`s This refactors away variant `Mod` of `ast::PathListItemKind` and refactors the remaining variant `Ident` to a struct `ast::PathListItem_`.
2016-08-28Rollup merge of #35591 - GuillaumeGomez:generics_span, r=jntrmrJeffrey Seyfried-8/+16
Add Span field for Generics structs
2016-08-27Change Constness to Spanned<Constness>Keith Yeung-23/+41
2016-08-27Rollup merge of #36014 - slash3g:stabilize-type-macros, r=nikomatsakisManish Goregaokar-15/+3
Stabilize type-macros Closes #27245 r? @nikomatsakis
2016-08-27Rollup merge of #35953 - Aatch:better-missing-block-error, r=nrcManish Goregaokar-3/+24
Improve error message when failing to parse a block We want to catch this error: ``` if (foo) bar; ``` as it's valid syntax in other languages, and say how to fix it. Unfortunately it didn't care if the suggestion made sense and just highlighted the unexpected token. Now it attempts to parse a statement, and if it succeeds, it shows the help message. Fixes #35907
2016-08-26Stabilize type-macrosDaniele Baracchi-15/+3
Closes #27245
2016-08-25Refactor away `AttrMetaMethods`.Jeffrey Seyfried-64/+38
2016-08-25Refactor away `AttributeMethods`.Jeffrey Seyfried-11/+4
2016-08-25Refactor away `AttrNestedMetaItemMethods`.Jeffrey Seyfried-44/+36
2016-08-25Implement RFC#1559: allow all literals in attributes.Sergio Benitez-159/+459
2016-08-24Remove drop flags from structs and enums implementing Drop.Eduard Burtescu-15/+17
2016-08-24Disable old trans access via -Z orbit, #[rustc_no_mir] or --disable-orbit.Eduard Burtescu-5/+0
2016-08-23Improve error message when failing to parse a blockJames Miller-3/+24
We want to catch this error: ``` if (foo) bar; ``` as it's valid syntax in other languages, and say how to fix it. Unfortunately it didn't care if the suggestion made sense and just highlighted the unexpected token. Now it attempts to parse a statement, and if it succeeds, it shows the help message. Fixes #35907
2016-08-21Refactor away variant `ast::PathListItemKind::Mod`Jeffrey Seyfried-74/+28
and refactor `ast::PathListItemKind::Ident` -> `ast::PathListItem_`.
2016-08-19Auto merge of #33922 - estebank:doc-comment, r=alexcrichtonbors-17/+45
Specific error message for missplaced doc comments Identify when documetation comments have been missplaced in the following places: * After a struct element: ```rust // file.rs: struct X { a: u8 /** document a */, } ``` ```bash $ rustc file.rs file.rs:2:11: 2:28 error: found documentation comment that doesn't document anything file.rs:2 a: u8 /** document a */, ^~~~~~~~~~~~~~~~~ file.rs:2:11: 2:28 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a struct: ```rust // file.rs: struct X { a: u8, /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a `fn`: ```rust // file.rs: fn main() { let x = 1; /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` Fix #27429, #30322
2016-08-18Add Span field for Generics structsGuillaume Gomez-8/+16
2016-08-18Split `AstBuilder::pat_enum` into `pat_tuple_struct` and `pat_path`Vadim Petrochenkov-20/+20
2016-08-18Fix #[derive] for empty tuple structs/variantsVadim Petrochenkov-1/+1
2016-08-16Auto merge of #35538 - cgswords:libproc_macro, r=nrcbors-0/+76
Kicking off libproc_macro This PR introduces `libproc_macro`, which is currently quite bare-bones (just a few macro construction tools and an initial `quote!` macro). This PR also introduces a few test cases for it, and an additional `shim` file (at `src/libsyntax/ext/proc_macro_shim.rs` to allow a facsimile usage of Macros 2.0 *today*!
2016-08-16Proc_macro is alivecgswords-0/+76
2016-08-16Auto merge of #35162 - canndrew:bang_type_coerced, r=nikomatsakisbors-18/+33
Implement the `!` type This implements the never type (`!`) and hides it behind the feature gate `#[feature(never_type)]`. With the feature gate off, things should build as normal (although some error messages may be different). With the gate on, `!` is usable as a type and diverging type variables (ie. types that are unconstrained by anything in the code) will default to `!` instead of `()`.
2016-08-15Auto merge of #35340 - michaelwoerister:incr-comp-cli-args, r=nikomatsakisbors-1/+1
Take commandline arguments into account for incr. comp. Implements the conservative strategy described in https://github.com/rust-lang/rust/issues/33727. From now one, every time a new commandline option is added, one has to specify if it influences the incremental compilation cache. I've tried to implement this as automatic as possible: One just has to added either the `[TRACKED]` or the `[UNTRACKED]` marker next to the field. The `Options`, `CodegenOptions`, and `DebuggingOptions` definitions in `session::config` show plenty of examples. The PR removes some cruft from `session::config::Options`, mostly unnecessary copies of flags also present in `DebuggingOptions` or `CodeGenOptions` in the same struct. One notable removal is the `cfg` field that contained the values passed via `--cfg` commandline arguments. I chose to remove it because (1) its content is only a subset of what later is stored in `hir::Crate::config` and it's pretty likely that reading the cfgs from `Options` would not be what you wanted, and (2) we could not incorporate it into the dep-tracking hash of the `Options` struct because of how the test framework works, leaving us with a piece of untracked but vital data. It is now recommended (just as before) to access the crate config via the `krate()` method in the HIR map. Because the `cfg` field is not present in the `Options` struct any more, some methods in the `CompilerCalls` trait now take the crate config as an explicit parameter -- which might constitute a breaking change for plugin authors.
2016-08-14Rollup merge of #35606 - Mark-Simulacrum:no-std-fix, r=brsonEduard-Mihai Burtescu-1/+1
Change stabilization version of no_std from 1.0 to 1.6. I don't know if more than this is needed. Fixes #35579.
2016-08-14Rollup merge of #35539 - cgswords:ts_concat, r=nrcEduard-Mihai Burtescu-20/+92
Implemented a smarter TokenStream concatenation system The new algorithm performs 'aggressive compacting' during concatenation as follows: - If the nodes' combined total total length is less than 32, we copy both of them into a new vector and build a new leaf node. - If one node is an internal node and the other is a 'small' leaf (length<32), we recur down the internal node on the appropriate side. - Otherwise, we construct a new internal node that points to them as left and right. This should produce notably better behavior than the current concatenation implementation.
2016-08-14Rollup merge of #35491 - sanxiyn:pub-restricted-span, r=nikomatsakisEduard-Mihai Burtescu-9/+10
Correct span for pub_restricted field Fix #35435.
2016-08-13Auto merge of #35453 - jseyfried:hygienize_metavariables, r=nrcbors-12/+12
macros: Make metavariables hygienic This PR makes metavariables hygienic. For example, consider: ```rust macro_rules! foo { ($x:tt) => { // Suppose that this token tree argument is always a metavariable. macro_rules! bar { ($x:expr, $y:expr) => { ($x, $y) } } } } fn main() { foo!($z); // This currently compiles. foo!($y); // This is an error today but compiles after this PR. } ``` Today, the `macro_rules! bar { ... }` definition is only valid when the metavariable passed to `foo` is not `$y` (since it unhygienically conflicts with the `$y` in the definition of `bar`) or `$x` (c.f. #35450). After this PR, the definition of `bar` is always valid (and `bar!(a, b)` always expands to `(a, b)` as expected). This can break code that was allowed in #34925 (landed two weeks ago). For example, ```rust macro_rules! outer { ($t:tt) => { macro_rules! inner { ($i:item) => { $t } } } } outer!($i); // This `$i` should not interact with the `$i` in the definition of `inner!`. inner!(fn main() {}); // After this PR, this is an error ("unknown macro variable `i`"). ``` Due to the severe limitations on nested `macro_rules!` before #34925, this is not a breaking change for stable/beta. Fixes #35450. r? @nrc
2016-08-13Fix bug in PostExpansionVisitorAndrew Cann-1/+1
2016-08-13Minor fixups based on feedbackAndrew Cann-1/+1
2016-08-13Minor fixup.Andrew Cann-2/+1
2016-08-13Rename empty/bang to neverAndrew Cann-10/+10
Split Ty::is_empty method into is_never and is_uninhabited
2016-08-13Control usage of `!` through a feature gate.Andrew Cann-3/+24
Adds the `bang_type` feature gate. `!` in a non-return-type position now relies on that feature.
2016-08-13Remove obsolete divergence related stuffAndrew Cann-11/+0
Replace FnOutput with Ty Replace FnConverging(ty) with ty Purge FnDiverging, FunctionRetTy::NoReturn and FunctionRetTy::None
2016-08-13Switch on TyEmptyAndrew Cann-5/+1
Parse -> ! as FnConverging(!) Add AdjustEmptyToAny coercion to all ! expressions Some fixes
2016-08-13Parse `!` as TyEmpty (except in fn return type)Andrew Cann-0/+2
2016-08-13Start implementation of RFC 1216 (make ! a type)Andrew Cann-0/+8
Add `TyKind::Empty` and fix resulting build errors.
2016-08-13Parse numeric fields in struct expressions and patternsVadim Petrochenkov-2/+11
2016-08-13Remove restrictions from tuple structs/variantsVadim Petrochenkov-4/+20
Hard errors are turned into feature gates
2016-08-12Correct span for pub_restricted fieldSeo Sanghyeon-9/+10
2016-08-12Auto merge of #35091 - eddyb:impl-trait, r=nikomatsakisbors-2/+39
Implement `impl Trait` in return type position by anonymization. This is the first step towards implementing `impl Trait` (cc #34511). `impl Trait` types are only allowed in function and inherent method return types, and capture all named lifetime and type parameters, being invariant over them. No lifetimes that are not explicitly named lifetime parameters are allowed to escape from the function body. The exposed traits are only those listed explicitly, i.e. `Foo` and `Clone` in `impl Foo + Clone`, with the exception of "auto traits" (like `Send` or `Sync`) which "leak" the actual contents. The implementation strategy is anonymization, i.e.: ```rust fn foo<T>(xs: Vec<T>) -> impl Iterator<Item=impl FnOnce() -> T> { xs.into_iter().map(|x| || x) } // is represented as: type A</*invariant over*/ T> where A<T>: Iterator<Item=B<T>>; type B</*invariant over*/ T> where B<T>: FnOnce() -> T; fn foo<T>(xs: Vec<T>) -> A<T> { xs.into_iter().map(|x| || x): $0 where $0: Iterator<Item=$1>, $1: FnOnce() -> T } ``` `$0` and `$1` are resolved (to `iter::Map<vec::Iter<T>, closure>` and the closure, respectively) and assigned to `A` and `B`, after checking the body of `foo`. `A` and `B` are *never* resolved for user-facing type equality (typeck), but always for the low-level representation and specialization (trans). The "auto traits" exception is implemented by collecting bounds like `impl Trait: Send` that have failed for the obscure `impl Trait` type (i.e. `A` or `B` above), pretending they succeeded within the function and trying them again after type-checking the whole crate, by replacing `impl Trait` with the real type. While passing around values which have explicit lifetime parameters (of the function with `-> impl Trait`) in their type *should* work, regionck appears to assign inference variables in *way* too many cases, and never properly resolving them to either explicit lifetime parameters, or `'static`. We might not be able to handle lifetime parameters in `impl Trait` without changes to lifetime inference, but type parameters can have arbitrary lifetimes in them from the caller, so most type-generic usecases (or not generic at all) should not run into this problem. cc @rust-lang/lang
2016-08-11Auto merge of #34811 - DanielJCampbell:Expander, r=jseyfriedbors-42/+80
Extended expand.rs to support alternate expansion behaviours (eg. stepwise expansion) r? nrc
2016-08-12syntax: add anonymized type syntax, i.e. impl TraitA+TraitB.Eduard Burtescu-2/+39
2016-08-11Change stabilization version of no_std from 1.0 to 1.6.Mark-Simulacrum-1/+1
2016-08-11Add the notion of a dependency tracking status to commandline arguments.Michael Woerister-1/+1
Commandline arguments influence whether incremental compilation can use its compilation cache and thus their changes relative to previous compilation sessions need to be taking into account. This commit makes sure that one has to specify for every commandline argument whether it influences incremental compilation or not.
2016-08-10Implemented a smarter concatenation system that will hopefully produce more ↵cgswords-20/+92
efficient tokenstream usages.
2016-08-10Extended expand.rs to support alternate expansion behavioursDaniel Campbell-42/+80
Added single_step & keep_macs flags and functionality to expander
2016-08-07Fix old call in lexer testsJonathan Turner-3/+1
2016-08-07Turn on new errors, json mode. Remove duplicate unicode testJonathan Turner-1/+0
2016-08-07Make metavariables hygienic.Jeffrey Seyfried-12/+12
2016-08-01Auto merge of #35018 - cgswords:rope_tstream, r=nrcbors-610/+374
Reimplement TokenStreams using ropes Title says it all; a reimplementation of TokenStreams as ropes. r? @nrc