Commit Graph

264407 Commits

Author SHA1 Message Date
Nicholas Nethercote 46fe09f3f3 Add `warn(unreachable_pub)` to `rustc_index`. 2024-08-27 14:33:24 +10:00
Nicholas Nethercote 37becf7bdc Add `warn(unreachable_pub)` to `rustc_incremental`. 2024-08-27 14:30:20 +10:00
Nicholas Nethercote 7fc0444340 Add `warn(unreachable_pub)` to `rustc_hir_typeck`. 2024-08-27 14:22:07 +10:00
Nicholas Nethercote 3aae994ca2 Add `warn(unreachable_pub)` to `rustc_hir_pretty`. 2024-08-27 13:25:40 +10:00
Nicholas Nethercote 5acf4e7b4b Add `warn(unreachable_pub)` to `rustc_hir_analysis`. 2024-08-27 13:14:50 +10:00
Nicholas Nethercote bffa2244ed Add `warn(unreachable_pub)` to `rustc_hir`. 2024-08-27 12:59:20 +10:00
Nicholas Nethercote fa18140994 Add `warn(unreachable_pub)` to `rustc_graphviz`. 2024-08-27 12:58:29 +10:00
Nicholas Nethercote a510813e03 Add `warn(unreachable_pub)` to `rustc_fluent_macro`. 2024-08-27 12:56:54 +10:00
Nicholas Nethercote 0d8d05c07f Add `warn(unreachable_pub)` to `rustc_feature`. 2024-08-27 12:55:54 +10:00
Nicholas Nethercote df5fbf05a1 Add `warn(unreachable_pub)` to `rustc_expand`.
Plus a tiny bit of reformatting.
2024-08-27 12:40:38 +10:00
Nicholas Nethercote 5fd503ab44 Add `warn(unreachable_pub)` to `rustc_errors`. 2024-08-27 12:03:37 +10:00
Nicholas Nethercote 2b5621280c Add `warn(unreachable_pub)` to `rustc_error_messages`. 2024-08-27 11:52:08 +10:00
Nicholas Nethercote d607cfb336 Add `warn(unreachable_pub)` to `rustc_error_codes`. 2024-08-27 11:49:59 +10:00
Nicholas Nethercote e81fad2b4d Add `warn(unreachable_pub)` to `rustc_driver_impl`. 2024-08-27 11:47:25 +10:00
bors bf662eb808 Auto merge of #129632 - matthiaskrgr:rollup-8055gq6, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #126013 (Add `#[warn(unreachable_pub)]` to a bunch of compiler crates)
 - #128157 (deduplicate and clarify rules for converting pointers to references)
 - #129032 (Document & implement the transmutation modeled by `BikeshedIntrinsicFrom`)
 - #129250 (Do not ICE on non-ADT rcvr type when looking for crate version collision)
 - #129340 (Remove Duplicate E0381 Label)
 - #129560 ([rustdoc] Generate source link on impl associated types)
 - #129622 (Remove a couple of unused feature enables)
 - #129625 (Rename `ParenthesizedGenericArgs` to `GenericArgsMode`)
 - #129626 (Remove `ParamMode::ExplicitNamed`)

Failed merges:

 - #128166 (Improved `checked_isqrt` and `isqrt` methods)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-26 22:56:04 +00:00
Matthias Krüger b3b6baf833
Rollup merge of #129626 - compiler-errors:explicit-named, r=fmease
Remove `ParamMode::ExplicitNamed`

This was introduced as a hack to improve a diagnostics suggestion in #61679. It was subsequently broken, but also it was an incomplete hack that I don't believe we need to support, so let's just remove it.
2024-08-27 00:42:02 +02:00
Matthias Krüger 3d8d9da6a0
Rollup merge of #129625 - compiler-errors:generic-args-mode, r=fmease
Rename `ParenthesizedGenericArgs` to `GenericArgsMode`

A bit easier to digest name. Broken out of a PR implementing return type notation.
2024-08-27 00:42:02 +02:00
Matthias Krüger 90a1b6d158
Rollup merge of #129622 - bjorn3:less_unstable, r=lqd
Remove a couple of unused feature enables
2024-08-27 00:42:01 +02:00
Matthias Krüger 862b911551
Rollup merge of #129560 - GuillaumeGomez:impl-assoc-type-source-link, r=notriddle
[rustdoc] Generate source link on impl associated types

Currently, impl associated types are generated but don't get a source link. This PR fixes that.

Before:

![image](https://github.com/user-attachments/assets/3a22adb5-8b66-4124-9267-7c26eed1aa5e)

After:

![Screenshot from 2024-08-25 16-31-36](https://github.com/user-attachments/assets/6e9b35e7-4357-4ecf-8c49-1d8294051283)

r? `@notriddle`
2024-08-27 00:42:01 +02:00
Matthias Krüger 53f5294c0f
Rollup merge of #129340 - stephen-lazaro:u/slazaro/issue-129274, r=compiler-errors
Remove Duplicate E0381 Label

Aims to resolve https://github.com/rust-lang/rust/issues/129274, and adds a test for the case.

Essentially, we are duplicating this span for some reason. For now, I'm just using a set to collect the spans rather than the vec. I imagine there's probably no real reason to inspect duplicates in this area, but if I'm wrong I can adjust to collect "seen spans" in just the point where this label is applied.

I'm not sure why it's producing duplicate spans. Looks like this has been this way for a while? I think it gives the duplicate label on 1.75.0 for example.
2024-08-27 00:42:00 +02:00
Matthias Krüger d4d4b6b4fa
Rollup merge of #129250 - estebank:issue-129205, r=compiler-errors
Do not ICE on non-ADT rcvr type when looking for crate version collision

When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to #128786.
Fixes #129205
Fixes #129216
2024-08-27 00:42:00 +02:00
Matthias Krüger 29923b6801
Rollup merge of #129032 - jswrenn:transmute-method, r=compiler-errors
Document & implement the transmutation modeled by `BikeshedIntrinsicFrom`

Documents that `BikeshedIntrinsicFrom` models transmute-via-union, which is slightly more expressive than the transmute-via-cast implemented by `transmute_copy`. Additionally, we provide an implementation of transmute-via-union as a method on the `BikeshedIntrinsicFrom` trait with additional documentation on the boundary between trait invariants and caller obligations.

Whether or not transmute-via-union is the right kind of transmute to model remains up for discussion [1]. Regardless, it seems wise to document the present behavior.

[1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20'kind'.20of.20transmute.20to.20model.3F/near/426331967

Tracking Issue: https://github.com/rust-lang/rust/issues/99571

r? `@compiler-errors`

cc `@scottmcm,` `@Lokathor`
2024-08-27 00:41:59 +02:00
Matthias Krüger c6ceb5be24
Rollup merge of #128157 - lolbinarycat:unify-ptr-ref-docs, r=cuviper
deduplicate and clarify rules for converting pointers to references

part of #124669
2024-08-27 00:41:58 +02:00
Matthias Krüger 110c3df7fd
Rollup merge of #126013 - nnethercote:unreachable_pub, r=Urgau
Add `#[warn(unreachable_pub)]` to a bunch of compiler crates

By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal.

There are plenty more crates to do but this seems like enough for a first PR.

r? `@compiler-errors`
2024-08-27 00:41:57 +02:00
Michael Goulet 2db1d2e261 Rename ParenthesizedGenericArgs to GenericArgsMode 2024-08-26 16:48:13 -04:00
Michael Goulet b4d3fa4829 Remove ParamMode::ExplicitNamed 2024-08-26 16:47:52 -04:00
bors 515395af0e Auto merge of #129615 - matthiaskrgr:rollup-lw733x7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #129190 (Add f16 and f128 to tests/ui/consts/const-float-bits-conv.rs)
 - #129377 (Add implementations for `unbounded_shl`/`unbounded_shr`)
 - #129539 (link to Future::poll from the Poll docs)
 - #129588 (pal/hermit: correctly round up microseconds in `Thread::sleep`)
 - #129592 (Remove cfg(test) from library/core)
 - #129597 (mv `build_reduced_graph_for_external_crate_res` into Resolver)
 - #129600 (Tie `impl_trait_overcaptures` lint to Rust 2024)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-26 20:04:35 +00:00
bjorn3 4e1555462f Remove a couple of unused feature enables 2024-08-26 19:52:14 +00:00
Josh Stone b11e0a883b
Apply suggestions from code review 2024-08-26 12:36:58 -07:00
Michael Goulet 4a088d9070 Remove crashes from type_of on resolution that doesn't have a type_of 2024-08-26 13:07:01 -04:00
Esteban Küber 00c435d9b3 Do not ICE on non-ADT rcvr type when looking for crate version collision
When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to #128786. Fix #129205.
2024-08-26 13:02:21 -04:00
Matthias Krüger 114e60ff79
Rollup merge of #129600 - traviscross:TC/tie-impl_trait_overcaptures-to-rust-2024, r=compiler-errors
Tie `impl_trait_overcaptures` lint to Rust 2024

The `impl_trait_overcaptures` lint is part of the migration to Rust 2024 and the Lifetime Capture Rules 2024.  Now that we've stabilized precise capturing (RFC 3617), let's tie this lint to the `rust_2024_compatibility` lint group.

Tracking:

- https://github.com/rust-lang/rust/issues/117587

r? `@compiler-errors`
2024-08-26 17:25:34 +02:00
Matthias Krüger 1d58ac0ff7
Rollup merge of #129597 - bvanjoi:resolve, r=petrochenkov
mv `build_reduced_graph_for_external_crate_res` into Resolver

`build_reduced_graph_for_external_crate_res` is only related to `Resolver`, so move it there.

r? `@petrochenkov`
2024-08-26 17:25:34 +02:00
Matthias Krüger b9dfb4d6f8
Rollup merge of #129592 - saethlin:core-cfg-test, r=tgross35
Remove cfg(test) from library/core

The diff here is very small with the ignore whitespace option.

`core` doesn't/can't have unit tests. All of its tests are just modules under `tests/`, so it has no use for `cfg(test)`, because the entire contents of `library/core/src` are only ever compiled with that cfg off, and the entire contents of `library/core/tests` are only ever compiled with that cfg on.

You can tell this is what's happening because we had `#[cfg(test)]` on a module declaration that has no source file.

I also deleted the extra `mod tests {` layer of nesting; there's no need to mention again in the module path that this is a module of tests. This exposes a name collision between the `u128` module of tests and `core::u128`. Fixed that by using `<u128>::MAX` like is done in the `check!` macro, which is what avoids this name ambiguity for the other types.
2024-08-26 17:25:33 +02:00
Matthias Krüger d0b3c3a110
Rollup merge of #129588 - hermit-os:sleep-micros, r=workingjubilee
pal/hermit: correctly round up microseconds in `Thread::sleep`

This fixes the Hermit-related part of https://github.com/rust-lang/rust/issues/129212 and thus the whole issue, since ESP-IDF is already fixed, as far as I understand.

Fixes https://github.com/rust-lang/rust/issues/129212

r? `@workingjubilee`

CC: `@stlankes`
2024-08-26 17:25:32 +02:00
Matthias Krüger b1c9064071
Rollup merge of #129539 - oconnor663:poll_link, r=tgross35
link to Future::poll from the Poll docs

The most important thing about Poll is that Future::poll returns it, but previously the docs didn't emphasize this.
2024-08-26 17:25:32 +02:00
Matthias Krüger 68aff290fd
Rollup merge of #129377 - chorman0773:unbounded-shifts-impl, r=scottmcm
Add implementations for `unbounded_shl`/`unbounded_shr`

Tracking Issue: https://github.com/rust-lang/rust/issues/129375

This implements `unbounded_shl` and `unbounded_shr` under the feature gate `unbounded_shifts`
2024-08-26 17:25:31 +02:00
Matthias Krüger dedfb35711
Rollup merge of #129190 - rezwanahmedsami:master, r=tgross35
Add f16 and f128 to tests/ui/consts/const-float-bits-conv.rs

Fixes #129163

try-job: x86_64-msvc
try-job: x86_64-mingw
try-job: i686-msvc
try-job: i686-mingw
2024-08-26 17:25:31 +02:00
bors 22572d0994 Auto merge of #129508 - RalfJung:transient-locals, r=cjgillot
const checking: properly compute the set of transient locals

For const-checking the MIR of a const/static initializer, we have to know the set of "transient" locals. The reason for this is that creating a mutable (or interior mutable) reference to a transient local is "safe" in the sense that this reference cannot possibly end up in the final value of the const -- even if it is turned into a raw pointer and stored in a union, we will see that pointer during interning and reliably reject it as dangling.

So far, we determined the set of transient locals as "locals that have a `StorageDead` somewhere". But that's not quite right -- if we had MIR like
```rust
StorageLive(_5);
StorageDead(_5);
StorageLive(_5);
// no further storage annotations for _5
```
Then we'd consider `_5` to be "transient", but it is not actually transient.

We do not currently generate such MIR, but I feel uneasy relying on subtle invariants like this. So this PR implements a proper analysis for computing the set of "transient" locals: a local is "transient" if it is guaranteed dead at all `Return` terminators.

Cc `@cjgillot`
2024-08-26 08:44:10 +00:00
Travis Cross 6982785f18 Tie `impl_trait_overcaptures` lint to Rust 2024
The `impl_trait_overcaptures` lint is part of the migration to Rust
2024 and the Lifetime Capture Rules 2024.  Now that we've stabilized
precise capturing (RFC 3617), let's tie this lint to the
`rust_2024_compatibility` lint group.
2024-08-26 06:46:56 +00:00
bors f48062e7d0 Auto merge of #129595 - matthiaskrgr:rollup-4udn7nn, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #129288 (Use subtyping for `UnsafeFnPointer` coercion, too)
 - #129405 (Fixing span manipulation and indentation of the suggestion introduced by #126187)
 - #129518 (gitignore: ignore ICE reports regardless of directory)
 - #129519 (Remove redundant flags from `lower_ty_common` that can be inferred from the HIR)
 - #129525 (rustdoc: clean up tuple <-> primitive conversion docs)
 - #129526 (Use `FxHasher` on new solver unconditionally)
 - #129544 (Removes dead code from the compiler)
 - #129553 (add back test for stable-const-can-only-call-stable-const)
 - #129590 (Avoid taking reference of &TyKind)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-26 05:45:40 +00:00
bohan c31b9fa425 mv `build_reduced_graph_for_external_crate_res` into Resolver 2024-08-26 09:24:42 +08:00
Ben Kimock 4f3ef2ac90 Remove cfg(test) from library/core 2024-08-25 20:04:26 -04:00
Matthias Krüger d6a3aa4fc4
Rollup merge of #129590 - compiler-errors:ref-tykind, r=fmease
Avoid taking reference of &TyKind

It's already a ref anyways. Just a tiny cleanup here.
2024-08-26 01:49:04 +02:00
Matthias Krüger 0a8e305d91
Rollup merge of #129553 - RalfJung:const-stability, r=compiler-errors
add back test for stable-const-can-only-call-stable-const

This got accidentally removed in https://github.com/rust-lang/rust/pull/128596 (file `tests/ui/internal/internal-unstable-const.rs`). The test has little to do with "allow internal unstable" though, so add it in a file that already tests various const stability things.

Also tweak the help that suggests to add `rustc_allow_const_fn_unstable` to make it clear that this needs team approval, since it is a fairly big gun.
2024-08-26 01:49:03 +02:00
Matthias Krüger c6e00680ac
Rollup merge of #129544 - mu001999-contrib:dead-code/clean, r=compiler-errors
Removes dead code from the compiler

Detected by #128637
2024-08-26 01:49:03 +02:00
Matthias Krüger a8a242c0ec
Rollup merge of #129526 - compiler-errors:fx, r=lqd
Use `FxHasher` on new solver unconditionally

r? lqd

This should actually fix the inference problem in ad855fe6db, since `HashSet::default` was not inferring the hasher when `HashSet` was coming from the stdlib due to the way that defaulted types/inference vars work. You could cherry-pick this on top of your PR alternatively.
2024-08-26 01:49:02 +02:00
Matthias Krüger aa26e1ad97
Rollup merge of #129525 - notriddle:notriddle/fake-variadic-tuple-array, r=GuillaumeGomez
rustdoc: clean up tuple <-> primitive conversion docs

This adds a minor missing feature to `fake_variadic`, so that it can render `impl From<(T,)> for [T; 1]` correctly.
2024-08-26 01:49:02 +02:00
Matthias Krüger ae21236530
Rollup merge of #129519 - compiler-errors:lowering-flags, r=fmease
Remove redundant flags from `lower_ty_common` that can be inferred from the HIR

...and then get rid of `lower_ty_common`.

r? ``@fmease`` or re-roll if you're busy!
2024-08-26 01:49:01 +02:00
Matthias Krüger 5a07308a14
Rollup merge of #129518 - GrigorenkoPV:gitignore-library-ice, r=tgross35
gitignore: ignore ICE reports regardless of directory

Quite often when working on compiler I end up running into ICEs during the standard library compilation.

These ICEs generate reports in `/library/` and not at the root of the repo, so they aren't `gitignore`d.

I finally ended up committing one today, by accident: https://github.com/rust-lang/rust/pull/129487#event-14002067843
2024-08-26 01:49:01 +02:00