Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5e89312a
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,发现更多精彩内容 >>
提交
5e89312a
编写于
4月 18, 2018
作者:
V
varkor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Inline get_type
上级
fc27c2eb
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
63 addition
and
40 deletion
+63
-40
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/resolve_lifetime.rs
+5
-2
src/librustc/traits/error_reporting.rs
src/librustc/traits/error_reporting.rs
+7
-2
src/librustc/traits/on_unimplemented.rs
src/librustc/traits/on_unimplemented.rs
+8
-8
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+6
-8
src/librustc/ty/subst.rs
src/librustc/ty/subst.rs
+2
-6
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+7
-2
src/librustc_traits/dropck_outlives.rs
src/librustc_traits/dropck_outlives.rs
+6
-2
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/compare_method.rs
+13
-3
src/librustdoc/clean/auto_trait.rs
src/librustdoc/clean/auto_trait.rs
+1
-1
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+3
-4
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+5
-2
未找到文件。
src/librustc/middle/resolve_lifetime.rs
浏览文件 @
5e89312a
...
...
@@ -20,7 +20,7 @@
use
hir
::
map
::
Map
;
use
hir
::
ItemLocalId
;
use
hir
::
LifetimeName
;
use
ty
::{
self
,
TyCtxt
};
use
ty
::{
self
,
TyCtxt
,
GenericParamDef
};
use
errors
::
DiagnosticBuilder
;
use
rustc
::
lint
;
...
...
@@ -1662,7 +1662,10 @@ fn visit_segment_parameters(
.params
.iter
()
.filter_map
(|
param
|
{
param
.get_type
()
.and_then
(|
ty
|
Some
(
ty
.object_lifetime_default
))
match
*
param
{
GenericParamDef
::
Type
(
ty
)
=>
Some
(
ty
.object_lifetime_default
),
GenericParamDef
::
Lifetime
(
_
)
=>
None
,
}
})
.collect
()
})
...
...
src/librustc/traits/error_reporting.rs
浏览文件 @
5e89312a
...
...
@@ -35,7 +35,7 @@
use
std
::
fmt
;
use
syntax
::
ast
;
use
session
::
DiagnosticMessageId
;
use
ty
::{
self
,
AdtKind
,
ToPredicate
,
ToPolyTraitRef
,
Ty
,
TyCtxt
,
TypeFoldable
};
use
ty
::{
self
,
AdtKind
,
ToPredicate
,
ToPolyTraitRef
,
Ty
,
TyCtxt
,
TypeFoldable
,
GenericParamDef
};
use
ty
::
error
::
ExpectedFound
;
use
ty
::
fast_reject
;
use
ty
::
fold
::
TypeFolder
;
...
...
@@ -378,7 +378,12 @@ fn on_unimplemented_note(
flags
.push
((
"_Self"
.to_string
(),
Some
(
self
.tcx
.type_of
(
def
.did
)
.to_string
())));
}
for
param
in
generics
.params
.iter
()
.filter_map
(|
param
|
param
.get_type
())
{
for
param
in
generics
.params
.iter
()
.filter_map
(|
param
|
{
match
*
param
{
GenericParamDef
::
Type
(
ty
)
=>
Some
(
ty
),
GenericParamDef
::
Lifetime
(
_
)
=>
None
,
}
})
{
let
name
=
param
.name
.to_string
();
let
ty
=
trait_ref
.substs
.type_for_def
(
&
param
);
let
ty_str
=
ty
.to_string
();
...
...
src/librustc/traits/on_unimplemented.rs
浏览文件 @
5e89312a
...
...
@@ -254,10 +254,9 @@ fn verify(&self,
Position
::
ArgumentNamed
(
s
)
if
s
==
name
=>
(),
// So is `{A}` if A is a type parameter
Position
::
ArgumentNamed
(
s
)
=>
match
generics
.params
.iter
()
.find
(|
param
|
{
if
let
GenericParamDef
::
Type
(
ty
)
=
param
{
ty
.name
==
s
}
else
{
false
match
*
param
{
GenericParamDef
::
Type
(
ty
)
=>
ty
.name
==
s
,
GenericParamDef
::
Lifetime
(
_
)
=>
false
,
}
})
{
Some
(
_
)
=>
(),
...
...
@@ -292,10 +291,11 @@ pub fn format(&self,
let
trait_str
=
tcx
.item_path_str
(
trait_ref
.def_id
);
let
generics
=
tcx
.generics_of
(
trait_ref
.def_id
);
let
generic_map
=
generics
.params
.iter
()
.filter_map
(|
param
|
{
if
let
Some
(
ty
)
=
param
.get_type
()
{
Some
((
ty
.name
.to_string
(),
trait_ref
.substs
.type_for_def
(
&
ty
)
.to_string
()))
}
else
{
None
match
*
param
{
GenericParamDef
::
Type
(
ty
)
=>
{
Some
((
ty
.name
.to_string
(),
trait_ref
.substs
.type_for_def
(
&
ty
)
.to_string
()))
},
GenericParamDef
::
Lifetime
(
_
)
=>
None
}
})
.collect
::
<
FxHashMap
<
String
,
String
>>
();
...
...
src/librustc/ty/mod.rs
浏览文件 @
5e89312a
...
...
@@ -777,13 +777,6 @@ pub fn def_id(&self) -> DefId {
GenericParamDef
::
Type
(
ty
)
=>
ty
.def_id
,
}
}
pub
fn
get_type
(
&
self
)
->
Option
<
TypeParamDef
>
{
match
*
self
{
GenericParamDef
::
Type
(
ty
)
=>
Some
(
ty
),
_
=>
None
,
}
}
}
pub
struct
GenericParamCount
{
...
...
@@ -834,7 +827,12 @@ pub fn param_counts(&self) -> GenericParamCount {
}
pub
fn
requires_monomorphization
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
)
->
bool
{
if
self
.params
.iter
()
.any
(|
p
|
p
.get_type
()
.is_some
())
{
if
self
.params
.iter
()
.any
(|
param
|
{
match
*
param
{
GenericParamDef
::
Type
(
_
)
=>
true
,
GenericParamDef
::
Lifetime
(
_
)
=>
false
}
})
{
return
true
;
}
if
let
Some
(
parent_def_id
)
=
self
.parent
{
...
...
src/librustc/ty/subst.rs
浏览文件 @
5e89312a
...
...
@@ -243,12 +243,8 @@ fn fill_single<FR, FT>(substs: &mut Vec<Kind<'tcx>>,
FT
:
FnMut
(
&
ty
::
TypeParamDef
,
&
[
Kind
<
'tcx
>
])
->
Ty
<
'tcx
>
{
for
def
in
&
defs
.params
{
let
param
=
match
def
{
ty
::
GenericParamDef
::
Lifetime
(
ref
lt
)
=>
{
mk_region
(
lt
,
substs
)
.into
()
}
ty
::
GenericParamDef
::
Type
(
ref
ty
)
=>
{
mk_type
(
ty
,
substs
)
.into
()
}
ty
::
GenericParamDef
::
Lifetime
(
ref
lt
)
=>
mk_region
(
lt
,
substs
)
.into
(),
ty
::
GenericParamDef
::
Type
(
ref
ty
)
=>
mk_type
(
ty
,
substs
)
.into
(),
};
assert_eq!
(
def
.index
()
as
usize
,
substs
.len
());
substs
.push
(
param
);
...
...
src/librustc/util/ppaux.rs
浏览文件 @
5e89312a
...
...
@@ -19,7 +19,7 @@
use
ty
::{
TyParam
,
TyRawPtr
,
TyRef
,
TyNever
,
TyTuple
};
use
ty
::{
TyClosure
,
TyGenerator
,
TyGeneratorWitness
,
TyForeign
,
TyProjection
,
TyAnon
};
use
ty
::{
TyDynamic
,
TyInt
,
TyUint
,
TyInfer
};
use
ty
::{
self
,
Ty
,
TyCtxt
,
TypeFoldable
,
GenericParamCount
};
use
ty
::{
self
,
Ty
,
TyCtxt
,
TypeFoldable
,
GenericParamCount
,
GenericParamDef
};
use
util
::
nodemap
::
FxHashSet
;
use
std
::
cell
::
Cell
;
...
...
@@ -337,7 +337,12 @@ fn parameterized<F: fmt::Write>(&mut self,
if
!
verbose
{
let
mut
type_params
=
generics
.params
.iter
()
.rev
()
.filter_map
(|
param
|
param
.get_type
());
generics
.params
.iter
()
.rev
()
.filter_map
(|
param
|
{
match
*
param
{
GenericParamDef
::
Type
(
ty
)
=>
Some
(
ty
),
GenericParamDef
::
Lifetime
(
_
)
=>
None
,
}
});
if
let
Some
(
last_ty
)
=
type_params
.next
()
{
if
last_ty
.has_default
{
if
let
Some
(
substs
)
=
tcx
.lift
(
&
substs
)
{
...
...
src/librustc_traits/dropck_outlives.rs
浏览文件 @
5e89312a
...
...
@@ -13,7 +13,7 @@
use
rustc
::
traits
::{
FulfillmentContext
,
Normalized
,
ObligationCause
};
use
rustc
::
traits
::
query
::{
CanonicalTyGoal
,
NoSolution
};
use
rustc
::
traits
::
query
::
dropck_outlives
::{
DtorckConstraint
,
DropckOutlivesResult
};
use
rustc
::
ty
::{
self
,
ParamEnvAnd
,
Ty
,
TyCtxt
};
use
rustc
::
ty
::{
self
,
ParamEnvAnd
,
Ty
,
TyCtxt
,
GenericParamDef
};
use
rustc
::
ty
::
subst
::
Subst
;
use
rustc
::
util
::
nodemap
::
FxHashSet
;
use
rustc_data_structures
::
sync
::
Lrc
;
...
...
@@ -278,9 +278,13 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>(
debug!
(
"dtorck_constraint: {:?}"
,
def
);
if
def
.is_phantom_data
()
{
let
type_param
=
match
tcx
.generics_of
(
def_id
)
.params
[
0
]
{
GenericParamDef
::
Type
(
ty
)
=>
ty
,
GenericParamDef
::
Lifetime
(
_
)
=>
unreachable!
(),
};
let
result
=
DtorckConstraint
{
outlives
:
vec!
[],
dtorck_types
:
vec!
[
tcx
.mk_param_from_def
(
&
t
cx
.generics_of
(
def_id
)
.params
[
0
]
.get_type
()
.unwrap
()
)],
dtorck_types
:
vec!
[
tcx
.mk_param_from_def
(
&
t
ype_param
)],
overflows
:
vec!
[],
};
debug!
(
"dtorck_constraint: {:?} => {:?}"
,
def
,
result
);
...
...
src/librustc_typeck/check/compare_method.rs
浏览文件 @
5e89312a
...
...
@@ -10,7 +10,7 @@
use
rustc
::
hir
::{
self
,
ImplItemKind
,
TraitItemKind
};
use
rustc
::
infer
::{
self
,
InferOk
};
use
rustc
::
ty
::{
self
,
TyCtxt
};
use
rustc
::
ty
::{
self
,
TyCtxt
,
GenericParamDef
};
use
rustc
::
ty
::
util
::
ExplicitSelf
;
use
rustc
::
traits
::{
self
,
ObligationCause
,
ObligationCauseCode
,
Reveal
};
use
rustc
::
ty
::
error
::{
ExpectedFound
,
TypeError
};
...
...
@@ -728,8 +728,18 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let
mut
error_found
=
false
;
let
impl_m_generics
=
tcx
.generics_of
(
impl_m
.def_id
);
let
trait_m_generics
=
tcx
.generics_of
(
trait_m
.def_id
);
let
impl_m_type_params
=
impl_m_generics
.params
.iter
()
.filter_map
(|
param
|
param
.get_type
());
let
trait_m_type_params
=
trait_m_generics
.params
.iter
()
.filter_map
(|
param
|
param
.get_type
());
let
impl_m_type_params
=
impl_m_generics
.params
.iter
()
.filter_map
(|
param
|
{
match
*
param
{
GenericParamDef
::
Type
(
ty
)
=>
Some
(
ty
),
GenericParamDef
::
Lifetime
(
_
)
=>
None
,
}
});
let
trait_m_type_params
=
trait_m_generics
.params
.iter
()
.filter_map
(|
param
|
{
match
*
param
{
GenericParamDef
::
Type
(
ty
)
=>
Some
(
ty
),
GenericParamDef
::
Lifetime
(
_
)
=>
None
,
}
});
for
(
impl_ty
,
trait_ty
)
in
impl_m_type_params
.zip
(
trait_m_type_params
)
{
if
impl_ty
.synthetic
!=
trait_ty
.synthetic
{
let
impl_node_id
=
tcx
.hir
.as_local_node_id
(
impl_ty
.def_id
)
.unwrap
();
...
...
src/librustdoc/clean/auto_trait.rs
浏览文件 @
5e89312a
...
...
@@ -860,7 +860,7 @@ fn param_env_to_generics<'b, 'c, 'cx>(
ty
.bounds
.insert
(
0
,
TyParamBound
::
maybe_sized
(
self
.cx
));
}
}
_
=>
{}
GenericParamDef
::
Lifetime
(
_
)
=>
{}
}
}
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
5e89312a
...
...
@@ -1725,10 +1725,9 @@ pub enum GenericParamDef {
impl
GenericParamDef
{
pub
fn
is_synthetic_type_param
(
&
self
)
->
bool
{
if
let
GenericParamDef
::
Type
(
ref
t
)
=
*
self
{
t
.synthetic
.is_some
()
}
else
{
false
match
self
{
GenericParamDef
::
Type
(
ty
)
=>
ty
.synthetic
.is_some
(),
GenericParamDef
::
Lifetime
(
_
)
=>
false
,
}
}
}
...
...
src/librustdoc/html/render.rs
浏览文件 @
5e89312a
...
...
@@ -1437,8 +1437,11 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
impl
<
'a
>
Cache
{
fn
generics
(
&
mut
self
,
generics
:
&
clean
::
Generics
)
{
for
param
in
&
generics
.params
{
if
let
clean
::
GenericParamDef
::
Type
(
ref
typ
)
=
*
param
{
self
.typarams
.insert
(
typ
.did
,
typ
.name
.clone
());
match
*
param
{
clean
::
GenericParamDef
::
Type
(
ref
typ
)
=>
{
self
.typarams
.insert
(
typ
.did
,
typ
.name
.clone
());
}
clean
::
GenericParamDef
::
Lifetime
(
_
)
=>
{}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录