summary refs log tree commit diff
path: root/src/librustc_metadata/creader.rs
AgeCommit message (Collapse)AuthorLines
2016-10-31Changed most vec! invocations to use square bracesiirelu-8/+8
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
2016-10-29Move `CrateConfig` from `Crate` to `ParseSess`.Jeffrey Seyfried-8/+1
2016-10-24Clean up `CrateLoader::process_item`.Jeffrey Seyfried-62/+32
2016-10-24Refactor away `CrateLoader::load_macros`.Jeffrey Seyfried-14/+14
2016-10-24Refactor away `metadata::creader::Macros`.Jeffrey Seyfried-58/+30
2016-10-24Refactor away fields `MacroDef::{use_locally, export}`.Jeffrey Seyfried-3/+0
2016-10-24Import macros in `resolve` instead of in `metadata::macro_import`.Jeffrey Seyfried-8/+69
2016-10-22Rename `loader.rs` -> `locator.rs`.Jeffrey Seyfried-15/+15
2016-10-22Move `Library` into `creader.rs`.Jeffrey Seyfried-4/+10
2016-10-22Remove `CrateReader`, use `CrateLoader` instead.Jeffrey Seyfried-34/+14
2016-10-17Auto merge of #36969 - nnethercote:rename-Parser-fields, r=eddybbors-1/+1
Clarify the positions of the lexer and parser The lexer and parser use unclear names to indicate their positions in the source code. I propose the following renamings. Lexer: ``` pos -> next_pos # it's actually the next pos! last_pos -> pos # it's actually the current pos! curr -> ch # the current char curr_is -> ch_is # tests the current char col (unchanged) # the current column ``` parser ``` - last_span -> prev_span # the previous token's span - last_token_kind -> prev_token_kind # the previous token's kind - LastTokenKind -> PrevTokenKind # ditto (but the type) - token (unchanged) # the current token - span (unchanged) # the current span ``` Things to note: - This proposal removes all uses of "last", which is an unclear word because it could mean (a) previous, (b) final, or (c) most recent, i.e. current. - The "current" things (ch, col, token, span) consistently lack a prefix. The "previous" and "next" things consistently have a prefix.
2016-10-06rustc: Rename rustc_macro to proc_macroAlex Crichton-6/+6
This commit blanket renames the `rustc_macro` infrastructure to `proc_macro`, which reflects the general consensus of #35900. A follow up PR to Cargo will be required to purge the `rustc-macro` name as well.
2016-10-05Rename Parser::last_span as prev_span.Nicholas Nethercote-1/+1
This is a [breaking-change] for libsyntax.
2016-09-28Rollup merge of #36794 - japaric:target-panic, r=alexcrichtonJonathan Turner-2/+2
add a panic-strategy field to the target specification Now a target can define its panic strategy in its specification. If a user doesn't specify a panic strategy via the command line, i.e. '-C panic', then the compiler will use the panic strategy defined by the target specification. Custom targets can pick their panic strategy via the "panic-strategy" field of their target specification JSON file. If omitted in the specification, the strategy defaults to "unwind". closes #36647 --- I checked that compiling an executable for a custom target with "panic-strategy" set to "abort" doesn't need the "eh_personality" lang item and also that standard crates compiled for that custom target didn't contained undefined symbols to _Unwind_Resume. But this needs an actual unit test, any suggestion on how to test this? Most of the noise in the diff is due to moving `PanicStrategy` from the `rustc` to the `rustc_back` crate. r? @alexcrichton cc @phil-opp
2016-09-27add a panic-strategy field to the target specificationJorge Aparicio-2/+2
Now a target can define its panic strategy in its specification. If a user doesn't specify a panic strategy via the command line, i.e. '-C panic', then the compiler will use the panic strategy defined by the target specification. Custom targets can pick their panic strategy via the "panic-strategy" field of their target specification JSON file. If omitted in the specification, the strategy defaults to "unwind". closes #36647
2016-09-24Load macros from `#[macro_use]` extern crates in `resolve`.Jeffrey Seyfried-1/+1
2016-09-23Load extern crates in `resolve`.Jeffrey Seyfried-109/+74
2016-09-20rustc_metadata: replace RBML with a simple and type-safe scheme.Eduard Burtescu-172/+39
2016-09-20rustc_metadata: move all encoding/decoding helpers to methods.Eduard Burtescu-17/+18
2016-09-20rustc_metadata: use the shorthand encoding for predicates also.Eduard Burtescu-1/+0
2016-09-20rustc_metadata: group information into less tags.Eduard Burtescu-35/+30
2016-09-20rustc_metadata: move more RBML tags to auto-serialization.Eduard Burtescu-13/+1
2016-09-20rustc_metadata: go only through rustc_serialize in astencode.Eduard Burtescu-14/+16
2016-09-04Auto merge of #36203 - petrochenkov:uvsdot, r=nrcbors-8/+8
Replace `_, _` with `..` in patterns This is how https://github.com/rust-lang/rust/issues/33627 looks in action. Looks especially nice in leftmost/rightmost positions `(first, ..)`/`(.., last)`. I haven't touched libsyntax intentionally because the feature is still unstable.
2016-09-04Rollup merge of #36070 - gavinb:master, r=jonathandturnerManish Goregaokar-4/+6
Update error format for E0458, E0459 Fixes #35933, #35932 Part of #35233 r? @jonathandturner
2016-09-04Replace `_, _` with `..`Vadim Petrochenkov-8/+8
2016-09-02rustc: Implement custom derive (macros 1.1)Alex Crichton-56/+148
This commit is an implementation of [RFC 1681] which adds support to the compiler for first-class user-define custom `#[derive]` modes with a far more stable API than plugins have today. [RFC 1681]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md The main features added by this commit are: * A new `rustc-macro` crate-type. This crate type represents one which will provide custom `derive` implementations and perhaps eventually flower into the implementation of macros 2.0 as well. * A new `rustc_macro` crate in the standard distribution. This crate will provide the runtime interface between macro crates and the compiler. The API here is particularly conservative right now but has quite a bit of room to expand into any manner of APIs required by macro authors. * The ability to load new derive modes through the `#[macro_use]` annotations on other crates. All support added here is gated behind the `rustc_macro` feature gate, both for the library support (the `rustc_macro` crate) as well as the language features. There are a few minor differences from the implementation outlined in the RFC, such as the `rustc_macro` crate being available as a dylib and all symbols are `dlsym`'d directly instead of having a shim compiled. These should only affect the implementation, however, not the public interface. This commit also ended up touching a lot of code related to `#[derive]`, making a few notable changes: * Recognized derive attributes are no longer desugared to `derive_Foo`. Wasn't sure how to keep this behavior and *not* expose it to custom derive. * Derive attributes no longer have access to unstable features by default, they have to opt in on a granular level. * The `derive(Copy,Clone)` optimization is now done through another "obscure attribute" which is just intended to ferry along in the compiler that such an optimization is possible. The `derive(PartialEq,Eq)` optimization was also updated to do something similar. --- One part of this PR which needs to be improved before stabilizing are the errors and exact interfaces here. The error messages are relatively poor quality and there are surprising spects of this such as `#[derive(PartialEq, Eq, MyTrait)]` not working by default. The custom attributes added by the compiler end up becoming unstable again when going through a custom impl. Hopefully though this is enough to start allowing experimentation on crates.io! syntax-[breaking-change]
2016-08-29E0458 Update error format #35932Gavin Baker-2/+3
- Fixes #35932 - Part of #35233 r? @jonathandturner
2016-08-29E0459 Update error format #35933Gavin Baker-2/+3
- Fixes #35933 - Part of #35233 r? @jonathandturner
2016-08-25Refactor away `AttrMetaMethods`.Jeffrey Seyfried-1/+1
2016-08-25Refactor away `AttrNestedMetaItemMethods`.Jeffrey Seyfried-1/+1
2016-08-25Implement RFC#1559: allow all literals in attributes.Sergio Benitez-2/+1
2016-08-24Update E0445 and E0454 to new error formatMohit Agarwal-2/+4
Fixes #35922. Fixes #35930. Part of #35233. r? @GuillaumeGomez
2016-08-11Remove the 'cfg' field from session::config::Options.Michael Woerister-3/+7
The 'cfg' in the Options struct is only the commandline-specified subset of the crate configuration and it's almost always wrong to read that instead of the CrateConfig in HIR crate node.
2016-07-28Store `crate_disambiguator` as an `InternedString`Niko Matsakis-1/+1
We used to use `Name`, but the session outlives the tokenizer, which means that attempts to read this field after trans has complete otherwise panic. All reads want an `InternedString` anyhow.
2016-07-11Avoid passing around the thread-local interner in `librustc_metadata`.Jeffrey Seyfried-1/+0
2016-07-02make the metadata lock more robust and bump the metadata encoding versionAriel Ben-Yehuda-21/+2
check the metadata lock when loading rather than afterwards Fixes #33733 Fixes #33015
2016-06-28refactor rustc_metadata to use CamelCase names and IndexVecAriel Ben-Yehuda-42/+38
2016-06-26Rollup merge of #33943 - jseyfried:libsyntax_cleanup, r=nrcJeffrey Seyfried-2/+2
Miscellaneous low priority cleanup in `libsyntax`.
2016-06-23Move errors from libsyntax to its own crateJonathan Turner-6/+7
2016-06-16Add an abs_path member to FileMap, use it when writing debug info.Ted Mielczarek-0/+2
When items are inlined from extern crates, the filename in the debug info is taken from the FileMap that's serialized in the rlib metadata. Currently this is just FileMap.name, which is whatever path is passed to rustc. Since libcore and libstd are built by invoking rustc with relative paths, they wind up with relative paths in the rlib, and when linked into a binary the debug info uses relative paths for the names, but since the compilation directory for the final binary, tools trying to read source filenames will wind up with bad paths. We noticed this in Firefox with source filenames from libcore/libstd having bad paths. This change stores an absolute path in FileMap.abs_path, and uses that if available for writing debug info. This is not going to magically make debuggers able to find the source, but it will at least provide sensible paths.
2016-06-15prefer `if let` to match with `None => ()` arm in some placesZack M. Davis-23/+20
Casual grepping revealed some places in the codebase (some of which antedated `if let`'s December 2014 stabilization in c200ae5a) where we were using a match with a `None => ()` arm where (in the present author's opinion) an `if let` conditional would be more readable. (Other places where matching to the unit value did seem to better express the intent were left alone.) It's likely that we don't care about making such trivial, non-functional, sheerly æsthetic changes. But if we do, this is a patch.
2016-06-14Remove the type parameter from `syntax::visit::Visitor`Jeffrey Seyfried-2/+2
2016-05-25rustc: use a simpler scheme for plugin registrar symbol names.Eduard Burtescu-5/+9
2016-05-20Auto merge of #33625 - alexcrichton:rustbuild-moar-tests, r=aturonbors-49/+80
rustbuild: Touch up some test suites This adds in some missing test suites, primarily a few pretty suites. It also starts optimizing tests by default as the current test suite does, but also recognizes `--disable-optimize-tests`. Currently the optimization of tests isn't recognized by crate tests because Cargo doesn't support the ability to compile an unoptimized test suite against an optimized library. Perhaps a feature to add, though!
2016-05-20rustc: Fix again order-dependence in extern crateAlex Crichton-49/+80
Originally fixed in #29961 the bug was unfortunately still present in the face of crates using `#[macro_use]`. This commit refactors for the two code paths to share common logic to ensure that they both pick up the same bug fix. Closes #33762
2016-05-20Auto merge of #33553 - alexcrichton:cdylibs, r=brsonbors-0/+1
rustc: Add a new crate type, cdylib This commit is an implementation of [RFC 1510] which adds a new crate type, `cdylib`, to the compiler. This new crate type differs from the existing `dylib` crate type in a few key ways: * No metadata is present in the final artifact * Symbol visibility rules are the same as executables, that is only reachable `extern` functions are visible symbols * LTO is allowed * All libraries are always linked statically This commit is relatively simple by just plubming the compiler with another crate type which takes different branches here and there. The only major change is an implementation of the `Linker::export_symbols` function on Unix which now actually does something. This helps restrict the public symbols from a cdylib on Unix. With this PR a "hello world" `cdylib` is 7.2K while the same `dylib` is 2.4MB, which is some nice size savings! [RFC 1510]: https://github.com/rust-lang/rfcs/pull/1510 Closes #33132
2016-05-19rustc: Add a new crate type, cdylibAlex Crichton-0/+1
This commit is an implementation of [RFC 1510] which adds a new crate type, `cdylib`, to the compiler. This new crate type differs from the existing `dylib` crate type in a few key ways: * No metadata is present in the final artifact * Symbol visibility rules are the same as executables, that is only reachable `extern` functions are visible symbols * LTO is allowed * All libraries are always linked statically This commit is relatively simple by just plubming the compiler with another crate type which takes different branches here and there. The only major change is an implementation of the `Linker::export_symbols` function on Unix which now actually does something. This helps restrict the public symbols from a cdylib on Unix. With this PR a "hello world" `cdylib` is 7.2K while the same `dylib` is 2.4MB, which is some nice size savings! [RFC 1510]: https://github.com/rust-lang/rfcs/pull/1510 Closes #33132
2016-05-18allow retracing paths across cratesNiko Matsakis-0/+1
For external crates, we must build up a map that goes from the DefKey to the DefIndex. We do this by iterating over each index that is found in the metadata and loading the associated DefKey.
2016-05-11Make LocalCrateReader private to creader.Ms2ger-8/+19