Cleanup handling of hygiene for built-in macros
This makes most identifiers generated by built-in macros use def-site hygiene, not only the ones that previously used gensyms.
* `ExtCtxt::ident_of` now takes a `Span` and is preferred to `Ident::{from_str, from_str_and_span}`
* Remove `Span::with_legacy_ctxt`
* `assert` now uses call-site hygiene because it needs to resolve `panic` unhygienically.
* `concat_idents` now uses call-site hygiene because it wouldn't be very useful with def-site hygiene.
* everything else is moved to def-site hygiene
r? @petrochenkov
Warn on no_start, crate_id attribute use
These attributes are now deprecated; they don't have any use anymore.
`no_start` stopped being applicable in 3ee916e50b as part of #18967. Ideally we would've removed it pre-1.0, but since that didn't happen let's at least mark it deprecated.
`crate_id` was renamed to `crate_name` in 50ee1ec1b4 as part of #15319. Ideally we would've followed that up with a removal of crate_id itself as well, but that didn't happen; this PR finally marks it as deprecated at least.
Fixes https://github.com/rust-lang/rust/issues/43142 and resolves https://github.com/rust-lang/rust/issues/43144.
def_collector: Do not ICE on attributes on unnamed fields
The primary issue here is that the expansion infra needs to visit a field in isolation, and fields don't know their own indices during expansion, so they have to be kept in some other place (e.g. `struct Definitions`).
Fixes https://github.com/rust-lang/rust/issues/64385
Use `panic::set_hook` to print the ICE message
This allows custom frontends and backends to override the hook with their own, for example to point people to a different issue tracker.
ICE messages are printed in a slightly different order now. Nightly prints:
```
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0277, E0658.
For more information about an error, try `rustc --explain E0277`.
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.36.0-nightly (08bfe1612 2019-05-02) running on x86_64-unknown-linux-gnu
```
After this PR, rustc prints:
```
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.36.0-dev running on x86_64-unknown-linux-gnu
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0277, E0658.
For more information about an error, try `rustc --explain E0277`.
```
This is not perfectly correct as `#[attr] (5)` will still not lint, but
it does seem good enough, in particular as the parentheses in that case
are not unambiguously incorrect.
Rollup of 4 pull requests
Successful merges:
- #61797 (Stabilise weak_ptr_eq)
- #64290 (Provide a span if main function is not present in crate)
- #64406 (Ban non-extern rust intrinsics)
- #64462 (feature_gate: Remove dead code from attribute checking)
Failed merges:
r? @ghost
feature_gate: Remove dead code from attribute checking
https://github.com/rust-lang/rust/pull/63468 is merged, so all attributes go through name resolution now, so we can remove code that previously performed some checks for attributes not going through resolution.
Provide a span if main function is not present in crate
Unfortunately, the diagnostic machinery does not cope well with an empty
span which can happen if the crate is empty, in which case we merely set
a spanless note.
Tests are already updated for this change, so a dedicated test is not added.
Resolves#36561.
Unfortunately, the diagnotic machinery does not cope well with an empty
span which can happen if the crate is empty, in which case we merely set
a spanless note.
Rollup of 17 pull requests
Successful merges:
- #63846 (Added table containing the system calls used by Instant and SystemTime.)
- #64116 (Fix minor typo in docs.)
- #64203 (A few cosmetic improvements to code & comments in liballoc and libcore)
- #64302 (Shrink `ObligationCauseCode`)
- #64372 (use randSecure and randABytes)
- #64374 (Box `DiagnosticBuilder`.)
- #64375 (Fast path for vec.clear/truncate )
- #64378 (Fix inconsistent link formatting.)
- #64384 (Trim rustc-workspace-hack)
- #64393 ( declare EnvKey before use to fix build error)
- #64420 (Inline `mark_neighbours_as_waiting_from`.)
- #64422 (Remove raw string literal quotes from error index descriptions)
- #64423 (Add self to .mailmap)
- #64425 (typo fix)
- #64431 (fn ptr is structural match)
- #64435 (codegen: use "_N" (like for other locals) instead of "argN", for argument names.)
- #64439 (fix#64430, confusing `owned_box` error message in no_std build)
Failed merges:
r? @ghost
codegen: use "_N" (like for other locals) instead of "argN", for argument names.
Based on #64408 (second commit is new), fixing something I mentioned in #64408 (which turned to be an immediate blocker for unifying relevant codepaths).
Closes#64408 (by containing it).
r? @rkruppe