about summary refs log tree commit diff
path: root/src/libsyntax/codemap.rs
AgeCommit message (Collapse)AuthorLines
2016-05-27Auto merge of #33706 - jseyfried:refactor_cfg, r=nrcbors-25/+0
Perform `cfg` attribute processing during macro expansion and fix bugs This PR refactors `cfg` attribute processing and fixes bugs. More specifically: - It merges gated feature checking for stmt/expr attributes, `cfg_attr` processing, and `cfg` processing into a single fold. - This allows feature gated `cfg` variables to be used in `cfg_attr` on unconfigured items. All other feature gated attributes can already be used on unconfigured items. - It performs `cfg` attribute processing during macro expansion instead of after expansion so that macro-expanded items are configured the same as ordinary items. In particular, to match their non-expanded counterparts, - macro-expanded unconfigured macro invocations are no longer expanded, - macro-expanded unconfigured macro definitions are no longer usable, and - feature gated `cfg` variables on macro-expanded macro definitions/invocations are now errors. This is a [breaking-change]. For example, the following would break: ```rust macro_rules! m { () => { #[cfg(attr)] macro_rules! foo { () => {} } foo!(); // This will be an error macro_rules! bar { () => { fn f() {} } } #[cfg(attr)] bar!(); // This will no longer be expanded ... fn g() { f(); } // ... so that `f` will be unresolved. #[cfg(target_thread_local)] // This will be a gated feature error macro_rules! baz { () => {} } } } m!(); ``` r? @nrc
2016-05-27Update spans' `expn_id` during the marking foldJeffrey Seyfried-25/+0
2016-05-24syntax: Make codemap::get_filemap() return an OptionKamal Marhubi-3/+3
This is more idiomatic, putting the caller in charge of whether or not to panic.
2016-05-02Nit: remove push_primary_span, which was never calledNiko Matsakis-4/+0
2016-05-02Nit: add commentNiko Matsakis-3/+5
2016-05-02Nit: comments should be uppercase letterNiko Matsakis-4/+4
2016-05-02refactor to use new snippet code and modelNiko Matsakis-74/+13
Major changes: - Remove old snippet rendering code and use the new stuff. - Introduce `span_label` method to add a label - Remove EndSpan mode and replace with a fn to get the last character of a span. - Stop using `Option<MultiSpan>` and just use an empty `MultiSpan` - and probably a bunch of other stuff :)
2016-05-02revamp MultiSpan and introduce new snippet codeNiko Matsakis-135/+83
MultiSpan model is now: - set of primary spans - set of span+label pairs Primary spans render with `^^^`, secondary spans with `---`. Labels are placed next to the `^^^` or `---` marker as appropriate.
2016-04-21port compiletest to use JSON outputNiko Matsakis-0/+50
This uncovered a lot of bugs in compiletest and also some shortcomings of our existing JSON output. We had to add information to the JSON output, such as suggested text and macro backtraces. We also had to fix various bugs in the existing tests. Joint work with jntrnr.
2016-03-25do not overwrite spans as eagerlyNiko Matsakis-0/+25
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-22fix alignmentJorge Aparicio-65/+65
2016-03-22break long lineJorge Aparicio-1/+2
2016-03-22try! -> ?Jorge Aparicio-43/+32
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-02-12syntax: Replace unstable `vec.as_slice().get()` with `vec.get()`Erick Tryzelaar-1/+1
2016-02-03Changed macro spans in CSVs to point to the macro name, bugfixed nested spansDaniel Campbell-1/+20
2016-02-02Auto merge of #31279 - DanielJCampbell:MacroReferencing, r=nrcbors-0/+21
r? @nrc
2016-02-01Implemented macro referencing for save analysisDaniel Campbell-0/+21
2016-02-01Spans now derive equalityDaniel Campbell-13/+12
2016-01-28Implement MultiSpan error reportingmitaa-3/+260
This allows to render multiple spans on one line, or to splice multiple replacements into a code suggestion.
2016-01-22Extended save-analysis to support generated code, alterned some spans in ↵Daniel Campbell-2/+23
format_args! and derive to maintain compatability
2016-01-20syntax: Fix encoding and decoding spansErick Tryzelaar-5/+20
The protocol for `serialize::{En,De}code` doesn't allow for two integers to be serialized next to each other. This switches the protocol to serializing `Span`s as a struct. rbml structs don't have any overhead, so the metadata shouldn't increase in size, but it allows the json format to be properly generated, albeit slightly more heavy than when it was just serializing a span as a u64. Closes #31025. s
2015-12-28Use a more efficient encoding for opaque data in RBML.Michael Woerister-7/+4
2015-12-08Added pretty-printing for span expansion chains through span_to_expanded_string.Daniel Campbell-0/+204
2015-11-12Add -Zinput-statsNick Cameron-0/+8
Emits loc, and node count - before and after expansion. E.g., ``` rustc: x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore Lines of code: 32060 Pre-expansion node count: 120205 Post-expansion node count: 482749 ```
2015-10-09Some cleanup of no longer used AST thingsNick Cameron-22/+0
2015-10-03Add a method to test span containmentSeo Sanghyeon-1/+5
2015-09-24Cleanup interfaces of Name, SyntaxContext and IdentVadim Petrochenkov-1/+0
Make sure Name, SyntaxContext and Ident are passed by value Make sure Idents don't serve as keys (or parts of keys) in maps, Ident comparison is not well defined
2015-08-31Closures are not generated code.Nick Cameron-2/+0
2015-08-28Move ExpnInfo to NameManish Goregaokar-7/+9
2015-08-27Enumify CompilerExpansion in ExpnInfoManish Goregaokar-7/+34
2015-08-10add and use Span.substitute_dummy methodTim Neumann-0/+7
2015-07-22Instrumentation in effort to understand treatment of `allow_internal_unstable`.Felix S. Klock II-0/+4
It is all `debug!` instrumentation so it should not impose a cost on non-debug builds.
2015-07-21Use a span from the correct file for the inner span of a moduleNick Cameron-1/+1
This basically only affects modules which are empty (or only contain comments). Closes #26755
2015-07-21Provide a filemap ctor with line infoNick Cameron-14/+16
2015-07-21Allow for space between each filemap in the codemapNick Cameron-72/+90
So if a filemap's last byte is at position n in the codemap, then n+1 will not refer to any filemap, and the next filemap will begin an n+2. This is useful for empty files, it means that every file (even empty ones) has a byte in the codemap. Closes #23301, #26504
2015-06-19Move AST Repr impls to Debug impls in libsyntax.Eduard Burtescu-2/+16
2015-06-16Fix file!(), line!() and column!() macrosSimonas Kazlauskas-53/+44
These used to return wrong results in case they were expanded inside compiler’s iternal syntax sugar (closures, if-let) expansions Fixes #26322
2015-06-11Conver reborrows to .iter() calls where appropriateJoshua Landau-2/+2
2015-05-14syntax: abstract over the file loading mechanism.Eduard Burtescu-2/+46
2015-05-12Proper spans for for loop expansionNick Cameron-1/+3
2015-05-07Auto merge of #25013 - pnkfelix:span_to_lines-oflo, r=huonwbors-5/+26
Guard against overflow in `codemap::span_to_lines`. (Revised/expanded version of PR #24976) Make `span_to_lines` to return a `Result`. In `diagnostic`, catch `Err` from `span_to_lines` and print `"(unprintable span)"` instead. ---- There a number of recent issues that report the bug here. See e.g. #24761 and #24954. This change *might* fix them. However, that is *not* its main goal. The main goals are: 1. Make it possible for callers to recover from an error here, and 2. Insert a more conservative check, in that we are also checking that the files match up. ---- As a drive-by, fix #24997 , which was causing my attempts to `make check-stage1` on an `--enable-debug` build to fail.
2015-05-05Guard against overflow in `codemap::span_to_lines`.Felix S. Klock II-5/+26
Make `span_to_lines` to return a `Result`. (This is better than just asserting internally, since it allows caller to decide if they can recover from the problem.) Added type alias for `FileLinesResult` returned by `span_to_lines`. Update embedded unit test to reflect `span_to_lines` signature change. In diagnostic, catch `Err` from `span_to_lines` and print `"(internal compiler error: unprintable span)"` instead. ---- There a number of recent issues that report the bug here. See e.g. #24761 and #24954. This change *might* fix them. However, that is not its main goal. The main goals are: 1. Make it possible for callers to recover from an error here, and 2. Insert a more conservative check, in that we are also checking that the files match up.
2015-05-01syntax: Avoid reallocating or copying in CodeMap::new_filemapUlrik Sverdrup-8/+4
Avoid creating a new String when there is no BOM to strip, and otherwises use .drain(..3) to strip the BOM using the same allocation.
2015-04-24Change name of unit test sub-module to "tests".Johannes Oertel-1/+1
Changes the style guidelines regarding unit tests to recommend using a sub-module named "tests" instead of "test" for unit tests as "test" might clash with imports of libtest.
2015-04-21rollup merge of #24636: alexcrichton/remove-deprecatedAlex Crichton-2/+5
Conflicts: src/libcore/result.rs
2015-04-21std: Remove deprecated/unstable num functionalityAlex Crichton-2/+5
This commit removes all the old casting/generic traits from `std::num` that are no longer in use by the standard library. This additionally removes the old `strconv` module which has not seen much use in quite a long time. All generic functionality has been supplanted with traits in the `num` crate and the `strconv` module is supplanted with the [rust-strconv crate][rust-strconv]. [rust-strconv]: https://github.com/lifthrasiir/rust-strconv This is a breaking change due to the removal of these deprecated crates, and the alternative crates are listed above. [breaking-change]
2015-04-21syntax: Change ExpnId::{from,to}_llvm_cookie to {from,to}_u32Erick Tryzelaar-6/+4
2015-04-21syntax: Replace Vec::map_in_place with stable mut iteratorErick Tryzelaar-9/+11
2015-04-21syntax: Replace String::from_str with the stable String::fromErick Tryzelaar-2/+2
2015-04-21Model lexer: Fix remaining issuesPiotr Czarnecki-2/+0