Commit Graph

56242 Commits

Author SHA1 Message Date
Manish Goregaokar
2b3921e0c3 Rollup merge of #36014 - slash3g:stabilize-type-macros, r=nikomatsakis
Stabilize type-macros

Closes #27245

r? @nikomatsakis
2016-08-27 09:31:15 +05:30
Manish Goregaokar
30835ec4e4 Rollup merge of #36005 - apasel422:traitobj, r=alexcrichton
Replace unnecessary uses of `TraitObject` with casts

r? @alexcrichton
2016-08-27 09:31:15 +05:30
Manish Goregaokar
933d481bdd Rollup merge of #36004 - petrochenkov:hashloan, r=arielb1
rustc_borrowck: Don't hash types in loan paths

1) Types for equal loan paths are not always equal, they can sometimes differ in lifetimes, making equal loan paths hash differently.

Example:
71bdeea561/src/libcollections/linked_list.rs (L835-L856)

One of `self.list`s has type
```
&ReFree(CodeExtent(15013/CallSiteScope { fn_id: 18907, body_id: 18912 }), BrNamed(0:DefIndex(3066), 'a(397), WontChange)) mut linked_list::LinkedList<T>
```
and other has type
```
&ReScope(CodeExtent(15018/Remainder(BlockRemainder { block: 18912, first_statement_index: 0 }))) mut linked_list::LinkedList<T>
```
(... but I'm not sure it's not a bug actually.)

2) Not hashing types is faster than hashing types.

r? @arielb1
2016-08-27 09:31:15 +05:30
Manish Goregaokar
7a2a381e0e Rollup merge of #36002 - eddyb:abstract-kindness, r=nikomatsakis
Combine types and regions in Substs into one interleaved list.

Previously, `Substs` would contain types and regions, in two separate vectors, for example:
```rust
<X as Trait<'a, 'b, A, B>>::method::<'p, 'q, T, U>
/* corresponds to */
Substs { regions: ['a, 'b, 'p, 'q], types: [X, A, B, T, U] }
```

This PR continues the work started in #35605 by further removing the distinction.
A new abstraction over types and regions is introduced in the compiler, `Kind`.
Each `Kind` is a pointer (`&TyS` or `&Region`), with the lowest two bits used as a tag.
Two bits were used instead of just one (type = `0`, region = `1`) to allow adding more kinds.

`Substs` contain only a `Vec<Kind>`, with `Self` first, followed by regions and types (in the definition order):
```rust
Substs { params: [X, 'a, 'b, A, B, 'p, 'q, T, U] }
```
The resulting interleaved list has the property of being the concatenation of parameters for the (potentially) nested generic items it describes, and can be sliced back into those components:
```rust
params[0..5] = [X, 'a, 'b, A, B] // <X as Trait<'a, 'b, A, B>>
params[5..9] = ['p, 'q, T, U] // <_>::method::<'p, 'q, T, U>
```

r? @nikomatsakis
2016-08-27 09:31:14 +05:30
Manish Goregaokar
1385feb5ee Rollup merge of #35953 - Aatch:better-missing-block-error, r=nrc
Improve error message when failing to parse a block

We want to catch this error:

```
if (foo)
    bar;
```

as it's valid syntax in other languages, and say how to fix it.
Unfortunately it didn't care if the suggestion made sense and just
highlighted the unexpected token.

Now it attempts to parse a statement, and if it succeeds, it shows the
help message.

Fixes #35907
2016-08-27 09:31:14 +05:30
Manish Goregaokar
b5969ca318 Rollup merge of #35877 - KiChjang:issue-35869, r=arielb1
Fix ICE when arg types can't be found in impl/trait methods while comparing

Fixes #35869.
2016-08-27 09:31:14 +05:30
Manish Goregaokar
e8da947263 Rollup merge of #35124 - steveklabnik:remove_style, r=aturon
Remove style guide.

We originally imported this into the repository with the intent of
fixing it up. Instead, nothing happened.

Its appearance on rust-lang.org makes it seem semi-official, but it's
not. The rustfmt strike team will end up producing something like this
anyway, and leaving it around does nothing but mislead people.

r? @aturon
2016-08-27 09:31:14 +05:30
bors
1987131063 Auto merge of #36008 - eddyb:compound-fail, r=michaelwoerister
Do not emit "class method" debuginfo for types that are not DICompositeType.

Fixes #35991 by restricting the "class method" debuginfo sugar from #33358 to structs and enums only.

r? @michaelwoerister
2016-08-26 15:18:03 -07:00
Eduard Burtescu
7a8d4822d8 rustc: use Vec<Kind> in Substs, where Kind is a &TyS | &Region tagged pointer. 2016-08-27 01:15:07 +03:00
Eduard Burtescu
dffd238f8b rustc: pass ty::Region behind an interned 'tcx reference. 2016-08-27 01:15:06 +03:00
Eduard Burtescu
5222fa58a1 rustc: use accessors for Substs::{types,regions}. 2016-08-27 00:25:04 +03:00
Daniele Baracchi
ee055a1ff3
Stabilize type-macros
Closes #27245
2016-08-26 17:27:20 +02:00
Andrew Paseltiner
2b10df7f24
Replace unnecessary uses of TraitObject with casts 2016-08-26 06:37:36 -04:00
bors
d00c245415 Auto merge of #35975 - jonathandturner:error_buffering, r=alexcrichton
Buffer unix and lock windows to prevent message interleaving

When cargo does a build on multiple processes, multiple crates may error at the same time.  If this happens, currently you'll see interleaving of the error messages, which makes for an unreadable message.

Example:

```
    --> --> src/bin/multithread-unix.rs:16:35src/bin/singlethread.rs:16:24

      ||

1616  | |     Server::new(&addr).workers(8).    Server::new(&addr).serveserve(|r: Request| {(|r: Request| {

      | |                                                          ^^^^^^^^^^ expected struct `std::io::Error`, found () expected struct `std::io::Error`, found ()

      ||

      = = notenote: expected type `std::io::Error`: expected type `std::io::Error`

      = = notenote:    found type `()`:    found type `()`

      = = notenote: required because of the requirements on the impl of `futures_minihttp::Service<futures_minihttp::Request, futures_minihttp::Response>` for `[closure@src/bin/multithread-unix.rs:16:41: 22:6]`: required because of the requirements on the impl of `futures_minihttp::Service<futures_minihttp::Request, futures_minihttp::Response>` for `[closure@src/bin/singlethread.rs:16:30: 22:6]`

error: aborting due to previous error

error: aborting due to previous error
```

This patch uses two techniques to prevent this interleaving.  On Unix systems, since they use the text-based ANSI protocol for coloring, we can safely buffer up whole messages before we emit.  This PR does this buffering, and emits the whole message at once.

On Windows, term must use the Windows terminal API to color the output.  This disallows us from using the same buffering technique.  Instead, here we grab a Windows mutex (thanks to @alexcrichton for the lock code).  This lock only works in Windows and will hold a mutex for the duration of a message output.

r? @nikomatsakis
2016-08-26 03:29:45 -07:00
Eduard Burtescu
8407952346 Do not emit "class method" debuginfo for types that are not DICompositeType. 2016-08-26 07:39:17 +03:00
bors
eaf71f8d10 Auto merge of #35906 - jseyfried:local_prelude, r=eddyb
Use `#[prelude_import]` in `libcore` and `libstd`

r? @eddyb
2016-08-25 20:45:32 -07:00
bors
e07dd59eae Auto merge of #35885 - durka:gh35753, r=arielb1
modify fds-are-cloexec test to open a file that exists

Fixes #35753.

Is it a valid assumption that the current directory is always the root of the repo when the tests are run?

r? @nagisa
2016-08-25 15:44:22 -07:00
Vadim Petrochenkov
14b4d72e01 rustc_borrowck: Don't hash types in loan paths 2016-08-26 01:15:45 +03:00
Jonathan Turner
a65b201d94 prevent error message interleaving on win/unix 2016-08-25 13:28:35 -07:00
Steve Klabnik
57719e2d73 Also remove build steps for style 2016-08-25 15:22:57 -04:00
Steve Klabnik
00d4a43d84 Remove style guide.
We originally imported this into the repository with the intent of
fixing it up. Instead, nothing happened.

Its appearance on rust-lang.org makes it seem semi-official, but it's
not. The rustfmt strike team will end up producing something like this
anyway, and leaving it around does nothing but mislead people.
2016-08-25 15:22:12 -04:00
bors
71bdeea561 Auto merge of #34923 - eddyb:deny-fn-item-transmute, r=nikomatsakis
Deny (by default) transmuting from fn item types to pointer-sized types.

This sets the #19925 lint (transmute from zero-sized fn item type) to `deny` by default.
Technically a `[breaking-change]`, but will not affect dependent crates because of `--cap-lints`.
2016-08-25 11:28:30 -07:00
Alex Burka
b2cd3e59b8 use file!() even though it shouldn't be necessary 2016-08-25 12:39:25 -04:00
bors
528c6f3ed6 Auto merge of #35884 - habnabit:freebsd-arc4rand, r=alexcrichton
Use arc4rand(9) on FreeBSD

From rust-lang-nursery/rand#112:

>After reading through #30691 it seems that there's general agreement that using OS-provided facilities for seeding rust userland processes is fine as long as it doesn't use too much from libc. FreeBSD's `arc4random_buf(3)` is not only a whole lot of libc code, but also not even currently exposed in the libc crate. Fortunately, the mechanism `arc4random_buf(3)` et al. use for getting entropy from the kernel ([`arc4rand(9)`](https://www.freebsd.org/cgi/man.cgi?query=arc4random&apropos=0&sektion=9&manpath=FreeBSD+10.3-RELEASE&arch=default&format=html)) is exposed via `sysctl(3)` with constants that are already in the libc crate.

>I haven't found too much documentation on `KERN_ARND`—it's missing or only briefly described in most of the places that cover sysctl mibs. But, from digging through the kernel source, it appears that the sysctl used in this PR is very close to just calling `arc4rand(9)` directly (with `reseed` set to 0 and no way to change it).

I expected [rand](/rust-lang-nursery/rand) to reply quicker, so I tried submitting it there first. It's been a few weeks with no comment, so I don't know the state of it, but maybe someone will see it here and have an opinion. This is basically the same patch. It pains me to duplicate the code but I guess it hasn't been factored out into just one place yet.
2016-08-25 08:32:19 -07:00
bors
17a2be8c35 Auto merge of #35979 - Manishearth:rollup, r=Manishearth
Rollup of 6 pull requests

- Successful merges: #35238, #35867, #35885, #35916, #35947, #35955
- Failed merges:
2016-08-25 04:35:52 -07:00
Manish Goregaokar
cf597ab2ba Rollup merge of #35955 - frewsxcv:idiomatic-methods, r=eddyb
Use idiomatic names for string-related methods names.

None
2016-08-25 17:08:01 +05:30
Manish Goregaokar
5deee46e25 Rollup merge of #35947 - SimonSapin:decodeutf8-error-handling, r=alexcrichton
Yield Err in char::decode_utf8 per Unicode, like String::from_utf8_lossy

r? @alexcrichton
2016-08-25 17:08:01 +05:30
Manish Goregaokar
7963bbb084 Rollup merge of #35916 - eddyb:mir-no-dead-allocas, r=Aatch
rustc_trans: do not generate allocas for unused locals.

This fixes a regression observed in a [`mio` test](https://travis-ci.org/carllerche/mio/jobs/152142886) which was referencing a 4MB `const` array.
Even though MIR rvalue promotion would promote the borrow of the array, a dead temp was left behind.
As the array doesn't have an immediate type, an `alloca` was generated for it, even though it had no uses.

The fix is pretty dumb: assume that locals need to be borrowed or assigned before being used.
And if it can't be used, it doesn't get an `alloca`, even if the type would otherwise demand it.
This could change in the future, but all the MIR we generate now doesn't break that rule.
2016-08-25 17:08:00 +05:30
Manish Goregaokar
5e69622e0e Rollup merge of #35867 - frewsxcv:rustdoc-cleanup, r=alexcrichton
Various refactorings in the rustdoc module.

None
2016-08-25 17:08:00 +05:30
Manish Goregaokar
e0e1954bdc Rollup merge of #35238 - vadimcn:macro-debug-locs, r=michaelwoerister
Fix debug line number info for macro expansions.

Macro expansions result in code tagged with completely different debug locations than the surrounding expressions.  This wrecks havoc on debugger's ability the step over source lines.
This change fixes the problem by tagging expanded code as "inlined" at the macro expansion site, which allows the debugger to sort it out.
Note that only the outermost expansion is currently handled, stepping into a macro will still result in stepping craziness.

r? @eddyb
2016-08-25 17:07:59 +05:30
Vadim Chugunov
cf6461168f Fix debug line info for macro expansions.
Macro expansions produce code tagged with debug locations that are completely different from the surrounding expressions.  This wrecks havoc on debugger's ability the step over source lines.

In order to have a good line stepping behavior in debugger, we overwrite debug locations of macro expansions with that of the outermost expansion site.
2016-08-25 00:40:42 -07:00
Corey Farwell
42e8ac87eb Implement From<ast::FloatTy> for PrimitiveType. 2016-08-24 23:27:25 -07:00
Corey Farwell
168cfea8af Implement From<ast::UintTy> for PrimitiveType. 2016-08-24 23:27:25 -07:00
Corey Farwell
8a6f7a5ced Implement From<ast::IntTy> for PrimitiveType. 2016-08-24 23:27:25 -07:00
Corey Farwell
5c849f4a50 Remove unnecessary 'Primitive' prefix on PrimitiveType enum variants. 2016-08-24 23:27:25 -07:00
Corey Farwell
9dde563990 Stop reexporting PrimitiveType enum in librustdoc. 2016-08-24 23:27:24 -07:00
Corey Farwell
0c9ff54139 Migrate ItemType::from_type_kind to convert::From. 2016-08-24 23:25:26 -07:00
Corey Farwell
30397aee0d Migrate ItemType::from_item to convert::From. 2016-08-24 23:25:26 -07:00
Corey Farwell
7dc411667a Migrate Context::maybe_ignore_item method to standalone function.
The method wasn't using any `self` data from Context, so it seemed
miseading to implement it as a method.
2016-08-24 23:25:26 -07:00
Corey Farwell
28ecfb691d Move ItemEnum → Generics logic into method on ItemEnum. 2016-08-24 23:25:26 -07:00
bors
f5499a001d Auto merge of #35814 - alexcrichton:armv7-no-neon, r=brson
rustc: Don't enable NEON by default on armv7 Linux

One of the primary platforms for the `armv7-unknown-linux-gnueabihf` target,
Linux distributions, do not enable NEON extensions by default. This PR disables
that feature by defualt but enables the `d16` feature which enables VFP3D16 that
distributions do enable.

Closes #35590
2016-08-24 23:05:47 -07:00
bors
0ccd5c802b Auto merge of #35971 - jonathandturner:rollup, r=jonathandturner
Rollup of 4 pull requests

- Successful merges: #35876, #35920, #35948, #35961
- Failed merges: #35395
2016-08-24 18:42:24 -07:00
Jeffrey Seyfried
a9a2979dba Remove needless imports in libcollections. 2016-08-24 22:13:13 +00:00
Jeffrey Seyfried
9a2c8783d9 Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
Jeffrey Seyfried
e2ad3be178 Use #[prelude_import] in libcore. 2016-08-24 22:12:23 +00:00
bors
e9bc1bac8c Auto merge of #35764 - eddyb:byegone, r=nikomatsakis
Remove the old AST-based backend from rustc_trans.

Starting with Rust 1.13, `--disable-orbit` , `-Z orbit=off` and `#[rustc_no_mir]` have been removed.
Only the new MIR backend is left in the compiler, and only early const_eval uses ASTs from other crates.

Filling drop (previously "zeroing drop"), `#[unsafe_no_drop_flag]` and associated unstable APIs are gone.
Implementing `Drop` doesn't add a flag anymore to the type, all of the dynamic drop is function local.
This is a [breaking-change], please use `Option::None` and/or `mem::forget` if you are unsure about your ability to prevent/control the drop of a value. In the future, `union` will be usable in some such cases.

**NOTE**: DO NOT MERGE before we get the new beta as the stage0, there's some cruft to remove.

All of this will massively simplify any efforts to implement (and as such it blocks) features such as `union`s, safe use of `#[packed]` or new type layout optimizations, not to mention many other experiments.
2016-08-24 14:57:34 -07:00
Keith Yeung
3d9cf30ddf More robust testing 2016-08-24 11:48:53 -07:00
Keith Yeung
07e6e81e08 Extract error reporting into its own fn 2016-08-24 11:48:48 -07:00
Jonathan Turner
2932db19b5 Rollup merge of #35961 - 0xmohit:pr/error-codes-E0445-E0454, r=GuillaumeGomez
Update E0445 and E0454 to new error format

Fixes #35922.
Fixes #35930.
Part of #35233.

r? @GuillaumeGomez
2016-08-24 10:35:29 -07:00
Jonathan Turner
411a85e271 Rollup merge of #35948 - tshepang:missing-comma, r=steveklabnik
reference: add trailing commas
2016-08-24 10:35:29 -07:00