summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/mod.rs
AgeCommit message (Collapse)AuthorLines
2024-01-30Remove the lifetime from `DiagnosticArgValue`.Nicholas Nethercote-2/+2
Because it's almost always static. This makes `impl IntoDiagnosticArg for DiagnosticArgValue` trivial, which is nice. There are a few diagnostics constructed in `compiler/rustc_mir_build/src/check_unsafety.rs` and `compiler/rustc_mir_transform/src/errors.rs` that now need symbols converted to `String` with `to_string` instead of `&str` with `as_str`, but that' no big deal, and worth it for the simplifications elsewhere.
2024-01-25Auto merge of #119955 - kamalesh0406:master, r=WaffleLapkinbors-8/+24
Modify GenericArg and Term structs to use strict provenance rules This is the first PR to solve issue #119217 . In this PR, I have modified the GenericArg struct to use the `NonNull` struct as the pointer instead of `NonZeroUsize`. The change were tested by running `./x test compiler/rustc_middle`. Resolves https://github.com/rust-lang/rust/issues/119217 r? `@WaffleLapkin`
2024-01-18Modify GenericArg and Term structs to use strict provenance rulesKamalesh Palanisamy-8/+24
2024-01-17Improved collapse_debuginfo attribute, added command-line flag (no|external|yes)Andrew Zhogin-2/+1
2024-01-12Delegation implementation: step 1Bryanskiy-1/+5
2024-01-09Rollup merge of #118903 - azhogin:azhogin/skip_second_stmt_debuginfo.rs, ↵Matthias Krüger-11/+11
r=petrochenkov Improved support of collapse_debuginfo attribute for macros. Added walk_chain_collapsed function to consider collapse_debuginfo attribute in parent macros in call chain. Fixed collapse_debuginfo attribute processing for cranelift (there was if/else branches error swap). cc https://github.com/rust-lang/rust/issues/100758
2024-01-08Improved support of collapse_debuginfo attribute for macros.Andrew Zhogin-11/+11
2024-01-04Make iteration order of inferred_outlives_crate query stableMichael Woerister-1/+1
2024-01-04Make iteration order of crate_inherent_impls query result stable.Michael Woerister-1/+2
2023-12-31Auto merge of #119447 - Nilstrieb:STACKOVERFLOW, r=compiler-errorsbors-1/+2
Fix `<BoundConstness as Display>` There was infinite recursion, which is not very good. I'm not sure what the best way to implement this is, I just did something that felt right. r? `@fmease`
2023-12-30Update to bitflags 2 in the compilerNilstrieb-2/+4
This involves lots of breaking changes. There are two big changes that force changes. The first is that the bitflag types now don't automatically implement normal derive traits, so we need to derive them manually. Additionally, bitflags now have a hidden inner type by default, which breaks our custom derives. The bitflags docs recommend using the impl form in these cases, which I did.
2023-12-30Fix `<BoundConstness as Display>`Nilstrieb-1/+2
There was infinite recursion, which is not very good. I'm not sure what the best way to implement this is, I just did something that felt right.
2023-12-27Introduce `const Trait` (always-const trait bounds)León Orell Valerian Liehr-11/+10
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-23Give `DiagnosticBuilder` a default type.Nicholas Nethercote-1/+1
`IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the most common diagnostic level. It makes sense to do likewise for the closely-related (and much more widely used) `DiagnosticBuilder` type, letting us write `DiagnosticBuilder<'a, ErrorGuaranteed>` as just `DiagnosticBuilder<'a>`. This cuts over 200 lines of code due to many multi-line things becoming single line things.
2023-12-18Replace some instances of FxHashMap/FxHashSet with stable alternatives ↵Michael Woerister-1/+1
(mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-1/+1
2023-12-18resolve: Replace visibility table in resolver outputs with query feedingVadim Petrochenkov-1/+1
Also feed missing visibilities for import stems and trait impl items, which were previously evaluated lazily.
2023-12-15NFC: do not clone types that are copyMatthias Krüger-1/+1
2023-12-12Uplift ClosureKindMichael Goulet-1/+1
2023-12-08FeedbackMichael Goulet-22/+17
- Take more things by self, not &self - Clone more things - Rework namespacing so we can use `ty::` in the canonicalizer
2023-12-08Uplift canonicalizer into new trait solver crateMichael Goulet-6/+26
2023-12-07add unused `NormalizesTo` predicatelcnr-0/+39
2023-12-07Auto merge of #118684 - compiler-errors:yeet-poly-gen-sig, r=spastorinobors-3/+2
Remove `PolyGenSig` since it's always a dummy binder Coroutines are never polymorphic in their signature. This cleans up a FIXME in the code: ``` /// Returns the "coroutine signature", which consists of its yield /// and return types. /// /// N.B., some bits of the code prefers to see this wrapped in a /// binder, but it never contains bound regions. Probably this /// function should be removed. ```
2023-12-06Yeet PolyGenSigMichael Goulet-3/+2
2023-12-05rustc_arena: add `alloc_str`Josh Stone-3/+1
Two places called `from_utf8_unchecked` for strings from `alloc_slice`, and one's SAFETY comment said this was for lack of `alloc_str` -- so let's just add that instead!
2023-12-01vis note for no pub reexports glob importbohan-0/+17
2023-11-28resolve: Feed the `def_kind` query immediately on `DefId` creationVadim Petrochenkov-3/+0
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-3/+3
cleanup
2023-11-25Rollup merge of #117871 - klensy:unused-pub, r=cjgillotGuillaume Gomez-36/+0
remove unused pub fns This removes some unused `pub fn`; also fixes few obsoleted fn names or added fixmes with reminders to update them.
2023-11-24Auto merge of #118189 - compiler-errors:cache-flags-for-const, r=nnethercotebors-2/+2
Cache flags for `ty::Const` Not sure if this has been attempted yet, but worth a shot. It does make the code simpler in `rustc_type_ir`, since we can assume that consts have a `flags` method that is no-cost. r? `@ghost`
2023-11-23few moreklensy-17/+0
2023-11-23remove unused pub fnklensy-19/+0
2023-11-22Cache flags for ty::ConstMichael Goulet-2/+2
2023-11-22Auto merge of #118120 - compiler-errors:closure-kind, r=lcnrbors-4/+0
Remove `PredicateKind::ClosureKind` We don't need the `ClosureKind` predicate kind -- instead, `Fn`-family trait goals are left as ambiguous, and we only need to make progress on `FnOnce` projection goals for inference purposes. This is similar to how we do confirmation of `Fn`-family trait and projection goals in the new trait solver, which also doesn't use the `ClosureKind` predicate. Some hacky logic is added in the second commit so that we can keep the error messages the same.
2023-11-22Auto merge of #117582 - compiler-errors:uplift-canonical-var, r=jackh726bors-1/+43
Uplift `CanonicalVarInfo` and friends into `rustc_type_ir` Depends on #117580 and #117578 Uplift `CanonicalVarInfo` and friends into `rustc_type_ir` so they can be consumed by an interner-agnostic `Canonicalizer` implementation for the new trait solver ❤️ r? `@ghost`
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-4/+4
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-21Remove ClosureKind predicate kindMichael Goulet-4/+0
2023-11-21Uplift CanonicalVarInfo and friendsMichael Goulet-0/+42
2023-11-21Uplift BoundVarMichael Goulet-1/+1
2023-11-20Uplift InferConst to rustc_type_irMichael Goulet-4/+2
2023-11-14finish `RegionKind` renamelcnr-6/+7
- `ReFree` -> `ReLateParam` - `ReEarlyBound` -> `ReEarlyParam`
2023-11-06Auto merge of #117603 - HKalbasi:make-feature-additive, r=Nilstriebbors-1/+1
Make the randomize feature of rustc_abi additive The goal here is to make rust-analyzer able to build with the `rustc_private` versions of the rustc crates it depends on. See #116847
2023-11-05Make the randomize feature of rustc_abi additivehkalbasi-1/+1
2023-11-04No lifetime on PlaceholderConstMichael Goulet-1/+1
2023-10-26Auto merge of #112875 - compiler-errors:negative-coherence-rework, r=lcnrbors-0/+1
Rework negative coherence to properly consider impls that only partly overlap This PR implements a modified negative coherence that handles impls that only have partial overlap. It does this by: 1. taking both impl trait refs, instantiating them with infer vars 2. equating both trait refs 3. taking the equated trait ref (which represents the two impls' intersection), and resolving any vars 4. plugging all remaining infer vars with placeholder types these placeholder-plugged trait refs can then be used normally with the new trait solver, since we no longer have to worry about the issue with infer vars in param-envs. We use the **new trait solver** to reason correctly about unnormalized trait refs (due to deferred projection equality), since this avoid having to normalize anything under param-envs with infer vars in them. This PR then additionally: * removes the `FnPtr` knowable hack by implementing proper negative `FnPtr` trait bounds for rigid types. --- An example: Consider these two partially overlapping impls: ``` impl<T, U> PartialEq<&U> for &T where T: PartialEq<U> {} impl<F> PartialEq<F> for F where F: FnPtr {} ``` Under the old algorithm, we would take one of these impls and replace it with infer vars, then try unifying it with the other impl under identity substitutions. This is not possible in either direction, since it either sets `T = U`, or tries to equate `F = &?0`. Under the new algorithm, we try to unify `?0: PartialEq<?0>` with `&?1: PartialEq<&?2>`. This gives us `?0 = &?1 = &?2` and thus `?1 = ?2`. The intersection of these two trait refs therefore looks like: `&?1: PartialEq<&?1>`. After plugging this with placeholders, we get a trait ref that looks like `&!0: PartialEq<&!0>`, with the first impl having substs `?T = ?U = !0` and the second having substs `?F = &!0`[^1]. Then we can take the param-env from the first impl, and try to prove the negated where clause of the second. We know that `&!0: !FnPtr` never holds, since it's a rigid type that is also not a fn ptr, we successfully detect that these impls may never overlap. [^1]: For the purposes of this example, I just ignored lifetimes, since it doesn't really matter.
2023-10-25Add a IsIdentity extension trait for CanonicalUserTypeMichael Goulet-2/+2
2023-10-25Auto merge of #116993 - compiler-errors:clause-kind, r=jackh726bors-96/+4
Uplift `ClauseKind` and `PredicateKind` into `rustc_type_ir` Uplift `ClauseKind` and `PredicateKind` into `rustc_type_ir`. Blocked on #116951 r? `@ghost`
2023-10-24Get rid of 'tcx on ConstVid, EffectVidMichael Goulet-5/+5
2023-10-23pre-cleanupsMichael Goulet-0/+1