summary refs log tree commit diff
path: root/compiler/rustc_middle/src/middle
AgeCommit message (Collapse)AuthorLines
2024-10-04Simplify bound var resolution.Camille GILLOT-5/+5
2024-09-29cleanup: don't clone types that are CopyMatthias Krüger-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-7/+7
2024-09-21remove `#[cmse_nonsecure_entry]`Folkert-3/+1
2024-09-13Auto merge of #107251 - dingxiangfei2009:let-chain-rescope, r=jieyouxubors-0/+6
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-11Simplify some nested if statementsMichael Goulet-4/+5
2024-09-11rescope temp lifetime in let-chain into IfElseDing Xiang Fei-0/+6
apply rules by span edition
2024-09-01Revert "Auto merge of #127537 - veluca93:struct_tf, r=BoxyUwU"Jakub Beránek-4/+4
This reverts commit acb4e8b6251f1d8da36f08e7a70fa23fc581839e, reversing changes made to 100fde5246bf56f22fb5cc85374dd841296fce0e.
2024-08-28Implement RFC 3525.Luca Versari-4/+4
2024-08-22Use a LocalDefId in ResolvedArg.Camille GILLOT-4/+4
2024-08-07Hide implicit target features from diagnostics when possibleCaleb Zulawski-1/+10
2024-07-29Reformat `use` declarations.Nicholas Nethercote-22/+29
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-19Avoid ref when using format! in compilerYuri Astrakhan-1/+1
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
2024-07-05Rollup merge of #124290 - klensy:dep-format, r=jieyouxuGuillaume Gomez-3/+3
DependencyList: removed outdated comment Comment was outdated. Didn't updated description, as `Linkage` enum have descriptive names. Also added fixme about moving this file to rustc_metadata.
2024-07-03Rollup merge of #127145 - compiler-errors:as_lang_item, r=lcnrMatthias Krüger-0/+4
Add `as_lang_item` to `LanguageItems`, new trait solver Add `as_lang_item` which turns `DefId` into a `TraitSolverLangItem` in the new trait solver, so we can turn the large chain of if statements in `assemble_builtin_impl_candidates` into a match instead. r? lcnr
2024-07-02add TyCtxt::as_lang_item, use in new solverMichael Goulet-0/+4
2024-07-02Re-implement a type-size based limitMichael Goulet-1/+1
2024-06-28Rollup merge of #124741 - nebulark:patchable-function-entries-pr, ↵Matthias Krüger-0/+27
r=estebank,workingjubilee patchable-function-entry: Add unstable compiler flag and attribute Tracking issue: #123115 Add the -Z patchable-function-entry compiler flag and the #[patchable_function_entry(prefix_nops = m, entry_nops = n)] attribute. Rebased and adjusted the canditate implementation to match changes in the RFC.
2024-06-26coverage: Detach `#[coverage(..)]` from codegen attribute handlingZalathar-4/+1
2024-06-25Support `#[patchable_function_entries]`Matthew Maurer-0/+4
See [RFC](https://github.com/maurer/rust-rfcs/blob/patchable-function-entry/text/0000-patchable-function-entry.md) (yet to be numbered) TODO before submission: * Needs an RFC * Improve error reporting for malformed attributes
2024-06-25Support for -Z patchable-function-entryMatthew Maurer-0/+23
`-Z patchable-function-entry` works like `-fpatchable-function-entry` on clang/gcc. The arguments are total nop count and function offset. See MCP rust-lang/compiler-team#704
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+1
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-1/+1
2024-06-16Rename InstanceDef -> InstanceKindMichael Goulet-1/+1
2024-06-14Add TyCtxt::is_lang_itemMichael Goulet-0/+4
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-11/+10
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666. See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_middle`.Nicholas Nethercote-0/+2
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-11/+10
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
2024-05-21Rename buffer_lint_with_diagnostic to buffer_lintXiretza-1/+1
2024-05-21Make early lints translatableXiretza-14/+7
2024-05-21Port DeprecatedMacro to diag structsXiretza-85/+103
2024-05-21Generate lint diagnostic message from BuiltinLintDiagXiretza-2/+2
Translation of the lint message happens when the actual diagnostic is created, not when the lint is buffered. Generating the message from BuiltinLintDiag ensures that all required data to construct the message is preserved in the LintBuffer, eventually allowing the messages to be moved to fluent. Remove the `msg` field from BufferedEarlyLint, it is either generated from the data in the BuiltinLintDiag or stored inside BuiltinLintDiag::Normal.
2024-05-01add fixmeklensy-0/+3
2024-05-01DependencyList: remove outdated commentklensy-3/+0
2024-04-29Remove `extern crate bitflags` from a couple of crates.Nicholas Nethercote-1/+1
2024-04-29Remove `extern crate rustc_data_structures` from numerous crates.Nicholas Nethercote-1/+1
2024-04-29Remove `extern crate rustc_macros` from `rustc_middle`.Nicholas Nethercote-3/+8
2024-04-23Rollup merge of #124067 - RalfJung:weak-lang-items, r=davidtwcoMatthias Krüger-1/+1
weak lang items are not allowed to be #[track_caller] For instance the panic handler will be called via this import ```rust extern "Rust" { #[lang = "panic_impl"] fn panic_impl(pi: &PanicInfo<'_>) -> !; } ``` A `#[track_caller]` would add an extra argument and thus make this the wrong signature. The 2nd commit is a consistency rename; based on the docs [here](https://doc.rust-lang.org/unstable-book/language-features/lang-items.html) and [here](https://rustc-dev-guide.rust-lang.org/lang-items.html) I figured "lang item" is more widely used. (In the compiler output, "lang item" and "language item" seem to be pretty even.)
2024-04-23Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obkbors-0/+4
Add simple async drop glue generation This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work). This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit). Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html). This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work. Feature completeness: - [x] `AsyncDrop` trait - [ ] `async_drop_in_place_raw`/async drop glue generation support for - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.) - [x] Arrays and slices (array pointer is unsized into slice pointer) - [x] ADTs (enums, structs, unions) - [x] tuple-like types (tuples, closures) - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait)) - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948) - [x] Async drop glue includes sync drop glue code - [x] Cleanup branch generation for `async_drop_in_place_raw` - [ ] Union rejects non-trivially async destructible fields - [ ] `AsyncDrop` implementation requires same bounds as type definition - [ ] Skip trivially destructible fields (optimization) - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop) - [ ] Automatic async drop at the end of the scope in async context
2024-04-17consistency rename: language item -> lang itemRalf Jung-1/+1
2024-04-16Add simple async drop glue generationzetanumbers-0/+4
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801
2024-04-16Avoid lots of `hir::HirId{,Map,Set}` qualifiers.Nicholas Nethercote-9/+5
Because they're a bit redundant.
2024-04-01Auto merge of #122972 - beetrees:use-align-type, r=fee1-deadbors-1/+2
Use the `Align` type when parsing alignment attributes Use the `Align` type in `rustc_attr::parse_alignment`, removing the need to call `Align::from_bytes(...).unwrap()` later in the compilation process.
2024-04-01Use the `Align` type when parsing alignment attributesbeetrees-1/+2
2024-03-31Auto merge of #121851 - michaelwoerister:mcp-533-effective-vis, r=cjgillotbors-5/+4
Use FxIndexMap instead FxHashMap to stabilize iteration order in EffectiveVisibilities Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).
2024-03-05Rename `BuiltinLintDiagnostics` as `BuiltinLintDiag`.Nicholas Nethercote-2/+2
Not the dropping of the trailing `s` -- this type describes a single diagnostic and its name should be singular.
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-1/+1
Existing names for values of this type are `sess`, `parse_sess`, `parse_session`, and `ps`. `sess` is particularly annoying because that's also used for `Session` values, which are often co-located, and it can be difficult to know which type a value named `sess` refers to. (That annoyance is the main motivation for this change.) `psess` is nice and short, which is good for a name used this much. The commit also renames some `parse_sess_created` values as `psess_created`.
2024-03-03Add new `pattern_complexity` attribute to add possibility to limit and check ↵Guillaume Gomez-2/+9
recursion in pattern matching
2024-03-01Use FxIndexMap instead FxHashMap to stabilize iteration order in ↵Michael Woerister-5/+4
EffectiveVisibilities. Part of https://github.com/rust-lang/compiler-team/issues/533
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-2/+2
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.