Commit Graph

52721 Commits

Author SHA1 Message Date
Jeffrey Seyfried
ac264196e2 Address style nits 2016-04-28 03:43:35 +00: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
James Miller
5bda576cd6 Factor out function call checking to a helper method
The logic for checking `call` and `invoke` instructions was duplicated
between them, so factor it out to a helper method.
2016-04-28 13:18:51 +12:00
James Miller
b5d7783546 Check when building invoke as well as calls
LLVM's assertion doesn't provide much insight as to what the problem
was. We were already checking `call` instructions ourselves, so this
brings the checks from there to `invoke`.

Both the `invoke` and `call` checking is controlled by
`debug_assertions`.
2016-04-28 13:18:51 +12:00
James Miller
3bcee269b5 Handle immediate tuples in trans_arguments_untupled
Use either getelementptr or extractvalue depending on whether or not the
tuple is immediate or not.
2016-04-28 13:18:51 +12:00
James Miller
0e3b37a52e Fix codegen-units tests
I'm not sure what the signficance of `drop-glue i8` is, nor why one of
the tests had it appear while the others had it disappear. Either way it
doesn't seem like the presence or absense of it is the focus of the
tests.
2016-04-28 13:18:51 +12:00
James Miller
c55d9e591b Move zero-sized type handling logic to new_operand
`new_operand` now checks the type it's given and either creates the nil
value itself, or produces an empty operand.
2016-04-28 13:18:51 +12:00
James Miller
89edd96be8 Fix translation of Assign/AssignOp as rvalues
In code like `let x = y = z;`, `y = z` goes through `as_rvalue`, which
didn't handle it. Now it translates the assignment and produces `()`
directly.
2016-04-28 13:18:51 +12:00
James Miller
869172305f Fixup tests
The drop glue for `i8` is no longer generated as a trans item
2016-04-28 13:18:51 +12:00
James Miller
c2de80f05f Address comments
Moves `stmt_expr` into its own module, `expr::stmt`.
2016-04-28 13:18:51 +12:00
James Miller
f242fe3c04 Various improvements to MIR and LLVM IR Construction
Primarily affects the MIR construction, which indirectly improves LLVM
IR generation, but some LLVM IR changes have been made too.

* Handle "statement expressions" more intelligently. These are
  expressions that always evaluate to `()`. Previously a temporary would
  be generated as a destination to translate into, which is unnecessary.

  This affects assignment, augmented assignment, `return`, `break` and
  `continue`.
* Avoid inserting drops for non-drop types in more places. Scheduled
  drops were already skipped for types that we knew wouldn't need
  dropping at construction time. However manually-inserted drops like
  those for `x` in `x = y;` were still generated. `build_drop` now takes
  a type parameter like its `schedule_drop` counterpart and checks to
  see if the type needs dropping.
* Avoid generating an extra temporary for an assignment where the types
  involved don't need dropping. Previously an expression like
  `a = b + 1;` would result in a temporary for `b + 1`. This is so the
  RHS can be evaluated, then the LHS evaluated and dropped and have
  everything work correctly. However, this isn't necessary if the `LHS`
  doesn't need a drop, as we can just overwrite the existing value.
* Improves lvalue analysis to allow treating an `Rvalue::Use` as an
  operand in certain conditions. The reason for it never being an
  operand is so it can be zeroed/drop-filled, but this is only true for
  types that need dropping.

The first two changes result in significantly fewer MIR blocks being
generated, as previously almost every statement would end up generating
a new block due to the drop of the `()` temporary being generated.
2016-04-28 13:17:43 +12:00
Jeffrey Seyfried
78a8127ff0 Add tests 2016-04-27 23:40:46 +00:00
bors
cda7c1cf24 Auto merge of #33199 - mitaa:tokenize-responsibly, r=nrc
Make some fatal lexer errors recoverable

I've kept the changes to a minimum since I'm not really sure if this approach is a acceptable.

fixes #12834

cc @nrc
2016-04-27 13:49:45 -07:00
mitaa
6887202ea3 Make some fatal lexer errors recoverable 2016-04-27 20:48:18 +02:00
Oliver Middleton
48aabbd9e3 rustdoc: Render extern fn instead of extern "C" fn 2016-04-27 18:43:51 +01:00
Nick Cameron
7ca2b9461f Review changes and satisfy make tidy 2016-04-28 05:24:54 +12:00
Alex Crichton
c31e2e77ed std: Add compatibility with android-9
The Gecko folks currently use Android API level 9 for their builds, so they're
requesting that we move back our minimum supported API level from 18 to 9. Turns
out, ABI-wise at least, there's not that many changes we need to take care of.
The `ftruncate64` API appeared in android-12 and the `log2` and `log2f` APIs
appeared in android-18. We can have a simple shim for `ftruncate64` which falls
back on `ftruncate` and the `log2` function can be approximated with just
`ln(f) / ln(2)`.

This should at least get the standard library building on API level 9, although
the tests aren't quite happening there just yet. As we seem to be growing a
number of Android compatibility shims, they're now centralized in a common
`sys::android` module.
2016-04-27 09:28:48 -07:00
bors
b52d76a085 Auto merge of #33214 - oli-obk:const_err_var_exprs, r=eddyb
report `const_err` on all expressions that can fail

also a drive-by fix for reporting an "overflow in shift *left*" when shifting an `i64` *right*

This increases the warning noise for shifting by more than the bitwidth and for `-T::MIN`. I can silence the bitwidth warnings explicitly and fix the const evaluator to make sure `--$expr` is treated exactly like `$expr` (which is kinda wrong, but mathematically right).

r? @eddyb
2016-04-27 04:00:16 -07:00
Tomáš Hübelbauer
e6b9760df2 Fix use of the move command in the Windows shell
`move` work both in `cmd` and in Powershell. `mv` works only in Powershell and the book says nothing about which shell is recommended so this could confuse beginners.

Closes #33219.
2016-04-27 10:56:35 +02:00
Adolfo Ochagavía
6c50c8877f rustc_driver: Allow running the compiler with a FileLoader 2016-04-27 10:51:55 +02:00
Oliver Schneider
5cdcad9d35 update Cargo.toml for rustbuild 2016-04-27 10:47:46 +02:00
Jeffrey Seyfried
6aa9145753 Avoid using the hir map when visibility checking in resolve
Refactor `ty::Visibility` methods to use a new trait `NodeIdTree` instead of the ast map.
2016-04-27 06:40:54 +00:00
Jeffrey Seyfried
33bb26998c Refactor away a use of ast_map.span_if_local() 2016-04-27 06:40:52 +00:00
bors
80bff1eea7 Auto merge of #33226 - fabricedesre:update-llvm, r=alexcrichton
Update llvm to 751345228a0ef03fd147394bb5104359b7a808be

Picking up the changes from 751345228a

r? @alexcrichton
2016-04-26 22:47:40 -07:00
Jeffrey Seyfried
3bcf818a8f Refactor resolve_crate_relative_path and resolve_module_relative_path
to return a `NameBinding` instead of a `Def`
2016-04-27 01:13:22 +00:00
Jeffrey Seyfried
6da115374f Refactor away get_trait_name 2016-04-27 01:13:22 +00:00
Jeffrey Seyfried
82e0dd5ac1 Refactor away is_static_method 2016-04-27 01:13:22 +00:00
Jeffrey Seyfried
2ccaeed50e Refactor away FallbackChecks and remove dead code 2016-04-27 01:13:21 +00:00
Jeffrey Seyfried
c9d8e1493c Refactor field span of NameBinding from Option<Span> to Span. 2016-04-27 01:13:15 +00:00
Fabrice Desré
1d2846dcda Update llvm to 751345228a0ef03fd147394bb5104359b7a808be 2016-04-26 17:03:14 -07:00
bors
8f55218189 Auto merge of #31414 - durka:clone-copy, r=alexcrichton
special-case #[derive(Copy, Clone)] with a shallow clone

If a type is Copy then its Clone implementation can be a no-op. Currently `#[derive(Clone)]` generates a deep clone anyway. This can lead to lots of code bloat.

This PR detects the case where Copy and Clone are both being derived (the general case of "is this type Copy" can't be determined by a syntax extension) and generates the shallow Clone impl. Right now this can only be done if there are no type parameters (see https://github.com/rust-lang/rust/issues/31085#issuecomment-178988663), but this restriction can be removed after specialization.

Fixes #31085.
2016-04-26 14:54:37 -07:00
bors
897199a0fb Auto merge of #33191 - alexcrichton:rustdoc-create-dir-all-racy, r=steveklabnik
rustdoc: Handle concurrent mkdir requests

It's likely that `rustdoc` as a tool is run concurrently in the same output
(e.g. documenting multiple crates as Cargo does), in which case it needs to
handle concurrent calls to `fs::create_dir`.
2016-04-26 12:00:35 -07:00
Alex Burka
9249e6a1e2 shallow Clone for #[derive(Copy,Clone)]
Changes #[derive(Copy, Clone)] to use a faster impl of Clone when
both derives are present, and there are no generics in the type.

The faster impl is simply returning *self (which works because the
type is also Copy). See the comments in libsyntax_ext/deriving/clone.rs
for more details.

There are a few types which are Copy but not Clone, in violation
of the definition of Copy. These include large arrays and tuples. The
very existence of these types is arguably a bug, but in order for this
optimization not to change the applicability of #[derive(Copy, Clone)],
the faster Clone impl also injects calls to a new function,
core::clone::assert_receiver_is_clone, to verify that all members are
actually Clone.

This is not a breaking change, because pursuant to RFC 1521, any type
that implements Copy should not do any observable work in its Clone
impl.
2016-04-26 13:49:29 -04:00
bors
01a0207919 Auto merge of #33142 - tshepang:split-long-line, r=guillaumegomez
doc: that line was too long
2016-04-26 09:04:27 -07:00
Kaiyin Zhong
10abb666e4 Update references-and-borrowing.md
add as 2nd example.
2016-04-26 17:40:59 +02:00
Oliver Schneider
6343f261f4 allow InternedString to be compared to &str directly 2016-04-26 16:27:10 +02:00
bors
092b0738b7 Auto merge of #33203 - Ryman:patch-3, r=alexcrichton
libstd: fix typos in thread::LocalKey docs
2016-04-26 06:57:03 -07:00
Oliver Schneider
d3c489c917 don't demote expressions just because const_eval fails
this might introduce subtle bugs to code generation
2016-04-26 15:32:18 +02:00
Oliver Schneider
9d7ed99c06 skip non-const-path errors for now
Associated constants aren't implemented fully in early const eval
2016-04-26 14:11:14 +02:00
Oliver Schneider
89d1046503 don't report bitshift overflow twice 2016-04-26 14:10:07 +02:00
Oliver Schneider
735c018974 skip double negation in const eval 2016-04-26 14:09:05 +02:00
bors
03bef4c43b Auto merge of #32989 - GuillaumeGomez:e0393, r=Manishearth
Add E0393 error explanation

Part of #32777.

r? @Manishearth
cc @steveklabnik
2016-04-26 04:51:08 -07:00
bors
81d070f582 Auto merge of #32962 - taralx:patch-1, r=GuillaumeGomez
Clean up some info log spam.

Some of this looks like merge cruft, but the region spam is especially noisy.
2016-04-26 02:42:52 -07:00
Oliver Schneider
3acee3b6c5 const_err lint all constant expressions 2016-04-26 11:18:48 +02:00
Oliver Schneider
ee983230c9 report shift right error instead of shift left error on right shift 2016-04-26 11:17:32 +02:00
Guillaume Gomez
d648fc6865 Add E0393 error explanation 2016-04-26 11:16:36 +02:00
Jeffrey Seyfried
c46164b626 Refactor away field vis of ModuleS 2016-04-26 09:01:24 +00:00
bors
769ac42c2e Auto merge of #33099 - eddyb:issue-33096, r=michaelwoerister
Normalize types before using them in debuginfo.

Small oversight, fixes #33096 - odd thing is that the old code doesn't look like it should've ever worked, although it wasn't using all of the type parameters, so maybe that's what changed.
2016-04-26 00:36:03 -07:00
York Xiang
93486180d9 Improve error message about regions of function body 2016-04-26 13:37:03 +08:00
bors
41028def11 Auto merge of #33204 - Manishearth:rollup, r=Manishearth
Rollup of 7 pull requests

- Successful merges: #33107, #33133, #33160, #33167, #33194, #33196, #33200
- Failed merges:
2016-04-25 22:26:56 -07:00