bors [Fri, 27 Jan 2023 15:02:44 +0000 (15:02 +0000)]
Auto merge of #107055 - kylematsuda:eb-fn-sig, r=lcnr
Switch to `EarlyBinder` for `fn_sig` query
Part of the work to finish #105779 (also see https://github.com/rust-lang/types-team/issues/78).
Several queries `X` have a `bound_X` variant that wraps the output in [`EarlyBinder`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/subst/struct.EarlyBinder.html). This adds `EarlyBinder` to the return type of the `fn_sig` query and removes `bound_fn_sig`.
bors [Fri, 27 Jan 2023 09:01:05 +0000 (09:01 +0000)]
Auto merge of #107054 - petrochenkov:effvisdoc3, r=GuillaumeGomez
rustdoc: Collect "rustdoc-reachable" items during early doc link resolution
This pass only needs to know about visibilities, attributes and reexports, so it can be run early, similarly to `compute_effective_visibilities` in rustc.
Results of this pass can be used to prune the list of extern impls early thus improving performance of https://github.com/rust-lang/rust/pull/94857.
Yuki Okushi [Fri, 27 Jan 2023 03:57:56 +0000 (12:57 +0900)]
Rollup merge of #107284 - notriddle:notriddle/plus, r=jsha
rustdoc: use smarter encoding for playground URL
The old way would compress okay with DEFLATE, but this version makes uncompressed docs smaller, which matters for memory usage and stuff like `cargo doc`.
Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}>
In local testing, this change shrinks sample pages by anywhere between 4.0% and 0.031%
$ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html
759235 after.dir/std/vec/struct.Vec.html
781842 before.dir/std/vec/struct.Vec.html
100*((759235-781842)/781842)=-2.8
$ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html 3194173 after.dir/std/num/struct.Wrapping.html 3204351 before.dir/std/num/struct.Wrapping.html
Yuki Okushi [Fri, 27 Jan 2023 03:57:54 +0000 (12:57 +0900)]
Rollup merge of #107171 - petrochenkov:encattrs, r=cjgillot
rustc_metadata: Fix `encode_attrs`
This function didn't do what the authors intended it to do.
- Due to `move` in the closure `is_public` wasn't captured by mutalbe reference and wasn't used as a cache.
- Due to iterator cloning all the `should_encode_attr` logic run for the second time to calculate `may_have_doc_links`
This PR fixes these issues, and calculates all the needed attribute flags in one go.
(Noticed while implementing https://github.com/rust-lang/rust/pull/107136.)
Yuki Okushi [Fri, 27 Jan 2023 03:57:54 +0000 (12:57 +0900)]
Rollup merge of #106856 - vadorovsky:fix-atomic-annotations, r=joshtriplett
core: Support variety of atomic widths in width-agnostic functions
Before this change, the following functions and macros were annotated with `#[cfg(target_has_atomic = "8")]` or
`#[cfg(target_has_atomic_load_store = "8")]`:
However, none of those functions and macros actually depend on 8-bit width and they are needed for all atomic widths (16-bit, 32-bit, 64-bit etc.). Some targets might not support 8-bit atomics (i.e. BPF, if we would enable atomic CAS for it).
This change fixes that by removing the `"8"` argument from annotations, which results in accepting the whole variety of widths.
Fixes #106845
Fixes #106795
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
bors [Fri, 27 Jan 2023 00:03:09 +0000 (00:03 +0000)]
Auto merge of #107269 - bjorn3:sync_cg_clif-2023-01-24, r=bjorn3
Sync rustc_codegen_cranelift
For cg_clif itself there have been a couple of bug fixes since the last sync, a Cranelift update and implemented all remaining simd platform intrinsics used by `std::simd`. (`std::arch` still misses a lot though) Most of the diff is from reworking of the cg_clif build system though.
Michael Howell [Tue, 24 Jan 2023 22:39:59 +0000 (15:39 -0700)]
rustdoc: use smarter encoding for playground URL
The old way would compress okay with DEFLATE, but this version makes
uncompressed docs smaller, which matters for memory usage and stuff
like `cargo doc`.
Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}>
In local testing, this change shrinks sample pages by anywhere between
4.0% and 0.031%
$ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html
759235 after.dir/std/vec/struct.Vec.html
781842 before.dir/std/vec/struct.Vec.html
100*((759235-781842)/781842)=-2.8
$ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html 3194173 after.dir/std/num/struct.Wrapping.html 3204351 before.dir/std/num/struct.Wrapping.html
bors [Thu, 26 Jan 2023 15:58:08 +0000 (15:58 +0000)]
Auto merge of #107328 - matthiaskrgr:rollup-lfqwo0o, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #106904 (Preserve split DWARF files when building archives.)
- #106971 (Handle diagnostics customization on the fluent side (for one specific diagnostic))
- #106978 (Migrate mir_build's borrow conflicts)
- #107150 (`ty::tls` cleanups)
- #107168 (Use a type-alias-impl-trait in `ObligationForest`)
- #107189 (Encode info for Adt in a single place.)
- #107322 (Custom mir: Add support for some remaining, easy to support constructs)
- #107323 (Disable ConstGoto opt in cleanup blocks)
Matthias Krüger [Thu, 26 Jan 2023 14:02:22 +0000 (15:02 +0100)]
Rollup merge of #107323 - JakobDegen:const-goto, r=tmiasko
Disable ConstGoto opt in cleanup blocks
Fixes #107315 .
There is probably a smaller hammer that we could use here, but none that is super obviously correct. We can always revisit this in the future.
Could not add a test because custom mir does not support cleanup blocks. However, did check that the fallible_iterator crate no longer ICEs with the other PR cherry picked.
This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier.
This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`.
This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
Matthias Krüger [Thu, 26 Jan 2023 06:53:26 +0000 (07:53 +0100)]
Rollup merge of #107304 - Nilstrieb:ᐸTy as PartialEqᐳ::eq because what else are we gonna use in rustc_middle, r=compiler-errors
Use `can_eq` to compare types for default assoc type error
This correctly handles inference variables like `{integer}`. I had to move all of this `note_and_explain` code to `rustc_infer`, it made no sense for it to be in `rustc_middle` anyways.
Matthias Krüger [Thu, 26 Jan 2023 06:53:25 +0000 (07:53 +0100)]
Rollup merge of #107074 - lcnr:validate-dont-skip-opaque, r=compiler-errors
remove unnecessary check for opaque types
this isn't needed and may hide some errors.
after analysis there are no opaque types so it's a noop anyways
before analysis there are opaque types but due to `Reveal::UserFacing` we don't reveal them. `is_subtype` simply discards the opaque type constraints as these will get checked again during mir borrowck.
r? types
want to land this after the beta-cutoff as mir validator changes are apparently pretty scary
Matthias Krüger [Thu, 26 Jan 2023 06:53:24 +0000 (07:53 +0100)]
Rollup merge of #106946 - dtolnay:hashlinecolumn, r=m-ou-se
implement Hash for proc_macro::LineColumn
For use in `HashMap<LineColumn, TokenTree>` or `HashMap<LineColumn, Comment>`, for example.
[Here is an example of one case complicated by the absence of this impl.](https://github.com/andrewbaxter/genemichaels/blob/71bc45e417c3f9dae09f890f1ec4630e758e5c70/src/comments.rs#L25-L34)
Matthias Krüger [Thu, 26 Jan 2023 06:53:23 +0000 (07:53 +0100)]
Rollup merge of #106811 - khuey:dwp_extension, r=davidtwco
Append .dwp to the binary filename instead of replacing the existing extension.
gdb et al. expect to find the dwp file at `<binary>`.dwp, even if <binary> already has an extension (e.g. libfoo.so's dwp is expected to be at libfoo.so.dwp).
The TL;DR is that weak linkage causes LLVM to produce broken Wasm, presumably due to pointer mismatch. The code is casting a void pointer to a function pointer with specific signature, but Wasm is very strict about function pointer compatibility, so the resulting code is invalid.
Ideally LLVM should catch this earlier in the process rather than emit invalid Wasm, but it currently doesn't and this is an easy and valid fix, given that Emcripten doesn't have `__cxa_thread_atexit_impl` these days anyway.
Unfortunately, I can't add a regression test as even after looking into this issue for a long time, I couldn't reproduce it with any minimal Rust example, only with extracted LLVM IR or on a large project involving Rust + C++.
Matthias Krüger [Thu, 26 Jan 2023 06:53:22 +0000 (07:53 +0100)]
Rollup merge of #106625 - Swatinem:ref/cov6, r=nagisa
Remove backwards compat for LLVM 12 coverage format
The minimum external LLVM was updated to 13 recently in https://github.com/rust-lang/rust/pull/100611, so this PR removes backwards compat with older coverage formats.
I kept the version check and error message there, in accordance with this comment: https://github.com/rust-lang/rust/pull/91207#issuecomment-981121867
Matthias Krüger [Thu, 26 Jan 2023 06:53:21 +0000 (07:53 +0100)]
Rollup merge of #97373 - dimpolo:cell_dispatch_from_dyn, r=dtolnay
impl DispatchFromDyn for Cell and UnsafeCell
After some fruitful discussion on [Internals](https://internals.rust-lang.org/t/impl-dispatchfromdyn-for-cell-2/16520) here's my first PR to rust-lang/rust 🎉
Please let me know if there's something I missed.
This adds `DispatchFromDyn` impls for `Cell`, `UnsafeCell` and `SyncUnsafeCell`.
An existing test is also expanded to test the `Cell` impl (which requires the `UnsafeCell` impl)
The different `RefCell` types can not implement `DispatchFromDyn` since they have more than one (non ZST) field.
**Edit:**
### What:
These changes allow one to make types like `MyRc`(code below), to be object safe method receivers after implementing `DispatchFromDyn` and `Deref` for them.
This allows for code like this:
```rust
struct MyRc<T: ?Sized>(Cell<NonNull<RcBox<T>>>);
/* impls for DispatchFromDyn, CoerceUnsized and Deref for MyRc*/
trait Trait {
fn foo(self: MyRc<Self>);
}
let impls_trait = ...;
let rc = MyRc::new(impls_trait) as MyRc<dyn Trait>;
rc.foo();
```
Note: `Cell` and `UnsafeCell` won't directly become valid method receivers since they don't implement `Deref`. Making use of these changes requires a wrapper type and nightly features.
### Why:
A custom pointer type with interior mutability allows one to store extra information in the pointer itself.
These changes allow for such a type to be a method receiver.
### Examples:
My use case is a cycle aware custom `Rc` implementation that when dropping a cycle marks some references dangling.
On the [forum](https://internals.rust-lang.org/t/impl-dispatchfromdyn-for-cell/14762/8) andersk mentioned that they track if a `Gc` reference is rooted with an extra bit in the reference itself.
bors [Thu, 26 Jan 2023 06:23:14 +0000 (06:23 +0000)]
Auto merge of #107314 - matthiaskrgr:rollup-j40lnlj, r=matthiaskrgr
Rollup of 11 pull requests
Successful merges:
- #106407 (Improve proc macro attribute diagnostics)
- #106960 (Teach parser to understand fake anonymous enum syntax)
- #107085 (Custom MIR: Support binary and unary operations)
- #107086 (Print PID holding bootstrap build lock on Linux)
- #107175 (Fix escaping inference var ICE in `point_at_expr_source_of_inferred_type`)
- #107204 (suggest qualifying bare associated constants)
- #107248 (abi: add AddressSpace field to Primitive::Pointer )
- #107272 (Implement ObjectSafe and WF in the new solver)
- #107285 (Implement `Generator` and `Future` in the new solver)
- #107286 (ICE in new solver if we see an inference variable)
- #107313 (Add Style Team Triagebot config)
Matthias Krüger [Thu, 26 Jan 2023 05:15:29 +0000 (06:15 +0100)]
Rollup merge of #107286 - compiler-errors:new-solver-deny-infers, r=lcnr
ICE in new solver if we see an inference variable
By construction, we do not expect to see any `ty::Infer(ty::TyVar(_))` inference types in the solver (we treat this as ambiguous, since we need to be able to structurally resolve the self type at least one layer to assemble candidates for it). Additionally, since we're doing no freshening, we also don't expect to see any fresh vars of any kind in the solver.
Let's make that an ICE so we can catch any mistakes.
When #107282 lands, we should also ICE there too if we see a non-int/float infer.
Matthias Krüger [Thu, 26 Jan 2023 05:15:27 +0000 (06:15 +0100)]
Rollup merge of #107248 - erikdesjardins:addrspace, r=oli-obk
abi: add AddressSpace field to Primitive::Pointer
...and remove it from `PointeeInfo`, which isn't meant for this.
There are still various places (marked with FIXMEs) that assume all pointers
have the same size and alignment. Fixing this requires parsing non-default
address spaces in the data layout string (and various other changes),
which will be done in a followup.
(That is, if it's actually worth it to support multiple different pointer sizes.
There is a lot of code that would be affected by that.)
Matthias Krüger [Thu, 26 Jan 2023 05:15:26 +0000 (06:15 +0100)]
Rollup merge of #107175 - compiler-errors:bad-types-in-vec-push, r=estebank
Fix escaping inference var ICE in `point_at_expr_source_of_inferred_type`
Fixes #107158
`point_at_expr_source_of_inferred_type` uses `lookup_probe` to adjust the self type of a method receiver -- but that method returns inference variables from inside a probe. That means that the ty vars are no longer valid, so we can't use any infcx methods on them.
Also, pass some extra span info to hack a quick solution to bad labels, resulting in this diagnostic improvement:
```rust
fn example2() {
let mut x = vec![1];
x.push("");
}
```
```diff
error[E0308]: mismatched types
--> src/main.rs:5:12
|
5 | x.push("");
| ---- ^^
| | |
| | expected integer, found `&str`
- | | this is of type `&'static str`, which causes `x` to be inferred as `Vec<{integer}>`
| arguments to this method are incorrect
```
(since that "which causes `x` to be inferred as `Vec<{integer}>` part is wrong)
r? `@estebank`
(we really should make this code better in general, cc #106590, but that's a bit bigger issue that needs some more thinking about)
Matthias Krüger [Thu, 26 Jan 2023 05:15:24 +0000 (06:15 +0100)]
Rollup merge of #107085 - tmiasko:custom-mir-operators, r=oli-obk
Custom MIR: Support binary and unary operations
Lower binary and unary operations directly to corresponding unchecked MIR
operations. Ultimately this might not be syntax we want, but it allows for
experimentation in the meantime.
bors [Thu, 26 Jan 2023 03:10:52 +0000 (03:10 +0000)]
Auto merge of #105582 - saethlin:instcombine-assert-inhabited, r=cjgillot
InstCombine away intrinsic validity assertions
This optimization (currently) fires 246 times on the standard library. It seems to fire hardly at all on the big crates in the benchmark suite. Interesting.
bors [Wed, 25 Jan 2023 23:39:51 +0000 (23:39 +0000)]
Auto merge of #107309 - matthiaskrgr:rollup-0wgq6be, r=matthiaskrgr
Rollup of 9 pull requests
Successful merges:
- #105345 (Add hint for missing lifetime bound on trait object when type alias is used)
- #106897 (Tweak E0597)
- #106944 (Suggest using a lock for `*Cell: Sync` bounds)
- #107239 (Bring tests back into rustc source tarball)
- #107244 (rustdoc: rearrange HTML in primitive reference links)
- #107255 (add test where we ignore hr implied bounds)
- #107256 (Delete `SimplifyArmIdentity` and `SimplifyBranchSame` mir opts)
- #107266 (rustdoc: prohibit scroll bar on source viewer in Safari)
- #107282 (erica solver: implement builtin `Pointee` trait impl candidates)
Matthias Krüger [Wed, 25 Jan 2023 21:19:55 +0000 (22:19 +0100)]
Rollup merge of #107256 - JakobDegen:delete-sai, r=cjgillot
Delete `SimplifyArmIdentity` and `SimplifyBranchSame` mir opts
I had attempted to fix the first of these opts in #94177 . However, despite that PR already being a full re-write, it still did not fix some of the core soundness issues. The optimizations that are attempted here are likely to be desirable, but I do not expect any of the currently written code to survive into a sound implementation. Deleting the code keeps us from having to maintain the passes in the meantime.
Matthias Krüger [Wed, 25 Jan 2023 21:19:52 +0000 (22:19 +0100)]
Rollup merge of #106944 - Nilstrieb:there-once-was-a-diagnostic, r=WaffleLapkin
Suggest using a lock for `*Cell: Sync` bounds
I mostly did this for `OnceCell<T>` at first because users will be confused to see that the `OnceCell<T>` in `std` isn't `Sync` but then extended it to `Cell<T>` and `RefCell<T>` as well.
Matthias Krüger [Wed, 25 Jan 2023 21:19:51 +0000 (22:19 +0100)]
Rollup merge of #105345 - yanchen4791:issue-103582-fix, r=jackh726
Add hint for missing lifetime bound on trait object when type alias is used
Fix issue #103582.
The problem: When a type alias is used to specify the return type of the method in a trait impl, the suggestion for fixing the problem of "missing lifetime bound on trait object" of the trait impl will not be created. The issue caused by the code which searches for the return trait objects when constructing the hint suggestion is not able to find the trait objects since they are specified in the type alias path instead of the return path of the trait impl.
The solution: Trace the trait objects in the type alias path and provide them along with the alias span to generate the suggestion in case the type alias is used in return type of the method in the trait impl.
bors [Wed, 25 Jan 2023 16:39:29 +0000 (16:39 +0000)]
Auto merge of #103902 - vincenzopalazzo:macros/obligation_rulesv2, r=oli-obk
use `LocalDefId` instead of `HirId` in trait resolution to simplify the obligation clause resolution
This commit introduces a refactoring suggested by `@lcnr` to simplify the obligation clause resolution.
This is just the first PR that introduces a type of refactoring, but others PRs will follow this to introduce name changing to change from the variable name from `body_id` to something else.
bors [Wed, 25 Jan 2023 13:58:41 +0000 (13:58 +0000)]
Auto merge of #107290 - Dylan-DPC:rollup-tovojhr, r=Dylan-DPC
Rollup of 9 pull requests
Successful merges:
- #105552 (Add help message about function pointers)
- #106583 (Suggest coercion of `Result` using `?`)
- #106767 (Allow setting CFG_DISABLE_UNSTABLE_FEATURES to 0)
- #106823 (Allow fmt::Arguments::as_str() to return more Some(_).)
- #107166 (rustc_metadata: Support non-`Option` nullable values in metadata tables)
- #107213 (Add suggestion to remove if in let..else block)
- #107223 (`sub_ptr()` is equivalent to `usize::try_from().unwrap_unchecked()`, not `usize::from().unwrap_unchecked()`)
- #107227 (`new_outside_solver` -> `evaluate_root_goal`)
- #107232 (rustdoc: simplify settings popover DOM, CSS, JS)
Dylan DPC [Wed, 25 Jan 2023 11:31:44 +0000 (17:01 +0530)]
Rollup merge of #107232 - notriddle:notriddle/settings-choice, r=GuillaumeGomez
rustdoc: simplify settings popover DOM, CSS, JS
* Change the class names so that they all start with `setting-`. That should make it harder to accidentally use a setting class outside the settings popover, where loading the CSS might accidentally change the styles of something unrelated.
* Get rid of an unnecessary wrapper DIV around the radio button line.
* Simplify CSS selectors by making the DOM easier and more intuitive to target.
* Remove dead settings JS for obsolete select-wrapper