]> git.lizzy.rs Git - rust.git/log
rust.git
8 years agoAuto merge of #32496 - Manishearth:rollup, r=Manishearth
bors [Sat, 26 Mar 2016 08:13:31 +0000 (01:13 -0700)]
Auto merge of #32496 - Manishearth:rollup, r=Manishearth

Rollup of 11 pull requests

- Successful merges: #32131, #32199, #32257, #32325, #32435, #32447, #32448, #32456, #32469, #32476, #32482
- Failed merges: #32240

8 years agoFixup #32476
Manish Goregaokar [Sat, 26 Mar 2016 05:55:54 +0000 (11:25 +0530)]
Fixup #32476

8 years agoRollup merge of #32482 - nikomatsakis:erase-via-visitor, r=nagisa
Manish Goregaokar [Sat, 26 Mar 2016 03:37:22 +0000 (09:07 +0530)]
Rollup merge of #32482 - nikomatsakis:erase-via-visitor, r=nagisa

use new visitor to erase regions

r? @nagisa

8 years agoRollup merge of #32476 - diwic:63-null-thread-name, r=alexcrichton
Manish Goregaokar [Sat, 26 Mar 2016 03:37:22 +0000 (09:07 +0530)]
Rollup merge of #32476 - diwic:63-null-thread-name, r=alexcrichton

Fix unsound behaviour with null characters in thread names (issue #32475)

Previously, the thread name (&str) was converted to a CString in the
new thread, but outside unwind::try, causing a panic to continue into FFI.

This patch changes that behaviour, so that the panic instead happens
in the parent thread (where panic infrastructure is properly set up),
not the new thread.

This could potentially be a breaking change for architectures who don't
support thread names.

8 years agoRollup merge of #32469 - nikomatsakis:shared-cgu, r=eddyb
Manish Goregaokar [Sat, 26 Mar 2016 03:37:22 +0000 (09:07 +0530)]
Rollup merge of #32469 - nikomatsakis:shared-cgu, r=eddyb

make available monomorphizations shared by CGU

The current setup means that all generics are local to a codegen-unit,
which means massive duplication.

8 years agoRollup merge of #32456 - bluss:str-zero, r=alexcrichton
Manish Goregaokar [Sat, 26 Mar 2016 03:37:22 +0000 (09:07 +0530)]
Rollup merge of #32456 - bluss:str-zero, r=alexcrichton

Hardcode accepting 0 as a valid str char boundary

If we check explicitly for index == 0, that removes the need to read the
byte at index 0, so it avoids a trip to the string's memory, and it
optimizes out the slicing index' bounds check whenever it is (a constant) zero.

8 years agoRollup merge of #32448 - sfackler:time-augmented-assignment, r=alexcrichton
Manish Goregaokar [Sat, 26 Mar 2016 03:37:22 +0000 (09:07 +0530)]
Rollup merge of #32448 - sfackler:time-augmented-assignment, r=alexcrichton

Add augmented assignment operator impls for time types

r? @alexcrichton

8 years agoRollup merge of #32447 - nodakai:dots-in-err-idx, r=Manishearth
Manish Goregaokar [Sat, 26 Mar 2016 03:37:21 +0000 (09:07 +0530)]
Rollup merge of #32447 - nodakai:dots-in-err-idx, r=Manishearth

Remove ungrammatical dots from the error index.

They were probably meant as a shorthand for omitted code.

Part of #32446 but there should be a separate fix for the issue.

8 years agoRollup merge of #32435 - nrc:fix-err-recover, r=nikomatsakis
Manish Goregaokar [Sat, 26 Mar 2016 03:37:21 +0000 (09:07 +0530)]
Rollup merge of #32435 - nrc:fix-err-recover, r=nikomatsakis

Some fixes for error recovery in the compiler

8 years agoRollup merge of #32257 - alexcrichton:fix-status-stdin, r=aturon
Manish Goregaokar [Sat, 26 Mar 2016 03:37:21 +0000 (09:07 +0530)]
Rollup merge of #32257 - alexcrichton:fix-status-stdin, r=aturon

std: Fix inheriting stdin on status()

This regression was accidentally introduced in #31618, and it's just flipping a
boolean!

Closes #32254

8 years agoRollup merge of #32199 - nikomatsakis:limiting-constants-in-patterns-2, r=pnkfelix
Manish Goregaokar [Sat, 26 Mar 2016 03:37:21 +0000 (09:07 +0530)]
Rollup merge of #32199 - nikomatsakis:limiting-constants-in-patterns-2, r=pnkfelix

Restrict constants in patterns

This implements [RFC 1445](https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md). The primary change is to limit the types of constants used in patterns to those that *derive* `Eq` (note that implementing `Eq` is not sufficient). This has two main effects:

1. Floating point constants are linted, and will eventually be disallowed. This is because floating point constants do not implement `Eq` but only `PartialEq`. This check replaces the existing special case code that aimed to detect the use of `NaN`.
2. Structs and enums must derive `Eq` to be usable within a match.

This is a [breaking-change]: if you encounter a problem, you are most likely using a constant in an expression where the type of the constant is some struct that does not currently implement
`Eq`. Something like the following:

```rust
struct SomeType { ... }
const SOME_CONST: SomeType = ...;

match foo {
    SOME_CONST => ...
}
```

The easiest and most future compatible fix is to annotate the type in question with `#[derive(Eq)]` (note that merely *implementing* `Eq` is not enough, it must be *derived*):

```rust
struct SomeType { ... }
const SOME_CONST: SomeType = ...;

match foo {
    SOME_CONST => ...
}
```

Another good option is to rewrite the match arm to use an `if` condition (this is also particularly good for floating point types, which implement `PartialEq` but not `Eq`):

```rust
match foo {
    c if c == SOME_CONST => ...
}
```

Finally, a third alternative is to tag the type with `#[structural_match]`; but this is not recommended, as the attribute is never expected to be stabilized. Please see RFC #1445 for more details.

cc https://github.com/rust-lang/rust/issues/31434

r? @pnkfelix

8 years agoRollup merge of #32131 - petrochenkov:prim, r=eddyb
Manish Goregaokar [Sat, 26 Mar 2016 03:37:20 +0000 (09:07 +0530)]
Rollup merge of #32131 - petrochenkov:prim, r=eddyb

resolve: Minimize hacks in name resolution of primitive types

When resolving the first unqualified segment in a path with `n` segments and `n - 1` associated item segments, e.g. (`a` or `a::assoc` or `a::assoc::assoc` etc) try to resolve `a` without considering primitive types first. If the "normal" lookup fails or results in a module, then try to resolve `a` as a primitive type as a fallback.

This way backward compatibility is respected, but the restriction from E0317 can be lifted, i.e. primitive names mostly can be shadowed like any other names.

Furthermore, if names of primitive types are [put into prelude](https://github.com/petrochenkov/rust/tree/prim2) (now it's possible to do), then most of names will be resolved in conventional way and amount of code relying on this fallback will be greatly reduced. Although, it's not entirely convenient to put them into prelude right now due to temporary conflicts like `use prelude::v1::*; use usize;` in libcore/libstd, I'd better wait for proper glob shadowing before doing it.
I wish the `no_prelude` attribute were unstable as intended :(

cc @jseyfried @arielb1
r? @eddyb

8 years agoAuto merge of #32293 - nikomatsakis:incr-comp-def-path-munging, r=alexcrichton
bors [Sat, 26 Mar 2016 01:09:28 +0000 (18:09 -0700)]
Auto merge of #32293 - nikomatsakis:incr-comp-def-path-munging, r=alexcrichton

Revamp symbol names for impls (and make them deterministic, etc)

This builds on @michaelwoerister's epic PR #31539 (note that his PR never landed, so I just incorporated it into this one). The main change here is that we remove the "name" from `DefPathData` for impls, since that name is synthetic and not sufficiently predictable for incr comp. However, just doing that would cause bad symbol names since those are based on the `DefPath`. Therefore, I introduce a new mechanism for getting symbol names (and also paths for user display) called `item_path`. This is kind of simplistic for now (based on strings) but I expect to expand it later to support richer types, hopefully generating C++-mangled names that gdb etc can understand. Along the way I cleaned up how we track the path that leads to an extern crate.

There is still some cleanup left undone here. Notably, I didn't remove the impl names altogether -- that would probably make sense. I also didn't try to remove the `item_symbols` vector. Mostly I want to unblock my other incr. comp. work. =)

r? @eddyb
cc @eddyb @alexcrichton @michaelwoerister

8 years agoremove link-guard test
Niko Matsakis [Fri, 25 Mar 2016 23:33:13 +0000 (19:33 -0400)]
remove link-guard test

8 years agoAuto merge of #32167 - jseyfried:refactor_prelude, r=nikomatsakis
bors [Fri, 25 Mar 2016 22:53:16 +0000 (15:53 -0700)]
Auto merge of #32167 - jseyfried:refactor_prelude, r=nikomatsakis

resolve: Refactor how the prelude is handled

This PR refactors how the prelude is handled in `resolve`.

Instead of importing names from the prelude into each module's `resolutions`, this PR adds a new field `prelude: RefCell<Option<Module>>` to `ModuleS` that is set during import resolution but used only when resolving in a lexical scope (i.e. the scope of an initial segment of a relative path).

r? @nikomatsakis

8 years agoAdd and use `resolve_name_in_lexical_scope` and
Jeffrey Seyfried [Wed, 9 Mar 2016 04:21:54 +0000 (04:21 +0000)]
Add and use `resolve_name_in_lexical_scope` and
exclude the prelude from `resolve_name(.., allow_private_imports = true)`.

8 years agoRefactor away `NameResolution::result`
Jeffrey Seyfried [Wed, 9 Mar 2016 04:51:33 +0000 (04:51 +0000)]
Refactor away `NameResolution::result`

8 years agoRefactor away DefModifiers::PRELUDE
Jeffrey Seyfried [Wed, 9 Mar 2016 01:55:21 +0000 (01:55 +0000)]
Refactor away DefModifiers::PRELUDE

8 years agoRefactor how the prelude is handled
Jeffrey Seyfried [Wed, 9 Mar 2016 01:46:46 +0000 (01:46 +0000)]
Refactor how the prelude is handled

8 years agoRefactor away resolve_imports::Shadowable and rename shadowable -> is_prelude
Jeffrey Seyfried [Tue, 1 Mar 2016 01:43:10 +0000 (01:43 +0000)]
Refactor away resolve_imports::Shadowable and rename shadowable -> is_prelude

8 years agochange test to be specific for msvc
Niko Matsakis [Fri, 25 Mar 2016 21:33:17 +0000 (17:33 -0400)]
change test to be specific for msvc

8 years agofix error message
Niko Matsakis [Fri, 25 Mar 2016 19:14:45 +0000 (15:14 -0400)]
fix error message

8 years agofix cargo.toml for new dependency
Niko Matsakis [Fri, 25 Mar 2016 18:39:24 +0000 (14:39 -0400)]
fix cargo.toml for new dependency

8 years agoRebase over my PR
Niko Matsakis [Fri, 25 Mar 2016 18:36:49 +0000 (14:36 -0400)]
Rebase over my PR

8 years agoUpdate backtrace test for FIXME on windows
Niko Matsakis [Fri, 25 Mar 2016 16:48:47 +0000 (12:48 -0400)]
Update backtrace test for FIXME on windows

8 years agoDrive-by fix for unnecessary `&mut`
Niko Matsakis [Fri, 25 Mar 2016 16:48:30 +0000 (12:48 -0400)]
Drive-by fix for unnecessary `&mut`

8 years agodocument test, don't use grep
Niko Matsakis [Thu, 24 Mar 2016 17:24:04 +0000 (13:24 -0400)]
document test, don't use grep

8 years agotest for immediate symbol name hashing
Niko Matsakis [Thu, 24 Mar 2016 17:20:08 +0000 (13:20 -0400)]
test for immediate symbol name hashing

8 years agoinclude the immediate type in the symbol name hash
Niko Matsakis [Thu, 24 Mar 2016 17:19:36 +0000 (13:19 -0400)]
include the immediate type in the symbol name hash

the intention is to give some simple protection like link-guards
but not impede ability to upgrade dylib in place

8 years agoRevert "workarounds to make link guards work on windows"
Niko Matsakis [Thu, 24 Mar 2016 14:03:50 +0000 (10:03 -0400)]
Revert "workarounds to make link guards work on windows"

This reverts commit b52004d202ddfffa100d4963216e1673a0be0b95.

8 years agorip out link guards
Niko Matsakis [Thu, 24 Mar 2016 14:03:22 +0000 (10:03 -0400)]
rip out link guards

As discussed in
https://github.com/rust-lang/rust/pull/32293#issuecomment-200597130,
adding link guards are a heuristic that is causing undue complications:

- the link guards inject extra public symbols, which is not always OK.
- link guards as implemented could be a non-trivial performance hit,
  because no attempt is made to "de-duplicate" the dependency graph,
  so at worst you have O(N!) calls to the link guard functions.

Nonetheless, link guards are very helpful in detecting errors, so it may
be worth adding them back in some modified form in the future.

8 years agoworkarounds to make link guards work on windows
Niko Matsakis [Wed, 23 Mar 2016 00:32:08 +0000 (20:32 -0400)]
workarounds to make link guards work on windows

Link guards cause problems in some specific scenarios on windows because
they force libcore to be instantiated, since we do not GC functions
effectively on windows.

The changes here are two:

1. disable core for rsbegin/rsend
2. make panic_fmt an extern fn for smallest-hello-world so that it
   is not marked as "internal" for LLVM

8 years agorenumber error from E0522 to E0523
Niko Matsakis [Tue, 22 Mar 2016 16:18:30 +0000 (12:18 -0400)]
renumber error from E0522 to E0523

another name was added in the meantime

8 years agocheck only that symbol names are deterministic
Niko Matsakis [Tue, 22 Mar 2016 15:54:22 +0000 (11:54 -0400)]
check only that symbol names are deterministic

Full binary reproducible builds are not possible on all platforms
because linker injects a certain amount of randomness, apparently. Or,
at minimum, they don't work reliably yet.

8 years agoRemove static linking hack since we are now passing absolute paths
Niko Matsakis [Mon, 21 Mar 2016 19:13:40 +0000 (15:13 -0400)]
Remove static linking hack since we are now passing absolute paths

8 years agoFix accursed issue-4264.pp
Niko Matsakis [Mon, 21 Mar 2016 19:11:23 +0000 (15:11 -0400)]
Fix accursed issue-4264.pp

8 years agoCorreections due to refactoring .
Niko Matsakis [Mon, 21 Mar 2016 17:11:42 +0000 (13:11 -0400)]
Correections due to refactoring .

8 years agopacify the merciless tidy: s/E0521/E0522
Niko Matsakis [Thu, 17 Mar 2016 09:32:04 +0000 (05:32 -0400)]
pacify the merciless tidy: s/E0521/E0522

Gah. I always find it confusing that make tidy gives me the highest error
code, but not the **next** error code.

8 years agorenumber diagnostic to avoid conflict
Niko Matsakis [Wed, 16 Mar 2016 20:37:19 +0000 (16:37 -0400)]
renumber diagnostic to avoid conflict

specialization nabbed E0520

8 years agoremove unused variable in compiletest
Niko Matsakis [Wed, 16 Mar 2016 19:00:34 +0000 (15:00 -0400)]
remove unused variable in compiletest

8 years agounit-test symbol-names and item-paths
Niko Matsakis [Wed, 16 Mar 2016 19:00:20 +0000 (15:00 -0400)]
unit-test symbol-names and item-paths

8 years agorefactor item-paths in diagnostics, symbol names
Niko Matsakis [Wed, 16 Mar 2016 09:57:03 +0000 (05:57 -0400)]
refactor item-paths in diagnostics, symbol names

This change has a few parts. We introduce a new `item_path` module for
constructing item paths. The job of this module is basically to make
nice, user-readable paths -- but these paths are not necessarily 100%
unique. They meant to help a *human* find code, but not necessarily a
compute. These paths are used to drive `item_path_str` but also symbol
names.

Because the paths are not unique, we also modify the symbol name hash to
include the full `DefPath`, whereas before it included only those
aspects of the def-path that were not included in the "informative"
symbol name.

Eventually, I'd like to make the item-path infrastructure a bit more
declarative.  Right now it's based purely on strings. In particular, for
impls, we should supply the raw types to the `ItemPathBuffer`, so that
symbol names can be encoded using the C++ encoding scheme for better
integration with tooling.

8 years agoadd krate_attrs accessor
Niko Matsakis [Wed, 16 Mar 2016 09:53:45 +0000 (05:53 -0400)]
add krate_attrs accessor

makes better edges in dep graph

8 years agotrack the extern-crate def-id rather than path
Niko Matsakis [Wed, 16 Mar 2016 09:50:38 +0000 (05:50 -0400)]
track the extern-crate def-id rather than path

We used to track, for each crate, a path that led to the extern-crate
that imported it. Instead of that, track the def-id of the extern crate,
along with a bit more information, and derive the path on the fly.

8 years agofallout: update codegen-units tests
Niko Matsakis [Wed, 16 Mar 2016 09:35:03 +0000 (05:35 -0400)]
fallout: update codegen-units tests

8 years agorefactor DefPathData variants
Niko Matsakis [Wed, 16 Mar 2016 09:47:18 +0000 (05:47 -0400)]
refactor DefPathData variants

In particular, remove the name from the Impl, since that name is
synthesized and is not predictable (it tends to break incr. comp.).

Also rename the variants to be a bit more uniform and remove some
distinctions that we were not really taking advantage of anywhere.

8 years agostore krate information more uniformly
Niko Matsakis [Wed, 16 Mar 2016 09:40:14 +0000 (05:40 -0400)]
store krate information more uniformly

make DefPath store krate and enable uniform access to crate_name/crate_disambiguator

8 years agotrack def-id for inlined items
Niko Matsakis [Wed, 16 Mar 2016 09:31:51 +0000 (05:31 -0400)]
track def-id for inlined items

8 years agoAdd a "link-guard" to avoid accidentally linking to a wrong dylib at runtime.
Michael Woerister [Tue, 1 Mar 2016 13:19:00 +0000 (08:19 -0500)]
Add a "link-guard" to avoid accidentally linking to a wrong dylib at runtime.

We want to prevent compiling something against one version
of a dynamic library and then, at runtime accidentally
using a different version of the dynamic library. With the
old symbol-naming scheme this could not happen because every
symbol had the SVH in it and you'd get an error by the
dynamic linker when using the wrong version of a dylib. With
the new naming scheme this isn't the case any more, so this
patch adds the "link-guard" to prevent this error case.

This is implemented as follows:

- In every crate that we compile, we emit a function called
  "__rustc_link_guard_<crate-name>_<crate-svh>"
- The body of this function contains calls to the
  "__rustc_link_guard" functions of all dependencies.
- An executable contains a call to it's own
  "__rustc_link_guard" function.

As a consequence the "__rustc_link_guard" function call graph
mirrors the crate graph and the dynamic linker will fail if a
wrong dylib is loaded somewhere because its
"__rustc_link_guard" function will contain a different SVH in
its name.

8 years agoRemove old symbol naming code.
Michael Woerister [Tue, 1 Mar 2016 13:18:21 +0000 (08:18 -0500)]
Remove old symbol naming code.

8 years agoMake the compiler emit an error if the crate graph contains two crates with the same...
Michael Woerister [Fri, 26 Feb 2016 21:25:25 +0000 (16:25 -0500)]
Make the compiler emit an error if the crate graph contains two crates with the same crate-name and crate-salt but different SVHs.

8 years agoSalt test crates in buildsystem.
Michael Woerister [Thu, 18 Feb 2016 18:05:13 +0000 (13:05 -0500)]
Salt test crates in buildsystem.

8 years agoAdd a test to verify that we have reproducible compiler builds.
Michael Woerister [Thu, 18 Feb 2016 04:42:36 +0000 (23:42 -0500)]
Add a test to verify that we have reproducible compiler builds.

8 years agoUse new symbol names for items of various kinds.
Michael Woerister [Mon, 15 Feb 2016 20:41:16 +0000 (15:41 -0500)]
Use new symbol names for items of various kinds.

8 years agoUse new symbol naming scheme for object shims.
Michael Woerister [Tue, 1 Mar 2016 13:16:48 +0000 (08:16 -0500)]
Use new symbol naming scheme for object shims.

8 years agoUse new symbol naming scheme for fn-once-shims.
Michael Woerister [Sun, 14 Feb 2016 23:15:49 +0000 (18:15 -0500)]
Use new symbol naming scheme for fn-once-shims.

8 years agoUse new symbol naming scheme for fn-pointer-shims.
Michael Woerister [Sun, 14 Feb 2016 23:08:08 +0000 (18:08 -0500)]
Use new symbol naming scheme for fn-pointer-shims.

8 years agoMake drop glue use new symbol naming scheme.
Michael Woerister [Sun, 14 Feb 2016 22:38:49 +0000 (17:38 -0500)]
Make drop glue use new symbol naming scheme.

8 years agoMake closures use stable symbol names.
Michael Woerister [Sun, 14 Feb 2016 18:18:28 +0000 (13:18 -0500)]
Make closures use stable symbol names.

8 years agoMake monomorphized functions use stable symbol names.
Michael Woerister [Sun, 14 Feb 2016 18:01:44 +0000 (13:01 -0500)]
Make monomorphized functions use stable symbol names.

8 years agoMake the definite name of the local crate available in the tcx.
Michael Woerister [Sun, 14 Feb 2016 17:30:38 +0000 (12:30 -0500)]
Make the definite name of the local crate available in the tcx.

8 years agoCompute a salt from arguments passed via -Cmetadata.
Michael Woerister [Fri, 12 Feb 2016 13:41:30 +0000 (08:41 -0500)]
Compute a salt from arguments passed via -Cmetadata.

8 years agoMake library paths passed by compiletest tool absolute.
Michael Woerister [Mon, 29 Feb 2016 13:44:06 +0000 (08:44 -0500)]
Make library paths passed by compiletest tool absolute.

Otherwise, changing the current working directory can mess up runtime linking.

8 years agoMake CrateStore::crate_name() return an InternedString to avoid unnecessary allocations.
Michael Woerister [Fri, 12 Feb 2016 17:43:13 +0000 (12:43 -0500)]
Make CrateStore::crate_name() return an InternedString to avoid unnecessary allocations.

8 years agoAdd missing entries for enum variants in trans::CrateContext::external_srcs.
Michael Woerister [Sat, 13 Feb 2016 17:55:04 +0000 (12:55 -0500)]
Add missing entries for enum variants in trans::CrateContext::external_srcs.

8 years agoCrateStore: Allow for custom def_id_to_string mappings in encode_type().
Michael Woerister [Wed, 10 Feb 2016 15:04:45 +0000 (10:04 -0500)]
CrateStore: Allow for custom def_id_to_string mappings in encode_type().

8 years agoAuto merge of #32407 - alexcrichton:netbsd-gcc-s-link, r=aturon
bors [Fri, 25 Mar 2016 18:00:01 +0000 (11:00 -0700)]
Auto merge of #32407 - alexcrichton:netbsd-gcc-s-link, r=aturon

std: Link to gcc_s on NetBSD

Currently the nightlies we're producing fail when linking some C code into a
Rust application with the error message:

    libgcc_s.so.1: error adding symbols: DSO missing from command line

By linking `gcc_s` instead of `gcc` this error goes away. I haven't tested this
on NetBSD itself, but should help get the Linux cross-compile image moreso up
and working!

8 years agouse new visitor to erase regions
Niko Matsakis [Fri, 25 Mar 2016 17:10:32 +0000 (13:10 -0400)]
use new visitor to erase regions

8 years agocheck for both partialeq and eq
Niko Matsakis [Fri, 25 Mar 2016 14:02:56 +0000 (10:02 -0400)]
check for both partialeq and eq

8 years agoAuto merge of #31908 - jseyfried:disallow_shadowed_traits, r=nikomatsakis
bors [Fri, 25 Mar 2016 12:03:13 +0000 (05:03 -0700)]
Auto merge of #31908 - jseyfried:disallow_shadowed_traits, r=nikomatsakis

Disallow methods from traits that are not in scope

This PR only allows a trait method to be used if the trait is in scope (fixes #31379).
This is a [breaking-change]. For example, the following would break:
```rust
mod foo {
    pub trait T { fn f(&self) {} }
    impl T for () {}
}

mod bar { pub use foo::T; }

fn main() {
    pub use bar::*;
    struct T; // This shadows the trait `T`,
    ().f() // making this an error.
}
```
r? @nikomatsakis

8 years agonew tests for RFC #1445
Niko Matsakis [Fri, 11 Mar 2016 18:36:55 +0000 (13:36 -0500)]
new tests for RFC #1445

8 years agofallout in existing tests
Niko Matsakis [Fri, 11 Mar 2016 18:36:46 +0000 (13:36 -0500)]
fallout in existing tests

8 years agosuppress duplicate lints
Niko Matsakis [Fri, 11 Mar 2016 20:36:24 +0000 (15:36 -0500)]
suppress duplicate lints

8 years agoissue a future-compat lint for constants of invalid type
Niko Matsakis [Fri, 11 Mar 2016 18:30:32 +0000 (13:30 -0500)]
issue a future-compat lint for constants of invalid type

This is a [breaking-change]: according to RFC #1445, constants used as
patterns must be of a type that *derives* `Eq`. If you encounter a
problem, you are most likely using a constant in an expression where the
type of the constant is some struct that does not currently implement
`Eq`. Something like the following:

```rust
struct SomeType { ... }
const SOME_CONST: SomeType = ...;

match foo {
    SOME_CONST => ...
}
```

The easiest and most future compatible fix is to annotate the type in
question with `#[derive(Eq)]` (note that merely *implementing* `Eq` is
not enough, it must be *derived*):

```rust
struct SomeType { ... }
const SOME_CONST: SomeType = ...;

match foo {
    SOME_CONST => ...
}
```

Another good option is to rewrite the match arm to use an `if`
condition (this is also particularly good for floating point types,
which implement `PartialEq` but not `Eq`):

```rust
match foo {
    c if c == SOME_CONST => ...
}
```

Finally, a third alternative is to tag the type with
`#[structural_match]`; but this is not recommended, as the attribute is
never expected to be stabilized. Please see RFC #1445 for more details.

8 years agodo not overwrite spans as eagerly
Niko Matsakis [Fri, 11 Mar 2016 18:29:06 +0000 (13:29 -0500)]
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.

8 years agomodify #[deriving(Eq)] to emit #[structural_match]
Niko Matsakis [Fri, 11 Mar 2016 18:27:42 +0000 (13:27 -0500)]
modify #[deriving(Eq)] to emit #[structural_match]

to careful use of the span from deriving, we
can permit it in stable code if it derives from
deriving (not-even-a-pun intended)

8 years agomake `const_expr_to_pat` fallible (but never have it actually fail)
Niko Matsakis [Wed, 3 Feb 2016 21:38:48 +0000 (16:38 -0500)]
make `const_expr_to_pat` fallible (but never have it actually fail)

8 years agoAuto merge of #32428 - nikomatsakis:scopes-in-mir, r=nagisa
bors [Fri, 25 Mar 2016 06:12:57 +0000 (23:12 -0700)]
Auto merge of #32428 - nikomatsakis:scopes-in-mir, r=nagisa

Scopes in mir

This PR adds scopes to MIR. There is a tree of scopes (each represented by a `ScopeId`). Every statement, variable, and terminator now has an associated scope and span.  It also adds a `-Z dump-mir` switch one can use to conveniently examine the MIR as optimizations proceed.

The intention is two-fold. First, to support MIR debug-info. This PR does not attempt to modify trans to make use of the scope information, however.

Second, in a more temporary capacity, to support the goal of moving regionck and borowck into the MIR. To that end, the PR also constructs a "scope auxiliary" table storing the extent of each span (this is kept separate from the main MIR, since it contains node-ids) and the dom/post-dom of the region in the graph where the scope occurs. When we move to non-lexical lifetimes, I expect this auxiliary information to be discarded, but that is still some ways in the future (requires, at minimum, an RFC, and there are some thorny details to work out -- though I've got an in-progress draft).

Right now, I'm just dropping this auxiliary information after it is constructed. I was debating for some time whether to add some sort of sanity tests, but decided to just open this PR instead, because I couldn't figure out what such a test would look like (and we don't have independent tests for this today beyond the regionck and borrowck tests).

I'd prefer not to store the auxiliary data into any kind of "per-fn" map. Rather, I'd prefer that we do regionck/borrowck/whatever-else immediately after construction -- that is, we build the MIR for fn X and immediately thereafter do extended correctness checking on it. This will reduce peak memory usage and also ensure that the auxiliary data doesn't exist once optimizations begin. It also clarifies the transition point where static checks are complete and MIR can be more freely optimized.

cc @rust-lang/compiler @nagisa

8 years agoFix unsound behaviour with null characters in thread names (issue #32475)
David Henningsson [Fri, 25 Mar 2016 04:46:45 +0000 (05:46 +0100)]
Fix unsound behaviour with null characters in thread names (issue #32475)

Previously, the thread name (&str) was converted to a CString in the
new thread, but outside unwind::try, causing a panic to continue into FFI.

This patch changes that behaviour, so that the panic instead happens
in the parent thread (where panic infrastructure is properly set up),
not the new thread.

This could potentially be a breaking change for architectures who don't
support thread names.

Signed-off-by: David Henningsson <diwic@ubuntu.com>
8 years agoAuto merge of #32396 - nodakai:range-contains, r=alexcrichton
bors [Fri, 25 Mar 2016 02:38:43 +0000 (19:38 -0700)]
Auto merge of #32396 - nodakai:range-contains, r=alexcrichton

Add core::ops::Range*::contains() as per rust-lang/rust#32311

8 years agoCleanup
Vadim Petrochenkov [Thu, 10 Mar 2016 19:01:38 +0000 (22:01 +0300)]
Cleanup

+ Fix a comment and add a test based on it

8 years agoLift the restriction on reusing names of primitive types
Vadim Petrochenkov [Tue, 8 Mar 2016 21:08:29 +0000 (00:08 +0300)]
Lift the restriction on reusing names of primitive types

8 years agoIntroduce name resolution fallback for primitive types
Vadim Petrochenkov [Tue, 8 Mar 2016 18:40:13 +0000 (21:40 +0300)]
Introduce name resolution fallback for primitive types

8 years agoAuto merge of #32346 - nikomatsakis:no-erased-regions, r=eddyb
bors [Thu, 24 Mar 2016 21:22:26 +0000 (14:22 -0700)]
Auto merge of #32346 - nikomatsakis:no-erased-regions, r=eddyb

Remove `ErasedRegions` from substs

This commit removes the `ErasedRegions` enum from `Substs`. Instead, in trans, we just generate a vector of `ReStatic` of suitable length. The goal is both general cleanup and to help pave the way for a glorious future where erasure is used in type check.

r? @eddyb

One concern: might be nice to do some profiling. Not sure the best way to do that. Perhaps I'll investigate running nrc's test suite locally.

8 years agomake available monomorphizations shared by CGU
Niko Matsakis [Thu, 24 Mar 2016 18:56:02 +0000 (14:56 -0400)]
make available monomorphizations shared by CGU

The current setup means that all generics are local to a codegen-unit,
which means massive duplication.

8 years agoremove `empty_substs_for_node_id`
Niko Matsakis [Sat, 19 Mar 2016 09:33:16 +0000 (05:33 -0400)]
remove `empty_substs_for_node_id`

8 years agoremove ErasedRegions from substitutions
Niko Matsakis [Wed, 9 Mar 2016 23:22:05 +0000 (18:22 -0500)]
remove ErasedRegions from substitutions

This hack has long since outlived its usefulness; the transition to
trans passing around full substitutions is basically done. Instead of
`ErasedRegions`, just supply substitutions with a suitable number of
`'static` entries, and invoke `erase_regions` when needed (the latter of
which we already do).

8 years agorewrite foreign types lint not to trawl the HIR
Niko Matsakis [Wed, 16 Mar 2016 19:53:08 +0000 (15:53 -0400)]
rewrite foreign types lint not to trawl the HIR

It no longer reads from `ast_ty_to_ty_cache`, which was very wrong. It
also correctly handles higher-ranked regions.

8 years agoAuto merge of #32465 - steveklabnik:rollup, r=steveklabnik
bors [Thu, 24 Mar 2016 16:25:02 +0000 (09:25 -0700)]
Auto merge of #32465 - steveklabnik:rollup, r=steveklabnik

Rollup of 6 pull requests

- Successful merges: #32276, #32416, #32452, #32459, #32462, #32464
- Failed merges:

8 years agoRollup merge of #32464 - GuillaumeGomez:patch-6, r=steveklabnik
Steve Klabnik [Thu, 24 Mar 2016 14:37:24 +0000 (10:37 -0400)]
Rollup merge of #32464 - GuillaumeGomez:patch-6, r=steveklabnik

Improve some Option code example

Part of #29366.

r? @steveklabnik

8 years agoRollup merge of #32462 - tclfs:patch-1, r=steveklabnik
Steve Klabnik [Thu, 24 Mar 2016 14:37:24 +0000 (10:37 -0400)]
Rollup merge of #32462 - tclfs:patch-1, r=steveklabnik

Docs: some tiny corrections

TNT->`tnt`
firecracker->`firecracker`

8 years agoRollup merge of #32459 - nrc:json-err-text, r=nikomatsakis
Steve Klabnik [Thu, 24 Mar 2016 14:37:24 +0000 (10:37 -0400)]
Rollup merge of #32459 - nrc:json-err-text, r=nikomatsakis

Include source text in JSON errors

8 years agoRollup merge of #32452 - GuillaumeGomez:patch-5, r=steveklabnik
Steve Klabnik [Thu, 24 Mar 2016 14:37:24 +0000 (10:37 -0400)]
Rollup merge of #32452 - GuillaumeGomez:patch-5, r=steveklabnik

Add code examples for libstd/time

Fixes #29379.

r? @steveklabnik

8 years agoRollup merge of #32416 - GuillaumeGomez:patch-3, r=steveklabnik
Steve Klabnik [Thu, 24 Mar 2016 14:37:23 +0000 (10:37 -0400)]
Rollup merge of #32416 - GuillaumeGomez:patch-3, r=steveklabnik

Add doc example to clone trait

Fixes #29346.

r? @steveklabnik

8 years agoRollup merge of #32276 - brson:doc, r=alexcrichton
Steve Klabnik [Thu, 24 Mar 2016 14:37:23 +0000 (10:37 -0400)]
Rollup merge of #32276 - brson:doc, r=alexcrichton

doc: Stdin is not writable

8 years agopacify the merciless tidy
Niko Matsakis [Thu, 24 Mar 2016 11:11:11 +0000 (07:11 -0400)]
pacify the merciless tidy

8 years agoImprove some Option code example
Guillaume Gomez [Thu, 24 Mar 2016 12:24:39 +0000 (13:24 +0100)]
Improve some Option code example

8 years agorework MIR visitor
Niko Matsakis [Thu, 24 Mar 2016 10:12:19 +0000 (06:12 -0400)]
rework MIR visitor

We now visit more things (e.g., types) and also follow a deliberate
style designed to reduce omissions.

8 years agoDocs: some tiny corrections
Tang Chenglong [Thu, 24 Mar 2016 06:49:40 +0000 (14:49 +0800)]
Docs: some tiny corrections

TNT->`tnt`
firecracker->`firecracker`

8 years agoAuto merge of #32219 - brson:lints, r=alexcrichton
bors [Thu, 24 Mar 2016 06:09:47 +0000 (23:09 -0700)]
Auto merge of #32219 - brson:lints, r=alexcrichton

Make warnings of renamed and removed lints themselves lints

This adds the `renamed_and_removed_lints` warning, defaulting
to the warning level.

Fixes #31141