Commit graph

254922 commits

Author SHA1 Message Date
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
Oneirical 71fd2cf5b4 fix function call and import 2024-05-12 15:02:22 -04:00
Oneirical a1b5ea0cc2 make tidy happy 2024-05-12 14:13:02 -04:00
Oneirical f2de5fb2ae rewrite issue-14500 to rmake 2024-05-12 14:00:09 -04: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
Federico Maria Morrone a6f237ca85
docs: fix typo in platform-support docs 2024-05-12 19:07:11 +02: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
Michael Goulet c697ec41f4 Propagate errors rather than using return_if_err 2024-05-12 12:50:18 -04:00
bjorn3 cba05a7a14 Support naked functions
Fixes rust-lang/rustc_codegen_cranelift#1203
2024-05-12 18:20:14 +02:00
bjorn3 0627c63ad9 Remove polymorphize calls for statics in a couple more places 2024-05-12 18:20:14 +02:00
Michael Goulet fb298e80c3 Apply nits 2024-05-12 12:11:25 -04:00
Michael Goulet 5ab6dca6d3 Try structurally resolve 2024-05-12 12:11:25 -04:00
Michael Goulet 55cf09d761 Make LateCtxt be a type info delegate for EUV for clippy 2024-05-12 12:11:25 -04:00
Michael Goulet e4209f19fd Introduce TypeInformationCtxt to abstract over LateCtxt/FnCtxt 2024-05-12 12:11:25 -04:00
Michael Goulet 72eccf2c6e Remove unncessary mut ref 2024-05-12 11:52:13 -04:00
Michael Goulet d7595eb6df Inline MemCategorization into ExprUseVisitor 2024-05-12 11:52:13 -04:00
Michael Goulet 5808c5801d Assert that MemCategorizationVisitor actually errors when it bails ungracefully 2024-05-12 11:52:13 -04:00
bors d25cf6fc14 Auto merge of #125040 - ickk:patch-1, r=notriddle
Fix hidden title in rustdoc book

raw html is treated as actual html by markdown, so this title needs to use some form of escaping in order to display correctly
2024-05-12 15:40:49 +00:00
Jules Bertholet 9d92a7f355
Match ergonomics 2024: migration lint
Unfortunately, we can't always offer a machine-applicable suggestion when there are subpatterns from macro expansion.

Co-Authored-By: Guillaume Boisseau <Nadrieril@users.noreply.github.com>
2024-05-12 11:13:33 -04:00
bors dde8cfa597 Auto merge of #125045 - GuillaumeGomez:rollup-em6qdzw, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - #125021 (Update reference safety requirements)
 - #125022 (Migrate rustdoc scrape examples ordering)
 - #125030 (Fix some minor issues from the ui-test auto-porting)
 - #125036 (solve: all "non-structural" logging to trace)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-12 13:33:39 +00:00
bjorn3 6db27529dd Significantly reduce check cfg warnings 2024-05-12 12:59:10 +00:00
bjorn3 cfc919f532 Use cargo in y.sh
This will allow adding dependencies to the build system in the future.
2024-05-12 12:59:10 +00:00
Guillaume Gomez d3625fc8df
Rollup merge of #125036 - lcnr:new-solver-trace, r=compiler-errors
solve: all "non-structural" logging to trace

This enables us to start with `RUSTC_LOG=rustc_trait_selection::solve=debug` to figure out *where* something went wrong, to then separately use `trace` to get to the details.

r? ``@compiler-errors``
2024-05-12 13:41:58 +02:00
Guillaume Gomez 14271c2137
Rollup merge of #125030 - saethlin:ui-test-false-positives, r=compiler-errors
Fix some minor issues from the ui-test auto-porting

I'm not sure if these count as false positives, because well, starting a comment with `// incremental` was probably a valid compiletest directive.

But anyway, these tests directives became clearly goofy and now with the better syntax we can straighten things out.

r? jieyouxu
2024-05-12 13:41:58 +02:00
Guillaume Gomez 1393a87e4f
Rollup merge of #125022 - GuillaumeGomez:migrate-rustdoc-scrape-examples-ordering, r=jieyouxu
Migrate rustdoc scrape examples ordering

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

This one adds a lot of utility methods/functions. To prevent having too much changes at once, I didn't make the existing rmake tests use these yet but I'll send a follow-up so they all use it.

r? `@jieyouxu`
2024-05-12 13:41:57 +02:00
Guillaume Gomez 5087947695
Rollup merge of #125021 - joshlf:patch-11, r=RalfJung
Update reference safety requirements

Per https://github.com/rust-lang/rust/pull/116677#issuecomment-1945495786, the language as written promises too much. This PR relaxes the language to be consistent with current semantics. If and when #117945 is implemented, we can revert to the old language.

While we're here, we also require that references be non-null.

cc ``@RalfJung``
2024-05-12 13:41:57 +02:00
bors b71fa82d78 Auto merge of #124798 - devnexen:illumos_memalign_fix, r=RalfJung
std::alloc: use posix_memalign instead of memalign on solarish

`memalign` on Solarish requires the alignment to be at least the size of a pointer, which we did not honor. `posix_memalign` also requires that, but that code path already takes care of this requirement.

close GH-124787
2024-05-12 11:22:40 +00:00
Guillaume Gomez 114e25761f Migrate rustdoc-scrape-examples-ordering to rmake 2024-05-12 11:30:52 +02:00
bors 4fd98a4b1b Auto merge of #125012 - RalfJung:format-error, r=Mark-Simulacrum,workingjubilee
io::Write::write_fmt: panic if the formatter fails when the stream does not fail

Follow-up to https://github.com/rust-lang/rust/pull/124954
2024-05-12 08:34:32 +00:00
ickk 48506150f4
fix hidden title in command-line-arguments docs 2024-05-12 17:18:44 +10:00
bors 645bc609d9 Auto merge of #124883 - onur-ozkan:change-stage0-file, r=Mark-Simulacrum
use key-value format in stage0 file

Currently, we are working on the python removal task on bootstrap. Which means we have to extract some data from the stage0 file using shell scripts. However, parsing values from the stage0.json file is painful because shell scripts don't have a built-in way to parse json files.

This change simplifies the stage0 file format to key-value pairs, which makes it easily readable from any environment.

See the zulip thread for more details: https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/Using.20different.20format.20in.20the.20stage0.20file
2024-05-12 06:26:20 +00:00
Scott McMurray 99213ae164 Make index_by_increasing_offset return one item for primitives 2024-05-11 21:22:51 -07:00
Scott McMurray dcab06d7d2 Unify Rvalue::Aggregate paths in cg_ssa 2024-05-11 21:22:51 -07:00
bors 8cc6f34653 Auto merge of #119427 - dtolnay:maccall, r=compiler-errors
Fix, document, and test parser and pretty-printer edge cases related to braced macro calls

_Review note: this is a deceptively small PR because it comes with 145 lines of docs and 196 lines of tests, and only 25 lines of compiler code changed. However, I recommend reviewing it 1 commit at a time because much of the effect of the code changes is non-local i.e. affecting code that is not visible in the final state of the PR. I have paid attention that reviewing the PR one commit at a time is as easy as I can make it. All of the code you need to know about is touched in those commits, even if some of those changes disappear by the end of the stack._

This is a follow-up to https://github.com/rust-lang/rust/pull/119105. One case that is not relevant to `-Zunpretty=expanded`, but which came up as I'm porting #119105 and #118726 into `syn`'s printer and `prettyplease`'s printer where it **is** relevant, and is also relevant to rustc's `stringify!`, is statement boundaries in the vicinity of braced macro calls.

Rustc's AST pretty-printer produces invalid syntax for statements that begin with a braced macro call:

```rust
macro_rules! stringify_item {
    ($i:item) => {
        stringify!($i)
    };
}

macro_rules! repro {
    ($e:expr) => {
        stringify_item!(fn main() { $e + 1; })
    };
}

fn main() {
    println!("{}", repro!(m! {}));
}
```

**Before this PR:** output is not valid Rust syntax.

```console
fn main() { m! {} + 1; }
```

```console
error: leading `+` is not supported
 --> <anon>:1:19
  |
1 | fn main() { m! {} + 1; }
  |                   ^ unexpected `+`
  |
help: try removing the `+`
  |
1 - fn main() { m! {} + 1; }
1 + fn main() { m! {}  1; }
  |
```

**After this PR:** valid syntax.

```console
fn main() { (m! {}) + 1; }
```
2024-05-12 04:18:20 +00:00
lcnr c66328f9ad structurally important functions to debug 2024-05-12 03:46:24 +00:00
lcnr 41ebd16266 solve: replace all debug with trace 2024-05-12 03:29:50 +00:00
ivan-shrimp 7fde7308bf reverse condition in uN::checked_sub 2024-05-12 11:29:24 +08:00
bors ee97564e3a Auto merge of #125001 - compiler-errors:uplift-trait-predicate, r=lcnr
Uplift various `*Predicate` types into `rustc_type_ir`

Uplifts `ProjectionPredicate`, `ExistentialTraitRef`, `ExistentialProjection`, `TraitPredicate`, `NormalizesTo`, `CoercePredicate`, and `SubtypePredicate`.

Adds `rustc_type_ir_macros`, which semi-duplicates the derive for `TypeVisitable`, `TypeFoldable`, and `Lift`, but in a way that is interner-agnostic.

Moves `rustc_type_ir::trait_ref` to `rustc_type_ir::predicate`. The specific placement of all these structs doesn't matter b/c of glob imports, tho.
2024-05-12 02:12:17 +00:00
David Tolnay 78c8dc1234
Fix redundant parens around braced macro call in match arms 2024-05-11 18:18:20 -07:00
David Tolnay 10227eaee7
Add classify::expr_is_complete 2024-05-11 18:18:20 -07:00
Michael Goulet 848f3c2c6e Make crashes dump mir to build dir 2024-05-11 20:39:25 -04:00
bors 8b64adc8cd Auto merge of #124153 - scottmcm:more-placevalue, r=saethlin
Refactoring after the `PlaceValue` addition

I added [`PlaceValue`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/mir/place/struct.PlaceValue.html) in #123775, but kept that one line-by-line simple because it touched so many places.

This goes through to add more helpers & docs, and change some `PlaceRef` to `PlaceValue` where the type didn't need to be included.

No behaviour changes -- the codegen is exactly the same.
2024-05-12 00:05:00 +00:00
Ben Kimock f11bd7e955 Fix some minor issues from the ui-test auto-porting 2024-05-11 19:58:35 -04:00
Michael Goulet d13e5c483d And ImplPolarity too 2024-05-11 19:29:26 -04:00
Federico Maria Morrone 923cdb35aa
test: Add assembly tests for x86_64-unknown-linux-none target 2024-05-12 01:25:11 +02:00
David Tolnay 53521faf06
Remove MacCall special cases from Parser::parse_full_stmt
It is impossible for expr here to be a braced macro call. Expr comes
from `parse_stmt_without_recovery`, in which macro calls are parsed by
`parse_stmt_mac`. See this part:

    let kind = if (style == MacStmtStyle::Braces
        && self.token != token::Dot
        && self.token != token::Question)
        || self.token == token::Semi
        || self.token == token::Eof
    {
        StmtKind::MacCall(P(MacCallStmt { mac, style, attrs, tokens: None }))
    } else {
        // Since none of the above applied, this is an expression statement macro.
        let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac));
        let e = self.maybe_recover_from_bad_qpath(e)?;
        let e = self.parse_expr_dot_or_call_with(e, lo, attrs)?;
        let e = self.parse_expr_assoc_with(
            0,
            LhsExpr::AlreadyParsed { expr: e, starts_statement: false },
        )?;
        StmtKind::Expr(e)
    };

A braced macro call at the head of a statement is always either extended
into ExprKind::Field / MethodCall / Await / Try / Binary, or else
returned as StmtKind::MacCall. We can never get a StmtKind::Expr
containing ExprKind::MacCall containing brace delimiter.
2024-05-11 15:49:51 -07:00
David Tolnay aedc1b6ad4
Remove MacCall special case from recovery after missing 'if' after 'else'
The change to the test is a little goofy because the compiler was
guessing "correctly" before that `falsy! {}` is the condition as opposed
to the else body. But I believe this change is fundamentally correct.
Braced macro invocations in statement position are most often item-like
(`thread_local! {...}`) as opposed to parenthesized macro invocations
which are condition-like (`cfg!(...)`).
2024-05-11 15:49:51 -07:00
David Tolnay 0f6a51d495
Add macro calls to else-no-if parser test 2024-05-11 15:49:51 -07:00
David Tolnay 728e117166
Document MacCall special case in Parser::parse_arm 2024-05-11 15:49:51 -07:00