Commit Graph

51699 Commits

Author SHA1 Message Date
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
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
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
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
bors
d7a71687ef 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.
2016-03-24 14:22:26 -07:00
Niko Matsakis
c5d74be4ed remove empty_substs_for_node_id 2016-03-24 14:01:28 -04:00
Niko Matsakis
f3ac50927a 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).
2016-03-24 14:01:28 -04:00
Niko Matsakis
c74339052d 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.
2016-03-24 14:01:28 -04:00
bors
dcfb8d72e9 Auto merge of #32465 - steveklabnik:rollup, r=steveklabnik
Rollup of 6 pull requests

- Successful merges: #32276, #32416, #32452, #32459, #32462, #32464
- Failed merges:
2016-03-24 09:25:02 -07:00
Steve Klabnik
b2dfb7c0a2 Rollup merge of #32464 - GuillaumeGomez:patch-6, r=steveklabnik
Improve some Option code example

Part of #29366.

r? @steveklabnik
2016-03-24 10:37:24 -04:00
Steve Klabnik
bce02a207a Rollup merge of #32462 - tclfs:patch-1, r=steveklabnik
Docs: some tiny corrections

TNT->`tnt`
firecracker->`firecracker`
2016-03-24 10:37:24 -04:00
Steve Klabnik
38c6593592 Rollup merge of #32459 - nrc:json-err-text, r=nikomatsakis
Include source text in JSON errors
2016-03-24 10:37:24 -04:00
Steve Klabnik
a3b9b42d44 Rollup merge of #32452 - GuillaumeGomez:patch-5, r=steveklabnik
Add code examples for libstd/time

Fixes #29379.

r? @steveklabnik
2016-03-24 10:37:24 -04:00
Steve Klabnik
7a38ac8e87 Rollup merge of #32416 - GuillaumeGomez:patch-3, r=steveklabnik
Add doc example to clone trait

Fixes #29346.

r? @steveklabnik
2016-03-24 10:37:23 -04:00
Steve Klabnik
87aee45988 Rollup merge of #32276 - brson:doc, r=alexcrichton
doc: Stdin is not writable
2016-03-24 10:37:23 -04:00
Niko Matsakis
091a00797e pacify the merciless tidy 2016-03-24 09:23:15 -04:00
Guillaume Gomez
b922d1a405 Improve some Option code example 2016-03-24 13:24:39 +01:00
Niko Matsakis
ed7c30b888 rework MIR visitor
We now visit more things (e.g., types) and also follow a deliberate
style designed to reduce omissions.
2016-03-24 06:23:59 -04:00
Tang Chenglong
ceaf5dfdc1 Docs: some tiny corrections
TNT->`tnt`
firecracker->`firecracker`
2016-03-24 14:49:40 +08:00
bors
dc1f6831eb 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
2016-03-23 23:09:47 -07:00
Nick Cameron
9757516f12 Include source text in JSON errors 2016-03-24 15:32:42 +13:00
NODA, Kai
a21c5f267a
Add core::ops::Range*::contains() as per rust-lang/rust#32311
Signed-off-by: NODA, Kai <nodakai@gmail.com>
2016-03-24 08:57:45 +08:00
Niko Matsakis
0769865f7f rewrite scope drop to be iterative
while I'm at it, remove the "extra caching" that I was doing for no good
reason except laziness. Basically before I was caching at each scope in
the chain, but there's not really a reason to do that, since the cached
entry point at level N is always equal to the last cached exit point
from level N-1.
2016-03-23 20:46:38 -04:00
Brian Anderson
addde1fd6f Make warnings of renamed and removed lints themselves lints
This adds the `renamed_and_removed_lints` warning, defaulting
to the warning level.

Fixes #31141
2016-03-23 23:41:48 +00:00
Brian Anderson
b013ad55aa doc: Stdin is locked for reads, not writes 2016-03-23 23:39:01 +00:00
bors
43843d06ea Auto merge of #32455 - TimNN:patch-1, r=alexcrichton
add naked function tracking issue # to feature gate definition
2016-03-23 16:24:39 -07:00