Commit Graph

53324 Commits

Author SHA1 Message Date
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
Alex Crichton
7f09b1f6a6 std: Allow creating ExitStatus from raw values
Sometimes a process may be waited on externally from the standard library, in
which case it can be useful to create a raw `ExitStatus` structure to return.
This commit extends the existing Unix `ExitStatusExt` extension trait and adds a
new Windows-specific `ExitStatusExt` extension trait to do this. The methods are
currently called `ExitStatus::from_raw`.

cc #32713
2016-04-26 23:35:59 -07: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
bors
8ce735858d Auto merge of #33210 - alexcrichton:fix-ndk-dir, r=alexcrichton
mk: Fix use of deprecated configure var

The `--android-cross-path` has been deprecated for some time now, we should use
`CFG_ARM_LINUX_ANDROIDEABI_NDK` instead.

Ideally this would use the right triple, but we're only testing ARM for now.
2016-04-25 18:48:05 -07:00
Alex Crichton
1fac8a4564 mk: Fix use of deprecated configure var
The `--android-cross-path` has been deprecated for some time now, we should use
`CFG_ARM_LINUX_ANDROIDEABI_NDK` instead.

Ideally this would use the right triple, but we're only testing ARM for now.
2016-04-25 18:35:58 -07:00
Nick Cameron
f7652bf809 save-analysis-json: lower def ids 2016-04-26 10:31:48 +12:00
Nick Cameron
e1d61cb637 save-analysis: expand smoke test to cover json and csv formats 2016-04-26 10:16:44 +12:00
Nick Cameron
5065f0c2a2 save-analysis-json: thread through -z option
In fact, we make JSOn the default and add an option for save-analysis-csv for the legacy behaviour.

We also rename some bits and pieces `dxr` -> `save-analysis`
2016-04-26 10:14:44 +12:00
Manish Goregaokar
3dc0b55a47 Rollup merge of #33200 - sfackler:nonblocking-docs, r=alexcrichton
Fix reference to TCP in UDP docs

Closees #33195
2016-04-26 01:44:52 +05:30