Commit Graph

51895 Commits

Author SHA1 Message Date
Niko Matsakis
b184d2712f 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.
2016-03-25 14:07:20 -04:00
Niko Matsakis
7e8e6712b5 Remove static linking hack since we are now passing absolute paths 2016-03-25 14:07:20 -04:00
Niko Matsakis
bca94230f3 Fix accursed issue-4264.pp 2016-03-25 14:07:20 -04:00
Niko Matsakis
e8dfaa71e6 Correections due to refactoring . 2016-03-25 14:07:20 -04:00
Niko Matsakis
5a68116240 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.
2016-03-25 14:07:20 -04:00
Niko Matsakis
af057bdb1c renumber diagnostic to avoid conflict
specialization nabbed E0520
2016-03-25 14:07:20 -04:00
Niko Matsakis
86fa58d6c8 remove unused variable in compiletest 2016-03-25 14:07:19 -04:00
Niko Matsakis
977636156a unit-test symbol-names and item-paths 2016-03-25 14:07:19 -04:00
Niko Matsakis
2291abf313 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.
2016-03-25 14:07:19 -04:00
Niko Matsakis
cd5cf09635 add krate_attrs accessor
makes better edges in dep graph
2016-03-25 14:07:19 -04:00
Niko Matsakis
ab9b844146 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.
2016-03-25 14:07:19 -04:00
Niko Matsakis
6056c5fbed fallout: update codegen-units tests 2016-03-25 14:07:19 -04:00
Niko Matsakis
5e26508744 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.
2016-03-25 14:07:19 -04:00
Niko Matsakis
7b6270b537 store krate information more uniformly
make DefPath store krate and enable uniform access to crate_name/crate_disambiguator
2016-03-25 14:07:19 -04:00
Niko Matsakis
65c0b7c292 track def-id for inlined items 2016-03-25 14:07:19 -04:00
Michael Woerister
2475707322 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.
2016-03-25 14:07:19 -04:00
Michael Woerister
82b5f1d869 Remove old symbol naming code. 2016-03-25 14:07:18 -04:00
Michael Woerister
2eebb7b605 Make the compiler emit an error if the crate graph contains two crates with the same crate-name and crate-salt but different SVHs. 2016-03-25 14:07:18 -04:00
Michael Woerister
fafdfa8bdc Salt test crates in buildsystem. 2016-03-25 14:07:18 -04:00
Michael Woerister
9c965b786c Add a test to verify that we have reproducible compiler builds. 2016-03-25 14:07:18 -04:00
Michael Woerister
7def3768c6 Use new symbol names for items of various kinds. 2016-03-25 14:07:18 -04:00
Michael Woerister
68de171890 Use new symbol naming scheme for object shims. 2016-03-25 14:07:18 -04:00
Michael Woerister
8ef638e6fa Use new symbol naming scheme for fn-once-shims. 2016-03-25 14:07:18 -04:00
Michael Woerister
23e54b24ad Use new symbol naming scheme for fn-pointer-shims. 2016-03-25 14:07:18 -04:00
Michael Woerister
7a5a988579 Make drop glue use new symbol naming scheme. 2016-03-25 14:07:18 -04:00
Michael Woerister
6f60c9e1fd Make closures use stable symbol names. 2016-03-25 14:07:18 -04:00
Michael Woerister
c77f44eeee Make monomorphized functions use stable symbol names. 2016-03-25 14:07:18 -04:00
Michael Woerister
3a756fea50 Make the definite name of the local crate available in the tcx. 2016-03-25 14:07:17 -04:00
Michael Woerister
32a2e9a8e1 Compute a salt from arguments passed via -Cmetadata. 2016-03-25 14:07:17 -04:00
Michael Woerister
c7e54d7279 Make library paths passed by compiletest tool absolute.
Otherwise, changing the current working directory can mess up runtime linking.
2016-03-25 14:07:17 -04:00
Michael Woerister
606c985a50 Make CrateStore::crate_name() return an InternedString to avoid unnecessary allocations. 2016-03-25 14:07:17 -04:00
Michael Woerister
5027a79279 Add missing entries for enum variants in trans::CrateContext::external_srcs. 2016-03-25 14:07:17 -04:00
Michael Woerister
6fdeecf62f CrateStore: Allow for custom def_id_to_string mappings in encode_type(). 2016-03-25 14:07:17 -04:00
bors
cf9274b727 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!
2016-03-25 11:00:01 -07:00
Brian Anderson
c7049f6450 Fix the name of the 'check-cargotest' step 2016-03-25 17:33:10 +00:00
Niko Matsakis
e539b74f54 use new visitor to erase regions 2016-03-25 13:10:45 -04:00
Alejandro Wainzinger
6ce63fb3f1 Add note on str being an unsized type in strings section of book. 2016-03-25 23:25:40 +09:00
Niko Matsakis
93e44432e1 check for both partialeq and eq 2016-03-25 10:02:56 -04:00
bors
64a13a4660 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
2016-03-25 05:03:13 -07:00
Niko Matsakis
7f661ec417 new tests for RFC #1445 2016-03-25 06:45:43 -04:00
Niko Matsakis
56ebf2b046 fallout in existing tests 2016-03-25 06:45:42 -04:00
Niko Matsakis
73b4f06b83 suppress duplicate lints 2016-03-25 06:45:42 -04:00
Niko Matsakis
f69eb8efbe 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.
2016-03-25 06:45:42 -04:00
Niko Matsakis
05baf645e4 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.
2016-03-25 06:44:14 -04:00
Niko Matsakis
99c2a6b335 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)
2016-03-25 06:44:14 -04:00
Niko Matsakis
5bc2868060 make const_expr_to_pat fallible (but never have it actually fail) 2016-03-25 06:44:14 -04:00
bors
f1578d37dc 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
2016-03-24 23:12:57 -07:00
David Henningsson
78495d5082 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>
2016-03-25 06:14:03 +01:00
bors
40deb279a8 Auto merge of #32396 - nodakai:range-contains, r=alexcrichton
Add core::ops::Range*::contains() as per rust-lang/rust#32311
2016-03-24 19:38:43 -07:00
Vadim Petrochenkov
b418cd2306 Cleanup
+ Fix a comment and add a test based on it
2016-03-25 00:41:09 +03:00