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
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
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>
This commit implements the `unused_generic_params` query, an initial
version of polymorphization which detects when an item does not use
generic parameters and is being needlessly monomorphized as a result.
Signed-off-by: David Wood <david@davidtw.co>
This commit makes valid shim asserts more specific - checking for the
specific types that are valid for a given type of shim - and removes
asserts for types which require substitutions.
Signed-off-by: David Wood <david@davidtw.co>
This commit adds type metadata for generic parameters (that arise from
polymorphization). Generic parameter metadata is considered zero-sized
and named after the generic parameter.
Signed-off-by: David Wood <david@davidtw.co>
This commit skips generating debuginfo type metadata if substitutions
are required by the type. This avoids ICEs that result from layouts
of types with substitutions being computed.
Signed-off-by: David Wood <david@davidtw.co>
This commit adds doc comments to the `param_at`, `region_param` and
`const_param` methods on the `Generics` struct.
Signed-off-by: David Wood <david@davidtw.co>
This commit modifies the `substitute_normalize_and_test_predicates`
query, renaming it to `impossible_predicates` and only checking
predicates which do not require substs. By making this change,
polymorphization doesn't have to explicitly support vtables.
Signed-off-by: David Wood <david@davidtw.co>
This commit modifies the `STILL_FURTHER_SPECIALIZABLE` flag so that the
flag isn't set by the parent substs of closures or generators.
Signed-off-by: David Wood <david@davidtw.co>
This commit renames `should_monomorphize_locally` to
`should_codegen_locally` which better describes what the function
determines once polymorphization is added.
Signed-off-by: David Wood <david@davidtw.co>
This commit avoids a natural, free-range double substitution error by
monomorphizing the projection element before getting the type.
Signed-off-by: David Wood <david@davidtw.co>
Use italics for O notation
In documentation, I think it makes sense to italicize O notation (*O(n)*) as opposed to using back-ticks (`O(n)`). Visually, back-ticks focus the reader on the literal characters being used, making them ideal for representing code. Using italics, as far I can tell, more closely follows typographic conventions in mathematics and computer science.
Just a suggestion, of course! 😇
This commit 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.
Signed-off-by: David Wood <david@davidtw.co>
std: Fix compilation without backtrace feature
This should hopefully handle #74484 but in any case fixes compilation of
the standard library without the `backtrace` feature. The need for this
feature is somewhat unclear now because the `backtrace` crate should
always compile (no more C code!) but we can handle that later if
necessary.
fix documentation surrounding the `in` and `for` keywords
Addresses #74529
The `in` keyword incorrectly referenced the `Iterator` trait. This reference was changed to `IntoIterator` without changing the underlying link.
Additionally, the `IntoIterator` trait was referenced towards the end of the documentation for `for`. An additional reference was added earlier and broadened the existing documentation from any iterator to anything that can be turned into an iterator.