proc_macro: Preserve spans of attributes on functions
This commit updates the tokenization of items which are subsequently passed to
`proc_macro` to ensure that span information is preserved on attributes as much
as possible. Previously this area of the code suffered from #43081 where we
haven't actually implemented converting an attribute to to a token tree yet, but
a local fix was possible here.
Closes#47941
Calculate Vec capacities in librustc
Calculate the required capacity of a few vectors in rustc based on the number of elements they are populated with.
Fix docker/run.sh script when run locally
Switch a `mkdir $foo` to `mkdir -p $foo` to handle the case that this script is
being run locally and has previously executed.
rustc: Fix two custom attributes with custom derive
This commit fixes an issue where multiple custom attributes could not be fed
into a custom derive in some situations with the `use_extern_macros` feature
enabled. The problem was that the macro expander didn't consider that it was
making progress when we were deducing that attributes should be lumped in with
custom derive invocations.
The fix applied here was to track in the expander if our attribute is changing
(getting stashed away elsewhere and replaced with a new invocation). If it is
swapped then it's considered progress, otherwise behavior should remain the
same.
Closes#52525
rustc: Remove a workaround in ThinLTO fixed upstream
This commit removes a hack in our ThinLTO passes which removes available
externally functions manually. The [upstream bug][1] has long since been fixed,
so we should be able to rely on LLVM natively for this now!
[1]: https://bugs.llvm.org/show_bug.cgi?id=35736
fix unsafety: don't call ptr_rotate for ZST
`rotate::ptr_rotate` has a comment saying
```
/// # Safety
///
/// The specified range must be valid for reading and writing.
/// The type `T` must have non-zero size.
```
So we better make sure we don't call it on ZST...
Cc @scottmcm (author of https://github.com/rust-lang/rust/pull/41670)
stabilize lint handling in rustdoc
When https://github.com/rust-lang/rust/pull/51732 added CLI flags to manipulate lints in rustdoc, they were added as unstable flags. This made sense as they were new additions, but since they mirrored the flags that rustc has, it's worth considering them to not need an unstable period.
Stabilizing them also provides the opportunity for a critical fix: allowing Cargo to pass `--cap-lints allow` when documenting dependencies, the same as when it compiles them.
r? @rust-lang/rustdoc
Const propagate casts
fixes#49760
So... This fixes the original issue about the missing warnings.
But our test suite contains fun things like
```rust
fn foo() {}
assert_eq!(foo as i16, foo as usize as i16);
```
Which, will result in
> a raw memory access tried to access part of a pointer value as raw bytes
on both sides of the assertion. Because well... that's exactly what's going on! We're ripping out 16 bits of a pointer.
Categorize queries for later self-profiling
Change the define_queries! macro per feedback on #51657.
Big thanks to @mark-i-m for the help getting the macro changes correct!
I'm pulling this commit out of the other PR because it's hard to keep up-to-date as queries are added or changed.
r? @nikomatsakis
Squash all lints tied to foreign macros by default
This PR is a continuation of https://github.com/rust-lang/rust/pull/49755 (thanks for the initial jump-start @Dylan-DPC!) and is targeted at solving https://github.com/rust-lang/rust/issues/48855. This change updates the lint infrastructure to, by default, ignore all lints emitted for code that originates in a foreign macro. For example if `println!("...")` injects some idiomatic warnings these are all ignored by default. The rationale here is that for almost all lints there's no action that can be taken if the code originates from a foreign lint.
Closes#48855Closes#52483Closes#52479
rustc: Stabilize #[wasm_import_module] as #[link(...)]
This commit stabilizes the `#[wasm_import_module]` attribute as
`#[link(wasm_import_module = "...")]`. Tracked by #52090 this new directive in
the `#[link]` attribute is used to configured the module name that the imports
are listed with. The WebAssembly specification indicates two utf-8 names are
associated with all imported items, one for the module the item comes from and
one for the item itself. The item itself is configurable in Rust via its
identifier or `#[link_name = "..."]`, but the module name was previously not
configurable and defaulted to `"env"`. This commit ensures that this is also
configurable.
Closes#52090
When encountering format string errors in a raw string, or regular
string literal with embedded newlines, account for the positional
change to use correct spans.
:drive by fix: 🚗
- Don't print the newline on its own to avoid the possibility of
printing it out of order due to `stdout` locking.
- Modify wording of `concat!()` with non-literals to not mislead into
believing that only `&str` literals are accepted.
- Add test for `concat!()` with non-literals.