Skip to content

Commit

Permalink
Rollup merge of rust-lang#97288 - compiler-errors:tcxify-rustdoc, r=D…
Browse files Browse the repository at this point in the history
…ylan-DPC

Lifetime variance fixes for rustdoc

rust-lang#97287 migrates rustc to a `Ty` type that is invariant over its lifetime `'tcx`, so I need to fix a bunch of places that assume that `Ty<'a>` and `Ty<'b>` can be unified by shortening both to some common lifetime.

This is doable, since everything is already `'tcx`, so all this PR does is be a bit more explicit that elided lifetimes are actually `'tcx`.

Split out from rust-lang#97287 so the rustdoc team can review independently.
  • Loading branch information
Dylan-DPC authored May 24, 2022
2 parents 43d9f38 + b2a95cb commit 300e8c4
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 154 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,12 @@ pub struct GenericArgs<'hir> {
pub span_ext: Span,
}

impl GenericArgs<'_> {
impl<'hir> GenericArgs<'hir> {
pub const fn none() -> Self {
Self { args: &[], bindings: &[], parenthesized: false, span_ext: DUMMY_SP }
}

pub fn inputs(&self) -> &[Ty<'_>] {
pub fn inputs(&self) -> &[Ty<'hir>] {
if self.parenthesized {
for arg in self.args {
match arg {
Expand Down Expand Up @@ -549,7 +549,7 @@ impl<'hir> Generics<'hir> {
&NOPE
}

pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'_>> {
pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'hir>> {
for param in self.params {
if name == param.name.ident().name {
return Some(param);
Expand Down Expand Up @@ -608,7 +608,7 @@ impl<'hir> Generics<'hir> {
pub fn bounds_for_param(
&self,
param_def_id: LocalDefId,
) -> impl Iterator<Item = &WhereBoundPredicate<'_>> {
) -> impl Iterator<Item = &WhereBoundPredicate<'hir>> {
self.predicates.iter().filter_map(move |pred| match pred {
WherePredicate::BoundPredicate(bp) if bp.is_param_bound(param_def_id.to_def_id()) => {
Some(bp)
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ pub(crate) fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean
}
}

fn build_external_function(cx: &mut DocContext<'_>, did: DefId) -> clean::Function {
fn build_external_function<'tcx>(cx: &mut DocContext<'tcx>, did: DefId) -> clean::Function {
let sig = cx.tcx.fn_sig(did);

let predicates = cx.tcx.predicates_of(did);
Expand Down
Loading

0 comments on commit 300e8c4

Please sign in to comment.