summary refs log tree commit diff
path: root/src/librustc_driver
AgeCommit message (Collapse)AuthorLines
2017-01-06rustc: Stabilize the `proc_macro` featureAlex Crichton-2/+1
This commit stabilizes the `proc_macro` and `proc_macro_lib` features in the compiler to stabilize the "Macros 1.1" feature of the language. Many more details can be found on the tracking issue, #35900. Closes #35900
2016-12-15Use StableHasher everywhereAriel Ben-Yehuda-8/+4
The standard implementations of Hasher have architecture-dependent results when hashing integers. This causes problems when the hashes are stored within metadata - metadata written by one host architecture can't be read by another. To fix that, implement an architecture-independent StableHasher and use it in all places an architecture-independent hasher is needed. Fixes #38177.
2016-12-12Auto merge of #38057 - KiChjang:display-formal-type-param, r=nikomatsakisbors-3/+5
Display better error messages for E0282 Fixes #36554.
2016-12-05Refactor FnSig to contain a Slice for its inputs and outputs.Mark-Simulacrum-6/+1
2016-12-04Auto merge of #38092 - pnkfelix:mir-stats, r=nikomatsakisbors-1/+13
Adds `-Z mir-stats`, which is similar to `-Z hir-stats`. Adds `-Z mir-stats`, which is similar to `-Z hir-stats`. Some notes: * This code attempts to present the breakdown of each variant for every enum in the MIR. This is meant to guide decisions about how to revise representations e.g. when to box payloads for rare variants to shrink the size of the enum overall. * I left out the "Total:" line that hir-stats presents, because this implementation uses the MIR Visitor infrastructure, and the memory usage of structures directly embedded in other structures (e.g. the `func: Operand` in a `TerminatorKind:Call`) is not distinguished from similar structures allocated in a `Vec` (e.g. the `args: Vec<Operand>` in a `TerminatorKind::Call`). This means that a naive summation of all the accumulated sizes is misleading, because it will double-count the contribution of the `Operand` of the `func` as well as the size of the whole `TerminatorKind`. * I did consider abandoning the MIR Visitor and instead hand-coding a traversal that distinguished embedded storage from indirect storage. But such code would be fragile; better to just require people to take care when interpreting the presented results. * This traverses the `mir.promoted` rvalues to capture stats for MIR stored there, even though the MIR visitor super_mir method does not do so. (I did not observe any promoted mir being newly traversed when compiling the rustc crate, however.) * It might be nice to try to unify this code with hir-stats. Then again, the reporting portion is the only common code (I think), and it is small compared to the visitors in hir-stats and mir-stats.
2016-12-03Add TypeVariableOrigin enumKeith Yeung-3/+5
2016-12-03Auto merge of #38079 - BurntSushi:attrtarget, r=alexcrichtonbors-1/+2
Add new #[target_feature = "..."] attribute. This commit adds a new attribute that instructs the compiler to emit target specific code for a single function. For example, the following function is permitted to use instructions that are part of SSE 4.2: #[target_feature = "+sse4.2"] fn foo() { ... } In particular, use of this attribute does not require setting the -C target-feature or -C target-cpu options on rustc. This attribute does not have any protections built into it. For example, nothing stops one from calling the above `foo` function on hosts without SSE 4.2 support. Doing so may result in a SIGILL. I've also expanded the x86 target feature whitelist.
2016-12-03Auto merge of #38061 - cardoe:target-spec, r=alexcrichtonbors-0/+3
print option to dump target spec as JSON This lets the user dump out the target spec that the compiler is using. This is useful to people defining their own target.json to compare it against existing targets or understand how different targets change internal settings. It is also potentially useful for Cargo to determine if something has changed with a target and it needs to rebuild things.
2016-12-02rustc: add --print target-spec optionDoug Goldstein-0/+3
This option provides the user the ability to dump the configuration that is in use by rustc for the target they are building for. Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
2016-12-02limit the length of types in monomorphizationAriel Ben-Yehuda-1/+1
This adds the new insta-stable `#![type_size_limit]` crate attribute to control the limit, and is obviously a [breaking-change] fixable by that.
2016-11-30Adds `-Z mir-stats`, which is similar to `-Z hir-stats`.Felix S. Klock II-1/+13
Some notes: * This code attempts to present the breakdown of each variant for every enum in the MIR. This is meant to guide decisions about how to revise representations e.g. when to box payloads for rare variants to shrink the size of the enum overall. * I left out the "Total:" line that hir-stats presents, because this implementation uses the MIR Visitor infrastructure, and the memory usage of structures directly embedded in other structures (e.g. the `func: Operand` in a `TerminatorKind:Call`) is not distinguished from similar structures allocated in a `Vec` (e.g. the `args: Vec<Operand>` in a `TerminatorKind::Call`). This means that a naive summation of all the accumulated sizes is misleading, because it will double-count the contribution of the `Operand` of the `func` as well as the size of the whole `TerminatorKind`. * I did consider abandoning the MIR Visitor and instead hand-coding a traversal that distinguished embedded storage from indirect storage. But such code would be fragile; better to just require people to take care when interpreting the presented results. * This traverses the `mir.promoted` rvalues to capture stats for MIR stored there, even though the MIR visitor super_mir method does not do so. (I did not observe any new mir being traversed when compiling the rustc crate, however.) * It might be nice to try to unify this code with hir-stats. Then again, the reporting portion is the only common code (I think), and it is small compared to the visitors in hir-stats and mir-stats.
2016-11-30Auto merge of #37800 - alexcrichton:new-bootstrap, r=eddybbors-2/+0
Update the bootstrap compiler Now that we've got a beta build, let's use it!
2016-11-30Update the bootstrap compilerAlex Crichton-2/+0
Now that we've got a beta build, let's use it!
2016-11-30Auto merge of #38014 - jseyfried:refactor_path_resolution, r=nrcbors-3/+0
resolve: refactor path resolution This is a pure refactoring, modulo minor diagnostics improvements. r? @nrc
2016-11-30rustc: track the Span's of definitions across crates.Eduard-Mihai Burtescu-5/+1
2016-11-29Add new #[target_feature = "..."] attribute.Andrew Gallant-1/+2
This commit adds a new attribute that instructs the compiler to emit target specific code for a single function. For example, the following function is permitted to use instructions that are part of SSE 4.2: #[target_feature = "+sse4.2"] fn foo() { ... } In particular, use of this attribute does not require setting the -C target-feature or -C target-cpu options on rustc. This attribute does not have any protections built into it. For example, nothing stops one from calling the above `foo` function on hosts without SSE 4.2 support. Doing so may result in a SIGILL. This commit also expands the target feature whitelist to include lzcnt, popcnt and sse4a. Namely, lzcnt and popcnt have their own CPUID bits, but were introduced with SSE4.
2016-11-29rustc_driver: fix compilationFlorian Diebold-2/+5
2016-11-29Remove `resolver.record_resolution()`.Jeffrey Seyfried-3/+0
2016-11-28rustc: rework stability to be on-demand for type-directed lookup.Eduard Burtescu-12/+9
2016-11-28rustc_typeck: save the type cache for rustdoc and save-analysis.Eduard Burtescu-45/+47
2016-11-28rustc: embed path resolutions into the HIR instead of keeping DefMap.Eduard-Mihai Burtescu-8/+4
2016-11-24Revisions from review comments, squashed.Felix S. Klock II-6/+0
Biggest change: Revised print-type-sizes output to include breakdown of layout. Includes info about field sizes (and alignment + padding when padding is injected; the injected padding is derived from the offsets computed by layout module). Output format is illustrated in commit that has the ui tests. Note: there exists (at least) one case of variant w/o name: empty enums. Namely, empty enums use anonymous univariant repr. So for such cases, print the number of the variant instead of the name. ---- Also, eddyb suggested of reading from `layout_cache` post-trans. (For casual readers: the compiler source often uses the word "cache" for tables that are in fact not periodically purged, and thus are useful as the basis for data like this.) Some types that were previously not printed are now included in the output. (See e.g. the tests `print_type_sizes/generics.rs` and `print_type_sizes/variants.rs`) ---- Other review feedback: switch to an exhaustive match when filtering in just structural types. switch to hashset for layout info and move sort into print method. ---- Driveby change: Factored session::code_stats into its own module ---- incorporate njn feedback re output formatting.
2016-11-24Add `-Z print-type-sizes`, a tool for digging into how variants are laid out.Felix S. Klock II-0/+10
2016-11-22Auto merge of #37681 - nrc:crate-metadata, r=@alexcrichtonbors-0/+3
add --crate-type metadata r? @alexcrichton
2016-11-21Implement the `loop_break_value` feature.Geoffry Song-1/+1
This implements RFC 1624, tracking issue #37339. - `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the currently deduced type of that loop, the desired type, and a list of break expressions currently seen. `loop` loops get a fresh type variable as their initial type (this logic is stolen from that for arrays). `while` loops get `()`. - `break {expr}` looks up the broken loop, and unifies the type of `expr` with the type of the loop. - `break` with no expr unifies the loop's type with `()`. - When building MIR, `loop` loops no longer construct a `()` value at termination of the loop; rather, the `break` expression assigns the result of the loop. `while` loops are unchanged. - `break` respects contexts in which expressions may not end with braced blocks. That is, `while break { break-value } { while-body }` is illegal; this preserves backwards compatibility. - The RFC did not make it clear, but I chose to make `break ()` inside of a `while` loop illegal, just in case we wanted to do anything with that design space in the future. This is my first time dealing with this part of rustc so I'm sure there's plenty of problems to pick on here ^_^
2016-11-21Fix fallout in `rustdoc` and tests.Jeffrey Seyfried-4/+4
2016-11-21Remove `Rc` from the interner.Jeffrey Seyfried-8/+0
2016-11-21Use `Symbol` instead of `InternedString` in the AST, HIR, and various other ↵Jeffrey Seyfried-6/+5
places.
2016-11-20Move `syntax::util::interner` -> `syntax::symbol`, cleanup.Jeffrey Seyfried-10/+11
2016-11-21TestsNick Cameron-0/+3
2016-11-21Read in rmeta cratesNick Cameron-1/+0
2016-11-21Add --crate-type metadataNick Cameron-0/+1
With the same semantics as -Zno-trans
2016-11-20Move `MetaItemKind`'s `Name` to a field of `MetaItem`.Jeffrey Seyfried-1/+2
2016-11-20Refactor `CrateConfig`.Jeffrey Seyfried-48/+22
2016-11-20Refactor `MetaItemKind` to use `Name`s instead of `InternedString`s.Jeffrey Seyfried-4/+3
2016-11-20Avoid clearing the string interner.Jeffrey Seyfried-3/+0
2016-11-19Auto merge of #37826 - keeperofdakeys:proc-macro-test, r=alexcrichtonbors-0/+2
Show a better error when using --test with #[proc_macro_derive] Fixes https://github.com/rust-lang/rust/issues/37480 Currently using `--test` with a crate that contains a `#[proc_macro_derive]` attribute causes an error. This PR doesn't attempt to fix the issue itself, or determine what tesing of a proc_macro_derive crate should be - just to provide a better error message.
2016-11-17Auto merge of #37660 - nikomatsakis:incremental-36349, r=eddybbors-3/+7
Separate impl items from the parent impl This change separates impl item bodies out of the impl itself. This gives incremental more resolution. In so doing, it refactors how the visitors work, and cleans up a bit of the collect/check logic (mostly by moving things out of collect that didn't really belong there, because they were just checking conditions). However, this is not as effective as I expected, for a kind of frustrating reason. In particular, when invoking `foo.bar()` you still wind up with dependencies on private items. The problem is that the method resolution code scans that list for methods with the name `bar` -- and this winds up touching *all* the methods, even private ones. I can imagine two obvious ways to fix this: - separating fn bodies from fn sigs (#35078, currently being pursued by @flodiebold) - a more aggressive model of incremental that @michaelwoerister has been advocating, in which we hash the intermediate results (e.g., the outputs of collect) so that we can see that the intermediate result hasn't changed, even if a particular impl item has changed. So all in all I'm not quite sure whether to land this or not. =) It still seems like it has to be a win in some cases, but not with the test cases we have just now. I can try to gin up some test cases, but I'm not sure if they will be totally realistic. On the other hand, some of the early refactorings to the visitor trait seem worthwhile to me regardless. cc #36349 -- well, this is basically a fix for that issue, I guess r? @michaelwoerister NB: Based atop of @eddyb's PR https://github.com/rust-lang/rust/pull/37402; don't land until that lands.
2016-11-17Auto merge of #37732 - jseyfried:use_extern_macros, r=nrcbors-2/+0
Support `use`ing externally defined macros behind `#![feature(use_extern_macros)]` With `#![feature(use_extern_macros)]`, - A name collision between macros from different upstream crates is much less of an issue since we can `use` the macros in different submodules or rename with `as`. - We can reexport macros with `pub use`, so `#![feature(macro_reexport)]` is no longer needed. - These reexports are allowed in any module, so crates can expose a macro-modular interface. If a macro invocation can resolve to both a `use` import and a `macro_rules!` or `#[macro_use]`, it is an ambiguity error. r? @nrc
2016-11-17Show a better error when using --test with #[proc_macro_derive]Josh Driver-0/+2
2016-11-17Auto merge of #37717 - nikomatsakis:region-obligations-pre, r=eddybbors-4/+3
Refactoring towards region obligation Two refactorings towards the intermediate goal of propagating region obligations through the `InferOk` structure (which in turn leads to the possibility of lazy normalization). 1. Remove `TypeOrigin` and add `ObligationCause` - as we converge subtyping and obligations and so forth, the ability to keep these types distinct gets harder 2. Propagate obligations from `InferOk` into the surrounding fulfillment context After these land, I have a separate branch (which still needs a bit of work) that can make the actual change to stop directly adding subregion edges and instead propagate obligations. (This should also make it easier to fix the unsoundness in specialization around lifetimes.) r? @eddyb
2016-11-17Resolve imports during expansion.Jeffrey Seyfried-2/+0
2016-11-16fallout from separating impl-items from implsNiko Matsakis-0/+4
Basically adding `visit_impl_item` in various places and so forth.
2016-11-16refactor Visitor into ItemLikeVisitor and intravisit::VisitorNiko Matsakis-3/+3
There are now three patterns (shallow, deep, and nested visit). These are described in detail on the docs in `itemlikevisit::ItemLikeVisitor`.
2016-11-16rustc: Implement #[link(cfg(..))] and crt-staticAlex Crichton-0/+29
This commit is an implementation of [RFC 1721] which adds a new target feature to the compiler, `crt-static`, which can be used to select how the C runtime for a target is linked. Most targets dynamically linke the C runtime by default with the notable exception of some of the musl targets. [RFC 1721]: https://github.com/rust-lang/rfcs/blob/master/text/1721-crt-static.md This commit first adds the new target-feature, `crt-static`. If enabled, then the `cfg(target_feature = "crt-static")` will be available. Targets like musl will have this enabled by default. This feature can be controlled through the standard target-feature interface, `-C target-feature=+crt-static` or `-C target-feature=-crt-static`. Next this adds an gated and unstable `#[link(cfg(..))]` feature to enable the `crt-static` semantics we want with libc. The exact behavior of this attribute is a little squishy, but it's intended to be a forever-unstable implementation detail of the liblibc crate. Specifically the `#[link(cfg(..))]` annotation means that the `#[link]` directive is only active in a compilation unit if that `cfg` value is satisfied. For example when compiling an rlib, these directives are just encoded and ignored for dylibs, and all staticlibs are continued to be put into the rlib as usual. When placing that rlib into a staticlib, executable, or dylib, however, the `cfg` is evaluated *as if it were defined in the final artifact* and the library is decided to be linked or not. Essentially, what'll happen is: * On MSVC with `-C target-feature=-crt-static`, the `msvcrt.lib` library will be linked to. * On MSVC with `-C target-feature=+crt-static`, the `libcmt.lib` library will be linked to. * On musl with `-C target-feature=-crt-static`, the object files in liblibc.rlib are removed and `-lc` is passed instead. * On musl with `-C target-feature=+crt-static`, the object files in liblibc.rlib are used and `-lc` is not passed. This commit does **not** include an update to the liblibc module to implement these changes. I plan to do that just after the 1.14.0 beta release is cut to ensure we get ample time to test this feature. cc #37406
2016-11-15remove TypeOrigin and use ObligationCause insteadNiko Matsakis-4/+3
In general having all these different structs for "origins" is not great, since equating types can cause obligations and vice-versa. I think we should gradually collapse these things. We almost certainly also need to invest a big more energy into the `error_reporting` code to rationalize it: this PR does kind of the minimal effort in that direction.
2016-11-14don't build an object file for emit=asm,llvm-irJorge Aparicio-1/+5
2016-11-12use write::run_assemblerJorge Aparicio-1/+12
2016-11-10rustc_typeck: correctly track "always-diverges" and "has-type-errors".Eduard Burtescu-2/+0
2016-11-10rustc: use an Expr instead of a Block for function bodies.Eduard Burtescu-6/+5