Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b000cf07
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,发现更多精彩内容 >>
提交
b000cf07
编写于
6月 04, 2018
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add lint for intra link resolution failure
上级
40f20b53
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
76 addition
and
9 deletion
+76
-9
src/librustc/lint/builtin.rs
src/librustc/lint/builtin.rs
+7
-0
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+15
-5
src/librustdoc/core.rs
src/librustdoc/core.rs
+24
-4
src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs
src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs
+14
-0
src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr
...test/rustdoc-ui/deny-intra-link-resolution-failure.stderr
+16
-0
未找到文件。
src/librustc/lint/builtin.rs
浏览文件 @
b000cf07
...
...
@@ -298,6 +298,12 @@
"detects duplicate macro exports"
}
declare_lint!
{
pub
INTRA_LINK_RESOLUTION_FAILURE
,
Warn
,
"warn about documentation intra links resolution failure"
}
/// Does nothing as a lint pass, but registers some `Lint`s
/// which are used by other parts of the compiler.
#[derive(Copy,
Clone)]
...
...
@@ -351,6 +357,7 @@ fn get_lints(&self) -> LintArray {
UNSTABLE_NAME_COLLISIONS
,
DUPLICATE_ASSOCIATED_TYPE_BINDINGS
,
DUPLICATE_MACRO_EXPORTS
,
INTRA_LINK_RESOLUTION_FAILURE
,
)
}
}
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
b000cf07
...
...
@@ -21,7 +21,7 @@
use
syntax
;
use
rustc_target
::
spec
::
abi
::
Abi
;
use
syntax
::
ast
::{
self
,
AttrStyle
,
Ident
};
use
syntax
::
ast
::{
self
,
AttrStyle
,
NodeId
,
Ident
};
use
syntax
::
attr
;
use
syntax
::
codemap
::{
dummy_spanned
,
Spanned
};
use
syntax
::
feature_gate
::
UnstableFeatures
;
...
...
@@ -46,9 +46,10 @@
use
rustc
::
util
::
nodemap
::{
FxHashMap
,
FxHashSet
};
use
rustc_typeck
::
hir_ty_to_ty
;
use
rustc
::
infer
::
region_constraints
::{
RegionConstraintData
,
Constraint
};
use
rustc
::
lint
as
lint
;
use
std
::
collections
::
hash_map
::
Entry
;
use
std
::
fmt
;
use
std
::
default
::
Default
;
use
std
::{
mem
,
slice
,
vec
};
use
std
::
iter
::{
FromIterator
,
once
};
...
...
@@ -1283,10 +1284,16 @@ fn resolution_failure(
link_range
.end
+
code_dox_len
,
);
diag
=
cx
.sess
()
.struct_span_warn
(
sp
,
&
msg
);
diag
=
cx
.tcx
.struct_span_lint_node
(
lint
::
builtin
::
INTRA_LINK_RESOLUTION_FAILURE
,
NodeId
::
new
(
0
),
sp
,
&
msg
);
diag
.span_label
(
sp
,
"cannot be resolved, ignoring"
);
}
else
{
diag
=
cx
.sess
()
.struct_span_warn
(
sp
,
&
msg
);
diag
=
cx
.tcx
.struct_span_lint_node
(
lint
::
builtin
::
INTRA_LINK_RESOLUTION_FAILURE
,
NodeId
::
new
(
0
),
sp
,
&
msg
);
let
last_new_line_offset
=
dox
[
..
link_range
.start
]
.rfind
(
'\n'
)
.map_or
(
0
,
|
n
|
n
+
1
);
let
line
=
dox
[
last_new_line_offset
..
]
.lines
()
.next
()
.unwrap_or
(
""
);
...
...
@@ -1303,7 +1310,10 @@ fn resolution_failure(
}
diag
}
else
{
cx
.sess
()
.struct_span_warn
(
sp
,
&
msg
)
cx
.tcx
.struct_span_lint_node
(
lint
::
builtin
::
INTRA_LINK_RESOLUTION_FAILURE
,
NodeId
::
new
(
0
),
sp
,
&
msg
)
};
diag
.emit
();
}
...
...
src/librustdoc/core.rs
浏览文件 @
b000cf07
...
...
@@ -17,7 +17,7 @@
use
rustc
::
middle
::
privacy
::
AccessLevels
;
use
rustc
::
ty
::{
self
,
TyCtxt
,
AllArenas
};
use
rustc
::
hir
::
map
as
hir_map
;
use
rustc
::
lint
;
use
rustc
::
lint
::{
self
,
LintPass
}
;
use
rustc
::
session
::
config
::
ErrorOutputType
;
use
rustc
::
util
::
nodemap
::{
FxHashMap
,
FxHashSet
};
use
rustc_resolve
as
resolve
;
...
...
@@ -187,7 +187,23 @@ pub fn run_core(search_paths: SearchPaths,
_
=>
None
};
let
warning_lint
=
lint
::
builtin
::
WARNINGS
.name_lower
();
let
intra_link_resolution_failure_name
=
lint
::
builtin
::
INTRA_LINK_RESOLUTION_FAILURE
.name
;
let
warnings_lint_name
=
lint
::
builtin
::
WARNINGS
.name
;
let
lints
=
lint
::
builtin
::
HardwiredLints
.get_lints
()
.iter
()
.filter_map
(|
lint
|
{
if
lint
.name
==
warnings_lint_name
{
None
}
else
{
let
level
=
if
lint
.name
==
intra_link_resolution_failure_name
{
lint
::
Warn
}
else
{
lint
::
Allow
};
Some
((
lint
.name_lower
(),
level
))
}
})
.collect
::
<
Vec
<
_
>>
();
let
host_triple
=
TargetTriple
::
from_triple
(
config
::
host_triple
());
// plays with error output here!
...
...
@@ -195,8 +211,12 @@ pub fn run_core(search_paths: SearchPaths,
maybe_sysroot
,
search_paths
,
crate_types
:
vec!
[
config
::
CrateTypeRlib
],
lint_opts
:
if
!
allow_warnings
{
vec!
[(
warning_lint
,
lint
::
Allow
)]
}
else
{
vec!
[]
},
lint_cap
:
Some
(
lint
::
Allow
),
lint_opts
:
if
!
allow_warnings
{
lints
}
else
{
vec!
[]
},
lint_cap
:
Some
(
lint
::
Warn
),
cg
,
externs
,
target_triple
:
triple
.unwrap_or
(
host_triple
),
...
...
src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs
0 → 100644
浏览文件 @
b000cf07
// Copyright 2015 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.
#![deny(intra_link_resolution_failure)]
/// [v2] //~ ERROR
pub
fn
foo
()
{}
src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr
0 → 100644
浏览文件 @
b000cf07
warning: [v2] cannot be resolved, ignoring it...
--> src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs:13:1
|
LL | /// [v2] //~ ERROR
| ^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs:11:9
|
LL | #![deny(intra_link_resolution_failure)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: the link appears in this line:
[v2] //~ ERROR
^^
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录