Commit Graph

2502 Commits

Author SHA1 Message Date
Jeffrey Seyfried
0558df24af Refactor expand_expr 2016-05-27 00:01:04 +00:00
Jeffrey Seyfried
1aa34e0b5f Strip unconfigured items during macro expansion 2016-05-27 00:01:04 +00:00
Jeffrey Seyfried
25c733360b Update spans' expn_id during the marking fold 2016-05-27 00:01:04 +00:00
Leo Testard
864b3c8017 Reject a LHS formed of a single sequence TT during macro_rules! checking.
This was already rejected during expansion. Encountering malformed LHS or RHS during expansion is now considered a bug.
2016-05-26 19:05:44 +02:00
bors
dc91467db0 Auto merge of #33766 - jseyfried:cleanup_expansion, r=nrc
Cleanup macro expansion and improve diagnostics

Cleanup macro expansion and improve diagnostics. Fixes #33709.
r? @nrc
2016-05-26 08:32:21 -07:00
Vadim Petrochenkov
d69aeaf662 Implement .. in tuple (struct) patterns 2016-05-26 11:11:58 +03:00
Vadim Petrochenkov
1a1de5bf89 Add a new AST-only type variant ImplicitSelf 2016-05-25 21:55:04 +03:00
Vadim Petrochenkov
5660a00486 Remove ExplicitSelf from AST 2016-05-25 21:55:04 +03:00
bors
da66f2fd8c Auto merge of #33713 - LeoTestard:macro-rules-invalid-lhs, r=pnkfelix
Make sure that macros that didn't pass LHS checking are not expanded.

This avoid duplicate errors for things like invalid fragment specifiers, or
parsing errors for ambiguous macros.
2016-05-25 09:40:06 -07:00
Georg Brandl
2e812e10f4 syntax/hir: give loop labels a span
This makes the "shadowing labels" warning *not* print the entire loop
as a span, but only the lifetime.

Also makes #31719 go away, but does not fix its root cause (the span
of the expanded loop is still wonky, but not used anymore).
2016-05-24 14:22:14 +02:00
Jeffrey Seyfried
e9c0283369 Add comments and fix a nit 2016-05-24 11:48:00 +00:00
Leo Testard
7d521445fd Avoid iterating two times over the list of LHSes. 2016-05-24 11:21:37 +02:00
Leo Testard
eb364e9c29 Make sure that macros that didn't pass LHS checking are not expanded.
This avoids duplicate errors for things like invalid fragment specifiers, or
parsing errors for ambiguous macros. Fixes #29231.
2016-05-24 11:21:28 +02:00
Jeffrey Seyfried
ba8b9324d6 Move placement_in_syntax gated feature checking from expansion to the post-expansion visitor 2016-05-21 23:02:34 +00:00
Jeffrey Seyfried
82b49cd200 Refactor away check_attributes 2016-05-21 23:01:02 +00:00
Jeffrey Seyfried
a3d705ef30 Refactor away expand_item_mac 2016-05-21 23:01:02 +00:00
Jeffrey Seyfried
3192adbf87 Refactor out mac_result in expand_mac_invoc 2016-05-21 23:01:02 +00:00
Jeffrey Seyfried
215c1460f6 Check attributes in expand_mac_invoc 2016-05-21 23:01:02 +00:00
Jeffrey Seyfried
f4075e9467 Use expand_mac_invoc in expand_pat 2016-05-21 23:01:01 +00:00
Jeffrey Seyfried
8ee93b73d1 Re-fold expanded items in expand_mac_invoc 2016-05-21 23:01:01 +00:00
Jeffrey Seyfried
2e7afd7367 Improve diagnostics 2016-05-21 23:01:01 +00:00
Jeffrey Seyfried
7f30eef2ee Introduce MacroGenerable trait 2016-05-21 23:00:57 +00:00
Jeffrey Seyfried
f630419351 Fix bug in macro expression spans 2016-05-18 11:46:08 +00:00
Alex Crichton
0ec321f7b5 rustc: Implement custom panic runtimes
This commit is an implementation of [RFC 1513] which allows applications to
alter the behavior of panics at compile time. A new compiler flag, `-C panic`,
is added and accepts the values `unwind` or `panic`, with the default being
`unwind`. This model affects how code is generated for the local crate, skipping
generation of landing pads with `-C panic=abort`.

[RFC 1513]: https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md

Panic implementations are then provided by crates tagged with
`#![panic_runtime]` and lazily required by crates with
`#![needs_panic_runtime]`. The panic strategy (`-C panic` value) of the panic
runtime must match the final product, and if the panic strategy is not `abort`
then the entire DAG must have the same panic strategy.

With the `-C panic=abort` strategy, users can expect a stable method to disable
generation of landing pads, improving optimization in niche scenarios,
decreasing compile time, and decreasing output binary size. With the `-C
panic=unwind` strategy users can expect the existing ability to isolate failure
in Rust code from the outside world.

Organizationally, this commit dismantles the `sys_common::unwind` module in
favor of some bits moving part of it to `libpanic_unwind` and the rest into the
`panicking` module in libstd. The custom panic runtime support is pretty similar
to the custom allocator support with the only major difference being how the
panic runtime is injected (takes the `-C panic` flag into account).
2016-05-09 08:22:36 -07: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
Niko Matsakis
1ff1887cc9 thread tighter span for closures around
Track the span corresponding to the `|...|` part of the closure.
2016-05-02 11:47:10 -04:00
bors
b0aefff714 Auto merge of #32846 - jseyfried:allow_unconfigured_gated_expanded_items, r=nrc
Avoid gated feature checking unconfigured expanded items

Avoid gated feature checking unconfigured macro-expanded items (fixes #32840).
Unconfigured items that are not macro-expanded are already not gated feature checked.
r? @nrc
2016-04-30 02:07:33 -07:00
bors
435095f32a Auto merge of #32791 - LeoTestard:feature-gate-clean, r=nikomatsakis
Feature gate clean

This PR does a bit of cleaning in the feature-gate-handling code of libsyntax. It also fixes two bugs (#32782 and #32648). Changes include:

* Change the way the existing features are declared in `feature_gate.rs`. The array of features and the `Features` struct are now defined together by a single macro. `featureck.py` has been updated accordingly. Note: there are now three different arrays for active, removed and accepted features instead of a single one with a `Status` item to tell wether a feature is active, removed, or accepted. This is mainly due to the way I implemented my macro in the first time and I can switch back to a single array if needed. But an advantage of the way it is now is that when an active feature is used, the parser only searches through the list of active features. It goes through the other arrays only if the feature is not found. I like to think that error checking (in this case, checking that an used feature is active) does not slow down compilation of valid code. :) But this is not very important...
* Feature-gate checking pass now use the `Features` structure instead of looking through a string vector. This should speed them up a bit. The construction of the `Features` struct should be faster too since it is build directly when parsing features instead of calling `has_feature` dozens of times.
* The MacroVisitor pass has been removed, it was mostly useless since the `#[cfg]-stripping` phase happens before (fixes #32648). The features that must actually be checked before expansion are now checked at the time they are used. This also allows us to check attributes that are generated by macro expansion and not visible to MacroVisitor, but are also removed by macro expansion and thus not visible to PostExpansionVisitor either. This fixes #32782. Note that in order for `#[derive_*]` to be feature-gated but still accepted when generated by `#[derive(Trait)]`, I had to do a little bit of trickery with spans that I'm not totally confident into. Please review that part carefully. (It's in `libsyntax_ext/deriving/mod.rs`.)::

Note: this is a [breaking change], since programs with feature-gated attributes on macro-generated macro invocations were not rejected before. For example:

```rust
macro_rules! bar (
    () => ()
);

macro_rules! foo (
    () => (
        #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
        bar!();
    );
);
```
foo!();
2016-04-27 18:35:29 -07:00
mitaa
6887202ea3 Make some fatal lexer errors recoverable 2016-04-27 20:48:18 +02:00
Manish Goregaokar
a31658de51
Rollup merge of #33041 - petrochenkov:path, r=nrc,Manishearth
Paths are mostly parsed without taking whitespaces into account, e.g. `std :: vec :: Vec :: new ()` parses successfully, however, there are some special cases involving keywords `super`, `self` and `Self`. For example, `self::` is considered a path start only if there are no spaces between `self` and `::`. These restrictions probably made sense when `self` and friends weren't keywords, but now they are unnecessary.

The first two commits remove this special treatment of whitespaces by removing `token::IdentStyle` entirely and therefore fix https://github.com/rust-lang/rust/issues/14109.
This change also affects naked `self` and `super` (which are not tightly followed by `::`, obviously) they can now be parsed as paths, however they are still not resolved correctly in imports (cc @jseyfried, see `compile-fail/use-keyword.rs`), so https://github.com/rust-lang/rust/issues/29036 is not completely fixed.

The third commit also makes `super`, `self`, `Self` and `static` keywords nominally (before this they acted as keywords for all purposes) and removes most of remaining \"special idents\".

The last commit (before tests) contains some small improvements - some qualified paths with type parameters are parsed correctly, `parse_path` is not used for parsing single identifiers, imports are sanity checked for absence of type parameters - such type parameters can be generated by syntax extensions or by macros when https://github.com/rust-lang/rust/issues/10415 is fixed (~~soon!~~already!).

This patch changes some pretty basic things in `libsyntax`, like `token::Token` and the keyword list, so it's a plugin-[breaking-change].

r? @eddyb
2016-04-25 00:47:44 +05:30
Vadim Petrochenkov
6c44bea644 syntax: Check paths in visibilities for type parameters
syntax: Merge PathParsingMode::NoTypesAllowed and PathParsingMode::ImportPrefix
syntax: Rename PathParsingMode and its variants to better express their purpose
syntax: Remove obsolete error message about 'self lifetime
syntax: Remove ALLOW_MODULE_PATHS workaround
syntax/resolve: Adjust some error messages
resolve: Compare unhygienic (not renamed) names with keywords::Invalid, invalid identifiers may appear to be valid after renaming
2016-04-24 20:59:44 +03:00
Vadim Petrochenkov
b32d7b5923 syntax: Merge keywords and remaining special idents in one list
Simplify the macro used for generation of keywords
Make `Keyword::ident` private
2016-04-24 20:59:44 +03:00
Vadim Petrochenkov
e2c821d35e syntax: Make static/super/self/Self keywords + special ident cleanup 2016-04-24 20:59:44 +03:00
Vadim Petrochenkov
546c052d22 syntax: Get rid of token::IdentStyle 2016-04-24 20:59:44 +03:00
Niko Matsakis
ecd10f04ce thread tighter span for closures around
Track the span corresponding to the `|...|` part of the closure.
2016-04-24 18:10:57 +05:30
Leo Testard
fa23d10863 Remove some useless code. 2016-04-22 01:40:33 +02:00
Leo Testard
03ab057f97 Remove the MacroVisitor pass.
This pass was supposed to check use of gated features before
`#[cfg]`-stripping but this was not the case since it in fact happens
after. Checks that are actually important and must be done before macro
expansion are now made where the features are actually used. Close #32648.
Also ensure that attributes on macro-generated macro invocations are
checked as well. Close #32782 and #32655.
2016-04-22 01:40:33 +02:00
Leo Testard
ef1de519ff Generate the features structure and arrays with new macros.
This is more readable, safer, and allows for a much more efficient parsing.
2016-04-21 14:00:14 +02:00
Manish Goregaokar
90c8d81ee4
Rollup merge of #32945 - durka:rfc1494, r=pnkfelix
implement RFC amendment 1494

Adds `:block` to the follow set for `:ty` and `:path`. See rust-lang/rfcs#1494.
2016-04-16 01:18:07 +05:30
Alex Burka
01aebf01bc implement RFC amendment 1494 2016-04-13 23:25:42 -04:00
Jeffrey Seyfried
5a8bbf1202 Fixes #32922, a macro hygiene bug 2016-04-13 00:24:21 +00:00
Jeffrey Seyfried
86f069d41a Remove redundant call to expand_item_multi_modifier 2016-04-09 05:37:56 +00:00
Vadim Petrochenkov
8fe4290f1c Move span into StructField 2016-04-06 11:19:10 +03:00
Vadim Petrochenkov
7f3744f07f Get rid of ast::StructFieldKind 2016-04-06 10:33:15 +03:00
Niko Matsakis
05baf645e4 do not overwrite spans as eagerly
this was required to preserve the span from
the #[structural_match] attribute -- but honestly
I am not 100% sure if it makes sense.
2016-03-25 06:44:14 -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
Richo Healey
178b28099f syntax: impl ToTokens for P<ast::ImplItem> 2016-03-15 19:50:11 +01:00
Aaron Turon
8fe63e2342 Add default as contextual keyword, and parse it for impl items. 2016-03-14 15:04:33 -07:00
bors
cbbd3d9b92 Auto merge of #31631 - jonas-schievink:agoraphobia, r=nrc
[breaking-batch] Move more uses of `panictry!` out of libsyntax
2016-03-09 05:25:48 -08:00
Jeffrey Seyfried
472fcb5973 Fix the search paths for macro-expanded non-inline modules 2016-03-02 23:50:19 +00:00
Corey Farwell
5850d16d52 Remove unnecessary explicit lifetime bounds.
These explicit lifetimes can be ommitted because of lifetime elision
rules. Instances were found using rust-clippy.
2016-02-18 08:37:10 -05:00
ggomez
eca0ab25d8 Add check on find_best_match_for_name and improve help message for undefined macro 2016-02-16 22:30:08 +01:00
Jonas Schievink
3a872782d3 Move more uses of panictry! out of libsyntax
[breaking-change] for syntax extensions
2016-02-16 13:32:40 +01:00
Vadim Petrochenkov
9f414a44a7 Split ast::PatKind::Enum into tuple struct and path patterns 2016-02-13 15:51:27 +03:00
Vadim Petrochenkov
14adc9bb63 Rename ast::Pat_ and its variants 2016-02-13 13:49:24 +03:00
Jonas Schievink
c877d61b15 Use more autoderef in libsyntax 2016-02-12 19:28:42 +01:00
Vadim Petrochenkov
77cc5764b9 Remove some unnecessary indirection from AST structures 2016-02-11 23:33:09 +03:00
Oliver 'ker' Schneider
2b816b0d6a [breaking-change] don't glob export ast::PathListItem_ variants 2016-02-11 12:34:48 +01:00
Oliver 'ker' Schneider
8b3856b1bc [breaking-change] don't glob export ast::StrStyle variants 2016-02-11 12:34:48 +01:00
Oliver 'ker' Schneider
d844bfb196 [breaking-change] don't glob export ast::Visibility variants 2016-02-11 12:34:48 +01:00
Oliver 'ker' Schneider
dfe35da6b8 [breaking-change] don't glob export ast::TraitItemKind variants 2016-02-11 12:34:48 +01:00
Oliver 'ker' Schneider
73fa9b2da2 [breaking-change] don't glob export ast::Mutablity variants 2016-02-11 12:34:48 +01:00
Oliver 'ker' Schneider
14e09ad468 [breaking-change] don't glob export ast::MetaItem_ 2016-02-11 12:34:48 +01:00
Oliver 'ker' Schneider
e797e1961d [breaking-change] don't glob export ast::MacStmtStyle 2016-02-11 12:34:48 +01:00
Oliver 'ker' Schneider
798974cae5 [breaking-change] don't glob export ast::KleeneOp variants 2016-02-11 12:34:48 +01:00
Oliver 'ker' Schneider
019614f03d [breaking-change] don't glob export ast::Item_ variants 2016-02-11 12:34:48 +01:00
Oliver Schneider
8290c950a8 [breaking-change] don't pub export ast::Stmt_ variants 2016-02-11 12:34:48 +01:00
Oliver Schneider
498a2e416e [breaking-change] don't pub export ast::IntLitType variants 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
Oliver Schneider
05d4cefd63 [breaking-change] don't pub export ast::Ty_ variants 2016-02-11 12:34:48 +01:00
Oliver Schneider
bfa66bb389 [breaking-change] remove the sign from integer literals in the ast 2016-02-11 12:34:48 +01:00
Oliver Schneider
625e78b700 [breaking-change] don't glob export ast::{UintTy, IntTy} variants 2016-02-11 12:34:48 +01:00
Oliver Schneider
80bf9ae18a [breaking-change] don't glob export ast::Expr_ variants 2016-02-11 12:34:48 +01:00
Oliver Schneider
79fa657abc [breaking-change] don't glob export ast::Decl_ variants 2016-02-11 12:34:48 +01:00
Oliver Schneider
8516ba367d [breaking-change] don't glob export ast::CaptureClause variants 2016-02-11 12:34:48 +01:00
Oliver Schneider
243a30c931 [breaking-change] don't glob import/export syntax::abi enum variants 2016-02-11 12:34:48 +01:00
Oliver Schneider
47b0784ba8 [breaking-change] don't glob export ast::BlockCheckMode variants 2016-02-11 12:34:48 +01:00
Oliver Schneider
3b57d40fe5 [breaking-change] don't glob import ast::FunctionRetTy variants 2016-02-11 12:34:48 +01:00
Oliver Schneider
05e25de4f0 [breaking-change] don't glob export ast::BinOp_ 2016-02-11 12:34:48 +01:00
Oliver Schneider
f875f4c4c2 [breaking-change] don't glob export ast::UnOp variants 2016-02-11 12:34:48 +01:00
Alex Burka
fd4d013a2c trpl: fix macro follow sets 2016-01-27 13:26:47 -05:00
Manish Goregaokar
b46bd2fb29 Rollup merge of #31152 - durka:ty-follow-bracket, r=pnkfelix
cc #31135 rust-lang/rfcs#1462 #30923 @retep998
r? @pnkfelix
2016-01-26 13:11:57 +05:30
Alex Burka
e1e0de86ec add [ to FOLLOW(ty) and FOLLOW(path)
Following RFC 1462 (amending 550). Closes #31135.
2016-01-23 16:37:14 -05:00
Nick Cameron
0ac8915875 The war on abort_if_errors 2016-01-22 08:19:27 +13:00
Felix S. Klock II
3703ef5820 extending FOLLOW(NT) as specified in amendment.
See RFC amendment 1384:

  https://github.com/rust-lang/rfcs/pull/1384
2016-01-07 20:53:33 +01:00
Felix S. Klock II
076e64475a macro_rules: proper FIRST/FOLLOW computations for checking macro_rules validity.
See RFC amendment 1384 and tracking issue 30450:
  https://github.com/rust-lang/rfcs/pull/1384
  https://github.com/rust-lang/rust/issues/30450

Moved old check_matcher code into check_matcher_old

combined the two checks to enable a warning cycle (where we will
continue to error if the two checks agree to reject, accept if the new
check says accept, and warn if the old check accepts but the new check
rejects).
2016-01-07 20:53:33 +01:00
bors
5daa75373d Auto merge of #30654 - nrc:panictry, r=brson
The motivation (other than removing boilerplate) is that this is a baby step towards a parser with error recovery.

[breaking-change] if you use any of the changed functions, you'll need to remove a try! or panictry!
2016-01-06 20:30:55 +00:00
Guillaume Gomez
6e68cdfcc2 Add test for "malformed macro lhs" and change back span_bug to span_fatal 2016-01-04 01:13:57 +01: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
bors
85fb3b6fc0 Auto merge of #30526 - Ms2ger:PathParameters, r=brson 2015-12-30 14:19:08 +00:00
Nick Cameron
95dc7efad0 use structured errors 2015-12-30 14:27:59 +13:00
bors
4ce1dafd1d Auto merge of #30377 - Wafflespeanut:levenshtein, r=Manishearth
fixes part of #30197
2015-12-23 08:55:38 +00:00
Ms2ger
2359ab0dc9 Stop re-exporting PathParameters's variants. 2015-12-22 17:12:33 +01:00
bors
709d00a231 Auto merge of #30460 - Ms2ger:BindingMode, r=alexcrichton 2015-12-21 19:10:51 +00:00
Ms2ger
143b9d80d0 Stop re-exporting the ast::BindingMode variants. 2015-12-20 22:15:26 +01:00
Manish Goregaokar
9e953df6f0 Rollup merge of #30420 - petrochenkov:owned2, r=nrc
Part of https://github.com/rust-lang/rust/pull/30095 not causing mysterious segfaults.

r? @nrc
2015-12-18 20:02:12 +05:30
Manish Goregaokar
c2902965cb Rollup merge of #30384 - nrc:diagnostics, r=@nikomatsakis
Should make it possible to add JSON or HTML errors. Also tidies up a lot.
2015-12-18 16:47:37 +05:30
Vadim Petrochenkov
0d298f9904 Deprecate name OwnedSlice and don't use it 2015-12-18 00:52:56 +03:00
Jeffrey Seyfried
8364a6feef Remove unused imports 2015-12-17 05:43:27 +00:00
Nick Cameron
6309b0f5bb move error handling from libsyntax/diagnostics.rs to libsyntax/errors/*
Also split out emitters into their own module.
2015-12-17 09:35:50 +13:00
Manish Goregaokar
b0b9a556df Rollup merge of #30388 - DanielJCampbell:macro-ident-spans, r=nrc
r? @nrc
2015-12-16 17:46:29 +05:30
Ravi Shankar
51ff171948 Modify the Levenshtein-based suggestions to include imports 2015-12-16 16:33:24 +05:30
Seo Sanghyeon
bb21b6738a Fix expansion tests 2015-12-15 15:04:47 +09:00
Seo Sanghyeon
f9ba107824 Move built-in syntax extensions to a separate crate 2015-12-15 15:04:46 +09:00
Daniel Campbell
2dcd791d46 Generated code spans now point to callsite parameters (where applicable) 2015-12-15 17:41:03 +13:00
faineance
ec8ea22c7f [breaking-change] move ast_util functions to methods 2015-12-14 21:15:01 +00:00
bors
50a02b43ba Auto merge of #29735 - Amanieu:asm_indirect_constraint, r=pnkfelix
This PR reverts #29543 and instead implements proper support for "=*m" and "+*m" indirect output operands. This provides a framework on top of which support for plain memory operands ("m", "=m" and "+m") can be implemented.

This also fixes the liveness analysis pass not handling read/write operands correctly.
2015-12-14 13:48:41 +00:00
Tamir Duberstein
b964b1d043 remove deprecated APIs missed in #30182 2015-12-13 01:02:12 -05:00
Alex Crichton
464cdff102 std: Stabilize APIs for the 1.6 release
This commit is the standard API stabilization commit for the 1.6 release cycle.
The list of issues and APIs below have all been through their cycle-long FCP and
the libs team decisions are listed below

Stabilized APIs

* `Read::read_exact`
* `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`)
* libcore -- this was a bit of a nuanced stabilization, the crate itself is now
  marked as `#[stable]` and the methods appearing via traits for primitives like
  `char` and `str` are now also marked as stable. Note that the extension traits
  themeselves are marked as unstable as they're imported via the prelude. The
  `try!` macro was also moved from the standard library into libcore to have the
  same interface. Otherwise the functions all have copied stability from the
  standard library now.
* The `#![no_std]` attribute
* `fs::DirBuilder`
* `fs::DirBuilder::new`
* `fs::DirBuilder::recursive`
* `fs::DirBuilder::create`
* `os::unix::fs::DirBuilderExt`
* `os::unix::fs::DirBuilderExt::mode`
* `vec::Drain`
* `vec::Vec::drain`
* `string::Drain`
* `string::String::drain`
* `vec_deque::Drain`
* `vec_deque::VecDeque::drain`
* `collections::hash_map::Drain`
* `collections::hash_map::HashMap::drain`
* `collections::hash_set::Drain`
* `collections::hash_set::HashSet::drain`
* `collections::binary_heap::Drain`
* `collections::binary_heap::BinaryHeap::drain`
* `Vec::extend_from_slice` (renamed from `push_all`)
* `Mutex::get_mut`
* `Mutex::into_inner`
* `RwLock::get_mut`
* `RwLock::into_inner`
* `Iterator::min_by_key` (renamed from `min_by`)
* `Iterator::max_by_key` (renamed from `max_by`)

Deprecated APIs

* `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`)
* `OsString::from_bytes`
* `OsStr::to_cstring`
* `OsStr::to_bytes`
* `fs::walk_dir` and `fs::WalkDir`
* `path::Components::peek`
* `slice::bytes::MutableByteVector`
* `slice::bytes::copy_memory`
* `Vec::push_all` (renamed to `extend_from_slice`)
* `Duration::span`
* `IpAddr`
* `SocketAddr::ip`
* `Read::tee`
* `io::Tee`
* `Write::broadcast`
* `io::Broadcast`
* `Iterator::min_by` (renamed to `min_by_key`)
* `Iterator::max_by` (renamed to `max_by_key`)
* `net::lookup_addr`

New APIs (still unstable)

* `<[T]>::sort_by_key` (added to mirror `min_by_key`)

Closes #27585
Closes #27704
Closes #27707
Closes #27710
Closes #27711
Closes #27727
Closes #27740
Closes #27744
Closes #27799
Closes #27801
cc #27801 (doesn't close as `Chars` is still unstable)
Closes #28968
2015-12-05 15:09:44 -08:00
Amanieu d'Antras
65707dfc00 Use a struct instead of a tuple for inline asm output operands 2015-12-05 10:11:20 +00:00
Amanieu d'Antras
9d7b113b44 Add proper support for indirect output constraints in inline asm 2015-12-05 08:18:30 +00:00
bors
77ed39cfe3 Auto merge of #29850 - Kimundi:attributes_that_make_a_statement, r=pnkfelix
See https://github.com/rust-lang/rfcs/pull/16 and https://github.com/rust-lang/rust/issues/15701

- Added syntax support for attributes on expressions and all syntax nodes in statement position.
- Extended `#[cfg]` folder to allow removal of statements, and
of expressions in optional positions like expression lists and trailing
block expressions.
- Extended lint checker to recognize lint levels on expressions and
locals.
- As per RFC, attributes are not yet accepted on `if` expressions.

Examples:
  ```rust
let x = y;
{
        ...
}
assert_eq!((1, #[cfg(unset)] 2, 3), (1, 3));

let FOO = 0;
```

Implementation wise, there are a few rough corners and open questions:
- The parser work ended up a bit ugly.
- The pretty printer change was based mostly on guessing.
- Similar to the `if` case, there are some places in the grammar where a new `Expr` node starts,
  but where it seemed weird to accept attributes and hence the parser doesn't. This includes:
  - const expressions in patterns
  - in the middle of an postfix operator chain (that is, after `.`, before indexing, before calls)
  - on range expressions, since `#[attr] x .. y` parses as  `(#[attr] x) .. y`, which is inconsistent with
    `#[attr] .. y` which would parse as `#[attr] (.. y)`
- Attributes are added as additional `Option<Box<Vec<Attribute>>>` fields in expressions and locals.
- Memory impact has not been measured yet.
- A cfg-away trailing expression in a block does not currently promote the previous `StmtExpr` in a block to a new trailing expr. That is to say, this won't work:
```rust
let x = {
    #[cfg(foo)]
    Foo { data: x }
    #[cfg(not(foo))]
    Foo { data: y }
};
```
- One-element tuples can have their inner expression removed to become Unit, but just Parenthesis can't. Eg, `(#[cfg(unset)] x,) == ()` but `(#[cfg(unset)] x) == error`. This seemed reasonable to me since tuples and unit are type constructors, but could probably be argued either way.
- Attributes on macro nodes are currently unconditionally dropped during macro expansion, which seemed fine since macro disappear at that point?
- Attributes on `ast::ExprParens` will be prepend-ed to the inner expression in the hir folder.
- The work on pretty printer tests for this did trigger, but not fix errors regarding macros:
  - expression `foo![]` prints as `foo!()`
  - expression `foo!{}` prints as `foo!()`
  - statement `foo![];` prints as `foo!();`
  - statement `foo!{};` prints as `foo!();`
  - statement `foo!{}` triggers a `None` unwrap ICE.
2015-12-04 08:46:29 +00:00
Marvin Löbel
3f33cbcbff Improved comments around dropped attributes in the macro expander 2015-11-30 22:26:03 +01:00
bors
5dc91a74b1 Auto merge of #30064 - fhartwig:macro-suggestions, r=sanxiyn
Fixes #13677
This does the same sort of suggestion for misspelt macros that we already do for misspelt identifiers.
Example. Compiling this program:

```rust
macro_rules! foo {
    ($e:expr) => ( $e )
}

fn main() {
    fob!("hello!");
}
```

gives the following error message:

```
/Users/mcp/temp/test.rs:7:5: 7:8 error: macro undefined: 'fob!'
/Users/mcp/temp/test.rs:7     fob!("hello!");
                              ^~~
/Users/mcp/temp/test.rs:7:5: 7:8 help: did you mean `foo`?
/Users/mcp/temp/test.rs:7     fob!("hello!");
```

I had to move the levenshtein distance function into libsyntax for this. Maybe this should live somewhere else (some utility crate?), but I couldn't find a crate to put it in that is imported by libsyntax and the other rustc crates.
2015-11-27 18:41:53 +00:00
Florian Hartwig
4bb7cf11dc Introduce max_suggestion_distance function to avoid duplicating the heuristic 2015-11-27 17:52:29 +01:00
Marvin Löbel
296c3613ca Added stmt_expr_attribute feature gate 2015-11-26 21:47:44 +01:00
Marvin Löbel
c56b47ab8c Some TLC for the MoveMap trait 2015-11-26 21:46:12 +01:00
Marvin Löbel
0608b1d414 Fixed macro expander not folding attributes (though I'm not sure if that is actually neccessary) 2015-11-26 21:46:12 +01:00
Marvin Löbel
2a8f358de7 Add syntax support for attributes on expressions and all syntax
nodes in statement position.

Extended #[cfg] folder to allow removal of statements, and
of expressions in optional positions like expression lists and trailing
block expressions.

Extended lint checker to recognize lint levels on expressions and
locals.
2015-11-26 21:46:12 +01:00
Florian Hartwig
9ba657cad5 Add '!' to macro name suggestion, use fileline_help instead of span_help 2015-11-26 11:59:41 +01:00
Florian Hartwig
a5e5c67756 Add suggestion of similar macro names to macro undefined error message 2015-11-26 00:21:38 +01:00
Jonas Schievink
fc9f9882f3 Fix "Cannot fill in a NT" ICE 2015-11-25 20:58:57 +01:00
bors
7fa2c6ca31 Auto merge of #30011 - jonas-schievink:macro-context, r=nrc
Fixes #22425

Also fixes #30007, since it's just a change from `true` to `false`.
2015-11-25 03:02:05 +00:00
Jonas Schievink
52d3de7a7e Remove "this" 2015-11-24 16:34:48 +01:00
bors
561d0884e5 Auto merge of #30000 - Manishearth:unreachable-call, r=nrc
Fixes #1889
2015-11-24 06:58:25 +00:00
Manish Goregaokar
7fbcb51589 Fix unreachable code in libsyntax 2015-11-24 10:05:51 +05:30
bors
040a77f772 Auto merge of #29952 - petrochenkov:depr, r=brson
Part of https://github.com/rust-lang/rust/issues/29935

The deprecation lint is still called "deprecated", so people can continue using `#[allow(deprecated)]` and similar things.
2015-11-23 20:08:49 +00:00
Jonas Schievink
d4a0e545e7 Print the macro context name on incomplete parse
Fixes #22425

Also fixes #30007, since it's just a change from `true` to `false`.
2015-11-23 21:06:51 +01:00
Manish Goregaokar
99925fb562 Look up macro names as well when suggesting replacements for function resolve errors
fixes #5780
2015-11-22 06:48:46 +05:30
Vadim Petrochenkov
a613059e3f Rename #[deprecated] to #[rustc_deprecated] 2015-11-20 16:11:20 +03:00
bors
b2f539375a Auto merge of #29887 - sanxiyn:match-ref-pats, r=sfackler 2015-11-17 20:10:25 +00:00
Seo Sanghyeon
95f6ea920d Fix match_ref_pats flagged by Clippy 2015-11-17 23:24:49 +09:00
Oliver Schneider
d09220de13 rename ast::ImplItem_::*ImplItem to ast::ImplItemKind::* 2015-11-16 10:35:30 +01:00
bors
bf78389656 Auto merge of #29828 - sanxiyn:check-macro, r=nrc
Fix #27409.
2015-11-16 05:48:35 +00:00
Seo Sanghyeon
cce7b8bd25 Check macro definition and do not expand invalid macros 2015-11-14 19:50:46 +09:00
Seo Sanghyeon
289b1b400a Reindent code 2015-11-14 19:18:32 +09:00
Seo Sanghyeon
fdadba5786 Store TokenTree in MacroRulesMacroExpander 2015-11-14 19:11:40 +09:00
Kyle Mayes
44d8abcc0f Move the panicking parse functions out of the parser
Since these functions are only used by the AST quoting syntax extensions, they should be there instead of in the parser.
2015-11-13 22:18:59 -05:00
bors
b12a3582b1 Auto merge of #29761 - eefriedman:rename-nopanic, r=sanxiyn
Just `sed s/_nopanic//g`.  Hopefully makes libsyntax a bit more
readable.
2015-11-13 10:28:25 +00:00
bors
5a872880bd Auto merge of #29780 - KyleMayes:quote-ext, r=nrc
This is my first code contribution to Rust, so I'm sure there are some issues with the changes I've made.

I've added the `quote_arg!`, `quote_block!`, `quote_path!`, and `quote_meta_item!` quasiquoting macros. From my experience trying to build AST in compiler plugins, I would like to be able to build any AST piece with a quasiquoting macro (e.g., `quote_struct_field!` or `quote_variant!`) and then use those AST pieces in other quasiquoting macros, but this pull request just adds some of the low-hanging fruit.

I'm not sure if these additions are desirable, and I'm sure these macros can be implemented in an external crate if not.
2015-11-12 20:31:12 +00:00
Kevin Butler
d64e551248 libsyntax: deny warnings in doctests 2015-11-12 05:16:57 +00:00
Kyle Mayes
8c88308c68 libsyntax: Add more quasiquoting macros 2015-11-11 15:19:01 -05:00
bors
b53020a5f4 Auto merge of #29744 - sanxiyn:modernize, r=nrc 2015-11-11 05:47:13 +00:00
Eli Friedman
69210a9635 Rename _nopanic methods to remove the suffix.
Just `sed s/_nopanic//g`.  Hopefully makes libsyntax a bit more
readable.
2015-11-10 16:10:31 -08:00
Seo Sanghyeon
dfc314d19b Use lifetime elision 2015-11-10 20:42:00 +09:00
Seo Sanghyeon
791003ad3c Use deref coercions 2015-11-10 20:16:28 +09:00
Alex Crichton
5d55533f93 syntax: Use let _ in #[derive(Debug)]
This should help avoid triggering the unused_results lint which can frequently
be turned on.

Closes #29710
2015-11-09 10:42:58 -08:00
bors
475f91f46e Auto merge of #29582 - oli-obk:token_tree, r=sfackler 2015-11-06 21:11:06 +00:00
Oliver Schneider
fcc7067904 remove Tt prefix from TokenType variants
[breaking change]
2015-11-06 14:52:02 +01:00
bors
2f59977d96 Auto merge of #29615 - steveklabnik:lol_strings, r=alexcrichton
&format!("...") is the same as "" if we're not doing any interpolation,
and doesn't allocate an intermediate String.
2015-11-06 11:28:07 +00:00
bors
3a0409d291 Auto merge of #29565 - sfackler:issue-29540, r=huonw
Closes #29540

r? @huonw
2015-11-05 18:15:26 +00:00
Steve Klabnik
63576c23e4 remove excess string allocation
&format!("...") is the same as "" if we're not doing any interpolation,
and doesn't allocate an intermediate String.
2015-11-05 15:30:34 +01:00
Steven Fackler
d0bc6a1f49 Don't chain method calls in #[derive(Debug)]
Closes #29540
2015-11-03 22:48:28 -08:00
Amanieu d'Antras
1805e5fb48 Allow indirect operands to be used as inputs for inline asm 2015-11-03 15:19:46 +00:00
bors
b7fbfb658e Auto merge of #29285 - eefriedman:libsyntax-panic, r=nrc
A set of commits which pushes some panics out of core parser methods, and into users of those parser methods.
2015-11-03 03:06:03 +00:00
Vadim Petrochenkov
3468b8d42c Remove PatWildMulti 2015-10-31 03:44:43 +03: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
Eli Friedman
1dd87dcfea Don't use panicking helpers in Parser. 2015-10-27 20:09:10 -07:00
Vadim Petrochenkov
e8ddbba2ed syntax/rustc_front: Simplify VariantData::fields
And use VariantData instead of P<VariantData> in Item_ and Variant_
2015-10-25 18:33:51 +03:00
bors
97ba52ec37 Auto merge of #29148 - petrochenkov:noshow, r=alexcrichton
Closes https://github.com/rust-lang/rust/issues/29145

[breaking-change], needs a crater run.
2015-10-20 19:02:27 +00:00
Vadim Petrochenkov
629c2a840c Generate stability attributes for derived impls
The attributes are copied from the item for which the trait impl is derived
2015-10-19 01:55:53 +03:00
Vadim Petrochenkov
025cf75864 Remove #[derive(Show)] 2015-10-18 19:12:09 +03:00
bors
747d951e88 Auto merge of #29014 - petrochenkov:stability, r=brson
Stricter checking of stability attributes + enforcement of their invariants at compile time
(+ removed dead file librustc_front/attr.rs)
I intended to enforce use of `reason` for unstable items as well (it normally presents for new items), but it turned out too intrusive, many older unstable items don't have `reason`s.

r? @aturon 
I'm studying how stability works and do some refactoring along the way, so it's probably not the last PR.
2015-10-16 17:47:01 +00:00
bors
785932f9d8 Auto merge of #28980 - nrc:unsafe-macros, r=@pnkfelix
This is a [breaking change].

@brson could you do a Crater run with this PR please?

Lets not land till Crater says its OK.

This was discussed at https://internals.rust-lang.org/t/does-anyone-use-the-push-pop-unsafe-macros/2702
2015-10-15 03:26:48 +00:00
Vadim Petrochenkov
46750d0409 Merge VariantData and VariantData_ 2015-10-13 15:19:27 +03:00
Vadim Petrochenkov
40aa09e4c9 Merge struct fields and struct kind 2015-10-13 15:19:25 +03:00
Vadim Petrochenkov
30af54dede Dict -> Struct, StructDef -> VariantData, def -> data 2015-10-13 15:19:24 +03:00
Vadim Petrochenkov
877c35e8a2 Remove now redundant NodeId from Variant 2015-10-13 15:19:18 +03:00
Vadim Petrochenkov
495566ee61 Decouple structure kinds from NodeIds 2015-10-13 15:19:17 +03:00
Vadim Petrochenkov
ea47c2b6b3 Unify structures and enum variants in AST 2015-10-13 15:19:15 +03:00
Vadim Petrochenkov
ab671552c3 Refactor attr::Stability
Stricter checking + enforcement of invariants at compile time
2015-10-13 06:01:31 +03:00
Nick Cameron
d399098fd8 Remove the push_unsafe! and pop_unsafe! macros.
This is a [breaking change].
2015-10-12 15:50:12 +13:00
bors
c14609035d Auto merge of #28857 - nrc:lowering, r=nikomatsakis
r? @nikomatsakis
2015-10-09 08:53:45 +00:00
Nick Cameron
ba43c228b5 Some cleanup of no longer used AST things 2015-10-09 11:53:42 +13:00
Nick Cameron
08f3752270 hygiene for for loops, if let, while let
and some unrelated test cleanups
2015-10-09 11:53:41 +13:00
Nick Cameron
e0c74868c3 Fix stability 2015-10-09 11:53:41 +13:00
Nick Cameron
7f469ba6c5 Move placement in desugaring to lowering 2015-10-09 11:53:41 +13:00
Nick Cameron
bc364b4a0d if let and while let 2015-10-09 11:53:41 +13:00
Nick Cameron
20083c1e1f Move for loop desugaring to lowering 2015-10-09 11:53:41 +13:00
Cristi Cobzarenco
4b308b44e1 typos: fix a grabbag of typos all over the place 2015-10-08 19:49:31 +01:00
Vadim Petrochenkov
b82d76c8a1 Add comment for the use of Ident in hash map in mtwt 2015-10-06 01:47:35 +03:00
Vadim Petrochenkov
f37d6fc6f3 libsyntax: Do not derive Hash for Ident 2015-10-03 12:44:47 +03:00
Ms2ger
b093060c2a Stop re-exporting AttrStyle's variants and rename them. 2015-10-01 18:03:34 +02:00
bors
2e88c36ebc Auto merge of #28642 - petrochenkov:name3, r=nrc
This PR removes random remaining `Ident`s outside of libsyntax and performs general cleanup
In particular, interfaces of `Name` and `Ident` are tidied up, `Name`s and `Ident`s being small `Copy` aggregates are always passed to functions by value, and `Ident`s are never used as keys in maps, because `Ident` comparisons are tricky.

Although this PR closes https://github.com/rust-lang/rust/issues/6993 there's still work related to it:
- `Name` can be made `NonZero` to compress numerous `Option<Name>`s and `Option<Ident>`s but it requires const unsafe functions.
- Implementation of `PartialEq` on `Ident` should be eliminated and replaced with explicit hygienic, non-hygienic or member-wise comparisons.
- Finally, large parts of AST can potentially be converted to `Name`s in the same way as HIR to clearly separate identifiers used in hygienic and non-hygienic contexts.

r? @nrc
2015-09-26 14:48:56 +00: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
Eduard Burtescu
f293ea28b4 Remove the deprecated box(PLACE) syntax. 2015-09-24 18:00:08 +03:00
Ms2ger
184c8a99ed Use ast::AsmDialect's variants qualified, and drop the pointless prefix. 2015-09-21 16:48:25 +02:00
Andrew Paseltiner
85b8b447fa Replace ast::Mac_ enum with struct
Closes #28527.
2015-09-20 17:15:04 -04:00
Manish Goregaokar
8aef16c2a5 Move tts instead of cloning in expansion 2015-09-20 06:45:19 +05:30
Simonas Kazlauskas
f5a99ae7fb Remove Visibility field from enum variants
Followup on #28440
2015-09-17 10:02:59 +03:00
Huon Wilson
31310f5b65 Allow tracking issues for lang features.
This is similar to the libs version, which allow an `issue` field in the
`#[unstable]` attribute.

cc #28244
2015-09-08 11:01:42 +10:00
Vadim Petrochenkov
405c616eaf Use consistent terminology for byte string literals
Avoid confusion with binary integer literals and binary operator expressions in libsyntax
2015-09-03 10:54:53 +03:00
bors
ae75ef9e62 Auto merge of #28137 - nrc:remove-non-multi, r=huonw
This is a [breaking-change] for syntax extension authors. The fix is to use MultiModifier or MultiDecorator, which have the same functionality but are more flexible. Users of syntax extensions are unaffected.
2015-09-01 09:12:52 +00:00
Nick Cameron
20e1ea2dd8 Remove the Modifier and Decorator kinds of syntax extensions.
This is a [breaking-change] for syntax extension authors. The fix is to use MultiModifier or MultiDecorator, which have the same functionality but are more flexible. Users of syntax extensions are unaffected.
2015-09-01 13:16:03 +12:00
Nick Cameron
ef4853041a Closures are not generated code. 2015-08-31 17:06:30 +12:00
Michael Layzell
38d450fad2 Allow #[derive()] to generate unsafe trait impls 2015-08-29 14:50:05 -04:00
Manish Goregaokar
25cbb4385e Move ExpnInfo to Name 2015-08-28 03:37:13 +05:30
Manish Goregaokar
4ec7b713dd Enumify CompilerExpansion in ExpnInfo 2015-08-27 05:16:05 +05:30
bors
4c996499a1 Auto merge of #27239 - apasel422:issue-19102, r=huonw
closes #19102
2015-08-24 18:43:41 +00:00
bors
7e13faee17 Auto merge of #27849 - jonas-schievink:macro-errors, r=nikomatsakis
And some small indentation/code style fixes in the macro parser.
2015-08-19 00:54:38 +00:00
Huon Wilson
e364f0eb5a feature gate cfg(target_feature).
This is theoretically a breaking change, but GitHub search turns up no
uses of it, and most non-built-in cfg's are passed via cargo features,
which look like `feature = "..."`, and hence can't overlap.
2015-08-17 14:41:37 -07:00
Huon Wilson
c8b6d5b23c Implement repr(simd) as an alias for #[simd]. 2015-08-17 10:57:18 -07:00
Jonas Schievink
5e8d39ebfd Slightly improved macro diagnostics + Indentation fixes 2015-08-15 21:27:52 +02:00
bors
29455557aa Auto merge of #27827 - w00ns:for-loop-expn-issue-27639, r=alexcrichton
Fixes #27639
2015-08-15 14:50:13 +00:00
w00ns
ae68e90af4 Fix issue with for loop expansion 2015-08-15 10:17:12 +02:00
Jonas Schievink
59f8e3238a Fix span of invalid metavariable repetition 2015-08-15 00:45:34 +02:00
bors
6a5c4e77a8 Auto merge of #27691 - jonas-schievink:for-macro, r=alexcrichton
Closes #27004
2015-08-12 20:58:31 +00:00
Jonas Schievink
a016dfb1d1 Fix macro expansion in for loop pattern 2015-08-12 10:34:14 +02:00
bors
58b0aa5e42 Auto merge of #27584 - TimNN:macro-eof-span, r=huonw
The ideas is to use the span of the complete macro invocation if the span of a macro error is `DUMMY_SP`.

fixes #7970
2015-08-11 23:21:19 +00:00
bors
8856927f64 Auto merge of #27451 - seanmonstar:use-groups-as, r=alexcrichton
An implementation of [RFC 1219](https://github.com/rust-lang/rfcs/pull/1219).

The RFC is not merged yet, but once merged, this could be.
2015-08-10 20:24:06 +00:00
Tim Neumann
d46e84081f add and use Span.substitute_dummy method 2015-08-10 20:43:11 +02:00
Sean McArthur
cfcd449c4c rustc: rename multiple imports in a list 2015-08-08 11:54:15 -07:00
Tim Neumann
c115c51363 improve span of erroneous empty macro invocation
The ideas is to use the span of the complete macro invocation if the span of a
macro error is `DUMMY_SP`.

fixes #7970
2015-08-07 16:53:13 +02:00
bors
11deb083f5 Auto merge of #27296 - jroesch:type-macros, r=huonw
This pull request implements the functionality for [RFC 873](https://github.com/rust-lang/rfcs/blob/master/text/0873-type-macros.md). This is currently just an update of @freebroccolo's branch from January, the corresponding commits are linked in each commit message.

@nikomatsakis and I had talked about updating the macro language to support a lifetime fragment specifier, and it is possible to do that work on this branch as well. If so we can (collectively) talk about it next week during the pre-RustCamp work week.
2015-08-06 19:11:17 +00:00
Jared Roesch
471370a16b Fix last nits 2015-08-04 16:05:07 -07:00
Jared Roesch
f004079de2 Actually commit tests 2015-08-04 16:05:07 -07:00
Jared Roesch
89d401f6ab Address nits 2015-08-04 16:05:07 -07:00
Jared Roesch
15e7aa79f5 Add feature gate 2015-08-04 16:05:07 -07:00
Jared Roesch
8602a7d898 Update and add test case
Test case from here: 9e93fef3c0
2015-08-04 16:05:07 -07:00
Jared Roesch
9fb11fe9f2 Extend macro machinery to expand macros in types
Reapplied the changes from 7aafe24139
to a clean branch of master
2015-08-04 16:05:06 -07:00
Alex Crichton
5cccf3cd25 syntax: Implement #![no_core]
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of
the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The
`#![no_std]` attribute now injects `extern crate core` at the top of the crate
as well as the libcore prelude into all modules (in the same manner as the
standard library's prelude). The `#![no_core]` attribute disables both std and
core injection.

[rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-08-03 17:23:01 -07:00
bors
d877e65404 Auto merge of #27134 - fhartwig:derive, r=huonw
Fixes #25022

This adapts the deriving mechanism to not repeat bounds for the same type parameter. To give an example: for the following code:

```rust
#[derive(Clone)]
pub struct FlatMap<I, U: IntoIterator, F> {
    iter: I,
    f: F,
    frontiter: Option<U::IntoIter>,
    backiter: Option<U::IntoIter>,
}
```
the latest nightly generates the following impl signature:

```rust
impl <I: ::std::clone::Clone,
      U: ::std::clone::Clone + IntoIterator,
      F: ::std::clone::Clone>
::std::clone::Clone for FlatMap<I, U, F> where
    I: ::std::clone::Clone,
    F: ::std::clone::Clone,
    U::IntoIter: ::std::clone::Clone,
    U::IntoIter: ::std::clone::Clone
```

With these changes, the signature changes to this:
```rust
impl <I, U: IntoIterator, F> ::std::clone::Clone for FlatMap<I, U, F> where
    I: ::std::clone::Clone,
    F: ::std::clone::Clone,
    U::IntoIter: ::std::clone::Clone
```
(Nothing in the body of the impl changes)
Note that the second impl is more permissive, as it doesn't have a `Clone` bound on `U` at all. There was a compile-fail test that failed due to this. I don't understand why we would want the old behaviour (and nobody on IRC could tell me either), so please tell me if there is a good reason that I missed.
2015-08-03 20:29:21 +00:00
Oliver Schneider
00a5e66f81 remove get_ident and get_name, make as_str sound 2015-07-28 18:07:20 +02:00
mitaa
adfdbc4bd7 Remove ast::LocalSource with only one used variant
`LocalSource` indicated wether a let binding originated from for-loop desugaring to enable specialized error messages, but for-loop expansion has changed and this is now achieved through `MatchSource::ForLoopDesugar`.
2015-07-26 08:56:29 +02:00
bors
04badd6a97 Auto merge of #27253 - bossmc:unbalanced-delimiters-cause-ice, r=nikomatsakis
This introduces a test for #23389 and improves the error behaviour to treat the malformed LHS as an error, not a compiler bug.

The parse phase that precedes the call to `check_lhs_nt_follows` could possibly be enhanced to police the format itself (which the old code suggests was the original intention), but I'm not sure that's any nicer than just parsing the matcher as generic rust code and then policing the specific requirements for being a macro matcher afterwards (as this does).

Fixes #23389
2015-07-25 11:20:15 +00:00
Andy Caldwell
4f58db485d Make ICE an error and use a sensible error message 2015-07-24 01:10:25 +00:00
Felix S. Klock II
2d68d09b46 review feedback: common-subexpression-elim across functions in pushpop_safe impl. 2015-07-23 23:39:28 +02:00
Andrew Paseltiner
3f1c7e1660 add #[allow(unused_qualifications)] to derived impls
closes #19102
2015-07-23 13:26:49 -04:00
Felix S. Klock II
07afe91fda Allow unstable code to be injected by placement-in expansion.
(Over time the stability checking has gotten more finicky; in
particular one must attach the (whole) span of the original `in PLACE
BLOCK` expression to the injected references to unstable paths, as
noted in the comments.)

call `push_compiler_expansion` during the placement-`in` expansion.
2015-07-22 15:34:00 +02:00
Felix S. Klock II
b325e4f28e Add feature-gates for desugaring-based box and placement-in.
update test/compile-fail/feature-gate-box-expr.rs to reflect new feature gates.

Part of what lands with Issue 22181.
2015-07-22 15:33:59 +02:00
Felix S. Klock II
d79bbbc4ef Revise placement-in expansion to use push/pop_unsafe and move_val_init. 2015-07-22 15:33:59 +02:00
Felix S. Klock II
866250c6d4 prototype Placer protocol for unstable overloaded-box and placement-in. 2015-07-22 15:33:59 +02:00
Felix S. Klock II
1829fa5199 Hack for "unsafety hygiene" -- push_unsafe! and pop_unsafe!.
Even after expansion, the generated expressions still track depth of
such pushes (i.e. how often you have "pushed" without a corresponding
"pop"), and we add a rule that in a context with a positive
`push_unsafe!` depth, it is effectively an `unsafe` block context.

(This way, we can inject code that uses `unsafe` features, but still
contains within it a sub-expression that should inherit the outer
safety checking setting, outside of the injected code.)

This is a total hack; it not only needs a feature-gate, but probably
should be feature-gated forever (if possible).

ignore-pretty in test/run-pass/pushpop-unsafe-okay.rs
2015-07-22 15:33:59 +02:00
Florian Hartwig
93e5a74c87 Avoid repeated trait bounds in derived impls 2015-07-21 21:59:57 +02:00
Nick Cameron
0e907fa542 Provide a filemap ctor with line info 2015-07-21 21:55:19 +12:00
bors
9ff2d19c45 Auto merge of #27000 - alexcrichton:semi-after-type, r=cmr
This commit expands the follow set of the `ty` and `path` macro fragments to
include the semicolon token as well. A semicolon is already allowed after these
tokens, so it's currently a little too restrictive to not have a semicolon
allowed. For example:

    extern {
        fn foo() -> i32; // semicolon after type
    }

    fn main() {
        struct Foo;

        Foo; // semicolon after path
    }
2015-07-13 13:55:29 +00:00
Alex Crichton
af556238eb syntax: Allow semi tokens after macro ty/path
This commit expands the follow set of the `ty` and `path` macro fragments to
include the semicolon token as well. A semicolon is already allowed after these
tokens, so it's currently a little too restrictive to not have a semicolon
allowed. For example:

    extern {
        fn foo() -> i32; // semicolon after type
    }

    fn main() {
        struct Foo;

        Foo; // semicolon after path
    }
2015-07-12 15:53:04 -07:00
Wesley Wiser
93ddee6cee Change some instances of .connect() to .join() 2015-07-10 19:40:46 -04:00
bors
736886c84b Auto merge of #26907 - nrc:save-fns, r=brson
r? @huonw
2015-07-10 00:47:35 +00:00
Ulrik Sverdrup
836f32e769 Use vec![elt; n] where possible
The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is
exactly equivalent to `vec![elt; n]`, do this replacement in the whole
tree.

(Actually, vec![] is smart enough to only call clone n - 1 times, while
the former solution would call clone n times, and this fact is
virtually irrelevant in practice.)
2015-07-09 11:05:32 +02:00
Nick Cameron
374af4aea7 save-analysis: API-ify paths 2015-07-09 12:24:39 +12:00
Nick Cameron
84cb4ad969 Fix a bug where macros in expression position don't have expansion inidices in their spans 2015-07-09 12:24:39 +12:00
bors
20d23d8e57 Auto merge of #26347 - nagisa:macro-exp, r=nrc
r? @nrc, because breakage was caused by https://github.com/rust-lang/rust/pull/25318
2015-06-18 00:26:23 +00:00
Simonas Kazlauskas
09ed27c05e Remove superfluous variable 2015-06-16 22:29:41 +03:00
Simonas Kazlauskas
7ff55eaf25 Fix file!(), line!() and column!() macros
These used to return wrong results in case they were expanded inside compiler’s
iternal syntax sugar (closures, if-let) expansions

Fixes #26322
2015-06-16 21:47:09 +03:00
Markus Westerlind
34d5b5450c Replaced a comment mentioning a fixed issue
Replaced it with a comment mentioning the rationale for checking the discriminants first.
2015-06-14 18:27:05 +02:00
Markus
7721d46bd7 Utilize discriminant_value for more efficient deriving
The new code generated for deriving on enums looks something like this:

```rust
let __self0_vi = unsafe {
    std::intrinsics::discriminant_value(&self) } as i32;
let __self1_vi = unsafe {
    std::intrinsics::discriminant_value(&__arg1) } as i32;
let __self2_vi = unsafe {
    std::intrinsics::discriminant_value(&__arg2) } as i32;
///
if __self0_vi == __self1_vi && __self0_vi == __self2_vi && ... {
    match (...) {
        (Variant1, Variant1, ...) => Body1
        (Variant2, Variant2, ...) => Body2,
        ...
        _ => ::core::intrinsics::unreachable()
    }
}
else {
    ... // catch-all remainder can inspect above variant index values.
}
```
This helps massively for C-like enums since they will be compiled as a
single comparison giving observed speedups of up to 8x. For more complex
enums the speedup is more difficult to measure but it should not be
slower to generate code this way regardless.
2015-06-13 20:40:59 +02:00
Joshua Landau
d7f5fa4636 Conver reborrows to .iter() calls where appropriate 2015-06-11 13:56:07 +01:00