about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
AgeCommit message (Collapse)AuthorLines
2025-05-05Deeply normalize in the new solver in WFMichael Goulet-8/+39
2025-05-05Rename Instance::new to Instance::new_raw and add a note that it is rawMichael Goulet-1/+1
2025-05-05Auto merge of #140453 - Zoxc:next-disambiguator, r=oli-obkbors-9/+25
Remove global `next_disambiguator` state and handle it with a `DisambiguatorState` type This removes `Definitions.next_disambiguator` as it doesn't guarantee deterministic def paths when `create_def` is called in parallel. Instead a new `DisambiguatorState` type is passed as a mutable reference to `create_def` to help create unique def paths. `create_def` calls with distinct `DisambiguatorState` instances must ensure that that the def paths are unique without its help. Anon associated types did rely on this global state for uniqueness and are changed to use (method they're defined in + their position in the method return type) as the `DefPathData` to ensure uniqueness. This also means that the method they're defined in appears in error messages, which is nicer. `DefPathData::NestedStatic` is added to use for nested data inside statics instead of reusing `DefPathData::AnonConst` to avoid conflicts with those. cc `@oli-obk`
2025-05-04Add comment on creation of lifetime inside opaque typesJohn Kåre Alsaker-0/+4
2025-05-02resolve: Support imports of associated types and glob imports from traitsVadim Petrochenkov-16/+18
2025-04-29Rollup merge of #139909 - oli-obk:or-patterns, r=BoxyUwUTrevor Gross-33/+61
implement or-patterns for pattern types These are necessary to represent `NonZeroI32`, as the range for that is `..0 | 1..`. The `rustc_scalar_layout_range_*` attributes avoided this by just implementing wraparound and having a single `1..=-1` range effectively. See https://rust-lang.zulipchat.com/#narrow/channel/481660-t-lang.2Fpattern-types/topic/.60or.20pattern.60.20representation.20in.20type.20system/with/504217694 for some background discussion cc https://github.com/rust-lang/rust/issues/123646 r? `@BoxyUwU`
2025-04-29Remove global `next_disambiguator` state and handle it with a ↵John Kåre Alsaker-9/+21
`DisambiguatorState` type
2025-04-28Rollup merge of #140302 - compiler-errors:inline_asm-bug, r=lcnrChris Denton-564/+0
Move inline asm check to typeck, properly handle aliases Pull `InlineAsmCtxt` down to `rustc_hir_typeck`, and instead of using things like `Ty::is_copy`, use the `InferCtxt`-aware methods. To fix https://github.com/rust-lang/trait-system-refactor-initiative/issues/189, we also add a `try_structurally_resolve_*` call to `expr_ty`. r? lcnr
2025-04-28Rollup merge of #140249 - BoxyUwU:remove_weak_alias_terminology, r=oli-obkGuillaume Gomez-14/+14
Remove `weak` alias terminology I find the "weak" alias terminology to be quite confusing. It implies the existence of "strong" aliases (which do not exist) and I'm not really sure what about weak aliases is "weak". I much prefer "free alias" as the term. I think it's much more obvious what it means as "free function" is a well defined term that already exists in rust. It's also a little confusing given "weak alias" is already a term in linker/codegen spaces which are part of the compiler too. Though I'm not particularly worried about that as it's usually very obvious if you're talking about the type system or not lol. I'm also currently trying to write documentation about aliases and it's somewhat awkward/confusing to be talking about *weak* aliases, when I'm not really sure what the basis for that as the term actually *is*. I would also be happy to just find out there's a nice meaning behind calling them "weak" aliases :-) r? `@oli-obk` maybe we want a types MCP to decide on a specific naming here? or maybe we think its just too late to go back on this naming decision ^^'
2025-04-28Add or-patterns to pattern typesOli Scherer-3/+18
2025-04-28Split out various pattern type matches into their own functionOli Scherer-6/+15
2025-04-28Separate pattern lowering from pattern type loweringOli Scherer-24/+28
2025-04-27Move inline_asm to typeck, properly handle aliasesMichael Goulet-564/+0
2025-04-27Auto merge of #139646 - lcnr:default-is-fully-concrete, r=BoxyUwUbors-0/+33
check types of const param defaults fixes #139643 by checking that the type of a const parameter default matches the type of the parameter as long as both types are fully concrete r? `@BoxyUwU`
2025-04-26Rollup merge of #140320 - lcnr:wf-use-term, r=compiler-errorsMatthias Krüger-14/+12
replace `GenericArg` with `Term` where applicable r? types
2025-04-26Rollup merge of #140317 - mejrs:check_on_uni, r=compiler-errorsMatthias Krüger-1/+0
Remove redundant check We still check for `rustc_on_unimplemented` on implementations, but this functionality was removed in https://github.com/rust-lang/rust/pull/139091, since then it always returns `Ok` when called with a non-trait defid. https://github.com/rust-lang/rust/blob/b4c8b0c3f0533bb342a4873ff59bdad3883ab8e3/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs#L557-L564
2025-04-26convert some `GenericArg` to `Term`lcnr-14/+12
2025-04-26Remove redundant checkmejrs-1/+0
2025-04-25Rollup merge of #140202 - est31:let_chains_feature_compiler, r=lcnrMatthias Krüger-1/+1
Make #![feature(let_chains)] bootstrap conditional in compiler/ Let chains have been stabilized recently in #132833, so we can remove the gating from our uses in the compiler (as the compiler uses edition 2024).
2025-04-24check types of const param defaultlcnr-0/+33
2025-04-24Remove `weak` alias terminologyBoxy-14/+14
2025-04-23Make #![feature(let_chains)] bootstrap conditional in compiler/est31-1/+1
2025-04-22Use `is_lang_item` and `as_lang_item` instead of handrolling their logicOli Scherer-35/+27
2025-04-20Don't compute name of associated item if it's an RPITITMichael Goulet-10/+10
2025-04-18Rollup merge of #138528 - dianne:implicit-deref-patterns, r=NadrierilMatthias Krüger-3/+7
deref patterns: implement implicit deref patterns This implements implicit deref patterns (per https://hackmd.io/4qDDMcvyQ-GDB089IPcHGg#Implicit-deref-patterns) and adds tests and an unstable book chapter. Best reviewed commit-by-commit. Overall there's a lot of additions, but a lot of that is tests, documentation, and simple(?) refactoring. Tracking issue: #87121 r? ``@Nadrieril``
2025-04-16respect the tcx's recursion limit when peelingdianne-3/+7
2025-04-17Rollup merge of #139770 - nnethercote:rename-LifetimeName, r=BoxyUwUMatthias Krüger-24/+24
Rename `LifetimeName` as `LifetimeKind`. It's a much better name, more consistent with how we name such things. Also rename `Lifetime::res` as `Lifetime::kind` to match. I suspect this field used to have the type `LifetimeRes` and then the type was changed but the field name remained the same. r? ``@BoxyUwU``
2025-04-16Rename `LifetimeName` as `LifetimeKind`.Nicholas Nethercote-24/+24
It's a much better name, more consistent with how we name such things. Also rename `Lifetime::res` as `Lifetime::kind` to match. I suspect this field used to have the type `LifetimeRes` and then the type was changed but the field name remained the same.
2025-04-15Don't compute name of associated item if it's an RPITITMichael Goulet-2/+1
2025-04-15Auto merge of #139845 - Zalathar:rollup-u5u5y1v, r=Zalatharbors-196/+224
Rollup of 17 pull requests Successful merges: - #138374 (Enable contracts for const functions) - #138380 (ci: add runners for vanilla LLVM 20) - #138393 (Allow const patterns of matches to contain pattern types) - #139517 (std: sys: process: uefi: Use NULL stdin by default) - #139554 (std: add Output::exit_ok) - #139660 (compiletest: Add an experimental new executor to replace libtest) - #139669 (Overhaul `AssocItem`) - #139671 (Proc macro span API redesign: Replace proc_macro::SourceFile by Span::{file, local_file}) - #139750 (std/thread: Use default stack size from menuconfig for NuttX) - #139772 (Remove `hir::Map`) - #139785 (Let CStrings be either 1 or 2 byte aligned.) - #139789 (do not unnecessarily leak auto traits in item bounds) - #139791 (drop global where-bounds before merging candidates) - #139798 (normalize: prefer `ParamEnv` over `AliasBound` candidates) - #139822 (Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix) - #139833 (Fix some HIR pretty-printing problems) - #139836 (Basic tests of MPMC receiver cloning) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-15Rollup merge of #139669 - nnethercote:overhaul-AssocItem, r=oli-obkStuart Cook-188/+220
Overhaul `AssocItem` `AssocItem` has multiple fields that only make sense some of the time. E.g. the `name` can be empty if it's an RPITIT associated type. It's clearer and less error prone if these fields are moved to the relevant `kind` variants. r? ``@fee1-dead``
2025-04-15Rollup merge of #138374 - celinval:issue-136925-const-contract, ↵Stuart Cook-8/+4
r=compiler-errors,oli-obk,RalfJung Enable contracts for const functions Use `const_eval_select!()` macro to enable contract checking only at runtime. The existing contract logic relies on closures, which are not supported in constant functions. This commit also removes one level of indirection for ensures clauses since we no longer build a closure around the ensures predicate. Resolves #136925 **Call-out:** This is still a draft PR since CI is broken due to a new warning message for unreachable code when the bottom of the function is indeed unreachable. It's not clear to me why the warning wasn't triggered before. r? ```@compiler-errors```
2025-04-15Move `name` field from `AssocItem` to `AssocKind` variants.Nicholas Nethercote-49/+55
To accurately reflect that RPITIT assoc items don't have a name. This avoids the use of `kw::Empty` to mean "no name", which is error prone. Helps with #137978.
2025-04-15Move two methods from `AssocKind` to `AssocItem`.Nicholas Nethercote-3/+3
Because all the other similar methods are on `AssocItem`.
2025-04-15Move `opt_rpitit_info` field to `hir::AssocKind::Type`.Nicholas Nethercote-21/+24
From `hir::AssocItem`.
2025-04-14Use `newtype_index!`-generated types more idiomaticallyYotam Ofek-5/+2
2025-04-14Move `has_self` field to `hir::AssocKind::Fn`.Nicholas Nethercote-122/+145
`hir::AssocItem` currently has a boolean `fn_has_self_parameter` field, which is misplaced, because it's only relevant for associated fns, not for associated consts or types. This commit moves it (and renames it) to the `AssocKind::Fn` variant, where it belongs. This requires introducing a new C-style enum, `AssocTag`, which is like `AssocKind` but without the fields. This is because `AssocKind` values are passed to various functions like `find_by_ident_and_kind` to indicate what kind of associated item should be searched for, and having to specify `has_self` isn't relevant there. New methods: - Predicates `AssocItem::is_fn` and `AssocItem::is_method`. - `AssocItem::as_tag` which converts `AssocItem::kind` to `AssocTag`. Removed `find_by_name_and_kinds`, which is unused. `AssocItem::descr` can now distinguish between methods and associated functions, which slightly improves some error messages.
2025-04-14Auto merge of #124141 - ↵bors-1/+0
nnethercote:rm-Nonterminal-and-TokenKind-Interpolated, r=petrochenkov Remove `Nonterminal` and `TokenKind::Interpolated` A third attempt at this; the first attempt was #96724 and the second was #114647. r? `@ghost`
2025-04-11Rollup merge of #137447 - folkertdev:simd-extract-insert-dyn, r=scottmcmStuart Cook-2/+6
add `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}` fixes https://github.com/rust-lang/rust/issues/137372 adds `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}`, which contrary to their non-dyn counterparts allow a non-const index. Many platforms (but notably not x86_64 or aarch64) have dedicated instructions for this operation, which stdarch can emit with this change. Future work is to also make the `Index` operation on the `Simd` type emit this operation, but the intrinsic can't be used directly. We'll need some MIR shenanigans for that. r? `@ghost`
2025-04-10add `simd_insert_dyn` and `simd_extract_dyn`Folkert de Vries-2/+6
2025-04-10Rollup merge of #139510 - nnethercote:name-to-ident, r=fee1-deadMatthias Krüger-64/+69
Rename some `name` variables as `ident`. It bugs me when variables of type `Ident` are called `name`. It leads to silly things like `name.name`. `Ident` variables should be called `ident`, and `name` should be used for variables of type `Symbol`. This commit improves things by by doing `s/name/ident/` on a bunch of `Ident` variables. Not all of them, but a decent chunk. r? `@fee1-dead`
2025-04-10Rollup merge of #139530 - oli-obk:rustc-intrinsic-cleanup, r=RalfJungMatthias Krüger-35/+9
Remove some dead or leftover code related to rustc-intrinsic abi removal r? ```@RalfJung``` PR that removed the ABI: https://github.com/rust-lang/rust/pull/139455 tracking issue: https://github.com/rust-lang/rust/issues/132735
2025-04-10Rename some `name` variables as `ident`.Nicholas Nethercote-64/+69
It bugs me when variables of type `Ident` are called `name`. It leads to silly things like `name.name`. `Ident` variables should be called `ident`, and `name` should be used for variables of type `Symbol`. This commit improves things by by doing `s/name/ident/` on a bunch of `Ident` variables. Not all of them, but a decent chunk.
2025-04-09Use a query rather than recomputing the tail repeatedlyMichael Goulet-23/+3
2025-04-09Rigidly project missing item due to guaranteed impossible sized predicateMichael Goulet-6/+2
2025-04-09Remove some dead or leftover code related to rustc-intrinsic abi removalOli Scherer-35/+9
2025-04-09Auto merge of #139552 - matthiaskrgr:rollup-b194mk8, r=matthiaskrgrbors-4/+10
Rollup of 10 pull requests Successful merges: - #139494 (Restrict some queries by def-kind more) - #139496 (Revert r-a changes of rust-lang/rust#139455) - #139506 (add missing word in doc comment (part 2)) - #139515 (Improve presentation of closure signature mismatch from `Fn` trait goal) - #139520 (compiletest maintenance: sort deps and drop dep on `anyhow`) - #139523 (Rustc dev guide subtree update) - #139526 (Fix deprecation note for std::intrinsics) - #139528 (compiletest: Remove the `--logfile` flag) - #139541 (Instantiate higher-ranked transmute goal w/ placeholders before emitting sub-obligations) - #139547 (Update library tracking issue template to set S-tracking-unimplemented) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-08Auto merge of #139536 - matthiaskrgr:rollup-j6goald, r=matthiaskrgrbors-9/+9
Rollup of 7 pull requests Successful merges: - #139476 (rm `RegionInferenceContext::var_infos`) - #139485 (compiletest: Stricter parsing for diagnostic kinds) - #139491 (Update books) - #139500 (document panic behavior of Vec::resize and Vec::resize_with) - #139501 (Fix stack overflow in exhaustiveness due to recursive HIR opaque hidden types) - #139504 (add missing word in doc comment) - #139509 (clean: remove Deref<Target=RegionKind> impl for Region and use `.kind()`) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-08Rollup merge of #139494 - compiler-errors:restrict-queries, r=oli-obkMatthias Krüger-4/+10
Restrict some queries by def-kind more Random cleanup. I prefer things to assert more so as to catch bugs :) r? oli-obk
2025-04-08Fix unreachable expression warningCelina G. Val-1/+1
Invert the order that we pass the arguments to the `contract_check_ensures` function to avoid the warning when the tail of the function is unreachable. Note that the call itself is also unreachable, but we have already handled that case by ignoring unreachable call for contract calls.