| Age | Commit message (Collapse) | Author | Lines |
|
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
|
|
|
|
This is more idiomatic, putting the caller in charge of whether or not
to panic.
|
|
|
|
|
|
|
|
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 :)
|
|
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.
|
|
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.
|
|
this was required to preserve the span from
the #[structural_match] attribute -- but honestly
I am not 100% sure if it makes sense.
|
|
|
|
|
|
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
|
|
|
|
|
|
r? @nrc
|
|
|
|
|
|
This allows to render multiple spans on one line,
or to splice multiple replacements into a code suggestion.
|
|
format_args! and derive to maintain compatability
|
|
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
|
|
|
|
|
|
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
```
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
It is all `debug!` instrumentation so it should not impose a cost on
non-debug builds.
|
|
This basically only affects modules which are empty (or only contain comments).
Closes #26755
|
|
|
|
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
|
|
|
|
These used to return wrong results in case they were expanded inside compiler’s
iternal syntax sugar (closures, if-let) expansions
Fixes #26322
|
|
|
|
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
Conflicts:
src/libcore/result.rs
|
|
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]
|
|
|
|
|
|
|
|
|