Guard against non-monomorphized type_id intrinsic call
This PR checks whether the type is sufficient monomorphized when calling type_id or type_name intrinsics. If the type is not sufficiently monomorphized, e.g. used in a pattern, the code will be rejected.
Fixes#73976
rustdoc: Always warn when linking from public to private items
Change the logic such that linking from a public to a private item always triggers `intra_doc_link_resolution_failure`.
Previously, the warning was not emitted when `--document-private-items` is passed.
This came up during the discussion in https://github.com/rust-lang/rust/pull/74147#discussion_r452597901.
This commit improves codegen for unchecked casts on WebAssembly targets
to use the singluar `iNN.trunc_fMM_{u,s}` instructions. Previously rustc
would codegen a bare `fptosi` and `fptoui` for float casts but for
WebAssembly targets the codegen for these instructions is quite large.
This large codegen is due to the fact that LLVM can speculate these
instructions so the trapping behavior of WebAssembly needs to be
protected against in case they're speculated.
The change here is to update the codegen for the unchecked cast
intrinsics to have a wasm-specific case where they call the appropriate
LLVM intrinsic to generate the right wasm instruction. The intrinsic is
explicitly opting-in to undefined behavior so a trap here for
out-of-bounds inputs on wasm should be acceptable.
cc #73591
Change the logic such that linking from a public to a private item always
triggers intra_doc_link_resolution_failure. Previously, the warning was
not emitted when --document-private-items is passed.
Also don't rely anymore on the item's visibility, which would falsely trigger
the lint now that the check for --document-private-items is gone.
Disable polymorphisation
Fixes#74614.
This PR disables polymorphisation to fix the regression in #74614 after investigation into the issue makes it clear that the fix won't be trivial. ~~I'll file an issue shortly to replace #74614 with the findings so far.~~ #74636 has been filed to track the fix of the underlying regression.
r? @eddyb
Apply #66379 to `*mut T` `as_ref`
#66379 changed the documentation of `as_ref` on the type `*const T` and `as_mut` on the type `*mut T`, but it missed making that same change for `as_ref` on the type `*mut T`.
refactor and reword intra-doc link errors
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.
Stabilize control-flow-guard codegen option
This is the stabilization PR discussed in #68793. It converts the `-Z control-flow-guard` debugging option into a codegen option (`-C control-flow-guard`), and changes the associated tests.
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>