rustc: Fix proc_macro expansions on trait methods
This commit fixes procedural macro attributes being attached to trait methods,
ensuring that they get resolved and expanded as other procedural macro
attributes. The bug here was that `current_module` on the resolver was
accidentally set to be a trait when it's otherwise only ever expecting a
`mod`/block module. The actual fix here came from @jseyfried, I'm just helping
to land it in the compiler!
Closes#42493
Make fields of `Span` private
I actually tried to intern spans and benchmark the result<sup>*</sup>, and this was a prerequisite.
This kind of encapsulation will be a prerequisite for any other attempt to compress span's representation, so I decided to submit this change alone.
The issue https://github.com/rust-lang/rust/issues/43088 seems relevant, but it looks like `SpanId` won't be able to reuse this interface, unless the tables are global (like interner that I tried) and are not a part of HIR.
r? @michaelwoerister anyway
<sup>*</sup> Interning means 2-3 times more space is required for a single span, but duplicates are free. In practice it turned out that duplicates are not *that* common, so more memory was wasted by interning rather than saved.
Remove the trait selection impl in method::probe
This removes the hacky trait selection reimplementation in `method::probe`, which occasionally comes and causes problems.
There are 2 issues I've found with this approach:
1. The older implementation sometimes had a "guess" type from an impl, which allowed subtyping to work. This is why I needed to make a change in `libtest`: there's an `impl<A> Clone for fn(A)` and we're calling `<for<'a> fn(&'a T) as Clone>::clone`. The older implementation would do a subtyping between the impl type and the trait type, so it would do the check for `<fn(A) as Clone>::clone`, and confirmation would continue with the subtyping. The newer implementation directly passes `<for<'a> fn(&'a T) as Clone>::clone` to selection, which fails. I'm not sure how big of a problem that would be in reality, especially after #43690 would remove the `Clone` problem, but I still want a crater run to avoid breaking the world.
2. The older implementation "looked into" impls to display error messages. I'm not sure that's an advantage - it looked exactly 1 level deep.
r? @eddyb
This map, like `trait_map`, is calculated in resolve, but we want to be sure to
track it for incremental compliation. Hide it behind a query to get more
refactorings later.
rustbuild: Avoid some extraneous rustc compiles on cross builds
This tweaks a few locations here and there to avoid compiling rustc too many times on our cross-builders on CI.
Closes https://github.com/rust-lang/rust/issues/44132
This map is calculated in resolve, but we want to be sure to track it for
incremental compliation. Hide it behind a query to get more refactorings later.
Rename the rls component to rls-preview on beta/stable
Background is that we will have automatic renaming with the next rustup release. We'll then rename rls to rls-preview. In the meantime, this ensures beta/stable users will always have rls-preview.
r? @alexcrichton
Fail ./x.py on invalid command
Make the ./x.py script fail when run with an invalid command, like:
```
./x.py nonsense
```
This helps in case of chaining multiple runs, eg.:
```
./x.py biuld && ./x.py test
```
Rewrite `std::net::ToSocketAddrs` doc examples.
in particular:
* show how to create an iterator that yields multiple socket addresses
* show more failing scenarios
done this as preliminary work while investigating https://github.com/rust-lang/rust/issues/22569
note: i haven't run doc tests on my machine for this, so would be good to confirm CI passes before approving
include Cargo.{toml,lock} in rust-src tarball
The lock file is interesting because e.g. xargo could use it to build libstd against the same dependencies that were used for the main build. More generally speaking, just documenting in this form which exact dependencies should be used IMHO makes lots of sense.
I added the Cargo.toml mostly because having the lock without the toml feels odd. Of course, the toml contains references to paths that don't actually exist in the rust-src tarball. Not sure if that is considered a problem.
Don't highlight # which does not start an attribute in rustdoc
Currently when we highlight some macros for rustdoc (e.g. `quote!` from https://github.com/dtolnay/quote), we get really bad syntax highlighting, because we assume that every token between a `#` character and the next `]` in the source must be an attribute.
This patch improves that highlighting behavior to instead only highlight after finding the `[` token after the `#` token.
(NOTE: I've only run this patch against https://github.com/nrc/rustdoc-highlight so if it doesn't build on travis that's why - I don't have a recent rustc build on this laptop)
I'm guessing r? @steveklabnik
Fix alloc_jemalloc debug feature
At least, I think that's how it should be. 'debug' is how the feature is called in liballoc_jemalloc/Cargo.toml and libstd/Cargo.toml. I verified this by making the build script panic rather than adding `--enable-debug`, and without this PR, the panic does not occur even when I set `debug-jemalloc = true` in config.toml. With the PR, the panic occurs as expected.
However, I actually have no idea what I am doing here.
This commit removes the `specialization_cache` field of `TyCtxt` by moving it to
a dedicated query, which it turned out was already quite easily structured to do
so!