Various HirTyLowerer cleanups#125819
Conversation
|
HIR ty lowering was modified cc @fmease |
This comment has been minimized.
This comment has been minimized.
|
Wasn't it a very intentional decision back in the day to have |
compiler-errors
left a comment
There was a problem hiding this comment.
Yeah, I concur w/ @fmease here. I think adding an InferCtxt gives rustc devs a much easier chance to misuse it.
|
Yea... I was wondering about that. I'd think we'd want to use a full |
|
Do you mean in preparation for potential changes to language like rust-lang/rfcs#3546 (which hasn't been accepted of course)? Or do you have something else in mind? To be honest, I haven't looked at the linked issue yet or at the issues in |
|
I removed the InferCtxt changes and left just the refactorings that do not have user-visible effects |
|
☔ The latest upstream changes (presumably #125960) made this pull request unmergeable. Please resolve the merge conflicts. |
fmease
left a comment
There was a problem hiding this comment.
sorry for the delay! that's very nice cleanup, thanks a lot! r=me with nits addressed
| @@ -90,7 +90,7 @@ pub trait HirTyLowerer<'tcx> { | |||
| fn tcx(&self) -> TyCtxt<'tcx>; | |||
|
|
|||
| /// Returns the [`DefId`] of the overarching item whose constituents get lowered. | |||
There was a problem hiding this comment.
| /// Returns the [`DefId`] of the overarching item whose constituents get lowered. | |
| /// Returns the [`LocalDefId`] of the overarching item whose constituents get lowered. |
| fn re_infer(&self, param: Option<&ty::GenericParamDef>, span: Span) | ||
| -> Option<ty::Region<'tcx>>; | ||
| /// | ||
| /// The `borrowed` argument states whether this lifetime is from a reference. |
There was a problem hiding this comment.
it's object_lifetime_default not borrowed (copy/paste error from lower_ty_common?)
| &self, | ||
| _: Option<&ty::GenericParamDef>, | ||
| span: Span, | ||
| object_lifetime_default: bool, |
There was a problem hiding this comment.
would love this bool to be a custom enum instead but that's not blocking
| // We will have already emitted an error E0106 complaining about a | ||
| // missing named lifetime in `&dyn Trait`, so we elide this one. |
There was a problem hiding this comment.
this comment doesn't make sense anymore. it was about delay_as_bug vs emit depending on borrowed : bool which you no longer do
| } | ||
|
|
||
| #[derive(Debug)] | ||
| pub enum RegionInferReason<'a> { |
There was a problem hiding this comment.
I guess we don't actually use most of the reasons but anyway...
There was a problem hiding this comment.
Yea, but that's true for obligation causes, too :D maybe we should. I dislike those delay span bugs
|
@bors r+ rollup |
|
☔ The latest upstream changes (presumably #125976) made this pull request unmergeable. Please resolve the merge conflicts. |
…r (can) use it for local items
`ct_infer` and `lower_ty` will correctly result in an error constant or type respectively, as they go through a `HirTyLowerer` method (just like `HirTyLowerer::allow_infer` is a method implemented by both implementors
…n enum that exhaustively supports all call sites
|
@bors r=fmease |
|
🌲 The tree is currently closed for pull requests below priority 101. This pull request will be tested once the tree is reopened. |
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#124746 (`rustc --explain E0582` additional example) - rust-lang#125407 (Detect when user is trying to create a lending `Iterator` and give a custom explanation) - rust-lang#125505 (Add intra-doc-links to rustc_middle crate-level docs.) - rust-lang#125792 (Don't drop `Unsize` candidate in intercrate mode) - rust-lang#125819 (Various `HirTyLowerer` cleanups) - rust-lang#125861 (rustc_codegen_ssa: fix `get_rpath_relative_to_output` panic when lib only contains file name) - rust-lang#125911 (delete bootstrap build before switching to bumped rustc) - rust-lang#125921 (coverage: Carve out hole spans in a separate early pass) - rust-lang#125940 (std::unix::fs::get_path: using fcntl codepath for netbsd instead.) - rust-lang#126022 (set `has_unconstrained_ty_var` when generalizing aliases in bivariant contexts) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#125819 - oli-obk:localize, r=fmease Various `HirTyLowerer` cleanups Previously there was some ad-hoc specialization going on, because you could call `allows_infer`, which basically was deciding between whether the trait object was backed by `FnCtxt` or by `ItemCtxt`. I moved all the different logic into dedicated methods on `HirTyLowerer` and removed `allows_infer` best reviewed commit-by-commit
Previously there was some ad-hoc specialization going on, because you could call
allows_infer, which basically was deciding between whether the trait object was backed byFnCtxtor byItemCtxt. I moved all the different logic into dedicated methods onHirTyLowererand removedallows_inferbest reviewed commit-by-commit