summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2024-10-11Auto merge of #131045 - compiler-errors:remove-unnamed_fields, r=wesleywiserbors-15/+5
Retire the `unnamed_fields` feature for now `#![feature(unnamed_fields)]` was implemented in part in #115131 and #115367, however work on that feature has (afaict) stalled and in the mean time there have been some concerns raised (e.g.[^1][^2]) about whether `unnamed_fields` is worthwhile to have in the language, especially in its current desugaring. Because it represents a compiler implementation burden including a new kind of anonymous ADT and additional complication to field selection, and is quite prone to bugs today, I'm choosing to remove the feature. However, since I'm not one to really write a bunch of words, I'm specifically *not* going to de-RFC this feature. This PR essentially *rolls back* the state of this feature to "RFC accepted but not yet implemented"; however if anyone wants to formally unapprove the RFC from the t-lang side, then please be my guest. I'm just not totally willing to summarize the various language-facing reasons for why this feature is or is not worthwhile, since I'm coming from the compiler side mostly. Fixes #117942 Fixes #121161 Fixes #121263 Fixes #121299 Fixes #121722 Fixes #121799 Fixes #126969 Fixes #131041 Tracking: * https://github.com/rust-lang/rust/issues/49804 [^1]: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Unnamed.20struct.2Funion.20fields [^2]: https://github.com/rust-lang/rust/issues/49804#issuecomment-1972619108
2024-10-08coverage. Adapt to mcdc mapping formats introduced by llvm 19zhuyunxing-40/+54
2024-10-08coverage. MCDC ConditionId start from 0 to keep with llvm 19zhuyunxing-12/+17
2024-10-06various fixes for `naked_asm!` implementationFolkert de Vries-7/+17
- fix for divergence - fix error message - fix another cranelift test - fix some cranelift things - don't set the NORETURN option for naked asm - fix use of naked_asm! in doc comment - fix use of naked_asm! in run-make test - use `span_bug` in unreachable branch
2024-10-01Remove unnamed field featureMichael Goulet-15/+5
2024-09-28tweak Const::identity_unevaluated name and docsRalf Jung-10/+6
2024-09-28try to get rid of mir::Const::normalizeRalf Jung-4/+2
2024-09-24be even more precise about "cast" vs "coercion"Lukas Markeffsky-11/+38
2024-09-24use more accurate spans for user type ascriptionsLukas Markeffsky-10/+23
2024-09-24unify dyn* coercions with other pointer coercionsLukas Markeffsky-1/+0
2024-09-23Rollup merge of #130715 - compiler-errors:mir-build-const-eval, r=BoxyUwUMatthias Krüger-3/+10
Replace calls to `ty::Const::{try_}eval` in mir build/pattern analysis We normalize consts in writeback: #130645. This means that consts are gonna be as normalized as they're ever gonna get in MIR building and pattern analysis. Therefore we can just use `try_to_target_usize` rather than calling `eval_target_usize`. Regarding the `.expect` calls, I'm not totally certain whether they're correct given rigid unevaluated consts. But this PR shouldn't make *more* ICEs occur; we may have to squash these ICEs when mGCE comes around, tho 😺
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-366/+273
2024-09-22Replace calls to Const::eval in mir buildMichael Goulet-3/+10
2024-09-20Rollup merge of #130526 - eholk:pin-reborrow, r=compiler-errorsGuillaume Gomez-1/+63
Begin experimental support for pin reborrowing This commit adds basic support for reborrowing `Pin` types in argument position. At the moment it only supports reborrowing `Pin<&mut T>` as `Pin<&mut T>` by inserting a call to `Pin::as_mut()`, and only in argument position (not as the receiver in a method call). This PR makes the following example compile: ```rust #![feature(pin_ergonomics)] fn foo(_: Pin<&mut Foo>) { } fn bar(mut x: Pin<&mut Foo>) { foo(x); foo(x); } ``` Previously, you would have had to write `bar` as: ```rust fn bar(mut x: Pin<&mut Foo>) { foo(x.as_mut()); foo(x); } ``` Tracking: - #130494 r? `@compiler-errors`
2024-09-19pin_ergonomics: allow reborrowing as Pin<&T>Eric Holk-6/+9
2024-09-19Allow shortening reborrowsEric Holk-43/+57
Generating a call to `as_mut()` let to more restrictive borrows than what reborrowing usually gives us. Instead, we change the desugaring to reborrow the pin internals directly which makes things more expressive.
2024-09-18Rollup merge of #130533 - compiler-errors:never-pat-unsafeck, r=NadrierilJubilee-4/+5
Never patterns constitute a read for unsafety This code is otherwise unsound if we don't emit an unsafety error here. Noticed when fixing #130528, but it's totally unrelated. r? `@Nadrieril`
2024-09-18Never patterns constitute a read for unsafetyMichael Goulet-4/+5
2024-09-18Check params for unsafety in THIRMichael Goulet-0/+14
2024-09-18Begin experimental support for pin reborrowingEric Holk-0/+45
This commit adds basic support for reborrowing `Pin` types in argument position. At the moment it only supports reborrowing `Pin<&mut T>` as `Pin<&mut T>` by inserting a call to `Pin::as_mut()`, and only in argument position (not as the receiver in a method call).
2024-09-14Rollup merge of #130294 - nnethercote:more-lifetimes, r=lcnrLeón Orell Valerian Liehr-7/+6
Lifetime cleanups The last commit is very opinionated, let's see how we go. r? `@oli-obk`
2024-09-13Add a machine-applicable suggestion to "unreachable pattern"Nadrieril-5/+32
2024-09-13Rename and reorder lots of lifetimes.Nicholas Nethercote-7/+6
- Replace non-standard names like 's, 'p, 'rg, 'ck, 'parent, 'this, and 'me with vanilla 'a. These are cases where the original name isn't really any more informative than 'a. - Replace names like 'cx, 'mir, and 'body with vanilla 'a when the lifetime applies to multiple fields and so the original lifetime name isn't really accurate. - Put 'tcx last in lifetime lists, and 'a before 'b.
2024-09-13Auto merge of #107251 - dingxiangfei2009:let-chain-rescope, r=jieyouxubors-1/+17
Rescope temp lifetime in if-let into IfElse with migration lint Tracking issue #124085 This PR shortens the temporary lifetime to cover only the pattern matching and consequent branch of a `if let`. At the expression location, means that the lifetime is shortened from previously the deepest enclosing block or statement in Edition 2021. This warrants an Edition change. Coming with the Edition change, this patch also implements an edition lint to warn about the change and a safe rewrite suggestion to preserve the 2021 semantics in most cases. Related to #103108. Related crater runs: https://github.com/rust-lang/rust/pull/129466.
2024-09-12Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoeristerStuart Cook-3/+2
Simplify some nested `if` statements Applies some but not all instances of `clippy::collapsible_if`. Some ended up looking worse afterwards, though, so I left those out. Also applies instances of `clippy::collapsible_else_if` Review with whitespace disabled please.
2024-09-11Simplify some nested if statementsMichael Goulet-3/+2
2024-09-11rescope temp lifetime in let-chain into IfElseDing Xiang Fei-1/+17
apply rules by span edition
2024-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-7/+5
2024-09-01Revert "Auto merge of #127537 - veluca93:struct_tf, r=BoxyUwU"Jakub Beránek-75/+6
This reverts commit acb4e8b6251f1d8da36f08e7a70fa23fc581839e, reversing changes made to 100fde5246bf56f22fb5cc85374dd841296fce0e.
2024-08-29Add `warn(unreachable_pub)` to `rustc_mir_build`.Nicholas Nethercote-1/+2
2024-08-28Implement RFC 3525.Luca Versari-6/+75
2024-08-25Avoid taking reference of &TyKindMichael Goulet-2/+2
2024-08-24Fix `elided_named_lifetimes` in codePavel Grigorenko-1/+1
2024-08-21Rollup merge of #129345 - compiler-errors:scratch4, r=jieyouxuMatthias Krüger-7/+2
Use shorthand field initialization syntax more aggressively in the compiler Caught these when cleaning up #129344 and decided to run clippy to find the rest
2024-08-21Rollup merge of #129344 - compiler-errors:less-option-unit-diagnostics, ↵Matthias Krüger-10/+10
r=jieyouxu Use `bool` in favor of `Option<()>` for diagnostics We originally only supported `Option<()>` for optional notes/labels, but we now support `bool`. Let's use that, since it usually leads to more readable code. I'm not removing the support from the derive macro, though I guess we could error on it... 🤔
2024-08-21Rollup merge of #129281 - Nadrieril:tweak-unreachable-lint-wording, r=estebankMatthias Krüger-12/+28
Tweak unreachable lint wording Some tweaks to the notes added in https://github.com/rust-lang/rust/pull/128034. r? `@estebank`
2024-08-21Simplify some redundant field namesMichael Goulet-7/+2
2024-08-21Use bool in favor of Option<()> for diagnosticsMichael Goulet-10/+10
2024-08-20Move the "matches no value" note to be a span labelNadrieril-9/+6
2024-08-20fix: simple typo in compiler directoryc8ef-1/+1
2024-08-19Cap the number of patterns pointed to by the lintNadrieril-3/+18
2024-08-19Add a note with a link to explain empty typesNadrieril-0/+4
2024-08-18rename AddressOf -> RawBorrow inside the compilerRalf Jung-14/+14
2024-08-17Remove a useless ref/id/ref round-trip from `pattern_from_hir`Zalathar-6/+2
This re-lookup of `&hir::Pat` by its ID appears to be an artifact of earlier complexity that has since been removed from the compiler.
2024-08-14Auto merge of #129060 - matthiaskrgr:rollup-s72gpif, r=matthiaskrgrbors-6/+29
Rollup of 7 pull requests Successful merges: - #122884 (Optimize integer `pow` by removing the exit branch) - #127857 (Allow to customize `// TODO:` comment for deprecated safe autofix) - #129034 (Add `#[must_use]` attribute to `Coroutine` trait) - #129049 (compiletest: Don't panic on unknown JSON-like output lines) - #129050 (Emit a warning instead of an error if `--generate-link-to-definition` is used with other output formats than HTML) - #129056 (Fix one usage of target triple in bootstrap) - #129058 (Add mw back to review rotation) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-13Remove a no-longer-true `assert`Nadrieril-4/+6
2024-08-13`#[deprecated_safe_2024]`: Also use the `// TODO:` hint in the compiler errorTobias Bucher-4/+11
This doesn't work for translated compiler error messages.
2024-08-13Allow to customize `// TODO:` comment for deprecated safe autofixTobias Bucher-6/+22
Relevant for the deprecation of `CommandExt::before_exit` in #125970.
2024-08-13Auto merge of #128742 - RalfJung:miri-vtable-uniqueness, r=saethlinbors-2/+4
miri: make vtable addresses not globally unique Miri currently gives vtables a unique global address. That's not actually matching reality though. So this PR enables Miri to generate different addresses for the same type-trait pair. To avoid generating an unbounded number of `AllocId` (and consuming unbounded amounts of memory), we use the "salt" technique that we also already use for giving constants non-unique addresses: the cache is keyed on a "salt" value n top of the actually relevant key, and Miri picks a random salt (currently in the range `0..16`) each time it needs to choose an `AllocId` for one of these globals -- that means we'll get up to 16 different addresses for each vtable. The salt scheme is integrated into the global allocation deduplication logic in `tcx`, and also used for functions and string literals. (So this also fixes the problem that casting the same function to a fn ptr over and over will consume unbounded memory.) r? `@saethlin` Fixes https://github.com/rust-lang/miri/issues/3737
2024-08-11Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errorsMatthias Krüger-2/+4
Use more slice patterns inside the compiler Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'. r? ghost