Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
15c1c065
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,发现更多精彩内容 >>
提交
15c1c065
编写于
6月 14, 2022
作者:
B
b-naber
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rebase
上级
e14b34c3
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
36 addition
and
82 deletion
+36
-82
compiler/rustc_const_eval/src/const_eval/mod.rs
compiler/rustc_const_eval/src/const_eval/mod.rs
+2
-2
compiler/rustc_const_eval/src/interpret/operand.rs
compiler/rustc_const_eval/src/interpret/operand.rs
+1
-1
compiler/rustc_middle/src/mir/mod.rs
compiler/rustc_middle/src/mir/mod.rs
+5
-13
compiler/rustc_middle/src/mir/pretty.rs
compiler/rustc_middle/src/mir/pretty.rs
+1
-1
compiler/rustc_middle/src/ty/consts.rs
compiler/rustc_middle/src/ty/consts.rs
+2
-2
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_middle/src/ty/context.rs
+19
-45
compiler/rustc_middle/src/ty/print/pretty.rs
compiler/rustc_middle/src/ty/print/pretty.rs
+3
-11
compiler/rustc_symbol_mangling/src/v0.rs
compiler/rustc_symbol_mangling/src/v0.rs
+1
-1
compiler/rustc_trait_selection/src/traits/fulfill.rs
compiler/rustc_trait_selection/src/traits/fulfill.rs
+1
-1
compiler/rustc_trait_selection/src/traits/select/mod.rs
compiler/rustc_trait_selection/src/traits/select/mod.rs
+1
-5
未找到文件。
compiler/rustc_const_eval/src/const_eval/mod.rs
浏览文件 @
15c1c065
...
...
@@ -97,7 +97,7 @@ pub(crate) fn try_destructure_const<'tcx>(
tcx
:
TyCtxt
<
'tcx
>
,
const_
:
ty
::
Const
<
'tcx
>
,
)
->
Option
<
ty
::
DestructuredConst
<
'tcx
>>
{
if
let
ty
::
ConstKind
::
Value
(
valtree
)
=
const_
.
val
()
{
if
let
ty
::
ConstKind
::
Value
(
valtree
)
=
const_
.
kind
()
{
let
branches
=
match
valtree
{
ty
::
ValTree
::
Branch
(
b
)
=>
b
,
_
=>
return
None
,
...
...
@@ -216,7 +216,7 @@ pub(crate) fn deref_mir_constant<'tcx>(
let
mplace
=
ecx
.deref_operand
(
&
op
)
.unwrap
();
if
let
Some
(
alloc_id
)
=
mplace
.ptr.provenance
{
assert_eq!
(
tcx
.get_global_alloc
(
alloc_id
)
.unwrap
()
.unwrap_memory
()
.0
.0
.mutability
,
tcx
.get_global_alloc
(
alloc_id
)
.unwrap
()
.unwrap_memory
()
.0.0
.mutability
,
Mutability
::
Not
,
"deref_mir_constant cannot be used with mutable allocations as
\
that could allow pattern matching to observe mutable statics"
,
...
...
compiler/rustc_const_eval/src/interpret/operand.rs
浏览文件 @
15c1c065
...
...
@@ -638,7 +638,7 @@ pub fn const_to_op(
span_bug!
(
self
.cur_span
(),
"const_to_op: Unexpected ConstKind {:?}"
,
c
)
}
ty
::
ConstKind
::
Value
(
valtree
)
=>
{
let
ty
=
val
.ty
();
let
ty
=
c
.ty
();
let
const_val
=
self
.tcx
.valtree_to_const_val
((
ty
,
valtree
));
self
.const_val_to_op
(
const_val
,
ty
,
layout
)
}
...
...
compiler/rustc_middle/src/mir/mod.rs
浏览文件 @
15c1c065
...
...
@@ -1446,11 +1446,7 @@ pub fn expand_statements<F, I>(&mut self, mut f: F)
}
pub
fn
visitable
(
&
self
,
index
:
usize
)
->
&
dyn
MirVisitable
<
'tcx
>
{
if
index
<
self
.statements
.len
()
{
&
self
.statements
[
index
]
}
else
{
&
self
.terminator
}
if
index
<
self
.statements
.len
()
{
&
self
.statements
[
index
]
}
else
{
&
self
.terminator
}
}
}
...
...
@@ -2471,11 +2467,7 @@ pub fn constant(&self) -> Option<&Constant<'tcx>> {
/// find as the `func` in a [`TerminatorKind::Call`].
pub
fn
const_fn_def
(
&
self
)
->
Option
<
(
DefId
,
SubstsRef
<
'tcx
>
)
>
{
let
const_ty
=
self
.constant
()
?
.literal
.ty
();
if
let
ty
::
FnDef
(
def_id
,
substs
)
=
*
const_ty
.kind
()
{
Some
((
def_id
,
substs
))
}
else
{
None
}
if
let
ty
::
FnDef
(
def_id
,
substs
)
=
*
const_ty
.kind
()
{
Some
((
def_id
,
substs
))
}
else
{
None
}
}
}
...
...
@@ -2995,7 +2987,7 @@ pub fn try_to_value(self, tcx: TyCtxt<'tcx>) -> Option<interpret::ConstValue<'tc
#[inline]
pub
fn
try_to_scalar
(
self
)
->
Option
<
Scalar
>
{
match
self
{
ConstantKind
::
Ty
(
c
)
=>
match
c
.
val
()
{
ConstantKind
::
Ty
(
c
)
=>
match
c
.
kind
()
{
ty
::
ConstKind
::
Value
(
valtree
)
=>
match
valtree
{
ty
::
ValTree
::
Leaf
(
scalar_int
)
=>
Some
(
Scalar
::
Int
(
scalar_int
)),
ty
::
ValTree
::
Branch
(
_
)
=>
None
,
...
...
@@ -3291,7 +3283,7 @@ fn from_opt_const_arg_anon_const(
}
pub
fn
from_const
(
c
:
ty
::
Const
<
'tcx
>
,
tcx
:
TyCtxt
<
'tcx
>
)
->
Self
{
match
c
.
val
()
{
match
c
.
kind
()
{
ty
::
ConstKind
::
Value
(
valtree
)
=>
{
let
const_val
=
tcx
.valtree_to_const_val
((
c
.ty
(),
valtree
));
Self
::
Val
(
const_val
,
c
.ty
())
...
...
@@ -3587,7 +3579,7 @@ fn pretty_print_const_value<'tcx>(
}
}
(
ConstValue
::
ByRef
{
alloc
,
offset
},
ty
::
Array
(
t
,
n
))
if
*
t
==
u8_type
=>
{
let
n
=
n
.
val
()
.try_to_bits
(
tcx
.data_layout.pointer_size
)
.unwrap
();
let
n
=
n
.
kind
()
.try_to_bits
(
tcx
.data_layout.pointer_size
)
.unwrap
();
// cast is ok because we already checked for pointer size (32 or 64 bit) above
let
range
=
AllocRange
{
start
:
offset
,
size
:
Size
::
from_bytes
(
n
)
};
let
byte_str
=
alloc
.inner
()
.get_bytes
(
&
tcx
,
range
)
.unwrap
();
...
...
compiler/rustc_middle/src/mir/pretty.rs
浏览文件 @
15c1c065
...
...
@@ -484,7 +484,7 @@ fn visit_constant(&mut self, constant: &Constant<'tcx>, _location: Location) {
// This reflects what `Const` looked liked before `val` was renamed
// as `kind`. We print it like this to avoid having to update
// expected output in a lot of tests.
self
.push
(
&
format!
(
"+ literal: Const {{ ty: {}, val: {} }}"
,
literal
.ty
(),
kind
));
self
.push
(
&
format!
(
"+ literal: Const {{ ty: {}, val: {} }}"
,
literal
.ty
(),
val
));
}
}
...
...
compiler/rustc_middle/src/ty/consts.rs
浏览文件 @
15c1c065
...
...
@@ -201,7 +201,7 @@ pub fn from_value(tcx: TyCtxt<'tcx>, val: ty::ValTree<'tcx>, ty: Ty<'tcx>) -> Se
/// Panics if self.kind != ty::ConstKind::Value
pub
fn
to_valtree
(
self
)
->
ty
::
ValTree
<
'tcx
>
{
match
self
.
val
()
{
match
self
.
kind
()
{
ty
::
ConstKind
::
Value
(
valtree
)
=>
valtree
,
_
=>
bug!
(
"expected ConstKind::Value"
),
}
...
...
@@ -286,7 +286,7 @@ pub fn eval(self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Const<'tcx> {
/// Tries to evaluate the constant if it is `Unevaluated` and creates a ConstValue if the
/// evaluation succeeds. If it doesn't succeed, returns the unevaluated constant.
pub
fn
eval_for_mir
(
self
,
tcx
:
TyCtxt
<
'tcx
>
,
param_env
:
ParamEnv
<
'tcx
>
)
->
ConstantKind
<
'tcx
>
{
if
let
Some
(
val
)
=
self
.
val
()
.try_eval_for_mir
(
tcx
,
param_env
)
{
if
let
Some
(
val
)
=
self
.
kind
()
.try_eval_for_mir
(
tcx
,
param_env
)
{
match
val
{
Ok
(
const_val
)
=>
ConstantKind
::
from_value
(
const_val
,
self
.ty
()),
Err
(
ErrorGuaranteed
{
..
})
=>
ConstantKind
::
Ty
(
tcx
.const_error
(
self
.ty
())),
...
...
compiler/rustc_middle/src/ty/context.rs
浏览文件 @
15c1c065
...
...
@@ -1186,7 +1186,11 @@ pub fn layout_scalar_valid_range(self, def_id: DefId) -> (Bound<u128>, Bound<u12
};
debug!
(
"layout_scalar_valid_range: attr={:?}"
,
attr
);
if
let
Some
(
&
[
ast
::
NestedMetaItem
::
Literal
(
ast
::
Lit
{
kind
:
ast
::
LitKind
::
Int
(
a
,
_
),
..
})],
&
[
ast
::
NestedMetaItem
::
Literal
(
ast
::
Lit
{
kind
:
ast
::
LitKind
::
Int
(
a
,
_
),
..
}),
],
)
=
attr
.meta_item_list
()
.as_deref
()
{
Bound
::
Included
(
a
)
...
...
@@ -1659,7 +1663,7 @@ pub trait Lift<'tcx>: fmt::Debug {
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
$ty
{
type
Lifted
=
$lifted
;
fn
lift_to_tcx
(
self
,
tcx
:
TyCtxt
<
'tcx
>
)
->
Option
<
Self
::
Lifted
>
{
if
tcx
.interners
.
$set
.contains_pointer_to
(
&
InternedInSet
(
&*
self
.0
.0
))
{
if
tcx
.interners
.
$set
.contains_pointer_to
(
&
InternedInSet
(
&*
self
.0.0
))
{
// SAFETY: `self` is interned and therefore valid
// for the entire lifetime of the `TyCtxt`.
Some
(
unsafe
{
mem
::
transmute
(
self
)
})
...
...
@@ -2244,11 +2248,7 @@ pub fn signature_unclosure(
/// `*r == kind`.
#[inline]
pub
fn
reuse_or_mk_region
(
self
,
r
:
Region
<
'tcx
>
,
kind
:
RegionKind
)
->
Region
<
'tcx
>
{
if
*
r
==
kind
{
r
}
else
{
self
.mk_region
(
kind
)
}
if
*
r
==
kind
{
r
}
else
{
self
.mk_region
(
kind
)
}
}
#[allow(rustc::usage_of_ty_tykind)]
...
...
@@ -2268,11 +2268,7 @@ pub fn reuse_or_mk_predicate(
pred
:
Predicate
<
'tcx
>
,
binder
:
Binder
<
'tcx
,
PredicateKind
<
'tcx
>>
,
)
->
Predicate
<
'tcx
>
{
if
pred
.kind
()
!=
binder
{
self
.mk_predicate
(
binder
)
}
else
{
pred
}
if
pred
.kind
()
!=
binder
{
self
.mk_predicate
(
binder
)
}
else
{
pred
}
}
pub
fn
mk_mach_int
(
self
,
tm
:
IntTy
)
->
Ty
<
'tcx
>
{
...
...
@@ -2417,11 +2413,7 @@ pub fn mk_unit(self) -> Ty<'tcx> {
#[inline]
pub
fn
mk_diverging_default
(
self
)
->
Ty
<
'tcx
>
{
if
self
.features
()
.never_type_fallback
{
self
.types.never
}
else
{
self
.types.unit
}
if
self
.features
()
.never_type_fallback
{
self
.types.never
}
else
{
self
.types.unit
}
}
#[inline]
...
...
@@ -2572,9 +2564,11 @@ pub fn intern_poly_existential_predicates(
eps
:
&
[
ty
::
Binder
<
'tcx
,
ExistentialPredicate
<
'tcx
>>
],
)
->
&
'tcx
List
<
ty
::
Binder
<
'tcx
,
ExistentialPredicate
<
'tcx
>>>
{
assert
!
(
!
eps
.is_empty
());
assert
!
(
eps
.array_windows
()
.all
(|[
a
,
b
]|
a
.skip_binder
()
.stable_cmp
(
self
,
&
b
.skip_binder
())
!=
Ordering
::
Greater
));
assert
!
(
eps
.array_windows
()
.all
(|[
a
,
b
]|
a
.skip_binder
()
.stable_cmp
(
self
,
&
b
.skip_binder
())
!=
Ordering
::
Greater
)
);
self
._intern_poly_existential_predicates
(
eps
)
}
...
...
@@ -2607,49 +2601,29 @@ pub fn intern_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx List<Ty<'tcx>> {
}
pub
fn
intern_substs
(
self
,
ts
:
&
[
GenericArg
<
'tcx
>
])
->
&
'tcx
List
<
GenericArg
<
'tcx
>>
{
if
ts
.is_empty
()
{
List
::
empty
()
}
else
{
self
._intern_substs
(
ts
)
}
if
ts
.is_empty
()
{
List
::
empty
()
}
else
{
self
._intern_substs
(
ts
)
}
}
pub
fn
intern_projs
(
self
,
ps
:
&
[
ProjectionKind
])
->
&
'tcx
List
<
ProjectionKind
>
{
if
ps
.is_empty
()
{
List
::
empty
()
}
else
{
self
._intern_projs
(
ps
)
}
if
ps
.is_empty
()
{
List
::
empty
()
}
else
{
self
._intern_projs
(
ps
)
}
}
pub
fn
intern_place_elems
(
self
,
ts
:
&
[
PlaceElem
<
'tcx
>
])
->
&
'tcx
List
<
PlaceElem
<
'tcx
>>
{
if
ts
.is_empty
()
{
List
::
empty
()
}
else
{
self
._intern_place_elems
(
ts
)
}
if
ts
.is_empty
()
{
List
::
empty
()
}
else
{
self
._intern_place_elems
(
ts
)
}
}
pub
fn
intern_canonical_var_infos
(
self
,
ts
:
&
[
CanonicalVarInfo
<
'tcx
>
],
)
->
CanonicalVarInfos
<
'tcx
>
{
if
ts
.is_empty
()
{
List
::
empty
()
}
else
{
self
._intern_canonical_var_infos
(
ts
)
}
if
ts
.is_empty
()
{
List
::
empty
()
}
else
{
self
._intern_canonical_var_infos
(
ts
)
}
}
pub
fn
intern_bound_variable_kinds
(
self
,
ts
:
&
[
ty
::
BoundVariableKind
],
)
->
&
'tcx
List
<
ty
::
BoundVariableKind
>
{
if
ts
.is_empty
()
{
List
::
empty
()
}
else
{
self
._intern_bound_variable_kinds
(
ts
)
}
if
ts
.is_empty
()
{
List
::
empty
()
}
else
{
self
._intern_bound_variable_kinds
(
ts
)
}
}
pub
fn
mk_fn_sig
<
I
>
(
...
...
compiler/rustc_middle/src/ty/print/pretty.rs
浏览文件 @
15c1c065
...
...
@@ -607,11 +607,7 @@ fn pretty_print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error>
}
}
}
else
{
if
verbose
{
p!
(
write
(
"{:?}"
,
infer_ty
))
}
else
{
p!
(
write
(
"{}"
,
infer_ty
))
}
if
verbose
{
p!
(
write
(
"{:?}"
,
infer_ty
))
}
else
{
p!
(
write
(
"{}"
,
infer_ty
))
}
}
}
ty
::
Error
(
_
)
=>
p!
(
"[type error]"
),
...
...
@@ -1335,11 +1331,7 @@ fn pretty_print_const_scalar_int(
ty
::
Uint
(
_
)
|
ty
::
Int
(
_
)
=>
{
let
int
=
ConstInt
::
new
(
int
,
matches!
(
ty
.kind
(),
ty
::
Int
(
_
)),
ty
.is_ptr_sized_integral
());
if
print_ty
{
p!
(
write
(
"{:#?}"
,
int
))
}
else
{
p!
(
write
(
"{:?}"
,
int
))
}
if
print_ty
{
p!
(
write
(
"{:#?}"
,
int
))
}
else
{
p!
(
write
(
"{:?}"
,
int
))
}
}
// Char
ty
::
Char
if
char
::
try_from
(
int
)
.is_ok
()
=>
{
...
...
@@ -2294,7 +2286,7 @@ impl<'tcx> ty::fold::TypeVisitor<'tcx> for LateBoundRegionNameCollector<'_, 'tcx
type
BreakTy
=
();
fn
visit_region
(
&
mut
self
,
r
:
ty
::
Region
<
'tcx
>
)
->
ControlFlow
<
Self
::
BreakTy
>
{
trace!
(
"address: {:p}"
,
r
.0
.0
);
trace!
(
"address: {:p}"
,
r
.0.0
);
if
let
ty
::
ReLateBound
(
_
,
ty
::
BoundRegion
{
kind
:
ty
::
BrNamed
(
_
,
name
),
..
})
=
*
r
{
self
.used_region_names
.insert
(
name
);
}
else
if
let
ty
::
RePlaceholder
(
ty
::
PlaceholderRegion
{
...
...
compiler/rustc_symbol_mangling/src/v0.rs
浏览文件 @
15c1c065
...
...
@@ -669,7 +669,7 @@ fn print_const(mut self, ct: ty::Const<'tcx>) -> Result<Self::Const, Self::Error
.expect
(
"tried to dereference on non-ptr type"
)
.ty
;
let
dereferenced_const
=
self
.tcx
.mk_const
(
ty
::
ConstS
{
val
:
ct
.val
(),
ty
:
pointee_ty
});
self
.tcx
.mk_const
(
ty
::
ConstS
{
kind
:
ct
.kind
(),
ty
:
pointee_ty
});
self
=
dereferenced_const
.print
(
self
)
?
;
}
}
...
...
compiler/rustc_trait_selection/src/traits/fulfill.rs
浏览文件 @
15c1c065
...
...
@@ -407,7 +407,7 @@ fn process_changed_obligations(
let
pred
=
ty
::
Binder
::
dummy
(
infcx
.replace_bound_vars_with_placeholders
(
binder
));
ProcessResult
::
Changed
(
mk_pending
(
vec!
[
obligation
.with
(
pred
.to_predicate
(
self
.selcx
.tcx
()))
obligation
.with
(
pred
.to_predicate
(
self
.selcx
.tcx
()))
,
]))
}
ty
::
PredicateKind
::
TypeWellFormedFromEnv
(
..
)
=>
{
...
...
compiler/rustc_trait_selection/src/traits/select/mod.rs
浏览文件 @
15c1c065
...
...
@@ -2578,11 +2578,7 @@ fn head(&self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
}
fn
depth
(
&
self
)
->
usize
{
if
let
Some
(
head
)
=
self
.head
{
head
.depth
}
else
{
0
}
if
let
Some
(
head
)
=
self
.head
{
head
.depth
}
else
{
0
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录