Commit Graph

56663 Commits

Author SHA1 Message Date
Jonathan Turner
965f50dad5 Rollup merge of #35980 - kyrias:E0094-underline, r=jonathandturner
Make E0094 underline better

r? @jonathandturner
2016-08-27 12:43:30 -07:00
Jonathan Turner
dc6ae4b669 Rollup merge of #35657 - ahmedcharles:e0389, r=jonathandturner
Update E0389 to the new format. #35630
2016-08-27 12:43:30 -07:00
bors
a23064af5e Auto merge of #35674 - ahmedcharles:rpass, r=alexcrichton
Fix compiletest so it respects warnings for run-pass.
2016-08-27 12:31:25 -07:00
Keith Yeung
4853456be0 Fix lifetime rules for 'if' conditions 2016-08-27 12:27:34 -07:00
Georg Brandl
a068fc70ab Doc: explain why Box/Rc/Arc methods do not take self
This can be confusing for newcomers, especially due to the argument
name "this".
2016-08-27 19:53:02 +02:00
Mikhail Modin
9c07ed2128 update error E0450 to new format 2016-08-27 19:39:22 +03:00
William Lee
eea03f5caa Fixes #35280 to update E0194 to support new error message format. Part of #35233. 2016-08-27 12:23:19 -04:00
bors
11946956a6 Auto merge of #35969 - bluss:memrchr-alignment, r=nagisa
memrchr: Correct aligned offset computation

The memrchr fallback did not compute the offset correctly. It was
intentioned to land on usize-aligned addresses but did not.
This was suspected to have resulted in a crash on ARMv7!

This bug affected non-linux platforms.

I think like this, if we have a slice with pointer `ptr` and length
`len`, we want to find the last usize-aligned offset in the slice.
The correct computation should be:

For example if ptr = 1 and len = 6, and `size_of::<usize>()` is 4:

```
[ x x x x x x ]
  1 2 3 4 5 6
        ^-- last aligned address at offset 3 from the start.
```

The last aligned address is ptr + len - (ptr + len) % usize_size.

Compute offset from the start as:

offset = len - (ptr + len) % usize_size = 6 - (1 + 6) % 4 = 6 - 3 = 3.

I believe the function's return value was always correct previously, if
the platform supported unaligned addresses.

Fixes #35967
2016-08-27 07:52:20 -07:00
Jonas Schievink
e468ede624 Fix the reproducible-build test 2016-08-27 15:20:45 +02:00
Jonas Schievink
dca01f9443 fix tidy 2016-08-27 15:20:45 +02:00
Jonas Schievink
2eeca3ccd2 Make metadata encoding deterministic
`ty::Predicate` was being used as a key for a hash map, but its hash
implementation indirectly hashed addresses, which vary between each
compiler run. This is fixed by sorting predicates by their ID before
encoding them.

In my tests, rustc is now able to produce deterministic results when
compiling libcore and libstd.

I've beefed up `run-make/reproducible-build` to compare the produced
artifacts bit-by-bit. This doesn't catch everything, but should be a
good start.

cc #34902
2016-08-27 15:20:45 +02:00
Jonas Schievink
5adf003b99 Use deterministic FnvHash{Map,Set} in rustdoc 2016-08-27 15:20:45 +02:00
Jonas Schievink
144e576c87 Use FnvHashMap in more places
* A step towards #34902
* More stable error messages in some places related to crate loading
* Possible slight performance improvements since all `HashMap`s
  replaced had small keys where `FnvHashMap` should be faster
  (although I didn't measure)
2016-08-27 15:20:45 +02:00
bors
099b9fdb1a Auto merge of #36030 - Manishearth:rollup, r=Manishearth
Rollup of 7 pull requests

- Successful merges: #35124, #35877, #35953, #36002, #36004, #36005, #36014
- Failed merges:
2016-08-27 03:07:48 -07:00
Manish Goregaokar
668d63132e
Fixup rustbuild on #35124 2016-08-27 15:40:25 +05:30
bors
6b74503aa4 Auto 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-26 23:57:17 -07:00
Jorge Aparicio
43615a03f3 fix cross compilation of std 2016-08-27 01:40:29 -05:00
Jorge Aparicio
1b9e9ab1dc update libc 2016-08-27 01:40:24 -05:00
Eduard Burtescu
3e313d9528 rustc_trans: don't round up the DST prefix size to its alignment. 2016-08-27 08:51:55 +03:00
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
Jorge Aparicio
027eab2f87 initial support for s390x
A new target, `s390x-unknown-linux-gnu`, has been added to the compiler
and can be used to build no_core/no_std Rust programs.

Known limitations:

- librustc_trans/cabi_s390x.rs is missing. This means no support for
  `extern "C" fn`.
- No support for this arch in libc. This means std can be cross compiled
  for this target.
2016-08-26 21:05:50 -05:00
bors
b7e2157dba Auto merge of #35542 - scottcarr:visitor_refactor, r=nikomatsakis
[MIR] track Location in MirVisitor, combine Location

All the users of MirVisitor::visit_statement implement their own statement index tracking.  This PR move the tracking into MirVisitor itself.

Also, there were 2 separate implementations of Location that were identical.  This PR eliminates one of them.
2016-08-26 19:05:11 -07:00
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
Jorge Aparicio
6a5bdb78f1 add mips64-gnu and mips64el-gnu targets
With this commit one can build no_core (and probably no_std as well)
Rust programs for these targets. It's not yet possible to cross compile
std for these targets because rust-lang/libc doesn't know about the
mips64 architecture.

These targets have been tested by cross compiling the "smallest hello"
program (see code below) and then running it under QEMU.

``` rust
#![feature(start)]
#![feature(lang_items)]
#![feature(no_core)]
#![no_core]

#[link(name = "c")]
extern {
    fn puts(_: *const u8);
}

#[start]
fn start(_: isize, _: *const *const u8) -> isize {
    unsafe {
        let msg = b"Hello, world!\0";
        puts(msg as *const _ as *const u8);
    }
    0
}

#[lang = "copy"]
trait Copy {}

#[lang = "sized"]
trait Sized {}
```
2016-08-26 17:17:03 -05: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
Scott A Carr
c043a27e42 fix port for visit_statement 2016-08-26 15:39:16 -04:00
Matthew Piziak
e2d9974b3b improve BitAnd trait documentation
This pull request is based on the discussion in PR #35927.

Add a module-level note that `&&` and `||` are short-circuiting operators and not overloadable.

Add a simple `Scalar` example that lifts the `&` operator to a trivial struct tuple.

Make `BooleanVector` a struct tuple.

Derive `PartialEq` for `BooleanVector` instead of implementing it.

Adds a `fn main` wrapper so that the example can integrate with Rust Playground.

simplified bitand expression

add a comment explaining what "rhs" means
2016-08-26 13:02:25 -04:00
Matthew Piziak
50e0fbc904 accumulate vector and assert for RangeFrom and RangeInclusive examples
PR #35695 for `Range` was approved, so it seems that this side-effect-free style is preferred for Range* examples. This PR performs the same translation for `RangeFrom` and `RangeInclusive`. It also removes what looks to be an erroneously commented line for `#![feature(step_by)]`, and an unnecessary primitive-type annotation in `0u8..`.

add `fn main` wrappers to enable Rust Playground "Run" button
2016-08-26 11:54:32 -04:00
Guillaume Gomez
3e1b33dbdd Add new error code tests 2016-08-26 17:28:50 +02:00
Guillaume Gomez
a9907a1dd1 Small error code explanations improvements 2016-08-26 17:28:47 +02: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
Mohit Agarwal
88e4def9c7
Update E0453 to new error format
Fixes #35929.
Part of #35233.

r? @jonathandturner
2016-08-26 07:59:20 +05:30
changchun.fan
f4c55dd08f Fix documentation in cell mod 2016-08-26 09:13:59 +08: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
Guillaume Gomez
aeedf22880 Add E0525 error explanation 2016-08-26 00:13:48 +02:00
Jeffrey Seyfried
469753f0ab Fix fallout in tests. 2016-08-25 20:41:41 +00:00
Jeffrey Seyfried
bfb01bbb26 Refactor away AttrMetaMethods. 2016-08-25 20:41:40 +00:00