Commit Graph

254797 Commits

Author SHA1 Message Date
Michael Goulet
d57e57ca1f Implement initial IMPL_TRAIT_OVERCAPTURES lint 2024-05-13 23:47:35 -04:00
bors
9105c57b7f Auto merge of #124256 - nnethercote:rm-NtIdent-NtLifetime, r=petrochenkov
Remove `NtIdent` and `NtLifetime`

This is one part of the bigger "remove `Nonterminal` and `TokenKind::Interpolated`" change drafted in #114647. More details in the individual commit messages.

r? `@petrochenkov`
2024-05-14 01:10:38 +00:00
bors
34582118af Auto merge of #125076 - compiler-errors:alias-term, r=lcnr
Split out `ty::AliasTerm` from `ty::AliasTy`

Splitting out `AliasTerm` (for use in project and normalizes goals) and `AliasTy` (for use in `ty::Alias`)

r? lcnr
2024-05-13 22:20:43 +00:00
Nicholas Nethercote
95e519ecbf Remove NtIdent and NtLifetime.
The extra span is now recorded in the new `TokenKind::NtIdent` and
`TokenKind::NtLifetime`. These both consist of a single token, and so
there's no operator precedence problems with inserting them directly
into the token stream.

The other way to do this would be to wrap the ident/lifetime in invisible
delimiters, but there's a lot of code that assumes an interpolated
ident/lifetime fits in a single token, and changing all that code to work with
invisible delimiters would have been a pain. (Maybe it could be done in a
follow-up.)

This change might not seem like much of a win, but it's a first step toward the
much bigger and long-desired removal of `Nonterminal` and
`TokenKind::Interpolated`. That change is big and complex enough that it's
worth doing this piece separately. (Indeed, this commit is based on part of a
late commit in #114647, a prior attempt at that big and complex change.)
2024-05-14 08:19:58 +10:00
Michael Goulet
fa84018c2e Apply nits 2024-05-13 16:55:58 -04:00
bors
ab14f944af Auto merge of #125086 - matthiaskrgr:rollup-xob4lof, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #119515 (style-guide: Format single associated type `where` clauses on the same line)
 - #119959 ([meta] Clarify prioritization alert)
 - #123817 (Stabilize `seek_seek_relative`)
 - #125063 (Don't call `env::set_var` in `rustc_driver::install_ice_hook`)
 - #125071 (Migrate rustdoc target spec json path)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-13 20:14:47 +00:00
Matthias Krüger
ed2c2c06e6
Rollup merge of #125071 - GuillaumeGomez:migrate-rustdoc-target-spec-json-path, r=jieyouxu
Migrate rustdoc target spec json path

Part of https://github.com/rust-lang/rust/issues/121876.

r? `@jieyouxu`
2024-05-13 20:29:19 +02:00
Matthias Krüger
472391dbf6
Rollup merge of #125063 - tbu-:pr_set_ice_hook_env, r=michaelwoerister
Don't call `env::set_var` in `rustc_driver::install_ice_hook`

Modifying an environment variable would make the function unsafe to call.
2024-05-13 20:29:19 +02:00
Matthias Krüger
b0cbd4e5f3
Rollup merge of #123817 - slanterns:seek_relative, r=dtolnay
Stabilize `seek_seek_relative`

This PR stabilizes `seek_seek_relative`:

```rust
// std::io::Seek

trait Seek {
    fn seek_relative(&mut self, offset: i64) -> Result<()>;
}
```

<br>

Tracking issue: https://github.com/rust-lang/rust/issues/117374.
Implementation PR: https://github.com/rust-lang/rust/pull/116750.

FCPs already completed in the tracking issue.

Closes https://github.com/rust-lang/rust/issues/117374.

r? libs-api
2024-05-13 20:29:18 +02:00
Matthias Krüger
cf8a084d26
Rollup merge of #119959 - fmease:triagebot-prioritization-alert-label, r=apiraino
[meta] Clarify prioritization alert

Apparently, there used to exist the label <kbd>I-nominated</kbd> judging from this entry:

8847bda592/triagebot.toml (L393)

Since it was replaced with individual team labels, I think it makes sense to update the prioritization alert. Of course, it's not super important since the members of WG-prioritization already know that. This is just cleanup.

r? apiraino or wg-prioritization
2024-05-13 20:29:17 +02:00
Matthias Krüger
4d1cce9de5
Rollup merge of #119515 - joshtriplett:style-guide-gat-where-clause-same-line, r=compiler-errors
style-guide: Format single associated type `where` clauses on the same line

In particular, lifetime-generic associated types often have a
`where Self: 'a` bound, which we can format on the same line.
2024-05-13 20:29:17 +02:00
Michael Goulet
3bcdf3058e split out AliasTy -> AliasTerm 2024-05-13 11:59:42 -04:00
bors
030a12ce2b Auto merge of #125074 - bjorn3:sync_cg_clif-2024-05-13, r=bjorn3
Subtree sync for rustc_codegen_cranelift

A variety of bug fixes, added support for naked functions, a couple more vendor intrinsics implemented.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-05-13 15:30:18 +00:00
Josh Triplett
163b1a6615 Reword formatting for where clauses
Suggested-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
2024-05-13 16:43:13 +02:00
Josh Triplett
9ff777bf50 style-guide: Also format where clauses on one line for short function decls 2024-05-13 16:43:13 +02:00
Josh Triplett
2af29af710 style-guide: Not all where clauses can be written as inline bounds 2024-05-13 16:43:13 +02:00
Josh Triplett
2f20bb4a97 style-guide: Give a second example for associated type formatting
Show an example that has bounds.
2024-05-13 16:43:13 +02:00
Josh Triplett
3742a4bd90 style-guide: Format single associated type where clauses on the same line
In particular, lifetime-generic associated types often have a
`where Self: 'a` bound, which we can format on the same line.
2024-05-13 16:42:47 +02:00
bjorn3
75f8bdbca4 Merge commit '3270432f4b0583104c8b9b6f695bf97d6bbf3ac2' into sync_cg_clif-2024-05-13 2024-05-13 13:26:33 +00:00
bors
421f7ca3a9 Auto merge of #125061 - RalfJung:interpret-error, r=cjgillot
interpret: move error macros into error.rs
2024-05-13 13:25:00 +00:00
bjorn3
3270432f4b Rustup to rustc 1.80.0-nightly (ef0027897 2024-05-12) 2024-05-13 13:22:02 +00:00
Guillaume Gomez
b515de83af Migrate run-make/rustdoc-target-spec-json-path to rmake 2024-05-13 15:21:13 +02:00
Guillaume Gomez
4057a7b1e3 Add library_search_path to Rustdoc 2024-05-13 15:21:12 +02:00
Guillaume Gomez
eea00ca354 Add target method to Rustdoc type 2024-05-13 15:04:10 +02:00
bors
abb95639ef Auto merge of #125024 - Oneirical:master, r=jieyouxu
Rewrite 3 very similar `run-make` alloc tests to rmake

Part of #121876

#121918 attempted to port these 3 tests 2 months ago. However, since then, the structure of `run-make-support` has changed a bit and new helper functions were added. Since there has been no activity on the PR, they are good low-hanging fruit to knock down, using the new functions of the current library.

There is also the removal of a useless import on a very similar test.
2024-05-13 11:20:00 +00:00
bors
6be7b0c7d2 Auto merge of #124999 - scottmcm:unify-aggregate, r=nnethercote
Unify `Rvalue::Aggregate` paths in cg_ssa

In #123840 and #123886 I added two different codepaths for `Rvalue::Aggregate` in `cg_ssa`.

This merges them into one, since raw pointers are also immediates that can be built from the immediates of their "fields".
2024-05-13 09:08:18 +00:00
Tobias Bucher
b98b8d76b1 Don't call env::set_var in rustc_driver::install_ice_hook
Modifying an environment variable would make the function unsafe to
call.
2024-05-13 09:37:29 +02:00
bors
982c9c1e81 Auto merge of #125055 - nnethercote:Comment-FIXME, r=compiler-errors
Avoid clone in `Comments::next`

`Comments::next`, in `rustc_ast_pretty`, has this comment:
```
// FIXME: This shouldn't probably clone lmao
```
The obvious thing to try is to return `Option<&Comment>` instead of `Option<Comment>`. But that leads to multiple borrows all over the place, because `Comments` must be borrowed from `PrintState` and then processed by `&mut self` methods within `PrintState`.

This PR instead rearranges things so that comments are consumed as they are used, preserving the `Option<Comment>` return type without requiring any cloning.

r? `@compiler-errors`
2024-05-13 06:30:25 +00:00
Ralf Jung
b15d09a6dd interpret: move error macros into error.rs 2024-05-13 08:15:45 +02:00
Nicholas Nethercote
9a63a42cb7 Remove a Span from TokenKind::Interpolated.
This span records the declaration of the metavariable in the LHS of the macro.
It's used in a couple of error messages. Unfortunately, it gets in the way of
the long-term goal of removing `TokenKind::Interpolated`. So this commit
removes it, which degrades a couple of (obscure) error messages but makes
things simpler and enables the next commit.
2024-05-13 10:30:30 +10:00
Nicholas Nethercote
74e1b46ab2 Make Comments::next consume a comment.
This avoids the need for a clone, fixing a FIXME comment.
2024-05-13 10:15:30 +10:00
bors
ba956ef4b0 Auto merge of #124914 - nnethercote:rm-extern-crate-rustc_middle, r=saethlin
Remove `#[macro_use] extern crate rustc middle` from numerous crates

Because explicit importing of macros via `use` items is nicer (more standard and readable) than implicit importing via `#[macro_use]`. This PR mops up some cases I didn't get to in #124511.

r? `@saethlin`
2024-05-13 00:13:34 +00:00
Nicholas Nethercote
5e7a80b2d2 Make handling of Comments more iterator-like.
The current way of stepping through each comment in `Comments` is a bit
weird. There is a `Vec<Comments>` and a `current` index, which is fine.
The `Comments::next` method clones the current comment but doesn't
advance `current`; the advancing instead happens in `print_comment`,
which is where each cloned comment is actually finally used (or not, in
some cases, if the comment fails to satisfy a predicate).

This commit makes things more iterator-like:
- `Comments::next` now advances `current` instead of `print_comment`.
- `Comments::peek` is added so you can inspect a comment and check a
  predicate without consuming it.
- This requires splitting `PrintState::comments` into immutable and
  mutable versions. The commit also moves the ref inside the `Option` of
  the return type, to save callers from having to use `as_ref`/`as_mut`.
- It also requires adding `PrintState::peek_comment` alongside the
  existing `PrintState::next_comment`. (The lifetimes in the signature
  of `peek_comment` ended up more complex than I expected.)

We now have a neat separation between consuming (`next`) and
non-consuming (`peek`) uses of each comment. As well as being clearer,
this will facilitate the next commit that avoids unnecessary cloning.
2024-05-13 10:11:29 +10:00
Nicholas Nethercote
c34ebba134 Remove extern crate rustc_middle from rustc_ty_utils. 2024-05-13 08:20:18 +10:00
Nicholas Nethercote
4bf20b2b55 Remove extern crate rustc_middle from rustc_trait_selection. 2024-05-13 08:20:18 +10:00
Nicholas Nethercote
573aa9f677 Remove extern crate rustc_middle from rustc_query_impl. 2024-05-13 08:20:18 +10:00
Nicholas Nethercote
d49d4ae192 Remove extern crate rustc_middle from rustc_mir_transform. 2024-05-13 08:20:18 +10:00
Nicholas Nethercote
900bcacf3a Remove extern crate rustc_middle from rustc_mir_build. 2024-05-13 08:20:18 +10:00
Nicholas Nethercote
00cfb45b54 Remove extern crate rustc_middle from rustc_metadata. 2024-05-13 08:20:18 +10:00
Nicholas Nethercote
34e247af1e Remove extern crate rustc_middle from rustc_infer. 2024-05-13 08:20:18 +10:00
Nicholas Nethercote
9b7d254d49 Remove extern crate rustc_middle from rustc_hir_typeck. 2024-05-13 08:16:51 +10:00
bors
ecbe3fd550 Auto merge of #125051 - dtolnay:printletelse, r=compiler-errors
Pretty-print let-else with added parenthesization when needed

Rustc used to produce invalid syntax for the following code, which is problematic because it means we cannot apply rustfmt to the output of `-Zunpretty=expanded`.

```rust
macro_rules! expr {
    ($e:expr) => { $e };
}

fn main() {
    let _ = expr!(loop {}) else { return; };
}
```

```console
$ rustc repro.rs -Zunpretty=expanded | rustfmt
error: `loop...else` loops are not supported
 --> <stdin>:9:29
  |
9 | fn main() { let _ = loop {} else { return; }; }
  |                     ----    ^^^^^^^^^^^^^^^^
  |                     |
  |                     `else` is attached to this loop
  |
  = note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run
```
2024-05-12 22:06:34 +00:00
Nicholas Nethercote
f59348ff09 Remove extern crate rustc_middle from rustc_hir_analysis. 2024-05-13 08:04:47 +10:00
Nicholas Nethercote
4497d345a8 Remove extern crate rustc_middle from rustc_const_eval.
This requires exporting the interpreter macros so they can be used with
`use crate::interpret::*`.
2024-05-13 08:02:14 +10:00
Nicholas Nethercote
f12e935795 Remove a stray backtick in an error explanation. 2024-05-13 07:53:38 +10:00
David Tolnay
94cc82c088
Pretty-print let-else with added parenthesization when needed 2024-05-12 13:42:37 -07:00
David Tolnay
68854b798e
Add AST pretty-printer tests for let-else 2024-05-12 13:37:00 -07:00
bors
ef0027897d Auto merge of #124639 - Jules-Bertholet:match-ergonomics-2024-migration-lint, r=Nadrieril
Match ergonomics 2024: migration lint

Depends on #124567

r? `@Nadrieril`

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

`@rustbot` label A-edition-2024 A-patterns
2024-05-12 19:58:50 +00:00
bors
852a78ea8d Auto merge of #124902 - compiler-errors:mem-cat-but-better, r=lcnr
Fix MemCategorization and ExprUse visitors for new solver (this time it's better)

Best reviewed by each commit. Supersedes #124859.

r? lcnr
2024-05-12 17:48:33 +00:00
bjorn3
df88c11867 Use the target cpu from the target spec on x86_64 when -Ctarget-cpu isn't used
Fixes rust-lang/rustc_codegen_cranelift#1148
2024-05-12 18:57:24 +02:00