summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
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
2016-08-01Reimplemented tokenstreams as ropes and reduced the exposed TokenStream API.cgswords-610/+374
2016-07-30Auto merge of #34904 - petrochenkov:rustcall, r=nikomatsakisbors-32/+41
Properly feature gate all unstable ABIs Fixes https://github.com/rust-lang/rust/issues/34900 [breaking-change] r? @pnkfelix --- Function-visiting machinery for AST/HIR is surprisingly error-prone, it's *very* easy to miss some cases or visit something twice while writing a visitor. This is the true problem behind https://github.com/rust-lang/rust/issues/34900. I'll try to restructure these visitors a bit and send one more PR later.
2016-07-29Auto merge of #34842 - cgswords:attr_enc, r=nrcbors-42/+94
Better attribute and metaitem encapsulation throughout the compiler This PR refactors most (hopefully all?) of the `MetaItem` interactions outside of `libsyntax` (and a few inside) to interact with MetaItems through the provided traits instead of directly creating / destruct / matching against them. This is a necessary first step to eventually converting `MetaItem`s to internally use `TokenStream` representations (which will make `MetaItem` interactions much nicer for macro writers once the new macro system is in place). r? @nrc
2016-07-28Auto merge of #34956 - nikomatsakis:incr-comp-o-files, r=mwbors-0/+10
Enable reuse of `.o` files if nothing has changed This PR completes a first "spike" for incremental compilation by enabling us to reuse `.o` files when nothing has changed. When in incr. mode, we will save `.o` files into the temporary directory, then copy them back out again if they are still valid. The code is still a bit rough but it does seem to work. =) r? @michaelwoerister Fixes #34036 Fixes #34037 Fixes #34038
2016-07-28Add a testing mechanism and a simple spike testNiko Matsakis-0/+10
2016-07-28Rollup merge of #34969 - jseyfried:fix_cfg_feature, r=nrcManish Goregaokar-1/+1
Avoid processing `feature`s on unconfigured crates Fixes #34932, a regression caused by #34272. r? @nrc
2016-07-25Adressed PR comments.cgswords-11/+10
2016-07-25General MetaItem encapsulation rewrites.cgswords-42/+95
2016-07-23macros: Improve `tt` fragmentsJeffrey Seyfried-3/+17
2016-07-23Auto merge of #34925 - jseyfried:nested_macros, r=eddybbors-1/+5
Support nested `macro_rules!` Fixes #6994. r? @eddyb
2016-07-21Avoid processing `feature`s on unconfigured crates.Jeffrey Seyfried-1/+1
2016-07-19Introduced `NoDelim` and modified the compiler to support it.cgswords-3/+10
2016-07-19Support nested `macro_rules!`.Jeffrey Seyfried-1/+5
2016-07-18Properly feature gate all unstable ABIsVadim Petrochenkov-32/+41
2016-07-18Auto merge of #34886 - jseyfried:improve_stmt_matchers, r=eddybbors-49/+31
macros: fix bug in `stmt` matchers Today, `stmt` matchers stop too early when parsing expression statements that begin with non-braced macro invocations. For example, ```rust fn main() { macro_rules! m { ($s:stmt;) => { $s } } id!(vec![].push(0);); //^ Before this PR, the `stmt` matcher only consumes "vec![]", so this is an error. //| After this PR, the `stmt` matcher consumes "vec![].push(0)", so this compiles. } ``` This change is backwards compatible due to the follow set for `stmt`. r? @eddyb
2016-07-17Auto merge of #34860 - jseyfried:encapsulate_hygiene, r=nrcbors-208/+135
Clean up and encapsulate `syntax::ext::mtwt`, rename `mtwt` to `hygiene` r? @nrc
2016-07-17Remove some unit tests and that are redundant with `run-pass/hygiene.rs`Jeffrey Seyfried-35/+0
and that would be painful to rewrite.
2016-07-17Rename `mtwt` to `hygiene`Jeffrey Seyfried-4/+4
2016-07-17Clean up and encapsulate `syntax::ext::mtwt`Jeffrey Seyfried-132/+94
2016-07-17macros: Fix bug in statement matchersJeffrey Seyfried-49/+31
2016-07-17Auto merge of #34829 - cgswords:tstream, r=nrcbors-1/+9
Added tokenstream parser procedure A tiny PR that simply adds a procedure for parsing `TokenStream`s to the parser in `src/libsyntax`. This is to ease using `TokenStream`s with the current (old) procedural macro system.