Commit Graph

259796 Commits

Author SHA1 Message Date
Nicholas Nethercote 022582ca46 Remove `Clone` derive from `LazyAttrTokenStreamImpl`. 2024-07-07 16:24:51 +10:00
Nicholas Nethercote 3a5c4b6e4e Rename some attribute types for consistency.
- `AttributesData` -> `AttrsTarget`
- `AttrTokenTree::Attributes` -> `AttrTokenTree::AttrsTarget`
- `FlatToken::AttrTarget` -> `FlatToken::AttrsTarget`
2024-07-07 16:14:30 +10:00
Nicholas Nethercote 9d33a8fe51 Simplify `ReplaceRange`.
Currently the second element is a `Vec<(FlatToken, Spacing)>`. But the
vector always has zero or one elements, and the `FlatToken` is always
`FlatToken::AttrTarget` (which contains an `AttributesData`), and the
spacing is always `Alone`. So we can simplify it to
`Option<AttributesData>`.

An assertion in `to_attr_token_stream` can can also be removed, because
`new_tokens.len()` was always 0 or 1, which means than `range.len()`
is always greater than or equal to it, because `range.is_empty()` is
always false (as per the earlier assertion).
2024-07-07 15:58:36 +10:00
Nicholas Nethercote b261501b71 Remove `HasSpan` trait.
The only place it is meaningfully used is in a panic message in
`TokenStream::from_ast`. But `node.span()` doesn't need to be printed
because `node` is also printed and it must contain the span.
2024-07-07 15:58:34 +10:00
Nicholas Nethercote 88373e9f0c Remove an unnecessary local variable. 2024-07-07 15:58:12 +10:00
Nicholas Nethercote 14b859fa3b Rename `Attribute::tokens` (the inherent method).
To distinguish it from the `HasTokens` method.
2024-07-07 15:58:10 +10:00
bors 35e6e4c5e9 Auto merge of #127321 - Kobzol:bootstrap-cmd-refactor-4, r=onur-ozkan
Bootstrap command refactoring: quality-of-life improvements (step 4)

Continuation of https://github.com/rust-lang/rust/pull/127120.

This PR simply introduce two new functions (`BootstrapCommand:run` and `command`) that make it a bit easier to use commands in bootstrap. It also adds several `#[must_use]` annotations. This shouldn't (hopefully) have any effect on behavior.

Especially the first commit IMO makes any code that runs commands more readable, and allows using the API in a fluent way, without needing to jump back and forth between the command and the `Build(er)`.

Tracking issue: https://github.com/rust-lang/rust/issues/126819

r? `@onur-ozkan`
2024-07-07 05:53:57 +00:00
Michael Goulet 58aad3c72c iter_identity is a better name 2024-07-07 00:12:35 -04:00
Chayim Refael Friedman 54556f49d3 Specialize `TrustedLen` for `Iterator::unzip()`
Don't check the capacity every time (and also for `Extend` for tuples, as this is how `unzip()` is implemented).

I did this with an unsafe method on `Extend` that doesn't check for growth (`extend_one_unchecked()`). I've marked it as perma-unstable currently, although we may want to expose it in the future so collections outside of std can benefit from it. Then specialize `Extend for (A, B)` for `TrustedLen` to call it.

It may seem that an alternative way of implementing this is to have a semi-public trait (`#[doc(hidden)]` public, so collections outside of core can implement it) for `extend()` inside tuples, and specialize it from collections. However, it is impossible due to limitations of `min_specialization`.

A concern that may arise with the current approach is that implementing `extend_one_unchecked()` correctly must also incur implementing `extend_reserve()`, otherwise you can have UB. This is a somewhat non-local safety invariant. However, I believe this is fine, since to have actual UB you must have unsafe code inside your `extend_one_unchecked()` that makes incorrect assumption, *and* not implement `extend_reserve()`. I've also documented this requirement.
2024-07-07 06:58:52 +03:00
bors 9e27377bec Auto merge of #127404 - compiler-errors:rpitit-entailment-false-positive, r=oli-obk
Don't try to label `ObligationCauseCode::CompareImplItem` for an RPITIT, since it has no name

The old (current) trait solver has a limitation that when a where clause in param-env must be normalized using the same where clause, then we get spurious errors in `normalize_param_env_or_error`. I don't think there's an issue tracking it, but it's the root cause for many of the "fixed-by-next-solver" labeled issues.

Specifically, these errors may occur when checking predicate entailment of the GAT that comes out of desugaring RPITITs. Since we use `ObligationCauseCode::CompareImplItem` for these predicates, we try calling `item_name` on an RPITIT which fails, since the RPITIT has no name.

We simply suppress this logic when we're reporting a predicate entailment error for an RPITIT. RPITITs should never have predicate entailment errors, *by construction*, but they may due to this bug in the old solver.

Addresses the ICE in #127331, though doesn't fix the underlying issue (which is fundamental to the old solver).

r? types
2024-07-07 03:22:12 +00:00
bors 289deb9ed7 Auto merge of #127335 - Oneirical:put-on-a-petestal, r=jieyouxu
Migrate `emit-shared-files` and `emit-path-unhashed` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: x86_64-msvc
try-job: aarch64-apple
try-job: armhf-gnu
try-job: test-various
2024-07-07 01:05:25 +00:00
bors 6ba80a9f8d Auto merge of #126987 - petrochenkov:atvisord2, r=pnkfelix
out_of_scope_macro_calls: Detect calls inside attributes more precisely

Fixes https://github.com/rust-lang/rust/issues/126984.
2024-07-06 22:53:07 +00:00
Michael Goulet 87d61f2540 Don't track visited outlives bounds when decomposing verify for alias 2024-07-06 18:49:20 -04:00
Caio c990e00f15 Add support for literals 2024-07-06 18:00:04 -03:00
bors ed7e35f349 Auto merge of #127430 - compiler-errors:rollup-76ni16s, r=compiler-errors
Rollup of 4 pull requests

Successful merges:

 - #127386 (Uplift outlives components to `rustc_type_ir`)
 - #127405 (uplift `PredicateEmittingRelation`)
 - #127410 (Correct description of E0502)
 - #127417 (Show fnsig's unit output  explicitly when there is output diff in diagnostics)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-06 20:26:50 +00:00
Elisha Hollander 8d8504300f remove regexes 2024-07-06 20:11:42 +00:00
Oli Scherer 8c2ea715e9 Use field ident spans directly instead of the full field span in diagnostics on local fields 2024-07-06 19:22:05 +00:00
Michael Goulet d6276b37ea Don't try to label ObligationCauseCode::CompareImplItem for an RPITIT, since it has no name 2024-07-06 15:20:37 -04:00
Michael Goulet 413345c61d
Rollup merge of #127417 - chenyukang:yukang-method-output-diff, r=oli-obk
Show fnsig's unit output  explicitly when there is output diff in diagnostics

Fixes #127263
2024-07-06 14:55:25 -04:00
Michael Goulet 9352026d26
Rollup merge of #127410 - trevyn:patch-1, r=compiler-errors
Correct description of E0502

Closes #126495
2024-07-06 14:55:24 -04:00
Michael Goulet f664171cb5
Rollup merge of #127405 - compiler-errors:uplift-predicate-emitting-relation, r=lcnr
uplift `PredicateEmittingRelation`

Small follow-up to #127333

r? lcnr
2024-07-06 14:55:24 -04:00
Michael Goulet dfc02d28c7
Rollup merge of #127386 - compiler-errors:uplift-outlives-components, r=lcnr
Uplift outlives components to `rustc_type_ir`

We need this to uplift `push_outlives_components`, since the elaborator uses `push_outlives_components` to elaborate type outlives obligations and I want to uplift elaboration.

This ends up reworking and inlining a fair portion of the `GenericArg::walk_shallow` function, whose only callsite was this one. I believe I got the logic correct, but may be worthwhile to look at it closely just in case. Unfortunately github was too dumb to understand that this is a rename + change -- I could also rework the git history to split the "copy the file over" part from the actual logical changes if that makes this easier to review.

r? lcnr
2024-07-06 14:55:23 -04:00
Jakub Beránek 061edfe1fa Add `#[must_use]` attribute to several command-related methods
This should make it harder to accidentally forget to use results of methods on `BootstrapCommand` and `CommandStatus`.
2024-07-06 20:47:54 +02:00
bors 8a8ad3433e Auto merge of #127388 - compiler-errors:elaboration-tweaks, r=lcnr
Elaboration tweaks

Removes `Filter::OnlySelfThatDefines` and reimplements `transitive_bounds_that_define_assoc_item` as a separate function, since I don't want to have to uplift that mode since it's both an implementation detail (only exists to avoid cycles in astconv) and requires exposing `Ident` as an associated type on `Interner`.

r? lcnr
2024-07-06 15:56:16 +00:00
yukang 81c86ddf8e show fnsig's output when there is difference 2024-07-06 23:29:58 +08:00
Michael Goulet c2a88ea6ca Remove walk_shallow 2024-07-06 10:47:46 -04:00
Michael Goulet cc6c5de39d Import via rustc_type_ir::outlives
We could use rustc_middle::ty::outlives I guess?
2024-07-06 10:47:46 -04:00
Michael Goulet 23c6f23b21 Uplift push_outlives_components 2024-07-06 10:47:46 -04:00
Michael Goulet e5d6a416e8 Uplift PredicateEmittingRelation first 2024-07-06 10:05:49 -04:00
yukang f46c4129e0 show unit output when there is only output diff in diagnostics 2024-07-06 21:00:30 +08:00
Vadim Petrochenkov 83cf471361 out_of_scope_macro_calls: Detect calls inside attributes more precisely 2024-07-06 15:36:30 +03:00
lukas 3e9c9a05a8 Mark format! with must_use hint 2024-07-06 14:24:20 +02:00
bors 3bec61736a Auto merge of #127420 - matthiaskrgr:rollup-vpitwow, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #127275 (offset_from, offset: clearly separate safety requirements the user needs to prove from corollaries that automatically follow)
 - #127379 (rustdoc-search: stop constructing pointless arrays in decode)
 - #127391 (Use verbose suggestion for `ptr::null_mut()`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-06 12:07:55 +00:00
Camille GILLOT 0184c6f52e Cache hir_owner_nodes in ParentHirIterator. 2024-07-06 11:56:37 +00:00
Matthias Krüger 1e0028197f
Rollup merge of #127391 - estebank:null_mut, r=cjgillot
Use verbose suggestion for `ptr::null_mut()`
2024-07-06 13:26:26 +02:00
Matthias Krüger 04056524a0
Rollup merge of #127379 - notriddle:notriddle/decode, r=GuillaumeGomez
rustdoc-search: stop constructing pointless arrays in decode

I'm not sure why I ever thought that would be okay. This is clearly hot code, and should avoid Array.prototype.map when it's not needed. In any case, it shows up in the profiler.

rustdoc-js-profiler:
https://notriddle.com/rustdoc-html-demo-11/decode-opt-1/index.html

Firefox profiler:
[Before](https://share.firefox.dev/3RRH2fR)
[After](https://share.firefox.dev/3Wblcq8)
2024-07-06 13:26:26 +02:00
Matthias Krüger 2137d19ef6
Rollup merge of #127275 - RalfJung:offset-from-isize-min, r=Amanieu
offset_from, offset: clearly separate safety requirements the user needs to prove from corollaries that automatically follow

By landing https://github.com/rust-lang/rust/pull/116675 we decided that objects larger than `isize::MAX` cannot exist in the address space of a Rust program, which lets us simplify these rules.

For `offset_from`, we can even state that the *absolute* distance fits into an `isize`, and therefore exclude `isize::MIN`. This PR also changes Miri to treat an `isize::MIN` difference like the other isize-overflowing cases.
2024-07-06 13:26:25 +02:00
Camille Gillot 12edc8db87
Update compiler/rustc_mir_transform/src/gvn.rs
Co-authored-by: Michael Goulet <michael@errs.io>
2024-07-06 12:45:23 +02:00
bors 28cc0b643d Auto merge of #127414 - workingjubilee:rollup-lcxw1eh, r=workingjubilee
Rollup of 5 pull requests

Successful merges:

 - #125751 (Add `new_range_api` for RFC 3550)
 - #127098 (Migrate `output-type-permutations` `run-make` test to rmake)
 - #127369 (Match ergonomics 2024: align with RFC again)
 - #127383 (Use verbose style for argument removal suggestion)
 - #127392 (Use verbose suggestion for changing arg type)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-06 07:17:53 +00:00
Jubilee 853148752f
Rollup merge of #127392 - estebank:arg-type, r=jieyouxu
Use verbose suggestion for changing arg type
2024-07-05 23:23:36 -07:00
Jubilee d0f61ce214
Rollup merge of #127383 - estebank:arg-removal, r=compiler-errors
Use verbose style for argument removal suggestion
2024-07-05 23:23:36 -07:00
Jubilee 3ba4195a68
Rollup merge of #127369 - Jules-Bertholet:match-ergonomics-2021, r=Nadrieril
Match ergonomics 2024: align with RFC again

- `&` matches `&mut` on old editions
- Add some more tests

r? ``@Nadrieril``

cc https://github.com/rust-lang/rust/issues/123076

``@rustbot`` label A-edition-2024 A-patterns
2024-07-05 23:23:35 -07:00
Jubilee 02629721ba
Rollup merge of #127098 - Oneirical:big-test-party, r=Kobzol,jieyouxu
Migrate `output-type-permutations` `run-make` test to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: x86_64-msvc
try-job: armhf-gnu
try-job: aarch64-apple
try-job: test-various
2024-07-05 23:23:35 -07:00
Jubilee 9c8a88996e
Rollup merge of #125751 - pitaj:new_range_api, r=jhpratt
Add `new_range_api` for RFC 3550

Initial implementation for #125687

This includes a `From<legacy::RangeInclusive> for RangeInclusive` impl for convenience, instead of the `TryFrom` impl from the RFC. Having `From` is highly convenient and the debug assert should find almost all misuses.

This includes re-exports of all existing `Range` types under `core::range`, plus the range-related traits (`RangeBounds`, `Step`, `OneSidedRange`) and the `Bound` enum.

Currently the iterators are just wrappers around the old range types.

Tracking issues:

- https://github.com/rust-lang/rust/issues/123741
- https://github.com/rust-lang/rust/issues/125687
2024-07-05 23:23:34 -07:00
trevyn 09b3fcebf4
Correct description of E0502 2024-07-06 09:13:14 +03:00
bors 51917e2e69 Auto merge of #127403 - compiler-errors:rollup-x2yb5t0, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #123600 (impl PathBuf::add_extension and Path::with_added_extension)
 - #127107 (Improve dead code analysis)
 - #127221 (Improve well known value check-cfg diagnostic for the standard library)
 - #127333 (Split `SolverDelegate` back out from `InferCtxtLike`)
 - #127363 (Improve readability of some fmt code examples)
 - #127366 (Use `ControlFlow` results for visitors that are only looking for a single value)
 - #127368 (Added dots at the sentence ends of rustc AST doc)
 - #127393 (Remove clubby789 from review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-06 02:48:17 +00:00
Michael Goulet b73a790904
Rollup merge of #127393 - clubby789:unreview, r=workingjubilee
Remove clubby789 from review rotation

These days I'm unfortunately too busy to be able to take up reviews, and it looks like some PRs have been blocked on this 😓
2024-07-05 20:49:35 -04:00
Michael Goulet aeb1a65dbf
Rollup merge of #127368 - YohDeadfall:dots-in-docs, r=fmease
Added dots at the sentence ends of rustc AST doc

Just a tiny improvement for the AST documentation by bringing consistency to sentence ends. I intentionally didn't terminate every sentence, there are still some members not having them, but at least there's no mixing style on the type level.
2024-07-05 20:49:34 -04:00
Michael Goulet a3535b963b
Rollup merge of #127366 - oli-obk:falliblevisitor, r=compiler-errors
Use `ControlFlow` results for visitors that are only looking for a single value

These visitors all had a `Option<Value>` or `bool` field, that, once set, was never unset or modified again. They have been refactored by removing the field and returning `ControlFlow` directly from the visitor
2024-07-05 20:49:34 -04:00
Michael Goulet 521d451bc4
Rollup merge of #127363 - GuillaumeGomez:improve-fmt-code-readability, r=Amanieu
Improve readability of some fmt code examples

Some indent was weird. Some examples were too long (overall better to keep it to maximum 80 columns, but only changed the most outstanding ones).

r? ```@Amanieu```
2024-07-05 20:49:33 -04:00