Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
62ac10ff
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,发现更多精彩内容 >>
提交
62ac10ff
编写于
1月 05, 2020
作者:
M
Mazdak Farrokhzad
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simplify reexports in rustc::hir
上级
77858341
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
72 addition
and
78 deletion
+72
-78
src/librustc/hir.rs
src/librustc/hir.rs
+0
-11
src/librustc/hir/intravisit.rs
src/librustc/hir/intravisit.rs
+1
-1
src/librustc_ast_lowering/expr.rs
src/librustc_ast_lowering/expr.rs
+4
-4
src/librustc_ast_lowering/lib.rs
src/librustc_ast_lowering/lib.rs
+14
-10
src/librustc_lint/types.rs
src/librustc_lint/types.rs
+2
-2
src/librustc_mir/hair/pattern/mod.rs
src/librustc_mir/hair/pattern/mod.rs
+1
-1
src/librustc_mir/transform/check_unsafety.rs
src/librustc_mir/transform/check_unsafety.rs
+1
-1
src/librustc_passes/region.rs
src/librustc_passes/region.rs
+1
-1
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+1
-1
src/librustc_resolve/lifetimes.rs
src/librustc_resolve/lifetimes.rs
+2
-2
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+8
-8
src/librustc_typeck/check/closure.rs
src/librustc_typeck/check/closure.rs
+3
-3
src/librustc_typeck/check/expr.rs
src/librustc_typeck/check/expr.rs
+6
-6
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/confirm.rs
+2
-2
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+5
-4
src/librustc_typeck/check/op.rs
src/librustc_typeck/check/op.rs
+6
-6
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/check/regionck.rs
+2
-2
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/check/writeback.rs
+2
-2
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+1
-1
src/librustc_typeck/expr_use_visitor.rs
src/librustc_typeck/expr_use_visitor.rs
+1
-1
src/librustc_typeck/mem_categorization.rs
src/librustc_typeck/mem_categorization.rs
+1
-1
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+2
-2
src/librustdoc/clean/utils.rs
src/librustdoc/clean/utils.rs
+6
-6
未找到文件。
src/librustc/hir.rs
浏览文件 @
62ac10ff
...
...
@@ -3,22 +3,11 @@
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/hir.html
pub
mod
check_attr
;
pub
use
rustc_hir
::
def
;
pub
mod
exports
;
pub
use
rustc_hir
::
def_id
;
pub
use
rustc_hir
::
hir_id
::
*
;
pub
mod
intravisit
;
pub
use
rustc_hir
::
itemlikevisit
;
pub
mod
map
;
pub
use
rustc_hir
::
pat_util
;
pub
use
rustc_hir
::
print
;
pub
mod
upvars
;
pub
use
rustc_hir
::
BlockCheckMode
::
*
;
pub
use
rustc_hir
::
FunctionRetTy
::
*
;
pub
use
rustc_hir
::
PrimTy
::
*
;
pub
use
rustc_hir
::
UnOp
::
*
;
pub
use
rustc_hir
::
UnsafeSource
::
*
;
pub
use
rustc_hir
::
*
;
use
crate
::
ty
::
query
::
Providers
;
...
...
src/librustc/hir/intravisit.rs
浏览文件 @
62ac10ff
...
...
@@ -867,7 +867,7 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(
}
pub
fn
walk_fn_ret_ty
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
ret_ty
:
&
'v
FunctionRetTy
<
'v
>
)
{
if
let
Return
(
ref
output_ty
)
=
*
ret_ty
{
if
let
FunctionRetTy
::
Return
(
ref
output_ty
)
=
*
ret_ty
{
visitor
.visit_ty
(
output_ty
)
}
}
...
...
src/librustc_ast_lowering/expr.rs
浏览文件 @
62ac10ff
...
...
@@ -207,9 +207,9 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
fn
lower_unop
(
&
mut
self
,
u
:
UnOp
)
->
hir
::
UnOp
{
match
u
{
UnOp
::
Deref
=>
hir
::
UnDeref
,
UnOp
::
Not
=>
hir
::
UnNot
,
UnOp
::
Neg
=>
hir
::
UnNeg
,
UnOp
::
Deref
=>
hir
::
Un
Op
::
Un
Deref
,
UnOp
::
Not
=>
hir
::
Un
Op
::
Un
Not
,
UnOp
::
Neg
=>
hir
::
Un
Op
::
Un
Neg
,
}
}
...
...
@@ -1374,7 +1374,7 @@ fn expr_unsafe(&mut self, expr: &'hir hir::Expr<'hir>) -> hir::Expr<'hir> {
stmts
:
&
[],
expr
:
Some
(
expr
),
hir_id
,
rules
:
hir
::
UnsafeBlock
(
hir
::
CompilerGenerated
),
rules
:
hir
::
BlockCheckMode
::
UnsafeBlock
(
hir
::
UnsafeSource
::
CompilerGenerated
),
span
,
targeted_by_break
:
false
,
}),
...
...
src/librustc_ast_lowering/lib.rs
浏览文件 @
62ac10ff
...
...
@@ -2144,12 +2144,14 @@ fn lower_fn_decl(
}
else
{
match
decl
.output
{
FunctionRetTy
::
Ty
(
ref
ty
)
=>
match
in_band_ty_params
{
Some
((
def_id
,
_
))
if
impl_trait_return_allow
=>
{
hir
::
Return
(
self
.lower_ty
(
ty
,
ImplTraitContext
::
OpaqueTy
(
Some
(
def_id
))))
}
_
=>
hir
::
Return
(
self
.lower_ty
(
ty
,
ImplTraitContext
::
disallowed
())),
Some
((
def_id
,
_
))
if
impl_trait_return_allow
=>
hir
::
FunctionRetTy
::
Return
(
self
.lower_ty
(
ty
,
ImplTraitContext
::
OpaqueTy
(
Some
(
def_id
))),
),
_
=>
hir
::
FunctionRetTy
::
Return
(
self
.lower_ty
(
ty
,
ImplTraitContext
::
disallowed
()),
),
},
FunctionRetTy
::
Default
(
span
)
=>
hir
::
DefaultReturn
(
span
),
FunctionRetTy
::
Default
(
span
)
=>
hir
::
FunctionRetTy
::
DefaultReturn
(
span
),
}
};
...
...
@@ -2940,8 +2942,10 @@ fn lower_anon_const(&mut self, c: &AnonConst) -> hir::AnonConst {
fn
lower_block_check_mode
(
&
mut
self
,
b
:
&
BlockCheckMode
)
->
hir
::
BlockCheckMode
{
match
*
b
{
BlockCheckMode
::
Default
=>
hir
::
DefaultBlock
,
BlockCheckMode
::
Unsafe
(
u
)
=>
hir
::
UnsafeBlock
(
self
.lower_unsafe_source
(
u
)),
BlockCheckMode
::
Default
=>
hir
::
BlockCheckMode
::
DefaultBlock
,
BlockCheckMode
::
Unsafe
(
u
)
=>
{
hir
::
BlockCheckMode
::
UnsafeBlock
(
self
.lower_unsafe_source
(
u
))
}
}
}
...
...
@@ -2956,8 +2960,8 @@ fn lower_binding_mode(&mut self, b: &BindingMode) -> hir::BindingAnnotation {
fn
lower_unsafe_source
(
&
mut
self
,
u
:
UnsafeSource
)
->
hir
::
UnsafeSource
{
match
u
{
CompilerGenerated
=>
hir
::
CompilerGenerated
,
UserProvided
=>
hir
::
UserProvided
,
CompilerGenerated
=>
hir
::
UnsafeSource
::
CompilerGenerated
,
UserProvided
=>
hir
::
U
nsafeSource
::
U
serProvided
,
}
}
...
...
@@ -3004,7 +3008,7 @@ fn block_all(
stmts
,
expr
,
hir_id
:
self
.next_id
(),
rules
:
hir
::
DefaultBlock
,
rules
:
hir
::
BlockCheckMode
::
DefaultBlock
,
span
,
targeted_by_break
:
false
,
};
...
...
src/librustc_lint/types.rs
浏览文件 @
62ac10ff
...
...
@@ -376,7 +376,7 @@ fn lint_literal<'a, 'tcx>(
impl
<
'a
,
'tcx
>
LateLintPass
<
'a
,
'tcx
>
for
TypeLimits
{
fn
check_expr
(
&
mut
self
,
cx
:
&
LateContext
<
'a
,
'tcx
>
,
e
:
&
'tcx
hir
::
Expr
<
'tcx
>
)
{
match
e
.kind
{
hir
::
ExprKind
::
Unary
(
hir
::
UnNeg
,
ref
expr
)
=>
{
hir
::
ExprKind
::
Unary
(
hir
::
Un
Op
::
Un
Neg
,
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
;
...
...
@@ -969,7 +969,7 @@ fn check_foreign_fn(&mut self, id: hir::HirId, decl: &hir::FnDecl<'_>) {
self
.check_type_for_ffi_and_report_errors
(
input_hir
.span
,
input_ty
,
false
);
}
if
let
hir
::
Return
(
ref
ret_hir
)
=
decl
.output
{
if
let
hir
::
FunctionRetTy
::
Return
(
ref
ret_hir
)
=
decl
.output
{
let
ret_ty
=
sig
.output
();
if
!
ret_ty
.is_unit
()
{
self
.check_type_for_ffi_and_report_errors
(
ret_hir
.span
,
ret_ty
,
false
);
...
...
src/librustc_mir/hair/pattern/mod.rs
浏览文件 @
62ac10ff
...
...
@@ -814,7 +814,7 @@ fn lower_lit(&mut self, expr: &'tcx hir::Expr<'tcx>) -> PatKind<'tcx> {
}
}
hir
::
ExprKind
::
Path
(
ref
qpath
)
=>
*
self
.lower_path
(
qpath
,
expr
.hir_id
,
expr
.span
)
.kind
,
hir
::
ExprKind
::
Unary
(
hir
::
UnNeg
,
ref
expr
)
=>
{
hir
::
ExprKind
::
Unary
(
hir
::
Un
Op
::
Un
Neg
,
ref
expr
)
=>
{
let
ty
=
self
.tables
.expr_ty
(
expr
);
let
lit
=
match
expr
.kind
{
hir
::
ExprKind
::
Lit
(
ref
lit
)
=>
lit
,
...
...
src/librustc_mir/transform/check_unsafety.rs
浏览文件 @
62ac10ff
...
...
@@ -482,7 +482,7 @@ fn nested_visit_map<'this>(&'this mut self) -> hir::intravisit::NestedVisitorMap
fn
visit_block
(
&
mut
self
,
block
:
&
'tcx
hir
::
Block
<
'tcx
>
)
{
hir
::
intravisit
::
walk_block
(
self
,
block
);
if
let
hir
::
UnsafeBlock
(
hir
::
UserProvided
)
=
block
.rules
{
if
let
hir
::
BlockCheckMode
::
UnsafeBlock
(
hir
::
UnsafeSource
::
UserProvided
)
=
block
.rules
{
self
.unsafe_blocks
.push
((
block
.hir_id
,
self
.used_unsafe
.contains
(
&
block
.hir_id
)));
}
}
...
...
src/librustc_passes/region.rs
浏览文件 @
62ac10ff
...
...
@@ -651,7 +651,7 @@ fn record_rvalue_scope<'tcx>(
match
expr
.kind
{
hir
::
ExprKind
::
AddrOf
(
_
,
_
,
ref
subexpr
)
|
hir
::
ExprKind
::
Unary
(
hir
::
UnDeref
,
ref
subexpr
)
|
hir
::
ExprKind
::
Unary
(
hir
::
Un
Op
::
Un
Deref
,
ref
subexpr
)
|
hir
::
ExprKind
::
Field
(
ref
subexpr
,
_
)
|
hir
::
ExprKind
::
Index
(
ref
subexpr
,
_
)
=>
{
expr
=
&
subexpr
;
...
...
src/librustc_resolve/lib.rs
浏览文件 @
62ac10ff
...
...
@@ -26,7 +26,7 @@
use
rustc
::
hir
::
def_id
::{
CrateNum
,
DefId
,
DefIdMap
,
CRATE_DEF_INDEX
,
LOCAL_CRATE
};
use
rustc
::
hir
::
exports
::
ExportMap
;
use
rustc
::
hir
::
map
::
Definitions
;
use
rustc
::
hir
::
{
Bool
,
Char
,
Float
,
Int
,
PrimTy
,
Str
,
Uint
};
use
rustc
::
hir
::
PrimTy
::{
self
,
Bool
,
Char
,
Float
,
Int
,
Str
,
Uint
};
use
rustc
::
hir
::{
GlobMap
,
TraitMap
};
use
rustc
::
lint
;
use
rustc
::
middle
::
cstore
::{
CrateStore
,
MetadataLoaderDyn
};
...
...
src/librustc_resolve/lifetimes.rs
浏览文件 @
62ac10ff
...
...
@@ -846,8 +846,8 @@ fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, _: hir::HirId) {
fn
visit_fn_decl
(
&
mut
self
,
fd
:
&
'tcx
hir
::
FnDecl
<
'tcx
>
)
{
let
output
=
match
fd
.output
{
hir
::
DefaultReturn
(
_
)
=>
None
,
hir
::
Return
(
ref
ty
)
=>
Some
(
&**
ty
),
hir
::
FunctionRetTy
::
DefaultReturn
(
_
)
=>
None
,
hir
::
FunctionRetTy
::
Return
(
ref
ty
)
=>
Some
(
&**
ty
),
};
self
.visit_fn_like_elision
(
&
fd
.inputs
,
output
);
}
...
...
src/librustc_typeck/astconv.rs
浏览文件 @
62ac10ff
...
...
@@ -2554,12 +2554,12 @@ pub fn res_to_ty(
assert_eq!
(
opt_self_ty
,
None
);
self
.prohibit_generics
(
path
.segments
);
match
prim_ty
{
hir
::
Bool
=>
tcx
.types.bool
,
hir
::
Char
=>
tcx
.types.char
,
hir
::
Int
(
it
)
=>
tcx
.mk_mach_int
(
it
),
hir
::
Uint
(
uit
)
=>
tcx
.mk_mach_uint
(
uit
),
hir
::
Float
(
ft
)
=>
tcx
.mk_mach_float
(
ft
),
hir
::
Str
=>
tcx
.mk_str
(),
hir
::
PrimTy
::
Bool
=>
tcx
.types.bool
,
hir
::
PrimTy
::
Char
=>
tcx
.types.char
,
hir
::
PrimTy
::
Int
(
it
)
=>
tcx
.mk_mach_int
(
it
),
hir
::
PrimTy
::
Uint
(
uit
)
=>
tcx
.mk_mach_uint
(
uit
),
hir
::
PrimTy
::
Float
(
ft
)
=>
tcx
.mk_mach_float
(
ft
),
hir
::
PrimTy
::
Str
=>
tcx
.mk_str
(),
}
}
Res
::
Err
=>
{
...
...
@@ -2773,11 +2773,11 @@ pub fn ty_of_fn(
}
let
input_tys
=
decl
.inputs
.iter
()
.map
(|
a
|
self
.ty_of_arg
(
a
,
None
));
let
output_ty
=
match
decl
.output
{
hir
::
Return
(
ref
output
)
=>
{
hir
::
FunctionRetTy
::
Return
(
ref
output
)
=>
{
visitor
.visit_ty
(
output
);
self
.ast_ty_to_ty
(
output
)
}
hir
::
DefaultReturn
(
..
)
=>
tcx
.mk_unit
(),
hir
::
FunctionRetTy
::
DefaultReturn
(
..
)
=>
tcx
.mk_unit
(),
};
debug!
(
"ty_of_fn: output_ty={:?}"
,
output_ty
);
...
...
src/librustc_typeck/check/closure.rs
浏览文件 @
62ac10ff
...
...
@@ -548,8 +548,8 @@ fn supplied_sig_of_closure(
// First, convert the types that the user supplied (if any).
let
supplied_arguments
=
decl
.inputs
.iter
()
.map
(|
a
|
astconv
.ast_ty_to_ty
(
a
));
let
supplied_return
=
match
decl
.output
{
hir
::
Return
(
ref
output
)
=>
astconv
.ast_ty_to_ty
(
&
output
),
hir
::
DefaultReturn
(
_
)
=>
match
body
.generator_kind
{
hir
::
FunctionRetTy
::
Return
(
ref
output
)
=>
astconv
.ast_ty_to_ty
(
&
output
),
hir
::
FunctionRetTy
::
DefaultReturn
(
_
)
=>
match
body
.generator_kind
{
// In the case of the async block that we create for a function body,
// we expect the return type of the block to match that of the enclosing
// function.
...
...
@@ -696,7 +696,7 @@ fn error_sig_of_closure(&self, decl: &hir::FnDecl<'_>) -> ty::PolyFnSig<'tcx> {
self
.tcx.types.err
});
if
let
hir
::
Return
(
ref
output
)
=
decl
.output
{
if
let
hir
::
FunctionRetTy
::
Return
(
ref
output
)
=
decl
.output
{
astconv
.ast_ty_to_ty
(
&
output
);
}
...
...
src/librustc_typeck/check/expr.rs
浏览文件 @
62ac10ff
...
...
@@ -306,11 +306,11 @@ fn check_expr_unary(
)
->
Ty
<
'tcx
>
{
let
tcx
=
self
.tcx
;
let
expected_inner
=
match
unop
{
hir
::
Un
Not
|
hir
::
UnNeg
=>
expected
,
hir
::
UnDeref
=>
NoExpectation
,
hir
::
Un
Op
::
UnNot
|
hir
::
UnOp
::
UnNeg
=>
expected
,
hir
::
Un
Op
::
Un
Deref
=>
NoExpectation
,
};
let
needs
=
match
unop
{
hir
::
UnDeref
=>
needs
,
hir
::
Un
Op
::
Un
Deref
=>
needs
,
_
=>
Needs
::
None
,
};
let
mut
oprnd_t
=
self
.check_expr_with_expectation_and_needs
(
&
oprnd
,
expected_inner
,
needs
);
...
...
@@ -318,7 +318,7 @@ fn check_expr_unary(
if
!
oprnd_t
.references_error
()
{
oprnd_t
=
self
.structurally_resolved_type
(
expr
.span
,
oprnd_t
);
match
unop
{
hir
::
UnDeref
=>
{
hir
::
Un
Op
::
Un
Deref
=>
{
if
let
Some
(
mt
)
=
oprnd_t
.builtin_deref
(
true
)
{
oprnd_t
=
mt
.ty
;
}
else
if
let
Some
(
ok
)
=
self
.try_overloaded_deref
(
expr
.span
,
oprnd_t
,
needs
)
{
...
...
@@ -362,14 +362,14 @@ fn check_expr_unary(
oprnd_t
=
tcx
.types.err
;
}
}
hir
::
UnNot
=>
{
hir
::
Un
Op
::
Un
Not
=>
{
let
result
=
self
.check_user_unop
(
expr
,
oprnd_t
,
unop
);
// If it's builtin, we can reuse the type, this helps inference.
if
!
(
oprnd_t
.is_integral
()
||
oprnd_t
.kind
==
ty
::
Bool
)
{
oprnd_t
=
result
;
}
}
hir
::
UnNeg
=>
{
hir
::
Un
Op
::
Un
Neg
=>
{
let
result
=
self
.check_user_unop
(
expr
,
oprnd_t
,
unop
);
// If it's builtin, we can reuse the type, this helps inference.
if
!
oprnd_t
.is_numeric
()
{
...
...
src/librustc_typeck/check/method/confirm.rs
浏览文件 @
62ac10ff
...
...
@@ -425,7 +425,7 @@ fn convert_place_derefs_to_mutable(&self) {
match
exprs
.last
()
.unwrap
()
.kind
{
hir
::
ExprKind
::
Field
(
ref
expr
,
_
)
|
hir
::
ExprKind
::
Index
(
ref
expr
,
_
)
|
hir
::
ExprKind
::
Unary
(
hir
::
UnDeref
,
ref
expr
)
=>
exprs
.push
(
&
expr
),
|
hir
::
ExprKind
::
Unary
(
hir
::
Un
Op
::
Un
Deref
,
ref
expr
)
=>
exprs
.push
(
&
expr
),
_
=>
break
,
}
}
...
...
@@ -471,7 +471,7 @@ fn convert_place_derefs_to_mutable(&self) {
&
[
index_expr_ty
],
);
}
hir
::
ExprKind
::
Unary
(
hir
::
UnDeref
,
ref
base_expr
)
=>
{
hir
::
ExprKind
::
Unary
(
hir
::
Un
Op
::
Un
Deref
,
ref
base_expr
)
=>
{
self
.convert_place_op_to_mutable
(
PlaceOp
::
Deref
,
expr
,
base_expr
,
&
[]);
}
_
=>
{}
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
62ac10ff
...
...
@@ -390,6 +390,7 @@ pub fn function(unsafety: hir::Unsafety, def: hir::HirId) -> UnsafetyState {
}
pub
fn
recurse
(
&
mut
self
,
blk
:
&
hir
::
Block
<
'_
>
)
->
UnsafetyState
{
use
hir
::
BlockCheckMode
;
match
self
.unsafety
{
// If this unsafe, then if the outer function was already marked as
// unsafe we shouldn't attribute the unsafe'ness to the block. This
...
...
@@ -399,16 +400,16 @@ pub fn recurse(&mut self, blk: &hir::Block<'_>) -> UnsafetyState {
unsafety
=>
{
let
(
unsafety
,
def
,
count
)
=
match
blk
.rules
{
hir
::
PushUnsafeBlock
(
..
)
=>
{
BlockCheckMode
::
PushUnsafeBlock
(
..
)
=>
{
(
unsafety
,
blk
.hir_id
,
self
.unsafe_push_count
.checked_add
(
1
)
.unwrap
())
}
hir
::
PopUnsafeBlock
(
..
)
=>
{
BlockCheckMode
::
PopUnsafeBlock
(
..
)
=>
{
(
unsafety
,
blk
.hir_id
,
self
.unsafe_push_count
.checked_sub
(
1
)
.unwrap
())
}
hir
::
UnsafeBlock
(
..
)
=>
{
BlockCheckMode
::
UnsafeBlock
(
..
)
=>
{
(
hir
::
Unsafety
::
Unsafe
,
blk
.hir_id
,
self
.unsafe_push_count
)
}
hir
::
DefaultBlock
=>
(
unsafety
,
self
.def
,
self
.unsafe_push_count
),
BlockCheckMode
::
DefaultBlock
=>
(
unsafety
,
self
.def
,
self
.unsafe_push_count
),
};
UnsafetyState
{
def
,
unsafety
,
unsafe_push_count
:
count
,
from_fn
:
false
}
}
...
...
src/librustc_typeck/check/op.rs
浏览文件 @
62ac10ff
...
...
@@ -689,16 +689,16 @@ pub fn check_user_unop(
),
);
match
actual
.kind
{
Uint
(
_
)
if
op
==
hir
::
UnNeg
=>
{
Uint
(
_
)
if
op
==
hir
::
Un
Op
::
Un
Neg
=>
{
err
.note
(
"unsigned values cannot be negated"
);
}
Str
|
Never
|
Char
|
Tuple
(
_
)
|
Array
(
_
,
_
)
=>
{}
Ref
(
_
,
ref
lty
,
_
)
if
lty
.kind
==
Str
=>
{}
_
=>
{
let
missing_trait
=
match
op
{
hir
::
UnNeg
=>
"std::ops::Neg"
,
hir
::
UnNot
=>
"std::ops::Not"
,
hir
::
UnDeref
=>
"std::ops::UnDerf"
,
hir
::
Un
Op
::
Un
Neg
=>
"std::ops::Neg"
,
hir
::
Un
Op
::
Un
Not
=>
"std::ops::Not"
,
hir
::
Un
Op
::
Un
Deref
=>
"std::ops::UnDerf"
,
};
err
.note
(
&
format!
(
"an implementation of `{}` might
\
...
...
@@ -771,9 +771,9 @@ fn lookup_op_method(
span_bug!
(
span
,
"&& and || are not overloadable"
)
}
}
}
else
if
let
Op
::
Unary
(
hir
::
UnNot
,
_
)
=
op
{
}
else
if
let
Op
::
Unary
(
hir
::
Un
Op
::
Un
Not
,
_
)
=
op
{
(
"not"
,
lang
.not_trait
())
}
else
if
let
Op
::
Unary
(
hir
::
UnNeg
,
_
)
=
op
{
}
else
if
let
Op
::
Unary
(
hir
::
Un
Op
::
Un
Neg
,
_
)
=
op
{
(
"neg"
,
lang
.neg_trait
())
}
else
{
bug!
(
"lookup_op_method: op not supported: {:?}"
,
op
)
...
...
src/librustc_typeck/check/regionck.rs
浏览文件 @
62ac10ff
...
...
@@ -492,7 +492,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
if
is_method_call
{
let
origin
=
match
expr
.kind
{
hir
::
ExprKind
::
MethodCall
(
..
)
=>
infer
::
ParameterOrigin
::
MethodCall
,
hir
::
ExprKind
::
Unary
(
op
,
_
)
if
op
==
hir
::
UnDeref
=>
{
hir
::
ExprKind
::
Unary
(
op
,
_
)
if
op
==
hir
::
Un
Op
::
Un
Deref
=>
{
infer
::
ParameterOrigin
::
OverloadedDeref
}
_
=>
infer
::
ParameterOrigin
::
OverloadedOperator
,
...
...
@@ -577,7 +577,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
intravisit
::
walk_expr
(
self
,
expr
);
}
hir
::
ExprKind
::
Unary
(
hir
::
UnDeref
,
ref
base
)
=>
{
hir
::
ExprKind
::
Unary
(
hir
::
Un
Op
::
Un
Deref
,
ref
base
)
=>
{
// For *a, the lifetime of a must enclose the deref
if
is_method_call
{
self
.constrain_call
(
expr
,
Some
(
base
),
None
::
<
hir
::
Expr
<
'_
>>
.iter
());
...
...
src/librustc_typeck/check/writeback.rs
浏览文件 @
62ac10ff
...
...
@@ -133,8 +133,8 @@ fn write_ty_to_tables(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) {
// operating on scalars, we clear the overload.
fn
fix_scalar_builtin_expr
(
&
mut
self
,
e
:
&
hir
::
Expr
<
'_
>
)
{
match
e
.kind
{
hir
::
ExprKind
::
Unary
(
hir
::
UnNeg
,
ref
inner
)
|
hir
::
ExprKind
::
Unary
(
hir
::
UnNot
,
ref
inner
)
=>
{
hir
::
ExprKind
::
Unary
(
hir
::
Un
Op
::
Un
Neg
,
ref
inner
)
|
hir
::
ExprKind
::
Unary
(
hir
::
Un
Op
::
Un
Not
,
ref
inner
)
=>
{
let
inner_ty
=
self
.fcx
.node_ty
(
inner
.hir_id
);
let
inner_ty
=
self
.fcx
.resolve_vars_if_possible
(
&
inner_ty
);
...
...
src/librustc_typeck/collect.rs
浏览文件 @
62ac10ff
...
...
@@ -2499,7 +2499,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
for
(
input
,
ty
)
in
decl
.inputs
.iter
()
.zip
(
*
fty
.inputs
()
.skip_binder
())
{
check
(
&
input
,
ty
)
}
if
let
hir
::
Return
(
ref
ty
)
=
decl
.output
{
if
let
hir
::
FunctionRetTy
::
Return
(
ref
ty
)
=
decl
.output
{
check
(
&
ty
,
*
fty
.output
()
.skip_binder
())
}
}
...
...
src/librustc_typeck/expr_use_visitor.rs
浏览文件 @
62ac10ff
...
...
@@ -192,7 +192,7 @@ pub fn walk_expr(&mut self, expr: &hir::Expr<'_>) {
hir
::
ExprKind
::
Type
(
ref
subexpr
,
_
)
=>
self
.walk_expr
(
subexpr
),
hir
::
ExprKind
::
Unary
(
hir
::
UnDeref
,
ref
base
)
=>
{
hir
::
ExprKind
::
Unary
(
hir
::
Un
Op
::
Un
Deref
,
ref
base
)
=>
{
// *base
self
.select_from_expr
(
base
);
}
...
...
src/librustc_typeck/mem_categorization.rs
浏览文件 @
62ac10ff
...
...
@@ -347,7 +347,7 @@ fn cat_expr_adjusted_with<F>(
let
expr_ty
=
self
.expr_ty
(
expr
)
?
;
match
expr
.kind
{
hir
::
ExprKind
::
Unary
(
hir
::
UnDeref
,
ref
e_base
)
=>
{
hir
::
ExprKind
::
Unary
(
hir
::
Un
Op
::
Un
Deref
,
ref
e_base
)
=>
{
if
self
.tables
.is_method_call
(
expr
)
{
self
.cat_overloaded_place
(
expr
,
e_base
)
}
else
{
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
62ac10ff
...
...
@@ -1003,8 +1003,8 @@ fn clean(&self, cx: &DocContext<'_>) -> FnDecl {
impl
Clean
<
FunctionRetTy
>
for
hir
::
FunctionRetTy
<
'_
>
{
fn
clean
(
&
self
,
cx
:
&
DocContext
<
'_
>
)
->
FunctionRetTy
{
match
*
self
{
hir
::
Return
(
ref
typ
)
=>
Return
(
typ
.clean
(
cx
)),
hir
::
DefaultReturn
(
..
)
=>
DefaultReturn
,
Self
::
Return
(
ref
typ
)
=>
Return
(
typ
.clean
(
cx
)),
Self
::
DefaultReturn
(
..
)
=>
DefaultReturn
,
}
}
}
...
...
src/librustdoc/clean/utils.rs
浏览文件 @
62ac10ff
...
...
@@ -567,12 +567,12 @@ pub fn resolve_type(cx: &DocContext<'_>, path: Path, id: hir::HirId) -> Type {
let
is_generic
=
match
path
.res
{
Res
::
PrimTy
(
p
)
=>
match
p
{
hir
::
Str
=>
return
Primitive
(
PrimitiveType
::
Str
),
hir
::
Bool
=>
return
Primitive
(
PrimitiveType
::
Bool
),
hir
::
Char
=>
return
Primitive
(
PrimitiveType
::
Char
),
hir
::
Int
(
int_ty
)
=>
return
Primitive
(
int_ty
.into
()),
hir
::
Uint
(
uint_ty
)
=>
return
Primitive
(
uint_ty
.into
()),
hir
::
Float
(
float_ty
)
=>
return
Primitive
(
float_ty
.into
()),
hir
::
PrimTy
::
Str
=>
return
Primitive
(
PrimitiveType
::
Str
),
hir
::
PrimTy
::
Bool
=>
return
Primitive
(
PrimitiveType
::
Bool
),
hir
::
PrimTy
::
Char
=>
return
Primitive
(
PrimitiveType
::
Char
),
hir
::
PrimTy
::
Int
(
int_ty
)
=>
return
Primitive
(
int_ty
.into
()),
hir
::
PrimTy
::
Uint
(
uint_ty
)
=>
return
Primitive
(
uint_ty
.into
()),
hir
::
PrimTy
::
Float
(
float_ty
)
=>
return
Primitive
(
float_ty
.into
()),
},
Res
::
SelfTy
(
..
)
if
path
.segments
.len
()
==
1
=>
{
return
Generic
(
kw
::
SelfUpper
.to_string
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录