This commit disables polymorphisation to resolve regressions related to
closures which inherit unused generic parameters and are then used in
casts or reflection.
Signed-off-by: David Wood <david@davidtw.co>
This commit changes the span and content of the "collection encountered
polymorphic constant" bug in monomorphization collection to point to the
use of the constant rather than the definition.
Signed-off-by: David Wood <david@davidtw.co>
Disable Azure Pipelines except for macOS
Following up on https://github.com/rust-lang/rust/pull/74565, this PR disables most of Azure Pipelines except for macOS auto builds, practically switching us to GitHub Actions 🎉
r? @Mark-Simulacrum
This adds a dedicated branch for perf to use for CI, intended to allow perf to
enqueue builds without needing to use bors. bors is great, but bors requires an
open PR to work, and we want to invoke perf on closed PRs sometimes (in
particular, rollups).
[AVR] Correctly set the pointer address space when constructing pointers to functions
NOTE: Pull request iterations:
* https://github.com/dylanmckay/rust/releases/tag/avr-use-correct-addrspace.0
* https://github.com/dylanmckay/rust/releases/tag/avr-use-correct-addrspace.1
* https://github.com/dylanmckay/rust/releases/tag/avr-use-correct-addrspace.2
This patch extends the existing `type_i8p` method so that it requires an
explicit address space to be specified. Before this patch, the
`type_i8p` method implcitily assumed the default address space, which is
not a safe transformation on all targets, namely AVR.
The Rust compiler already has support for tracking the "instruction
address space" on a per-target basis. This patch extends the code
generation routines so that an address space must always be specified.
In my estimation, around 15% of the callers of `type_i8p` produced
invalid code on AVR due to the loss of address space prior to LLVM final
code generation. This would lead to unavoidable assertion errors
relating to invalid bitcasts.
With this patch, the address space is always either 1) explicitly preserved
from the input type, or 2) explicitly set to the instruction address
space because the logic is dealing with functions which must be placed
there, or 3) explicitly set to the default address space 0 because the
logic can only operate on data space pointers and thus we keep the
existing semantics of assuming the default, "data" address space.
Fix rust-src component.
The rust-src component could not be installed by rustup because it included some symbolic links. #74520 added the backtrace directory which included some symlinks. Since the rust-src component doesn't need most of the files in the `backtrace` submodule, this changes it to only include the minimum necessary.
Tested with cargo's build-std that it can build from the resulting tarball.
Fixes#74577
Upload builds from GHA instead of Azure Pipelines
This PR does two things:
* Enables RLA comments on PRs (needed after the switch to GHA in RLA).
* Switches GitHub Actions as the CI authorized to upload non-macOS builds.
Note that Docker/LLVM caches will likely be busted.
r? @Mark-Simulacrum
Now that #74163 updated the minimum Linux kernel to 2.6.32, we can
assume the availability of APIs that open file descriptors that are
already set to close on exec, including the flags `O_CLOEXEC`,
`SOCK_CLOEXEC`, and `F_DUPFD_CLOEXEC`.
Before this patch, a function pointer stored within an aggregate like a
struct or an enum would always have the default address space `0`.
This patch removes this assumption and instead, introspects the inner
type being pointed at, storing the target address space in the PointeeInfo
struct so that downstream users may query it.
This patch extends the existing `type_i8p` method so that it requires an
explicit address space to be specified. Before this patch, the
`type_i8p` method implcitily assumed the default address space, which is
not a safe transformation on all targets, namely AVR.
The Rust compiler already has support for tracking the "instruction
address space" on a per-target basis. This patch extends the code
generation routines so that an address space must always be specified.
In my estimation, around 15% of the callers of `type_i8p` produced
invalid code on AVR due to the loss of address space prior to LLVM final
code generation. This would lead to unavoidable assertion errors
relating to invalid bitcasts.
With this patch, the address space is always either 1) explicitly set to
the instruction address space because the logic is dealing with functions
which must be placed there, or 2) explicitly set to the default address
space 0 because the logic can only operate on data space pointers and thus
we keep the existing semantics of assuming the default, "data" address space.
Add `RawFd` to WASI's `std::os::wasi::prelude`.
Add `RawFd` to WASI's `std::os::wasi::prelude`, making it consistent
with all other platforms which also have `AsRawFd`, `FromRawFd`, and
`IntoRawFd` in their respective preludes.
Polymorphization
This PR implements an analysis to detect when functions could remain polymorphic during code generation.
Fixes#46477
r? @eddyb
cc @rust-lang/wg-mir-opt @nikomatsakis @pnkfelix
This commit refactors intra-doc link error reporting to deduplicate code
and decouple error construction from the type of error. This greatly
improves flexibility at each error construction site, while reducing the
complexity of the diagnostic creation.
This commit also rewords the diagnostics for clarity and style:
- Diagnostics should not end in periods.
- It's unnecessary to say "ignoring it". Since this is a warning by
default, it's already clear that the link is ignored.
Improve "important traits" popup display on mobile
I implemented what @XAMPPRocky suggested in the [internals thread topic](https://internals.rust-lang.org/t/feedback-on-important-traits-rustdoc-feature/12752/18). I can confirm it works nicely.
r? @Manishearth
@Manishearth: By the way: I realized that when you click on the "i", you have to click again to make the popup disappear. Do you want me to extend the popup removal to any click outside the popup?
Update sanitizer docs
* Document AddressSanitizer memory leak detection defaults.
* Remove CC & CFLAGS from MemorySanitizer example - they are now unnecessary for pure Rust projects (backtrace-rs moved away from libbacktrace).
test caching opt_const_param_of on disc
Followup to #74113, implements parts of #74360
Tried caching `opt_const_param_of` on disk and adding an early exit if `tcx.dep_kind(def_id) != DefKind::AnonConst`.
Ended up causing a perf regression instead, so we just remove the FIXME and a short note to `opt_const_param_of`.
r? @eddyb
disallow non-static lifetimes in const generics
Disallow non-static lifetimes in const generics in order to to patch over an ICE caused when we encounter a non-static lifetime in a const generic during borrow checking. This restriction may be relaxed in the future, but we need more discussion before then, and in the meantime we should still deal with this ICE.
Fixes issue #60814
wf: check foreign fn decls for well-formedness
Fixes#73252 and fixes#73253.
This PR extends current well-formedness checking to apply to foreign function declarations, re-using the existing machinery for regular functions. In doing this, later parts of the compiler (such as the `improper_ctypes` lint) can rely on being operations not failing as a result of invalid code which would normally be caught earlier.
Impl Default for ranges
Couldn't find an issue about it.
`Range` and friends probably can implement `Default` if `Idx: Default`. For example, the following would be possible:
```rust
#[derive(Default)]
struct Foo(core::ops::RangeToInclusive<u64>);
let _ = [1, 2, 3].get(core::ops::Range::default());
core::ops::RangeFrom::<u8>::default().take(20).for_each(|x| { dbg!(x); });
fn stuff<T: Default>() { let instance = T::default(); ... more stuff }
stuff::<core::ops::RangeTo<f32>>();
```
Maybe there are some concerns about safety or misunderstandings?
This commit introduces a `FiniteBitSet` type which replaces the manual
bit manipulation which was being performed in polymorphization.
Signed-off-by: David Wood <david@davidtw.co>
This commit replaces the `-Z polymorphize-errors` debugging flag with a
`#[rustc_polymorphize_error]` attribute for use on functions.
Signed-off-by: David Wood <david@davidtw.co>
This commit records the results of `unused_generic_params` in crate
metadata, hopefully improving performance.
Signed-off-by: David Wood <david@davidtw.co>
This commit normalizes function signatures for instances before
substituting, a workaround for polymorphization considering
parameters unused when they show up in the signature, but not the
body (due to being normalized).
Unfortunately, this causes test output to change with the parallel
compiler only.
Signed-off-by: David Wood <david@davidtw.co>