Commit Graph

231143 Commits

Author SHA1 Message Date
bors
a17c7968b7 Auto merge of #114264 - matthiaskrgr:rollup-dfsuu1v, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #98154 (merge functionality of `io::Sink` into `io::Empty`)
 - #102198 (`const`-stablilize `NonNull::as_ref`)
 - #114074 (inline format!() args from rustc_middle up to and including rustc_codegen_llvm (3))
 - #114246 (Weaken unnameable_types lint)
 - #114256 (Fix invalid suggestion for mismatched types in closure arguments)
 - #114258 (Simplify `Span::can_be_used_for_suggestions` a little tiny bit)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-30 19:53:37 +00:00
Caleb Zulawski
77ed437de8 Fix simd_bswap for i8/u8 2023-07-30 15:40:32 -04:00
Matthias Krüger
4916ab5330
Rollup merge of #114258 - WaffleLapkin:reuse_in_derive_expansion, r=petrochenkov
Simplify `Span::can_be_used_for_suggestions` a little tiny bit

Just something I saw randomly.
2023-07-30 20:36:35 +02:00
Matthias Krüger
97bacad9c2
Rollup merge of #114256 - Urgau:fix-issue-114180, r=WaffleLapkin
Fix invalid suggestion for mismatched types in closure arguments

This PR fixes the invalid suggestion for mismatched types in closure arguments.

The invalid suggestion came from a wrongly created span in the parser for closure arguments that don't have a type specified. Specifically, the span in this case was the last token span, but in the case of tuples, the span represented the last parenthesis instead of the whole tuple, which is fixed by taking the more accurate span of the pattern.

There is one unfortunate downside of this fix, it worsens even more the diagnostic for mismatched types in closure args without an explicit type. This happens because there is no correct span for implied inferred type. I tried also fixing this but it's a rabbit hole.

Fixes https://github.com/rust-lang/rust/issues/114180
2023-07-30 20:36:35 +02:00
Matthias Krüger
d113b5b848
Rollup merge of #114246 - Bryanskiy:type-privacy-lints-fixes, r=petrochenkov
Weaken unnameable_types lint

`unnameable_types` lint is no longer emitted for
- associated types
- internal types

r? ``@petrochenkov``
2023-07-30 20:36:34 +02:00
Matthias Krüger
b192576036
Rollup merge of #114074 - matthiaskrgr:fmt_args_rustc_2, r=WaffleLapkin
inline format!() args from rustc_middle up to and including rustc_codegen_llvm (3)

r? `@WaffleLapkin`
2023-07-30 20:36:34 +02:00
Matthias Krüger
e3ca397593
Rollup merge of #102198 - lukas-code:nonnull_as_ref, r=Amanieu
`const`-stablilize `NonNull::as_ref`

A bunch of pointer to reference methods have been made unstably const some time ago in #91823 under the feature gate `const_ptr_as_ref`.
Out of these, `NonNull::as_ref` can be implemented as a `const fn` in stable rust today, so i hereby propose to const stabilize this function only.

Tracking issue: #91822

``@rustbot`` label +T-libs-api -T-libs
2023-07-30 20:36:34 +02:00
Matthias Krüger
27e3a740ae
Rollup merge of #98154 - vidhanio:master, r=workingjubilee
merge functionality of `io::Sink` into `io::Empty`

Many times, there is a need for a simple dummy `io::Read`er + `io::Write`r, but currently the only options are `io::Empty` and `io::Sink` respectively. Having both of their functionality together requires writing your own boilerplate for something that makes sense to have in the standard library. This PR adds the functionality of `io::Sink` to `io::Empty`, making `io::Empty` be able to perform the tasks of both of the previous structs. (This idea was first mentioned in #24235)

Note: I also updated some doc comments in `io::utils` in this pull request to fix inconsistencies between `io::Sink` and `io::Empty`.

API Change Proposal: https://github.com/rust-lang/libs-team/issues/49
2023-07-30 20:36:33 +02:00
bors
2ab124126d Auto merge of #11261 - y21:issue11260, r=blyxyas
[`unnecessary_find_map`]: look for then_some

Closes #11260

changelog: [`unnecessary_find_map`]: lint `.then_some()` in closure
2023-07-30 18:26:45 +00:00
bors
a8be6e070f Auto merge of #114204 - GuillaumeGomez:remove-unneeded-clone-calls, r=notriddle
[rustdoc] Remove unneeded `clone()` calls for `derive_id`

I realized we were cloning values before passing them to `derive_id` where they are cloned again, which isn't great. Since they'll be cloned anyway, let's allow to pass both by reference and by value.

r? `@notriddle`
2023-07-30 18:11:08 +00:00
Caio
35d434d08e [arithmetic_side_effects] Fix #11262 2023-07-30 14:33:38 -03:00
Lan, Jian
b4b540ced2 Improve the rust style guide doc
- Make the levels of headings consistent in this whole document
- Fix some headings
- Remove redundant empty lines
- Follow the markdown linter advices to use the same symbol for different level of unordered list entries
2023-07-31 01:33:33 +08:00
yukang
7b3d1b775f normalize backtrace error messages 2023-07-31 01:19:02 +08:00
Maybe Waffle
a3838780f2 Simplify Span::can_be_used_for_suggestions a little tiny bit 2023-07-30 15:37:39 +00:00
Urgau
8ea7e45e44 Fix invalid suggestion for mismatched types in closure arguments
The invalid suggestion came from a wrongly created span in `rustc_parse'
for closure arguments that didn't have a type specified. Specifically,
the span in this case was the last token span, but in the case of
tuples, the span represented the last parenthesis instead of the whole
tuple, which is fixed by taking the more accurate span of the pattern.
2023-07-30 17:15:55 +02:00
y21
be6a103c8c add more tests to unnecessary_find_map and unnecessary_filter_map 2023-07-30 16:52:53 +02:00
bors
89acdae9f2 Auto merge of #114250 - matthiaskrgr:rollup-0r0dhrr, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110056 (Fix the example in document for WaitTimeoutResult::timed_out)
 - #112655 (Mark `map_or` as `#[must_use]`)
 - #114018 (Make `--error-format human-annotate-rs` handle multiple files)
 - #114068 (inline format!() args up to and including rustc_middle (2))
 - #114223 (Documentation: Fix Stilted Language in Vec->Indexing)
 - #114227 (Add tidy check for stray rustfix files)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-30 13:59:25 +00:00
Matthias Krüger
b9f17f1e78
Rollup merge of #114227 - asquared31415:tidy_check_fixed, r=albertlarsan68
Add tidy check for stray rustfix files

`x.fixed` files that don't correspond to a test file now emit a tidy error.
2023-07-30 14:25:10 +02:00
Matthias Krüger
de6caffe3a
Rollup merge of #114223 - ryanoneill:vec-indexing-doc-language, r=workingjubilee
Documentation: Fix Stilted Language in Vec->Indexing

Problem

Language in the Vec->Indexing documentation sounds stilted due to incorrect word ordering: "... type allows to access values by index."

Solution

Reorder words in the Vec->Indexing documentation to flow better: "... type allows access to values by index." The phrase "allows access to" also matches other existing documentation.
2023-07-30 14:25:10 +02:00
Matthias Krüger
a964f948d5
Rollup merge of #114068 - matthiaskrgr:fmt_args_rustc_1, r=WaffleLapkin
inline format!() args up to and including rustc_middle (2)

r? `@WaffleLapkin`
2023-07-30 14:25:09 +02:00
Matthias Krüger
427f3d3266
Rollup merge of #114018 - Enselic:multi-annotation, r=b-naber
Make `--error-format human-annotate-rs` handle multiple files

Closes #64205 which is E-help-wanted
2023-07-30 14:25:09 +02:00
Matthias Krüger
e3bf088fb5
Rollup merge of #112655 - WaffleLapkin:must_use_map_or, r=workingjubilee
Mark `map_or` as `#[must_use]`

I don't know what else to say.

r? libs
2023-07-30 14:25:08 +02:00
Matthias Krüger
e517ee02b2
Rollup merge of #110056 - chenyukang:yukang/fix-110045, r=workingjubilee
Fix the example in document for WaitTimeoutResult::timed_out

Fixes #110045
2023-07-30 14:25:08 +02:00
Matthias Krüger
3ce90b1649 inline format!() args up to and including rustc_codegen_llvm 2023-07-30 14:22:50 +02:00
bors
483ef5f4d8 Auto merge of #114066 - matthiaskrgr:fmt_args_inline_bootstrap, r=WaffleLapkin
bootstrap: inline format!() args (0)

r? `@WaffleLapkin`
2023-07-30 12:14:04 +00:00
y21
008746cae4 [unnecessary_find_map]: look for then_some 2023-07-30 13:51:35 +02:00
Guillaume Gomez
148a0c1673 Remove some unneeded clone() calls 2023-07-30 13:26:36 +02:00
Matthias Krüger
23815467a2 inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
Bryanskiy
8203d1ddf6 Weaken unnameable_types lint 2023-07-30 14:02:21 +03:00
Maybe Waffle
90f9640528 Mark map_or as #[must_use] 2023-07-30 10:22:23 +00:00
Matthias Krüger
a0503a83d0 bootstrap: inline format!() args 2023-07-30 11:46:14 +02:00
León Orell Valerian Liehr
0ca432844c
Check lazy type aliases for well-formedness 2023-07-30 11:24:15 +02:00
yukang
d67d9890ae Fix the example in document for WaitTimeoutResult::timed_out 2023-07-30 16:39:33 +08:00
bors
c0bdb3d337 Auto merge of #11258 - Jarcho:ice_11256, r=Centri3
Resolve type aliases in `type_certainty`

Fixes #11256

changelog: `unwrap_or_default`: Fix ICE when local types are declared using alias types
2023-07-30 07:57:47 +00:00
bors
4c9ac1e93b Auto merge of #114236 - fee1-dead-contrib:rollup-m92j7q1, r=fee1-dead
Rollup of 3 pull requests

Successful merges:

 - #112151 (Clarify behavior of inclusive bounds in BTreeMap::{lower,upper}_bound)
 - #113512 (Updated lines doc to include trailing carriage return note)
 - #114203 (Effects: don't print `host` param in diagnostics)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-30 07:57:13 +00:00
Jason Newcomb
caf601434b Resolve type aliases in type_certainty 2023-07-30 03:26:32 -04:00
fee1-dead
7b4bfd640d
Rollup merge of #114203 - fee1-dead-contrib:effects/pp-no-host, r=oli-obk
Effects: don't print `host` param in diagnostics

r? ``@oli-obk``
2023-07-30 07:13:03 +00:00
fee1-dead
b97da75156
Rollup merge of #113512 - vallentin:lines-doc, r=workingjubilee
Updated lines doc to include trailing carriage return note

Updated `str::lines` doc to include explicit info about (trailing) carriage returns.

Reference: #100311
2023-07-30 07:13:02 +00:00
fee1-dead
3143030cda
Rollup merge of #112151 - chloekek:patch-1, r=workingjubilee
Clarify behavior of inclusive bounds in BTreeMap::{lower,upper}_bound

It wasn’t quite clear to me how these methods would interpret inclusive bounds so I added examples for those.
2023-07-30 07:13:01 +00:00
bors
2e0136a131 Auto merge of #112280 - zica87:master, r=workingjubilee
Remove redundant example of `BTreeSet::iter`

The usage and that `Values returned by the iterator are returned in ascending order` are already demonstrated by the other example and the description, so I removed the useless one.
2023-07-30 06:12:03 +00:00
bors
4c2f460dcc Auto merge of #8685 - Jarcho:redundant_closure_fixes, r=llogiq
`redundant_closure` fixes

fixes #8548

A good chunk of the code is fixing false negatives. The old code banned any non late-bound regions from appearing in the callee's signature. The new version checks when the late-bound region is actually required.

changelog: Better track when a early-bound region appears when a late-bound region is required in `redundant_closure`.
changelog: Don't lint `redundant_closure` when the closure gives explicit types.
2023-07-30 05:41:24 +00:00
Jason Newcomb
7423c2760b Don't lint redundant closure for any function call inserted by the compiler. 2023-07-30 01:19:36 -04:00
Jason Newcomb
4d80a2ed2e Rework redundant_closure
* Better track when a early-bound region appears when a late-bound region is required
* Don't lint when the closure gives explicit types.
2023-07-30 01:19:29 -04:00
Jason Newcomb
71cc39e1f2 Add debug assertions to implements_trait
Improve debug assertions for `make_projection`
2023-07-30 00:38:04 -04:00
bors
fb53384c94 Auto merge of #114226 - matthiaskrgr:rollup-wxdudsm, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #114129 (Rustdoc small cleanups)
 - #114152 ([rustc][data_structures] Simplify binary_search_slice.)
 - #114222 (Mark `lazy_type_alias` as incomplete)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-30 00:41:35 +00:00
asquared31415
6850a00bd0 add tidy check for stray rustfix files 2023-07-29 23:49:04 +00:00
Matthias Krüger
d4926b13aa
Rollup merge of #114222 - compiler-errors:lazy-type-alias-is-incomplete, r=oli-obk
Mark `lazy_type_alias` as incomplete

This feature is very not complete: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-lazy_type_alias

r? types
2023-07-30 01:22:43 +02:00
Matthias Krüger
b8895980bc
Rollup merge of #114152 - ttsugriy:master, r=WaffleLapkin
[rustc][data_structures] Simplify binary_search_slice.

Instead of using `binary_search_by_key`, it's possible to use `partition_point` to find the lower bound. This avoids the need to locate the leftmost matching entry separately.

It's also possible to use `partition_point` to find the upper bound, so I plan to send a separate PR for your consideration.
2023-07-30 01:22:42 +02:00
Matthias Krüger
fa94851b07
Rollup merge of #114129 - GuillaumeGomez:rustdoc-cleanup, r=notriddle
Rustdoc small cleanups

Each commit does some little cleanups:

 * We had some `Res` comparisons in multiple places (and still do, but unless we use a macro, it's not possible to "merge" any further) so I moved it into a function.
 * It was weird to have some utils function used everywhere in `visit_ast` so I instead moved it into `clean/utils.rs`.
 * In HTML rendering, we had some write "issues":
   * Multiple calls that could be merged into one.
   * Some `write!` that could be `write_str`.
   * We didn't use the new `format!` args much.

r? `@notriddle`
2023-07-30 01:22:42 +02:00
bors
b969b830aa Auto merge of #113704 - compiler-errors:rpitit-assumed-wf-inherit, r=spastorino
Make RPITITs inherit the `assumed_wf_types` of their parent method

... and then move the RPITIT well-formedness check to just use the regular logic of wfchecking an associated type.

---

We need to inherit the `assumed_wf_types` of the RPITIT's parent function in order for the given code to be considered well-formed:

```rust
trait Foo {
  fn bar<'a, T>(_: &'a T) -> impl Iterator<Output = &'a T>;
}
```

Since for `&'a T` to be WF, we need `T: 'a`.

In order for this to work for late-bound lifetimes, we need to do some additional mapping of any late-bound lifetimes captured by these assumed wf types. This is because within the body of the function (and thus in the `assumed_wf_types`), they're represented as `ReFree` variants of the original late-bound lifetimes declared in the function's generics, but in the RPITIT's GAT, they're represented as "reified" `ReEarlyBound` vars (duplicated during opaque type lowering). Luckily, the mapping between these two is already [stored in the opaque](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.OpaqueTy.html#structfield.lifetime_mapping).

Fixes #113796
2023-07-29 22:58:21 +00:00