Commit Graph

36007 Commits

Author SHA1 Message Date
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
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
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
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
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
Michael Goulet
c697ec41f4 Propagate errors rather than using return_if_err 2024-05-12 12:50:18 -04: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
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
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
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
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
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
Michael Goulet
d13e5c483d And ImplPolarity too 2024-05-11 19:29:26 -04: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
728e117166
Document MacCall special case in Parser::parse_arm 2024-05-11 15:49:51 -07:00
David Tolnay
9dbe33d256
Document MacCall special case in Parser::expr_is_complete 2024-05-11 15:49:51 -07:00
David Tolnay
8adcaf5df2
Mark Parser::expr_is_complete call sites 2024-05-11 15:49:51 -07:00
David Tolnay
c6c18a0151
Document the situation with unused_parens lint and braced macro calls 2024-05-11 15:49:03 -07:00
David Tolnay
d9bb73331e
Delete MacCall case from pretty-printing semicolon after StmtKind::Expr
I didn't figure out how to reach this condition with `expr` containing
`ExprKind::MacCall`. All the approaches I tried ended up with the macro
call ending up in the `StmtKind::MacCall` case below instead.

In any case, from visual inspection this is a bugfix. If we do end up
with a `StmtKind::Expr` containing `ExprKind::MacCall` with brace
delimiter, it would not need ";" printed after it.
2024-05-11 15:49:02 -07:00
David Tolnay
7f2ffbdbc6
Fix pretty printer statement boundaries after braced macro call 2024-05-11 15:49:01 -07:00
David Tolnay
9e1cf2098d
Macro call with braces does not require semicolon to be statement
This commit by itself is supposed to have no effect on behavior. All of
the call sites are updated to preserve their previous behavior.

The behavior changes are in the commits that follow.
2024-05-11 15:48:59 -07:00
David Tolnay
cbb8714a3f
Mark expr_requires_semi_to_be_stmt call sites
For each of these, we need to decide whether they need to be using
`expr_requires_semi_to_be_stmt`, or `expr_requires_comma_to_be_match_arm`,
which are supposed to be 2 different behaviors. Previously they were
conflated into one, causing either too much or too little
parenthesization.
2024-05-11 15:48:58 -07:00
David Tolnay
b431eec6f2
Expand on expr_requires_semi_to_be_stmt documentation 2024-05-11 15:48:57 -07:00
Michael Goulet
905f565824 Apply nits, uplift ExistentialPredicate too 2024-05-11 18:20:00 -04:00
Michael Goulet
0a8f33830c Uplift NormalizesTo, CoercePredicate, and SubtypePredicate 2024-05-11 18:20:00 -04:00
Michael Goulet
0d4dca2b82 Uplift ExistentialTraitRef, ExistentialProjection, ProjectionPredicate 2024-05-11 18:20:00 -04:00
Michael Goulet
204cde4564 Uplift TraitPredicate 2024-05-11 18:20:00 -04:00
Michael Goulet
d5797e938a Make it possible to derive Lift/TypeVisitable/TypeFoldable in rustc_type_ir 2024-05-11 18:20:00 -04:00
bors
78a7751270 Auto merge of #124988 - compiler-errors:name-span, r=lcnr
Consolidate obligation cause codes for where clauses

Removes some unncessary redundancy between `SpannedWhereClause`/`WhereClause`

r? lcnr
2024-05-11 19:48:04 +00:00
Federico Maria Morrone
a3ef01b1fc
Add x86_64-unknown-linux-none target 2024-05-11 21:37:23 +02:00
bors
686bfc4c42 Auto merge of #125010 - matthiaskrgr:rollup-270pck3, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #124928 (Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str`)
 - #124954 (Document proper usage of `fmt::Error` and `fmt()`'s `Result`.)
 - #124969 (check if `x test tests` missing any test directory)
 - #124978 (Handle Deref expressions in invalid_reference_casting)
 - #125005 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-11 12:46:54 +00:00
Matthias Krüger
8eac6d2333
Rollup merge of #124978 - saethlin:ref-casting_derefs, r=Urgau,Nilstrieb
Handle Deref expressions in invalid_reference_casting

Similar to https://github.com/rust-lang/rust/pull/124908

See https://github.com/rust-lang/rust/issues/124951 for context; this PR fixes the last of the known false postiive cases with this lint that we encounter in Crater.
2024-05-11 13:16:41 +02:00
bors
35c5e67c69 Auto merge of #124567 - Jules-Bertholet:and-eats-andmut, r=Nadrieril
Match ergonomics 2024: let `&` patterns eat `&mut`

r? `@Nadrieril`

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

`@rustbot` label A-edition-2024 A-patterns
2024-05-11 10:39:11 +00:00
bors
2259028a70 Auto merge of #124762 - madsmtm:refactor-apple-target-abi, r=lcnr,BlackHoleFox
Refactor Apple `target_abi`

This was bundled together with `Arch`, which complicated a few code paths and meant we had to do more string matching than necessary.

CC `@BlackHoleFox` as you've worked on the Apple target spec before

Related: Is there a reason why `Target`/`TargetOptions` use `StaticCow` for so many things, instead of an enum with defined values (and perhaps a catch-all case for custom target json files)? Tagging `@Nilstrieb,` as you might know?
2024-05-11 08:32:35 +00:00
Michael Goulet
e444017b49 Consolidate obligation cause codes for where clauses 2024-05-11 02:10:45 -04:00
Matthias Krüger
3c40e383df
Rollup merge of #124818 - compiler-errors:ena, r=Mark-Simulacrum
Update ena to 0.14.3

Includes https://github.com/rust-lang/ena/pull/53, which removes a trivial `Self: Sized` bound that prevents `ena` from building on the new solver.
2024-05-11 08:00:15 +02:00
Scott McMurray
9be16ebe89 Refactoring after the PlaceValue addition
I added `PlaceValue` 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.
2024-05-10 20:09:37 -07:00
Gurinder Singh
fb619ec208 FIx ICE while casting a type with error 2024-05-11 08:24:26 +05:30
bors
f9a3fd9661 Auto merge of #124993 - jieyouxu:rollup-u02aso7, r=jieyouxu
Rollup of 5 pull requests

Successful merges:

 - #124233 (Add `-lmingwex` second time in `mingw_libs`)
 - #124318 (ignore generics args in attribute paths)
 - #124899 (bootstrap: add comments for the automatic dry run)
 - #124904 (reachable computation: extend explanation of what this does, and why)
 - #124930 (Make sure we consume a generic arg when checking mistyped turbofish)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-11 00:31:30 +00:00
许杰友 Jieyou Xu (Joe)
e7bb090d0a
Rollup merge of #124930 - compiler-errors:consume-arg, r=petrochenkov
Make sure we consume a generic arg when checking mistyped turbofish

When recovering un-turbofish-ed args in expr position (e.g. `let x = a<T, U>();` in `check_mistyped_turbofish_with_multiple_type_params`, we used `parse_seq_to_before_end` to parse the fake generic args; however, it used `parse_generic_arg` which *optionally* parses a generic arg. If it doesn't end up parsing an arg, it returns `Ok(None)` and consumes no tokens. If we don't find a delimiter after this (`,`), we try parsing *another* element. In this case, we just infinitely loop looking for a subsequent element.

We can fix this by making sure that we either parse a generic arg or error in `parse_seq_to_before_end`'s callback.

Fixes #124897
2024-05-11 01:15:10 +01:00
许杰友 Jieyou Xu (Joe)
d8bf3fd584
Rollup merge of #124904 - RalfJung:reachable, r=tmiasko
reachable computation: extend explanation of what this does, and why

Follow-up to https://github.com/rust-lang/rust/pull/122769. I had the time to think about this some more, in particular in the context of https://github.com/rust-lang/rust/issues/119214, so I felt it was worth extending these comments some more.

I also gave up on the context of "externally reachable" as it is not called that way anywhere else in the compiler.

Cc `@tmiasko` `@saethlin`
2024-05-11 01:15:10 +01:00
许杰友 Jieyou Xu (Joe)
69122f1da4
Rollup merge of #124318 - bvanjoi:fix-123911, r=petrochenkov
ignore generics args in attribute paths

Fixes #97006
Fixes #123911
Fixes #123912

This patch ensures that we no longer have to handle invalid generic arguments in attribute paths.

r? `@petrochenkov`
2024-05-11 01:15:08 +01:00
许杰友 Jieyou Xu (Joe)
150633eea2
Rollup merge of #124233 - mati865:fix-support-for-upcoming-mingw-w64, r=petrochenkov
Add `-lmingwex` second time in `mingw_libs`

Upcoming mingw-w64 releases will contain small math functions refactor which moved implementation around. As a result functions like `lgamma`
now depend on libraries in this order:
`libmingwex.a` -> `libmsvcrt.a` -> `libmingwex.a`.

Fixes #124221
2024-05-11 01:15:08 +01:00
León Orell Valerian Liehr
35a5be2833
Also expand weak alias tys inside consts inside expand_weak_alias_tys 2024-05-11 00:39:42 +02:00
bors
19dacee0d8 Auto merge of #124982 - compiler-errors:uplift-trait-ref, r=lcnr
Uplift `TraitRef` into `rustc_type_ir`

Emotional rollercoaster

r? lcnr
2024-05-10 22:24:53 +00:00
bors
6e1d94708a Auto merge of #123886 - scottmcm:more-rvalue-operands, r=matthewjasper
Avoid `alloca`s in codegen for simple `mir::Aggregate` statements

The core idea here is to remove the abstraction penalty of simple newtypes in codegen.

Even something simple like constructing a
```rust
#[repr(transparent)] struct Foo(u32);
```
forces an `alloca` to be generated in nightly right now.

Certainly LLVM can optimize that away, but it would be nice if it didn't have to.

Quick example:
```rust
#[repr(transparent)]
pub struct Transparent32(u32);

#[no_mangle]
pub fn make_transparent(x: u32) -> Transparent32 {
    let a = Transparent32(x);
    a
}
```
on nightly we produce <https://rust.godbolt.org/z/zcvoM79ae>
```llvm
define noundef i32 `@make_transparent(i32` noundef %x) unnamed_addr #0 {
  %a = alloca i32, align 4
  store i32 %x, ptr %a, align 4
  %0 = load i32, ptr %a, align 4, !noundef !3
  ret i32 %0
}
```
but after this PR we produce
```llvm
define noundef i32 `@make_transparent(i32` noundef %x) unnamed_addr #0 {
start:
  ret i32 %x
}
```
(even before the optimizer runs).
2024-05-10 20:17:22 +00:00
Michael Goulet
b55d8a3b49 Apply nits, make some bounds into supertraits on inherent traits 2024-05-10 15:44:03 -04:00
Michael Goulet
f368527802 Also debug 2024-05-10 15:44:03 -04:00
Michael Goulet
1e5ec0a12c Lift TraitRef into rustc_type_ir 2024-05-10 15:44:03 -04:00
Michael Goulet
5e606c0bde Lift Lift 2024-05-10 15:44:03 -04:00
Jubilee Young
fa5964fa91 s/MetaVarExpr::Length/MetaVarExpr::Len/ 2024-05-10 12:29:01 -07:00
bors
2cce088584 Auto merge of #124952 - compiler-errors:no-error, r=lcnr
Rename some `FulfillmentErrorCode`/`ObligationCauseCode` variants to be less redundant

1. Rename some `FulfillmentErrorCode` variants.
2. Always use `ObligationCauseCode::` to prefix a code, rather than using a glob import and naming them through `traits::`.
3. Rename some `ObligationCauseCode` variants -- I wasn't particularly thorough with thinking of a new names for these, so could workshop them if necessary.
4. Misc stuff from renaming.

r? lcnr
2024-05-10 18:11:02 +00:00
Jules Bertholet
6d5c6f541f
Add comment on cap_to_weakly_not
Co-authored-by: Guillaume Boisseau <Nadrieril@users.noreply.github.com>
2024-05-10 13:53:48 -04:00
Jules Bertholet
7951311c1b
Move all ref pat logic into check_pat_ref 2024-05-10 13:50:19 -04:00
Jules Bertholet
bff287b4a5
Remove redundant comment 2024-05-10 13:47:39 -04:00
Jules Bertholet
d8a798b5e9
No more Option<Option<>> 2024-05-10 13:47:38 -04:00
Jules Bertholet
0f03c2be58
Rename explicit_ba 2024-05-10 13:47:38 -04:00
Jules Bertholet
f57b970de8
Comments and fixes 2024-05-10 13:47:37 -04:00
Jules Bertholet
91bbbaa0f7
Fix spans when macros are involved 2024-05-10 13:47:36 -04:00
Jules Bertholet
ed96c655c6
Various fixes:
- Only show error when move-check would not be triggered
- Add structured suggestion
2024-05-10 13:47:36 -04:00
Jules Bertholet
4f76f1069a
Match ergonomics 2024: let & patterns eat &mut 2024-05-10 13:47:34 -04:00
Ben Kimock
2bb25d3f4a Handle Deref expressions in invalid_reference_casting 2024-05-10 12:33:07 -04:00
bohan
f70f900036 ignore generics args in attribute paths 2024-05-11 00:13:27 +08:00
bors
6a19a87097 Auto merge of #124972 - matthiaskrgr:rollup-3fablim, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #124615 (coverage: Further simplify extraction of mapping info from MIR)
 - #124778 (Fix parse error message for meta items)
 - #124797 (Refactor float `Primitive`s to a separate `Float` type)
 - #124888 (Migrate `run-make/rustdoc-output-path` to rmake)
 - #124957 (Make `Ty::builtin_deref` just return a `Ty`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-10 16:04:26 +00:00
Michael Goulet
6f77bfe8b6 Name tweaks 2024-05-10 10:42:57 -04:00