PR feedback

This commit is contained in:
Scott McMurray 2021-05-02 12:11:13 -07:00
parent fe540ae1bb
commit 40ffa94244
3 changed files with 18 additions and 11 deletions

View File

@ -17,11 +17,11 @@
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_index::vec::{Idx, IndexVec}; use rustc_index::vec::{Idx, IndexVec};
use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData}; use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
use rustc_middle::bug;
use rustc_middle::middle::resolve_lifetime as rl; use rustc_middle::middle::resolve_lifetime as rl;
use rustc_middle::ty::fold::TypeFolder; use rustc_middle::ty::fold::TypeFolder;
use rustc_middle::ty::subst::{InternalSubsts, Subst}; use rustc_middle::ty::subst::{InternalSubsts, Subst};
use rustc_middle::ty::{self, AdtKind, Lift, Ty, TyCtxt}; use rustc_middle::ty::{self, AdtKind, Lift, Ty, TyCtxt};
use rustc_middle::{bug, span_bug};
use rustc_mir::const_eval::{is_const_fn, is_unstable_const_fn}; use rustc_mir::const_eval::{is_const_fn, is_unstable_const_fn};
use rustc_span::hygiene::{AstPass, MacroKind}; use rustc_span::hygiene::{AstPass, MacroKind};
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{kw, sym, Ident, Symbol};
@ -157,11 +157,14 @@ fn clean(&self, cx: &mut DocContext<'_>) -> GenericBound {
impl Clean<Type> for (ty::TraitRef<'_>, &[TypeBinding]) { impl Clean<Type> for (ty::TraitRef<'_>, &[TypeBinding]) {
fn clean(&self, cx: &mut DocContext<'_>) -> Type { fn clean(&self, cx: &mut DocContext<'_>) -> Type {
let (trait_ref, bounds) = *self; let (trait_ref, bounds) = *self;
let kind = match cx.tcx.def_kind(trait_ref.def_id) { let kind = cx.tcx.def_kind(trait_ref.def_id).into();
DefKind::Trait => ItemType::Trait, if !matches!(kind, ItemType::Trait | ItemType::TraitAlias) {
DefKind::TraitAlias => ItemType::TraitAlias, span_bug!(
other => bug!("`TraitRef` had unexpected kind {:?}", other), cx.tcx.def_span(trait_ref.def_id),
}; "`TraitRef` had unexpected kind {:?}",
kind
);
}
inline::record_extern_fqn(cx, trait_ref.def_id, kind); inline::record_extern_fqn(cx, trait_ref.def_id, kind);
let path = external_path( let path = external_path(
cx, cx,

View File

@ -0,0 +1,3 @@
#![feature(trait_alias)]
pub trait SomeAlias = std::fmt::Debug + std::marker::Copy;

View File

@ -1,9 +1,10 @@
#![feature(trait_alias)] // aux-build:trait-alias-mention.rs
#![feature(ptr_metadata)] // build-aux-docs
#![crate_name = "foo"] #![crate_name = "foo"]
// @has foo/fn.this_never_panics.html '//a[@title="traitalias core::ptr::metadata::Thin"]' 'Thin' extern crate trait_alias_mention;
pub fn this_never_panics<T: std::ptr::Thin>() {
assert_eq!(std::mem::size_of::<&T>(), std::mem::size_of::<usize>()) // @has foo/fn.mention_alias_in_bounds.html '//a[@href="../trait_alias_mention/traitalias.SomeAlias.html"]' 'SomeAlias'
pub fn mention_alias_in_bounds<T: trait_alias_mention::SomeAlias>() {
} }