Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4c71347e
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4c71347e
编写于
3月 22, 2016
作者:
M
mitaa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consider `doc(no_inline)` in crate-local inlining
上级
c7bdfd44
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
48 addition
and
11 deletion
+48
-11
src/librustdoc/clean/inline.rs
src/librustdoc/clean/inline.rs
+2
-2
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+3
-3
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+3
-2
src/librustdoc/lib.rs
src/librustdoc/lib.rs
+1
-1
src/librustdoc/passes.rs
src/librustdoc/passes.rs
+1
-1
src/librustdoc/visit_ast.rs
src/librustdoc/visit_ast.rs
+5
-2
src/test/rustdoc/inline_local/issue-32343.rs
src/test/rustdoc/inline_local/issue-32343.rs
+33
-0
未找到文件。
src/librustdoc/clean/inline.rs
浏览文件 @
4c71347e
...
...
@@ -256,7 +256,7 @@ fn populate_impls(cx: &DocContext, tcx: &TyCtxt,
cstore
::
DlImpl
(
did
)
=>
build_impl
(
cx
,
tcx
,
did
,
impls
),
cstore
::
DlDef
(
Def
::
Mod
(
did
))
=>
{
// Don't recurse if this is a #[doc(hidden)] module
if
load_attrs
(
cx
,
tcx
,
did
)
.list
_def
(
"doc"
)
.has_word
(
"hidden"
)
{
if
load_attrs
(
cx
,
tcx
,
did
)
.list
(
"doc"
)
.has_word
(
"hidden"
)
{
return
;
}
...
...
@@ -299,7 +299,7 @@ pub fn build_impl(cx: &DocContext,
if
let
Some
(
ref
t
)
=
associated_trait
{
// If this is an impl for a #[doc(hidden)] trait, be sure to not inline
let
trait_attrs
=
load_attrs
(
cx
,
tcx
,
t
.def_id
);
if
trait_attrs
.list
_def
(
"doc"
)
.has_word
(
"hidden"
)
{
if
trait_attrs
.list
(
"doc"
)
.has_word
(
"hidden"
)
{
return
}
}
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
4c71347e
...
...
@@ -418,7 +418,7 @@ fn clean(&self, cx: &DocContext) -> Item {
pub
trait
Attributes
{
fn
has_word
(
&
self
,
&
str
)
->
bool
;
fn
value
<
'a
>
(
&
'a
self
,
&
str
)
->
Option
<&
'a
str
>
;
fn
list
_def
<
'a
>
(
&
'a
self
,
&
str
)
->
&
'a
[
Attribute
];
fn
list
<
'a
>
(
&
'a
self
,
&
str
)
->
&
'a
[
Attribute
];
}
impl
Attributes
for
[
Attribute
]
{
...
...
@@ -447,7 +447,7 @@ fn value<'a>(&'a self, name: &str) -> Option<&'a str> {
}
/// Finds an attribute as List and returns the list of attributes nested inside.
fn
list
_def
<
'a
>
(
&
'a
self
,
name
:
&
str
)
->
&
'a
[
Attribute
]
{
fn
list
<
'a
>
(
&
'a
self
,
name
:
&
str
)
->
&
'a
[
Attribute
]
{
for
attr
in
self
{
if
let
List
(
ref
x
,
ref
list
)
=
*
attr
{
if
name
==
*
x
{
...
...
@@ -1535,7 +1535,7 @@ fn from_str(s: &str) -> Option<PrimitiveType> {
}
fn
find
(
attrs
:
&
[
Attribute
])
->
Option
<
PrimitiveType
>
{
for
attr
in
attrs
.list
_def
(
"doc"
)
{
for
attr
in
attrs
.list
(
"doc"
)
{
if
let
NameValue
(
ref
k
,
ref
v
)
=
*
attr
{
if
"primitive"
==
*
k
{
if
let
ret
@
Some
(
..
)
=
PrimitiveType
::
from_str
(
v
)
{
...
...
src/librustdoc/html/render.rs
浏览文件 @
4c71347e
...
...
@@ -432,7 +432,7 @@ pub fn run(mut krate: clean::Crate,
// Crawl the crate attributes looking for attributes which control how we're
// going to emit HTML
if
let
Some
(
attrs
)
=
krate
.module
.as_ref
()
.map
(|
m
|
m
.attrs
.list
_def
(
"doc"
))
{
if
let
Some
(
attrs
)
=
krate
.module
.as_ref
()
.map
(|
m
|
m
.attrs
.list
(
"doc"
))
{
for
attr
in
attrs
{
match
*
attr
{
clean
::
NameValue
(
ref
x
,
ref
s
)
...
...
@@ -832,7 +832,7 @@ fn extern_location(e: &clean::ExternalCrate, dst: &Path) -> ExternalLocation {
// Failing that, see if there's an attribute specifying where to find this
// external crate
e
.attrs
.list
_def
(
"doc"
)
.value
(
"html_root_url"
)
.map
(|
url
|
{
e
.attrs
.list
(
"doc"
)
.value
(
"html_root_url"
)
.map
(|
url
|
{
let
mut
url
=
url
.to_owned
();
if
!
url
.ends_with
(
"/"
)
{
url
.push
(
'/'
)
...
...
@@ -1846,6 +1846,7 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
fn
item_function
(
w
:
&
mut
fmt
::
Formatter
,
cx
:
&
Context
,
it
:
&
clean
::
Item
,
f
:
&
clean
::
Function
)
->
fmt
::
Result
{
// FIXME(#24111): remove when `const_fn` is stabilized
let
vis_constness
=
match
get_unstable_features_setting
()
{
UnstableFeatures
::
Allow
=>
f
.constness
,
_
=>
hir
::
Constness
::
NotConst
...
...
src/librustdoc/lib.rs
浏览文件 @
4c71347e
...
...
@@ -383,7 +383,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
// Process all of the crate attributes, extracting plugin metadata along
// with the passes which we are supposed to run.
for
attr
in
krate
.module
.as_ref
()
.unwrap
()
.attrs
.list
_def
(
"doc"
)
{
for
attr
in
krate
.module
.as_ref
()
.unwrap
()
.attrs
.list
(
"doc"
)
{
match
*
attr
{
clean
::
Word
(
ref
w
)
if
"no_default_passes"
==
*
w
=>
{
default_passes
=
false
;
...
...
src/librustdoc/passes.rs
浏览文件 @
4c71347e
...
...
@@ -33,7 +33,7 @@ struct Stripper<'a> {
}
impl
<
'a
>
fold
::
DocFolder
for
Stripper
<
'a
>
{
fn
fold_item
(
&
mut
self
,
i
:
Item
)
->
Option
<
Item
>
{
if
i
.attrs
.list
_def
(
"doc"
)
.has_word
(
"hidden"
)
{
if
i
.attrs
.list
(
"doc"
)
.has_word
(
"hidden"
)
{
debug!
(
"found one in strip_hidden; removing"
);
self
.stripped
.insert
(
i
.def_id
);
...
...
src/librustdoc/visit_ast.rs
浏览文件 @
4c71347e
...
...
@@ -229,7 +229,7 @@ fn inherits_doc_hidden(cx: &core::DocContext, mut node: ast::NodeId) -> bool {
while
let
Some
(
id
)
=
cx
.map
.get_enclosing_scope
(
node
)
{
node
=
id
;
let
attrs
=
cx
.map
.attrs
(
node
)
.clean
(
cx
);
if
attrs
.list
_def
(
"doc"
)
.has_word
(
"hidden"
)
{
if
attrs
.list
(
"doc"
)
.has_word
(
"hidden"
)
{
return
true
;
}
if
node
==
ast
::
CRATE_NODE_ID
{
...
...
@@ -251,11 +251,14 @@ fn inherits_doc_hidden(cx: &core::DocContext, mut node: ast::NodeId) -> bool {
Some
(
analysis
)
=>
analysis
,
None
=>
return
false
};
let
use_attrs
=
tcx
.map
.attrs
(
id
)
.clean
(
self
.cx
);
let
is_private
=
!
analysis
.access_levels
.is_public
(
def
);
let
is_hidden
=
inherits_doc_hidden
(
self
.cx
,
def_node_id
);
let
is_no_inline
=
use_attrs
.list
(
"doc"
)
.has_word
(
"no_inline"
);
// Only inline if requested or if the item would otherwise be stripped
if
!
please_inline
&&
!
is_private
&&
!
is_hidden
{
if
(
!
please_inline
&&
!
is_private
&&
!
is_hidden
)
||
is_no_inline
{
return
false
}
...
...
src/test/rustdoc/inline_local/issue-32343.rs
0 → 100644
浏览文件 @
4c71347e
// Copyright 2016 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// @!has issue_32343/struct.Foo.html
// @has issue_32343/index.html
// @has - '//code' 'pub use foo::Foo'
// @!has - '//code/a' 'Foo'
#[doc(no_inline)]
pub
use
foo
::
Foo
;
// @!has issue_32343/struct.Bar.html
// @has issue_32343/index.html
// @has - '//code' 'pub use foo::Bar'
// @has - '//code/a' 'Bar'
#[doc(no_inline)]
pub
use
foo
::
Bar
;
mod
foo
{
pub
struct
Foo
;
pub
struct
Bar
;
}
pub
mod
bar
{
// @has issue_32343/bar/struct.Bar.html
pub
use
::
foo
::
Bar
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录