about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2024-11-29Rollup merge of #133501 - lcnr:post-borrowck-analysis, r=compiler-errorsMatthias Krüger-84/+7
support revealing defined opaque post borrowck By adding a new `TypingMode::PostBorrowckAnalysis`. Currently only supported with the new solver and I didn't look into the way we replace `ReErased`. ``@compiler-errors`` mentioned that always using existentials may be unsound. r? ``@compiler-errors``
2024-11-29Revert "Rollup merge of #133418 - Zalathar:spans, r=jieyouxu"Zalathar-3/+19
This reverts commit adf9b5fcd1de43eaf0a779e10612caee8b47bede, reversing changes made to af1ca153d4aed5ffe22445273aa388a8d3f8f4ae. Reverting due to <https://github.com/rust-lang/rust/issues/133606>.
2024-11-29implement checks for tail callsMaybe Waffle-0/+6
this implements checks necessary to guarantee that we can actually perform a tail call. while extremely restrictive, this is what is documented in the RFC, and all these checks are needed for one reason or another.
2024-11-28Auto merge of #123244 - Mark-Simulacrum:share-inline-never-generics, r=saethlinbors-9/+18
Enable -Zshare-generics for inline(never) functions This avoids inlining cross-crate generic items when possible that are already marked inline(never), implying that the author is not intending for the function to be inlined by callers. As such, having a local copy may make it easier for LLVM to optimize but mostly just adds to binary bloat and codegen time. In practice our benchmarks indicate this is indeed a win for larger compilations, where the extra cost in dynamic linking to these symbols is diminished compared to the advantages in fewer copies that need optimizing in each binary. It might also make sense it expand this with other heuristics (e.g., `#[cold]`) in the future, but this seems like a good starting point. FWIW, I expect that doing cleanup in where we make the decision what should/shouldn't be shared is also a good idea. Way too much code needed to be tweaked to check this. But I'm hoping to leave that for a follow-up PR rather than blocking this on it.
2024-11-28Share inline(never) generics across cratesMark Rousskov-9/+18
This reduces code sizes and better respects programmer intent when marking inline(never). Previously such a marking was essentially ignored for generic functions, as we'd still inline them in remote crates.
2024-11-28uplift fold_regions to rustc_type_irlcnr-84/+7
2024-11-27Rollup merge of #133418 - Zalathar:spans, r=jieyouxuMatthias Krüger-19/+3
coverage: Store coverage source regions as `Span` until codegen Historically, coverage spans were converted into line/column coordinates during the MIR instrumentation pass. This PR moves that conversion step into codegen, so that coverage spans spend most of their time stored as `Span` instead. In addition to being conceptually nicer, this also reduces the size of coverage mappings in MIR, because `Span` is smaller than 4x u32. --- There should be no changes to coverage output.
2024-11-27Rollup merge of #132410 - bjorn3:yet_another_driver_refactor_round, r=cjgillotMatthias Krüger-4/+33
Some more refactorings towards removing driver queries Follow up to https://github.com/rust-lang/rust/pull/127184 ## Custom driver breaking change The `after_analysis` callback is changed to accept `TyCtxt` instead of `Queries`. The only safe query in `Queries` to call at this point is `global_ctxt()` which allows you to enter the `TyCtxt` either way. To fix your custom driver, replace the `queries: &'tcx Queries<'tcx>` argument with `tcx: TyCtxt<'tcx>` and remove your `queries.global_ctxt().unwrap().enter(|tcx| { ... })` call and only keep the contents of the closure. ## Custom driver deprecation The `after_crate_root_parsing` callback is now deprecated. Several custom drivers are incorrectly calling `queries.global_ctxt()` from inside of it, which causes some driver code to be skipped. As such I would like to either remove it in the future or if custom drivers still need it, change it to accept an `&rustc_ast::Crate` instead.
2024-11-26Rollup merge of #115293 - cjgillot:no-fuel, r=wesleywiser,DianQKMichael Goulet-8/+1
Remove -Zfuel. I'm not sure this feature is used. I only found 2 references in a google search, both referring to its introduction. Meanwhile, it's a global mutable state, untracked by incremental compilation, so incompatible with it.
2024-11-26Rollup merge of #133367 - compiler-errors:array-len-mismatch, r=BoxyUwUMichael Goulet-10/+3
Simplify array length mismatch error reporting (to not try to turn consts into target usizes) This changes `TypeError::FixedArrayLen` to use `ExpectedFound<ty::Const<'tcx>>` (instead of `ExpectedFound<u64>`), and renames it to `TypeError::ArrayLen`. This allows us to avoid a `try_to_target_usize` call in the type relation, which ICEs when we have a scalar of the wrong bit length (i.e. u8). This also makes `structurally_relate_tys` to always use this type error kind any time we have a const mismatch resulting from relating the array-len part of `[T; N]`. This has the effect of changing the error message we issue for array length mismatches involving non-valtree consts. I actually quite like the change, though, since before: ``` LL | fn test<const N: usize, const M: usize>() -> [u8; M] { | ------- expected `[u8; M]` because of return type LL | [0; N] | ^^^^^^ expected `M`, found `N` | = note: expected array `[u8; M]` found array `[u8; N]` ``` and after, which I think is far less verbose: ``` LL | fn test<const N: usize, const M: usize>() -> [u8; M] { | ------- expected `[u8; M]` because of return type LL | [0; N] | ^^^^^^ expected an array with a size of M, found one with a size of N ``` The only questions I have are: 1. Should we do something about backticks here? Right now we don't backtick either fully evaluated consts like `2`, or rigid consts like `Foo::BAR`.... but maybe we should? It seems kinda verbose to do for numbers -- maybe we could intercept those specifically. 2. I guess we may still run the risk of leaking unevaluated consts into error reporting like `2 + 1`...? r? ``@BoxyUwU`` Fixes #126359 Fixes #131101
2024-11-26Rollup merge of #133362 - compiler-errors:existential-preds, r=BoxyUwUMichael Goulet-4/+0
No need to re-sort existential preds in relate impl We already assert that these predicates are in the right ordering in `mk_poly_existential_predicates`. r? types
2024-11-26Remove -Zfuel.Camille GILLOT-8/+1
2024-11-25Refactor `where` predicates, and reserve for attributes supportFrank King-4/+4
2024-11-24coverage: Store coverage source regions as `Span` until codegenZalathar-19/+3
2024-11-24Rollup merge of #133371 - RalfJung:is_trivially_const_drop, r=compiler-errorsMatthias Krüger-39/+0
remove is_trivially_const_drop I'm not sure this still brings any perf benefits, so let's benchmark this. r? `@compiler-errors`
2024-11-24Simplify array length mismatch error reportingMichael Goulet-10/+3
2024-11-23Auto merge of #133242 - lcnr:questionable-uwu, r=compiler-errors,BoxyUwUbors-161/+62
finish `Reveal` removal After #133212 changed the `TypingMode` to be the only source of truth, this entirely rips out `Reveal`. cc #132279 r? `@compiler-errors`
2024-11-23rebaselcnr-1/+1
2024-11-23reviewlcnr-2/+3
2024-11-23global old solver cache: use `TypingEnv`lcnr-18/+8
2024-11-23remove remaining references to `Reveal`lcnr-12/+12
2024-11-23no more Reveal :(lcnr-130/+40
2024-11-23Rollup merge of #133366 - compiler-errors:expected-found, r=dtolnay许杰友 Jieyou Xu (Joe)-2/+2
Remove unnecessary bool from `ExpectedFound::new` It's true almost everywhere, and the one place it's not can be replaced w/ an if statement.
2024-11-23Auto merge of #132915 - veluca93:unsafe-fields, r=jswrennbors-5/+13
Implement the unsafe-fields RFC. RFC: rust-lang/rfcs#3458 Tracking: - https://github.com/rust-lang/rust/issues/132922 r? jswrenn
2024-11-23remove is_trivially_const_dropRalf Jung-39/+0
2024-11-23Remove unnecessary bool from ExpectedFoundMichael Goulet-2/+2
2024-11-23Auto merge of #133360 - compiler-errors:rollup-a2o38tq, r=compiler-errorsbors-118/+96
Rollup of 8 pull requests Successful merges: - #132090 (Stop being so bail-y in candidate assembly) - #132658 (Detect const in pattern with typo) - #132911 (Pretty print async fn sugar in opaques and trait bounds) - #133102 (aarch64 softfloat target: always pass floats in int registers) - #133159 (Don't allow `-Zunstable-options` to take a value ) - #133208 (generate-copyright: Now generates a library file too.) - #133215 (Fix missing submodule in `./x vendor`) - #133264 (implement OsString::truncate) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-23No need to re-sort existential predsMichael Goulet-4/+0
2024-11-22Check drop is trivial before checking ty needs dropMichael Goulet-1/+4
2024-11-22Pretty print AsyncFn traits tooMichael Goulet-11/+34
2024-11-22Implement ~const Destruct in new solverMichael Goulet-4/+13
2024-11-22Simplify logic a bitMichael Goulet-113/+68
2024-11-22Get rid of HIR const checkerMichael Goulet-5/+7
2024-11-21Implement the unsafe-fields RFC.Luca Versari-5/+13
Co-Authored-By: Jacob Pratt <jacob@jhpratt.dev>
2024-11-21Rollup merge of #133218 - compiler-errors:const-opaque, r=fee1-deadMatthias Krüger-4/+10
Implement `~const` item bounds in RPIT an RPIT in a `const fn` is allowed to be conditionally const itself :) r? fee1-dead or reroll
2024-11-20Auto merge of #133261 - matthiaskrgr:rollup-ekui4we, r=matthiaskrgrbors-21/+12
Rollup of 6 pull requests Successful merges: - #129838 (uefi: process: Add args support) - #130800 (Mark `get_mut` and `set_position` in `std::io::Cursor` as const.) - #132708 (Point at `const` definition when used instead of a binding in a `let` statement) - #133226 (Make `PointerLike` opt-in instead of built-in) - #133244 (Account for `wasm32v1-none` when exporting TLS symbols) - #133257 (Add `UnordMap::clear` method) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-20Rollup merge of #133226 - compiler-errors:opt-in-pointer-like, r=lcnrMatthias Krüger-14/+0
Make `PointerLike` opt-in instead of built-in The `PointerLike` trait currently is a built-in trait that computes the layout of the type. This is a bit problematic, because types implement this trait automatically. Since this can be broken due to semver-compatible changes to a type's layout, this is undesirable. Also, calling `layout_of` in the trait system also causes cycles. This PR makes the trait implemented via regular impls, and adds additional validation on top to make sure that those impls are valid. This could eventually be `derive()`d for custom smart pointers, and we can trust *that* as a semver promise rather than risking library authors accidentally breaking it. On the other hand, we may never expose `PointerLike`, but at least now the implementation doesn't invoke `layout_of` which could cause ICEs or cause cycles. Right now for a `PointerLike` impl to be valid, it must be an ADT that is `repr(transparent)` and the non-1zst field needs to implement `PointerLike`. There are also some primitive impls for `&T`/ `&mut T`/`*const T`/`*mut T`/`Box<T>`.
2024-11-20Rollup merge of #132708 - estebank:const-as-binding, r=NadrierilMatthias Krüger-7/+12
Point at `const` definition when used instead of a binding in a `let` statement Modify `PatKind::InlineConstant` to be `ExpandedConstant` standing in not only for inline `const` blocks but also for `const` items. This allows us to track named `const`s used in patterns when the pattern is a single binding. When we detect that there is a refutable pattern involving a `const` that could have been a binding instead, we point at the `const` item, and suggest renaming. We do this for both `let` bindings and `match` expressions missing a catch-all arm if there's at least one single binding pattern referenced. After: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | const PAT: u32 = 0; | -------------- missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable ... LL | let PAT = v1; | ^^^ pattern `1_u32..=u32::MAX` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` help: introduce a variable instead | LL | let PAT_var = v1; | ~~~~~~~ ``` Before: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | let PAT = v1; | ^^^ | | | pattern `1_u32..=u32::MAX` not covered | missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `PAT_var` | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` ``` CC #132582.
2024-11-20Auto merge of #131326 - dingxiangfei2009:issue-130836-attempt-2, r=nikomatsakisbors-9/+104
Reduce false positives of tail-expr-drop-order from consumed values (attempt #2) r? `@nikomatsakis` Tracked by #123739. Related to #129864 but not replacing, yet. Related to #130836. This is an implementation of the approach suggested in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/temporary.20drop.20order.20changes). A new MIR statement `BackwardsIncompatibleDrop` is added to the MIR syntax. The lint now works by inspecting possibly live move paths before at the `BackwardsIncompatibleDrop` location and the actual drop under the current edition, which should be one before Edition 2024 in practice.
2024-11-20Rip out built-in PointerLike implMichael Goulet-14/+0
2024-11-20reduce false positives of tail-expr-drop-order from consumed valuesDing Xiang Fei-9/+104
take 2 open up coroutines tweak the wordings the lint works up until 2021 We were missing one case, for ADTs, which was causing `Result` to yield incorrect results. only include field spans with significant types deduplicate and eliminate field spans switch to emit spans to impl Drops Co-authored-by: Niko Matsakis <nikomat@amazon.com> collect drops instead of taking liveness diff apply some suggestions and add explantory notes small fix on the cache let the query recurse through coroutine new suggestion format with extracted variable name fine-tune the drop span and messages bugfix on runtime borrows tweak message wording filter out ecosystem types earlier apply suggestions clippy check lint level at session level further restrict applicability of the lint translate bid into nop for stable mir detect cycle in type structure
2024-11-20Auto merge of #133234 - jhpratt:rollup-42dmg4p, r=jhprattbors-7/+6
Rollup of 5 pull requests Successful merges: - #132732 (Use attributes for `dangling_pointers_from_temporaries` lint) - #133108 (lints_that_dont_need_to_run: never skip future-compat-reported lints) - #133190 (CI: use free runner in dist-aarch64-msvc) - #133196 (Make rustc --explain compatible with BusyBox less) - #133216 (Implement `~const Fn` trait goal in the new solver) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-20Rollup merge of #133216 - compiler-errors:const-fn, r=lcnrJacob Pratt-1/+5
Implement `~const Fn` trait goal in the new solver Split out from https://github.com/rust-lang/rust/pull/132329 since this should be easier to review on its own. r? lcnr
2024-11-20Rollup merge of #133108 - RalfJung:future-compat-needs-to-run, r=lcnrJacob Pratt-6/+1
lints_that_dont_need_to_run: never skip future-compat-reported lints Follow-up to https://github.com/rust-lang/rust/pull/125116: future-compat lints show up with `--json=future-incompat` even if they are otherwise allowed in the crate. So let's ensure we do not skip those as part of the `lints_that_dont_need_to_run` logic. I could not find a current future compat lint that is emitted by a lint pass, so there's no clear way to add a test for this. Cc `@blyxyas` `@cjgillot`
2024-11-20Auto merge of #133212 - lcnr:questionable-uwu, r=compiler-errorsbors-67/+49
continue `ParamEnv` to `TypingEnv` transition cc #132279 r? `@compiler-errors`
2024-11-19Implement ~const Fn trait goals in the new solverMichael Goulet-1/+5
2024-11-19lints_that_dont_need_to_run: never skip future-compat-reported lintsRalf Jung-6/+1
2024-11-19additional `TypingEnv` cleanupslcnr-4/+1
2024-11-19`InterpCx` store `TypingEnv` instead of a `ParamEnv`lcnr-35/+22
2024-11-19Implement ~const opaquesMichael Goulet-1/+7