diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 2bf701d1f4e50..09792d29d3661 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -33,7 +33,6 @@ use rustc::middle::resolve_lifetime as rl; use rustc::middle::lang_items; use rustc::hir::def::{Def, CtorKind}; use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; -use rustc::traits::Reveal; use rustc::ty::subst::Substs; use rustc::ty::{self, Ty, AdtKind}; use rustc::middle::stability; @@ -2044,7 +2043,7 @@ impl Clean for hir::Ty { TySlice(ref ty) => Slice(box ty.clean(cx)), TyArray(ref ty, n) => { let def_id = cx.tcx.hir.body_owner_def_id(n); - let param_env = ty::ParamEnv::empty(Reveal::UserFacing); + let param_env = cx.tcx.param_env(def_id); let substs = Substs::identity_for_item(cx.tcx, def_id); let n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap(); let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val { @@ -2173,6 +2172,11 @@ impl<'tcx> Clean for Ty<'tcx> { ty::TyStr => Primitive(PrimitiveType::Str), ty::TySlice(ty) => Slice(box ty.clean(cx)), ty::TyArray(ty, n) => { + let mut n = cx.tcx.lift(&n).unwrap(); + if let ConstVal::Unevaluated(def_id, substs) = n.val { + let param_env = cx.tcx.param_env(def_id); + n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap() + }; let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val { n.to_string() } else if let ConstVal::Unevaluated(def_id, _) = n.val { diff --git a/src/test/rustdoc/auxiliary/issue-46727.rs b/src/test/rustdoc/auxiliary/issue-46727.rs new file mode 100644 index 0000000000000..f0869f016e666 --- /dev/null +++ b/src/test/rustdoc/auxiliary/issue-46727.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Cmetadata=aux + +pub trait Foo {} + +pub struct Bar { x: T } + +impl Foo for Bar<[T; 1 + 1 + 1]> {} diff --git a/src/test/rustdoc/issue-46727.rs b/src/test/rustdoc/issue-46727.rs new file mode 100644 index 0000000000000..5b202d8c4fe88 --- /dev/null +++ b/src/test/rustdoc/issue-46727.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-46727.rs + +extern crate issue_46727; + +// @has issue_46727/trait.Foo.html +// @has - '//code' 'impl Foo for Bar<[T; 3]>' +pub use issue_46727::{Foo, Bar};