This commit fixes a regression from #44601 where lowering attribute to HIR now
involves expanding interpolated tokens to their actual tokens. In that commit
all interpolated tokens were surrounded with a `DelimToken::None` group of
tokens, but this ended up causing regressions like #44730 where the various
attribute parsers in `syntax/attr.rs` weren't ready to cope with
`DelimToken::None`. Instead of fixing the parser in `attr.rs` this commit
instead opts to just avoid the `DelimToken::None` in the first place, ensuring
that the token stream should look the same as it did before where possible.
Closes#44730
Add clippy to `toolstate.toml`
r? @alexcrichton
cc @Manishearth
I have no idea how to get clippy working... it needs proc macros, and I think I did everything right (I just did what the cargo step is doing), but it's not working:
```
error: libproc_macro-6210e4b46662ec28.so: cannot open shared object file: No such file or directory
--> src/tools/clippy/clippy_lints/src/lib.rs:47:1
|
47 | extern crate serde_derive;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: libproc_macro-6210e4b46662ec28.so: cannot open shared object file: No such file or directory
--> src/tools/clippy/clippy_lints/src/lib.rs:47:1
|
47 | extern crate serde_derive;
| ^
```
It's especially weird since it used to work
Anyway. Fixing it can be left for a future PR, this one adds it to CI, but marks it as "broken"
`--cap-lints allow` switches off `can_emit_warnings`
This boolean field on the error `Handler` is toggled to silence
warnings when `-A warnings` is passed. (This is actually a separate
mechanism from the global lint level—whether there's some redundancy
to be factored away here is an important question, but not one we
concern ourselves with in this commit.) But the same rationale
applies for `--cap-lints allow`. In particular, this makes the "soft"
feature-gate warning introduced in 8492ad24 (which is not a lint, but
just calls `struct_span_warn`) not pollute the builds of dependent
crates.
Thanks to @kennytm for pointing out the potential of
`can_emit_warnings` for this purpose.
Resolves#44213.
Implement `Copy`/`Clone` for closures
Implement RFC [#2132](https://github.com/rust-lang/rfcs/pull/2132) (tracking issue: #44490).
NB: I'm not totally sure about the whole feature gates thing, that's my first PR of this kind...
Only consider yields coming after the expressions when computing generator interiors
When looking at the scopes which temporaries of expressions can live for during computation of generator interiors, only consider yields which appear after the expression in question in the HIR.
Correctly bubble up errors from libbacktrace
Previously the first part of this code didn't check for a null pointer and blindly passed it back down, causing a segfault if libbacktrace failed to initialise. I've changed this to check and bubble up the error if relevant.
Suggested diff view: https://github.com/rust-lang/rust/pull/44525/files?w=1
Optimize drain_filter
This PR cuts out two copies from each iteration of `drain_filter` by exchanging the swap operation for a copy_nonoverlapping function call instead. Since the data being swapped is not needed anymore we can just overwrite it instead.
rework the README.md for rustc and add other readmes
OK, so, long ago I committed to the idea of trying to write some high-level documentation for rustc. This has proved to be much harder for me to get done than I thought it would! This PR is far from as complete as I had hoped, but I wanted to open it so that people can give me feedback on the conventions that it establishes. If this seems like a good way forward, we can land it and I will open an issue with a good check-list of things to write (and try to take down some of them myself).
Here are the conventions I established on which I would like feedback.
**Use README.md files**. First off, I'm aiming to keep most of the high-level docs in `README.md` files, rather than entries on forge. My thought is that such files are (a) more discoverable than forge and (b) closer to the code, and hence can be edited in a single PR. However, since they are not *in the code*, they will naturally get out of date, so the intention is to focus on the highest-level details, which are least likely to bitrot. I've included a few examples of common functions and so forth, but never tried to (e.g.) exhaustively list the names of functions and so forth.
- I would like to use the tidy scripts to try and check that these do not go out of date. Future work.
**librustc/README.md as the main entrypoint.** This seems like the most natural place people will look first. It lays out how the crates are structured and **is intended** to give pointers to the main data structures of the compiler (I didn't update that yet; the existing material is terribly dated).
**A glossary listing abbreviations and things.** It's much harder to read code if you don't know what some obscure set of letters like `infcx` stands for.
**Major modules each have their own README.md that documents the high-level idea.** For example, I wrote some stuff about `hir` and `ty`. Both of them have many missing topics, but I think that is roughly the level of depth that would be good. The idea is to give people a "feeling" for what the code does.
What is missing primarily here is lots of content. =) Here are some things I'd like to see:
- A description of what a QUERY is and how to define one
- Some comments for `librustc/ty/maps.rs`
- An overview of how compilation proceeds now (i.e., the hybrid demand-driven and forward model) and how we would like to see it going in the future (all demand-driven)
- Some coverage of how incremental will work under red-green
- An updated list of the major IRs in use of the compiler (AST, HIR, TypeckTables, MIR) and major bits of interesting code (typeck, borrowck, etc)
- More advice on how to use `x.py`, or at least pointers to that
- Good choice for `config.toml`
- How to use `RUST_LOG` and other debugging flags (e.g., `-Zverbose`, `-Ztreat-err-as-bug`)
- Helpful conventions for `debug!` statement formatting
cc @rust-lang/compiler @mgattozzi
Fix a typo in rustc help menu
Change from native-static-deps to native-static-libs.
Fix a typo introduced by this merged pull request: https://github.com/rust-lang/rust/pull/43067
[libstd_unicode] Expose UnicodeVersion type
In <https://github.com/rust-lang/rust/pull/42998>, we added an
uninstantiable type for the internal `UNICODE_VERSION` value,
`UnicodeVersion`, but it was not made public to the outside of the
crate, resulting in the value becoming less useful. Here we make the
type accessible from the outside.
Also add a run-pass test to make sure the type and value can be accessed
as intended.
Skip passing /natvis to lld-link until supported.
### Overview
Teaching rustc about MSVC's undocumented linker flag, /NATVIS, broke rustc's compatability with LLVM's `lld-link` frontend, as it does not recognize the flag. This pull request works around the problem by excluding `lld-link` by name. @retep998 discovered this regression.
### Possible Issues
- Other linkers that try to be compatible with the MSVC linker flavor may also be broken and in need of workarounds.
- Warning about the workaround may be overkill for a minor reduction in debug functionality.
- Depending on how long this workaround sticks around, it may eventually be preferred to version check `lld-link` instead of assuming all versions are incompatible.
### Relevant issues
* Broke in https://github.com/rust-lang/rust/pull/43221 Embed MSVC .natvis files into .pdbs and mangle debuginfo for &str, *T, and [T].
* LLVM patched in 27b9c42853 to ignore the flag instead of erroring.
r? @michaelwoerister