Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9de2a792
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,发现更多精彩内容 >>
未验证
提交
9de2a792
编写于
4月 14, 2020
作者:
D
Dylan DPC
提交者:
GitHub
4月 14, 2020
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #71092 - marmeladema:dummy-hir-id-removal, r=eddyb
Remove some usage of `DUMMY_HIR_ID`
上级
048c8426
d0409ead
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
22 addition
and
30 deletion
+22
-30
src/librustc_infer/infer/error_reporting/mod.rs
src/librustc_infer/infer/error_reporting/mod.rs
+1
-1
src/librustc_lint/builtin.rs
src/librustc_lint/builtin.rs
+4
-4
src/librustc_lint/types.rs
src/librustc_lint/types.rs
+5
-5
src/librustc_privacy/lib.rs
src/librustc_privacy/lib.rs
+4
-4
src/librustc_traits/implied_outlives_bounds.rs
src/librustc_traits/implied_outlives_bounds.rs
+1
-1
src/librustc_ty/ty.rs
src/librustc_ty/ty.rs
+1
-1
src/librustc_typeck/check/demand.rs
src/librustc_typeck/check/demand.rs
+3
-7
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/method/probe.rs
+2
-6
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+1
-1
未找到文件。
src/librustc_infer/infer/error_reporting/mod.rs
浏览文件 @
9de2a792
...
...
@@ -191,7 +191,7 @@ fn msg_span_from_early_bound_and_free_regions(
let
sm
=
tcx
.sess
.source_map
();
let
scope
=
region
.free_region_binding_scope
(
tcx
);
let
node
=
tcx
.hir
()
.as_local_hir_id
(
scope
)
.unwrap
_or
(
hir
::
DUMMY_HIR_ID
);
let
node
=
tcx
.hir
()
.as_local_hir_id
(
scope
)
.unwrap
(
);
let
tag
=
match
tcx
.hir
()
.find
(
node
)
{
Some
(
Node
::
Block
(
_
))
|
Some
(
Node
::
Expr
(
_
))
=>
"body"
,
Some
(
Node
::
Item
(
it
))
=>
item_scope_tag
(
&
it
),
...
...
src/librustc_lint/builtin.rs
浏览文件 @
9de2a792
...
...
@@ -1354,7 +1354,7 @@ fn check_pat_post(&mut self, _cx: &EarlyContext<'_>, pat: &ast::Pat) {
}
pub
struct
UnnameableTestItems
{
boundary
:
hir
::
HirId
,
// HirId of the item under which things are not nameable
boundary
:
Option
<
hir
::
HirId
>
,
// HirId of the item under which things are not nameable
items_nameable
:
bool
,
}
...
...
@@ -1362,7 +1362,7 @@ pub struct UnnameableTestItems {
impl
UnnameableTestItems
{
pub
fn
new
()
->
Self
{
Self
{
boundary
:
hir
::
DUMMY_HIR_ID
,
items_nameable
:
true
}
Self
{
boundary
:
None
,
items_nameable
:
true
}
}
}
...
...
@@ -1372,7 +1372,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item<'_>) {
if
let
hir
::
ItemKind
::
Mod
(
..
)
=
it
.kind
{
}
else
{
self
.items_nameable
=
false
;
self
.boundary
=
it
.hir_id
;
self
.boundary
=
Some
(
it
.hir_id
)
;
}
return
;
}
...
...
@@ -1385,7 +1385,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item<'_>) {
}
fn
check_item_post
(
&
mut
self
,
_
cx
:
&
LateContext
<
'_
,
'_
>
,
it
:
&
hir
::
Item
<
'_
>
)
{
if
!
self
.items_nameable
&&
self
.boundary
==
it
.hir_id
{
if
!
self
.items_nameable
&&
self
.boundary
==
Some
(
it
.hir_id
)
{
self
.items_nameable
=
true
;
}
}
...
...
src/librustc_lint/types.rs
浏览文件 @
9de2a792
...
...
@@ -43,14 +43,14 @@
#[derive(Copy,
Clone)]
pub
struct
TypeLimits
{
/// Id of the last visited negated expression
negated_expr_id
:
hir
::
HirId
,
negated_expr_id
:
Option
<
hir
::
HirId
>
,
}
impl_lint_pass!
(
TypeLimits
=>
[
UNUSED_COMPARISONS
,
OVERFLOWING_LITERALS
]);
impl
TypeLimits
{
pub
fn
new
()
->
TypeLimits
{
TypeLimits
{
negated_expr_id
:
hir
::
DUMMY_HIR_ID
}
TypeLimits
{
negated_expr_id
:
None
}
}
}
...
...
@@ -244,7 +244,7 @@ fn lint_int_literal<'a, 'tcx>(
let
int_type
=
t
.normalize
(
cx
.sess
()
.target.ptr_width
);
let
(
min
,
max
)
=
int_ty_range
(
int_type
);
let
max
=
max
as
u128
;
let
negative
=
type_limits
.negated_expr_id
==
e
.hir_id
;
let
negative
=
type_limits
.negated_expr_id
==
Some
(
e
.hir_id
)
;
// Detect literal value out of range [min, max] inclusive
// avoiding use of -min to prevent overflow/panic
...
...
@@ -397,8 +397,8 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr<'tcx>) {
match
e
.kind
{
hir
::
ExprKind
::
Unary
(
hir
::
UnOp
::
UnNeg
,
ref
expr
)
=>
{
// propagate negation, if the negation itself isn't negated
if
self
.negated_expr_id
!=
e
.hir_id
{
self
.negated_expr_id
=
expr
.hir_id
;
if
self
.negated_expr_id
!=
Some
(
e
.hir_id
)
{
self
.negated_expr_id
=
Some
(
expr
.hir_id
)
;
}
}
hir
::
ExprKind
::
Binary
(
binop
,
ref
l
,
ref
r
)
=>
{
...
...
src/librustc_privacy/lib.rs
浏览文件 @
9de2a792
...
...
@@ -1012,7 +1012,7 @@ fn visit_def_id(&mut self, def_id: DefId, _kind: &str, _descr: &dyn fmt::Display
struct
NamePrivacyVisitor
<
'a
,
'tcx
>
{
tcx
:
TyCtxt
<
'tcx
>
,
tables
:
&
'a
ty
::
TypeckTables
<
'tcx
>
,
current_item
:
hir
::
HirId
,
current_item
:
Option
<
hir
::
HirId
>
,
empty_tables
:
&
'a
ty
::
TypeckTables
<
'tcx
>
,
}
...
...
@@ -1028,7 +1028,7 @@ fn check_field(
)
{
// definition of the field
let
ident
=
Ident
::
new
(
kw
::
Invalid
,
use_ctxt
);
let
current_hir
=
self
.current_item
;
let
current_hir
=
self
.current_item
.unwrap
()
;
let
def_id
=
self
.tcx
.adjust_ident_and_get_scope
(
ident
,
def
.did
,
current_hir
)
.1
;
if
!
def
.is_enum
()
&&
!
field
.vis
.is_accessible_from
(
def_id
,
self
.tcx
)
{
let
label
=
if
in_update_syntax
{
...
...
@@ -1074,7 +1074,7 @@ fn visit_nested_body(&mut self, body: hir::BodyId) {
}
fn
visit_item
(
&
mut
self
,
item
:
&
'tcx
hir
::
Item
<
'tcx
>
)
{
let
orig_current_item
=
mem
::
replace
(
&
mut
self
.current_item
,
item
.hir_id
);
let
orig_current_item
=
mem
::
replace
(
&
mut
self
.current_item
,
Some
(
item
.hir_id
)
);
let
orig_tables
=
mem
::
replace
(
&
mut
self
.tables
,
item_tables
(
self
.tcx
,
item
.hir_id
,
self
.empty_tables
));
intravisit
::
walk_item
(
self
,
item
);
...
...
@@ -2059,7 +2059,7 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: DefId) {
let
mut
visitor
=
NamePrivacyVisitor
{
tcx
,
tables
:
&
empty_tables
,
current_item
:
hir
::
DUMMY_HIR_ID
,
current_item
:
None
,
empty_tables
:
&
empty_tables
,
};
let
(
module
,
span
,
hir_id
)
=
tcx
.hir
()
.get_module
(
module_def_id
);
...
...
src/librustc_traits/implied_outlives_bounds.rs
浏览文件 @
9de2a792
...
...
@@ -62,7 +62,7 @@ fn compute_implied_outlives_bounds<'tcx>(
// unresolved inference variables here anyway, but there might be
// during typeck under some circumstances.)
let
obligations
=
wf
::
obligations
(
infcx
,
param_env
,
hir
::
DUMMY
_HIR_ID
,
ty
,
DUMMY_SP
)
.unwrap_or
(
vec!
[]);
wf
::
obligations
(
infcx
,
param_env
,
hir
::
CRATE
_HIR_ID
,
ty
,
DUMMY_SP
)
.unwrap_or
(
vec!
[]);
// N.B., all of these predicates *ought* to be easily proven
// true. In fact, their correctness is (mostly) implied by
...
...
src/librustc_ty/ty.rs
浏览文件 @
9de2a792
...
...
@@ -265,7 +265,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
let
unnormalized_env
=
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
predicates
),
traits
::
Reveal
::
UserFacing
,
None
);
let
body_id
=
tcx
.hir
()
.as_local_hir_id
(
def_id
)
.map_or
(
hir
::
DUMMY
_HIR_ID
,
|
id
|
{
let
body_id
=
tcx
.hir
()
.as_local_hir_id
(
def_id
)
.map_or
(
hir
::
CRATE
_HIR_ID
,
|
id
|
{
tcx
.hir
()
.maybe_body_owned_by
(
id
)
.map_or
(
id
,
|
body
|
body
.hir_id
)
});
let
cause
=
traits
::
ObligationCause
::
misc
(
tcx
.def_span
(
def_id
),
body_id
);
...
...
src/librustc_typeck/check/demand.rs
浏览文件 @
9de2a792
...
...
@@ -217,14 +217,10 @@ pub fn get_conversion_methods(
span
:
Span
,
expected
:
Ty
<
'tcx
>
,
checked_ty
:
Ty
<
'tcx
>
,
hir_id
:
hir
::
HirId
,
)
->
Vec
<
AssocItem
>
{
let
mut
methods
=
self
.probe_for_return_type
(
span
,
probe
::
Mode
::
MethodCall
,
expected
,
checked_ty
,
hir
::
DUMMY_HIR_ID
,
);
let
mut
methods
=
self
.probe_for_return_type
(
span
,
probe
::
Mode
::
MethodCall
,
expected
,
checked_ty
,
hir_id
);
methods
.retain
(|
m
|
{
self
.has_no_input_arg
(
m
)
&&
self
...
...
src/librustc_typeck/check/method/probe.rs
浏览文件 @
9de2a792
...
...
@@ -452,7 +452,7 @@ fn method_autoderef_steps<'tcx>(
tcx
.infer_ctxt
()
.enter_with_canonical
(
DUMMY_SP
,
&
goal
,
|
ref
infcx
,
goal
,
inference_vars
|
{
let
ParamEnvAnd
{
param_env
,
value
:
self_ty
}
=
goal
;
let
mut
autoderef
=
Autoderef
::
new
(
infcx
,
param_env
,
hir
::
DUMMY
_HIR_ID
,
DUMMY_SP
,
self_ty
)
let
mut
autoderef
=
Autoderef
::
new
(
infcx
,
param_env
,
hir
::
CRATE
_HIR_ID
,
DUMMY_SP
,
self_ty
)
.include_raw_pointers
()
.silence_errors
();
let
mut
reached_raw_pointer
=
false
;
...
...
@@ -1512,7 +1512,6 @@ fn probe_for_lev_candidate(&mut self) -> Result<Option<ty::AssocItem>, MethodErr
);
pcx
.allow_similar_names
=
true
;
pcx
.assemble_inherent_candidates
();
pcx
.assemble_extension_candidates_for_traits_in_scope
(
hir
::
DUMMY_HIR_ID
)
?
;
let
method_names
=
pcx
.candidate_method_names
();
pcx
.allow_similar_names
=
false
;
...
...
@@ -1522,10 +1521,7 @@ fn probe_for_lev_candidate(&mut self) -> Result<Option<ty::AssocItem>, MethodErr
pcx
.reset
();
pcx
.method_name
=
Some
(
method_name
);
pcx
.assemble_inherent_candidates
();
pcx
.assemble_extension_candidates_for_traits_in_scope
(
hir
::
DUMMY_HIR_ID
)
.map_or
(
None
,
|
_
|
{
pcx
.pick_core
()
.and_then
(|
pick
|
pick
.ok
())
.map
(|
pick
|
pick
.item
)
})
pcx
.pick_core
()
.and_then
(|
pick
|
pick
.ok
())
.map
(|
pick
|
pick
.item
)
})
.collect
();
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
9de2a792
...
...
@@ -4981,7 +4981,7 @@ pub fn suggest_ref_or_into(
}
else
if
!
self
.check_for_cast
(
err
,
expr
,
found
,
expected
)
{
let
is_struct_pat_shorthand_field
=
self
.is_hir_id_from_struct_pattern_shorthand_field
(
expr
.hir_id
,
expr
.span
);
let
methods
=
self
.get_conversion_methods
(
expr
.span
,
expected
,
found
);
let
methods
=
self
.get_conversion_methods
(
expr
.span
,
expected
,
found
,
expr
.hir_id
);
if
let
Ok
(
expr_text
)
=
self
.sess
()
.source_map
()
.span_to_snippet
(
expr
.span
)
{
let
mut
suggestions
=
iter
::
repeat
(
&
expr_text
)
.zip
(
methods
.iter
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录