about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/middle
AgeCommit message (Collapse)AuthorLines
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-0/+4
async_drop_in_place::{closure}, scoped async drop added.
2025-04-22Use `is_lang_item` and `as_lang_item` instead of handrolling their logicOli Scherer-10/+8
2025-04-03Make LevelAndSource a structOli Scherer-1/+1
2025-04-02Move methods from `Map` to `TyCtxt`, part 5.Nicholas Nethercote-1/+1
This eliminates all methods on `Map`. Actually removing `Map` will occur in a follow-up PR.
2025-03-31Rollup merge of #138842 - Noratrieb:inline-exported, r=me,saethlinMatthias Krüger-0/+2
Emit `unused_attributes` for `#[inline]` on exported functions I saw someone post a code sample that contained these two attributes, which immediately made me suspicious. My suspicions were confirmed when I did a small test and checked the compiler source code to confirm that in these cases, `#[inline]` is indeed ignored (because you can't exactly `LocalCopy`an unmangled symbol since that would lead to duplicate symbols, and doing a mix of an unmangled `GloballyShared` and mangled `LocalCopy` instantiation is too complicated for our current instatiation mode logic, which I don't want to change right now). So instead, emit the usual unused attribute lint with a message saying that the attribute is ignored in this position. I think this is not 100% true, since I expect LLVM `inlinehint` to still be applied to such a function, but that's not why people use this attribute, they use it for the `LocalCopy` instantiation mode, where it doesn't work. r? saethlin as the instantiation guy Procedurally, I think this should be fine to merge without any lang involvement, as this only does a very minor extension to an existing lint.
2025-03-28Remove ScopeDepth entirely.Mara Bos-5/+3
The scope depth was tracked, but never actually used for anything.
2025-03-26Simplify RvalueCandidateType.Mara Bos-18/+13
There is no difference between the Patternand Borrow cases. Reduce it to a simple struct.
2025-03-24Emit `unused_attributes` for `#[inline]` on exported functionsNoratrieb-0/+2
I saw someone post a code sample that contained these two attributes, which immediately made me suspicious. My suspicions were confirmed when I did a small test and checked the compiler source code to confirm that in these cases, `#[inline]` is indeed ignored (because you can't exactly `LocalCopy`an unmangled symbol since that would lead to duplicate symbols, and doing a mix of an unmangled `GloballyShared` and mangled `LocalCopy` instantiation is too complicated for our current instatiation mode logic, which I don't want to change right now). So instead, emit the usual unused attribute lint with a message saying that the attribute is ignored in this position. I think this is not 100% true, since I expect LLVM `inlinehint` to still be applied to such a function, but that's not why people use this attribute, they use it for the `LocalCopy` instantiation mode, where it doesn't work.
2025-03-17Mark #[rustc_std_internal_symbol] as extern indicatorbjorn3-0/+1
It currently implies #[no_mangle] which is alread an extern indicator, but this will change in a future commit.
2025-03-07depend more on attr_data_structures and move find_attr! thereJana Dönszelmann-2/+2
2025-02-22Fix binding mode problemsMichael Goulet-1/+1
2025-02-21Move methods from Map to TyCtxt, part 3.Nicholas Nethercote-1/+1
Continuing the work from #137162. Every method gains a `hir_` prefix.
2025-02-17Move `rustc_middle::limits` to `rustc_interface`.Nicholas Nethercote-89/+0
It's always good to make `rustc_middle` smaller. `rustc_interface` is the best destination, because it's the only crate that calls `get_recursive_limit`.
2025-02-17Improve comments about limits.Nicholas Nethercote-7/+8
2025-02-17Merge `get_limit` and `get_limit_size`.Nicholas Nethercote-13/+2
Thanks to the previous commit, they no longer need to be separate.
2025-02-17Add `pattern_complexity_limit` to `Limits`.Nicholas Nethercote-5/+11
It's similar to the other limits, e.g. obtained via `get_limit`. So it makes sense to handle it consistently with the other limits. We now use `Limit`/`usize` in most places instead of `Option<usize>`, so we use `Limit::new(usize::MAX)`/`usize::MAX` to emulate how `None` used to work. The commit also adds `Limit::unlimited`.
2025-02-11Simplify intra-crate qualifiers.Nicholas Nethercote-1/+1
The following is a weird pattern for a file within `rustc_middle`: ``` use rustc_middle::aaa; use crate::bbb; ``` More sensible and standard would be this: ``` use crate::{aaa, bbb}; ``` I.e. we generally prefer using `crate::` to using a crate's own name. (Exceptions are things like in macros where `crate::` doesn't work because the macro is used in multiple crates.) This commit fixes a bunch of these weird qualifiers.
2025-02-07Remove Linkage::Privatebjorn3-1/+1
This is the same as Linkage::Internal except that it doesn't emit any symbol. Some backends may not support it and it isn't all that useful anyway.
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-4/+4
2025-01-31Auto merge of #136332 - jhpratt:rollup-aa69d0e, r=jhprattbors-0/+4
Rollup of 9 pull requests Successful merges: - #132156 (When encountering unexpected closure return type, point at return type/expression) - #133429 (Autodiff Upstreaming - rustc_codegen_ssa, rustc_middle) - #136281 (`rustc_hir_analysis` cleanups) - #136297 (Fix a typo in profile-guided-optimization.md) - #136300 (atomic: extend compare_and_swap migration docs) - #136310 (normalize `*.long-type.txt` paths for compare-mode tests) - #136312 (Disable `overflow_delimited_expr` in edition 2024) - #136313 (Filter out RPITITs when suggesting unconstrained assoc type on too many generics) - #136323 (Fix a typo in conventions.md) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-29upstream rustc_codegen_ssa/rustc_middle changes for enzyme/autodiffManuel Drehwald-0/+4
2025-01-30Remove `NamedVarMap`.Nicholas Nethercote-4/+11
`NamedVarMap` is extremely similar to `ResolveBoundVars`. The former contains two `UnordMap<ItemLocalId, T>` fields (obscured behind `ItemLocalMap` typedefs). The latter contains two `SortedMap<ItemLocalId, T>` fields. We construct a `NamedVarMap` and then convert it into a `ResolveBoundVars` by sorting the `UnordMap`s, which is unnecessary busywork. This commit removes `NamedVarMap` and constructs a `ResolveBoundVars` directly. `SortedMap` and `NamedVarMap` have slightly different perf characteristics during construction (e.g. speed of insertion) but this code isn't hot enough for that to matter. A few details to note. - A `FIXME` comment is removed. - The detailed comments on the fields of `NamedVarMap` are copied to `ResolveBoundVars` (which has a single, incorrect comment). - `BoundVarContext::map` is renamed. - `ResolveBoundVars` gets a derived `Default` impl.
2025-01-24Rename `OptimizeAttr::None` to `Default`clubby789-1/+1
2025-01-15Rollup merge of #135003 - RalfJung:deprecate-allowed-through-unstable, ↵Guillaume Gomez-9/+12
r=davidtwco deprecate `std::intrinsics::transmute` etc, use `std::mem::*` instead The `rustc_allowed_through_unstable_modules` attribute lets users call `std::mem::transmute` as `std::intrinsics::transmute`. The former is a reexport of the latter, and for a long time we didn't properly check stability for reexports, so making this a hard error now would be a breaking change for little gain. But at the same time, `std::intrinsics::transmute` is not the intended path for this function, so I think it is a good idea to show a deprecation warning when that path is used. This PR implements that, for all the functions in `std::intrinsics` that carry the attribute. I assume this will need ``@rust-lang/libs-api`` FCP.
2025-01-15Auto merge of #134353 - oli-obk:safe-target-feature-unsafe-by-default, ↵bors-0/+3
r=wesleywiser Treat safe target_feature functions as unsafe by default [less invasive variant] This unblocks * #134090 As I stated in https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 I think the previous impl was too easy to get wrong, as by default it treated safe target feature functions as safe and had to add additional checks for when they weren't. Now the logic is inverted. By default they are unsafe and you have to explicitly handle safe target feature functions. This is the less (imo) invasive variant of #134317, as it doesn't require changing the Safety enum, so it only affects FnDefs and nothing else, as it should.
2025-01-15late_report_deprecation: move fast-path closer to the core logicRalf Jung-9/+12
2025-01-14Enforce syntactical stability of const traits in HIRMichael Goulet-2/+87
2025-01-14Add hir::HeaderSafety to make follow up commits simplerOli Scherer-0/+3
2024-12-31explicitly model that certain ABIs require/forbid certain target featuresRalf Jung-0/+1
2024-12-19Make DependencyList an IndexVecbjorn3-3/+3
2024-12-19Rename Scope.id to Scope.local_id, remove trivial accessorMichael Goulet-21/+11
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-6/+4
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-2/+2
2024-12-16split attributesJonathan Dönszelmann-2/+2
2024-12-15Add hir::AttributeJonathan Dönszelmann-12/+20
2024-12-13Make dependency_formats an FxIndexMap rather than a list of tuplesbjorn3-1/+2
It is treated as a map already. This is using FxIndexMap rather than UnordMap because the latter doesn't provide an api to pick a single value iff all values are equal, which each_linked_rlib depends on.
2024-11-22Pretty print AsyncFn traits tooMichael Goulet-0/+11
2024-11-20reduce false positives of tail-expr-drop-order from consumed valuesDing Xiang Fei-0/+5
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-18stability: remove skip_stability_check_due_to_privacyRalf Jung-28/+1
2024-11-04Rollup merge of #132544 - dianne:unstable-library-feature-backticks, ↵Matthias Krüger-2/+2
r=compiler-errors Use backticks instead of single quotes for library feature names in diagnostics This PR changes the text of library feature errors for using unstable or body-unstable items. Displaying library feature names in backticks is consistent with other diagnostics (e.g. those from `rustc_passes`) and with the `reason`s on unstable attributes in the library. Additionally, this simplifies diagnostics when supporting multiple unstable attributes on items (see #131824) since `DiagSymbolList` also displays symbols using backticks.
2024-11-03use backticks instead of single quotes when reporting "use of unstable ↵dianne-2/+2
library feature" This is consistent with all other diagnostics I could find containing features and enables the use of `DiagSymbolList` for generalizing diagnostics for unstable library features to multiple features.
2024-11-03compiler: Directly use rustc_abi in metadata and middleJubilee Young-1/+1
Stop reexporting ReprOptions from middle::ty
2024-10-30Remap impl-trait lifetimes on HIR instead of AST lowering.Camille GILLOT-1/+3
2024-10-28fix clippy::clone_on_ref_ptr for compilerklensy-1/+1
2024-10-22terminology: #[feature] *enables* a feature (instead of "declaring" or ↵Ralf Jung-4/+4
"activating" it)
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.