Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
34e05812
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
34e05812
编写于
5月 26, 2022
作者:
M
Michael Goulet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix TyKind lint, make consts no longer fn, etc
上级
a056a953
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
857 addition
and
527 deletion
+857
-527
compiler/rustc_borrowck/src/lib.rs
compiler/rustc_borrowck/src/lib.rs
+5
-3
compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
+2
-2
compiler/rustc_const_eval/src/interpret/traits.rs
compiler/rustc_const_eval/src/interpret/traits.rs
+5
-5
compiler/rustc_lint/src/internal.rs
compiler/rustc_lint/src/internal.rs
+123
-68
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_middle/src/ty/context.rs
+2
-0
compiler/rustc_middle/src/ty/fast_reject.rs
compiler/rustc_middle/src/ty/fast_reject.rs
+4
-4
compiler/rustc_middle/src/ty/mod.rs
compiler/rustc_middle/src/ty/mod.rs
+4
-4
compiler/rustc_middle/src/ty/sty.rs
compiler/rustc_middle/src/ty/sty.rs
+4
-200
compiler/rustc_middle/src/ty/vtable.rs
compiler/rustc_middle/src/ty/vtable.rs
+5
-3
compiler/rustc_span/src/symbol.rs
compiler/rustc_span/src/symbol.rs
+1
-0
compiler/rustc_trait_selection/src/traits/mod.rs
compiler/rustc_trait_selection/src/traits/mod.rs
+3
-5
compiler/rustc_trait_selection/src/traits/select/confirmation.rs
...r/rustc_trait_selection/src/traits/select/confirmation.rs
+2
-2
compiler/rustc_type_ir/src/lib.rs
compiler/rustc_type_ir/src/lib.rs
+0
-2
compiler/rustc_type_ir/src/sty.rs
compiler/rustc_type_ir/src/sty.rs
+577
-141
src/test/run-make-fulldeps/obtain-borrowck/driver.rs
src/test/run-make-fulldeps/obtain-borrowck/driver.rs
+1
-1
src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs
src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs
+34
-26
src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr
src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr
+85
-61
未找到文件。
compiler/rustc_borrowck/src/lib.rs
浏览文件 @
34e05812
...
...
@@ -98,8 +98,10 @@ struct Upvar<'tcx> {
by_ref
:
bool
,
}
const
fn
deref_projection
<
'tcx
>
()
->
&
'tcx
[
PlaceElem
<
'tcx
>
;
1
]
{
&
[
ProjectionElem
::
Deref
]
/// Associate some local constants with the `'tcx` lifetime
struct
TyCtxtConsts
<
'tcx
>
(
TyCtxt
<
'tcx
>
);
impl
<
'tcx
>
TyCtxtConsts
<
'tcx
>
{
const
DEREF_PROJECTION
:
&
'tcx
[
PlaceElem
<
'tcx
>
;
1
]
=
&
[
ProjectionElem
::
Deref
];
}
pub
fn
provide
(
providers
:
&
mut
Providers
)
{
...
...
@@ -1445,7 +1447,7 @@ fn check_for_invalidation_at_exit(
// Thread-locals might be dropped after the function exits
// We have to dereference the outer reference because
// borrows don't conflict behind shared references.
root_place
.projection
=
deref_projection
()
;
root_place
.projection
=
TyCtxtConsts
::
DEREF_PROJECTION
;
(
true
,
true
)
}
else
{
(
false
,
self
.locals_are_invalidated_at_exit
)
...
...
compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
浏览文件 @
34e05812
...
...
@@ -33,7 +33,7 @@
use
rustc_middle
::
ty
::
layout
::
LayoutOf
;
use
rustc_middle
::
ty
::
layout
::
TyAndLayout
;
use
rustc_middle
::
ty
::
subst
::
GenericArgKind
;
use
rustc_middle
::
ty
::{
self
,
common_vtable_entries
,
AdtKind
,
Instance
,
ParamEnv
,
Ty
,
TyCtxt
};
use
rustc_middle
::
ty
::{
self
,
AdtKind
,
Instance
,
ParamEnv
,
Ty
,
TyCtxt
};
use
rustc_session
::
config
::{
self
,
DebugInfo
};
use
rustc_span
::
symbol
::
Symbol
;
use
rustc_span
::
FileName
;
...
...
@@ -1392,7 +1392,7 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
tcx
.vtable_entries
(
trait_ref
)
}
else
{
common_vtable_entries
()
TyCtxt
::
COMMON_VTABLE_ENTRIES
};
// All function pointers are described as opaque pointers. This could be improved in the future
...
...
compiler/rustc_const_eval/src/interpret/traits.rs
浏览文件 @
34e05812
...
...
@@ -2,8 +2,8 @@
use
rustc_middle
::
mir
::
interpret
::{
InterpResult
,
Pointer
,
PointerArithmetic
};
use
rustc_middle
::
ty
::{
self
,
common_vtable_entries
,
Ty
,
COMMON_VTABLE_ENTRIES_ALIGN
,
COMMON_VTABLE_ENTRIES_
DROPINPLACE
,
COMMON_VTABLE_ENTRIES_
SIZE
,
self
,
Ty
,
TyCtxt
,
COMMON_VTABLE_ENTRIES_ALIGN
,
COMMON_VTABLE_ENTRIES_DROPINPLACE
,
COMMON_VTABLE_ENTRIES_SIZE
,
};
use
rustc_target
::
abi
::{
Align
,
Size
};
...
...
@@ -38,7 +38,7 @@ pub fn get_vtable(
}
/// Resolves the function at the specified slot in the provided
/// vtable. Currently an index of '3' (`
common_vtable_entries()
.len()`)
/// vtable. Currently an index of '3' (`
TyCtxt::COMMON_VTABLE_ENTRIES
.len()`)
/// corresponds to the first method declared in the trait of the provided vtable.
pub
fn
get_vtable_slot
(
&
self
,
...
...
@@ -64,7 +64,7 @@ pub fn read_drop_type_from_vtable(
let
vtable
=
self
.get_ptr_alloc
(
vtable
,
pointer_size
*
u64
::
try_from
(
common_vtable_entries
()
.len
())
.unwrap
(),
pointer_size
*
u64
::
try_from
(
TyCtxt
::
COMMON_VTABLE_ENTRIES
.len
())
.unwrap
(),
self
.tcx.data_layout.pointer_align.abi
,
)
?
.expect
(
"cannot be a ZST"
);
...
...
@@ -99,7 +99,7 @@ pub fn read_size_and_align_from_vtable(
let
vtable
=
self
.get_ptr_alloc
(
vtable
,
pointer_size
*
u64
::
try_from
(
common_vtable_entries
()
.len
())
.unwrap
(),
pointer_size
*
u64
::
try_from
(
TyCtxt
::
COMMON_VTABLE_ENTRIES
.len
())
.unwrap
(),
self
.tcx.data_layout.pointer_align.abi
,
)
?
.expect
(
"cannot be a ZST"
);
...
...
compiler/rustc_lint/src/internal.rs
浏览文件 @
34e05812
...
...
@@ -5,8 +5,8 @@
use
rustc_ast
as
ast
;
use
rustc_errors
::
Applicability
;
use
rustc_hir
::
def
::
Res
;
use
rustc_hir
::{
Expr
,
ExprKind
,
GenericArg
,
Path
,
PathSegment
,
QPath
};
use
rustc_hir
::{
HirId
,
Item
,
ItemKind
,
Node
,
Ty
,
TyKind
};
use
rustc_hir
::{
Expr
,
ExprKind
,
GenericArg
,
Pat
Kind
,
Pat
h
,
PathSegment
,
QPath
};
use
rustc_hir
::{
HirId
,
Item
,
ItemKind
,
Node
,
Pat
,
Ty
,
TyKind
};
use
rustc_middle
::
ty
;
use
rustc_session
::{
declare_lint_pass
,
declare_tool_lint
};
use
rustc_span
::
hygiene
::{
ExpnKind
,
MacroKind
};
...
...
@@ -123,55 +123,115 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
]);
impl
<
'tcx
>
LateLintPass
<
'tcx
>
for
TyTyKind
{
fn
check_path
(
&
mut
self
,
cx
:
&
LateContext
<
'_
>
,
path
:
&
'tcx
Path
<
'tcx
>
,
_
:
HirId
)
{
let
segments
=
path
.segments
.iter
()
.rev
()
.skip
(
1
)
.rev
();
if
let
Some
(
last
)
=
segments
.last
()
{
let
span
=
path
.span
.with_hi
(
last
.ident.span
.hi
());
if
lint_ty_kind_usage
(
cx
,
last
)
{
cx
.struct_span_lint
(
USAGE_OF_TY_TYKIND
,
span
,
|
lint
|
{
lint
.build
(
"usage of `ty::TyKind::<kind>`"
)
.span_suggestion
(
span
,
"try using ty::<kind> directly"
,
"ty"
.to_string
(),
Applicability
::
MaybeIncorrect
,
// ty maybe needs an import
)
.emit
();
})
}
fn
check_path
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
path
:
&
'tcx
rustc_hir
::
Path
<
'tcx
>
,
_
:
rustc_hir
::
HirId
,
)
{
if
let
Some
(
segment
)
=
path
.segments
.iter
()
.nth_back
(
1
)
&&
let
Some
(
res
)
=
&
segment
.res
&&
lint_ty_kind_usage
(
cx
,
res
)
{
let
span
=
path
.span
.with_hi
(
segment
.args
.map_or
(
segment
.ident.span
,
|
a
|
a
.span_ext
)
.hi
()
);
cx
.struct_span_lint
(
USAGE_OF_TY_TYKIND
,
path
.span
,
|
lint
|
{
lint
.build
(
"usage of `ty::TyKind::<kind>`"
)
.span_suggestion
(
span
,
"try using `ty::<kind>` directly"
,
"ty"
.to_string
(),
Applicability
::
MaybeIncorrect
,
// ty maybe needs an import
)
.emit
();
});
}
}
fn
check_ty
(
&
mut
self
,
cx
:
&
LateContext
<
'_
>
,
ty
:
&
'tcx
Ty
<
'tcx
>
)
{
match
&
ty
.kind
{
TyKind
::
Path
(
QPath
::
Resolved
(
_
,
path
))
=>
{
if
let
Some
(
last
)
=
path
.segments
.iter
()
.last
()
{
if
lint_ty_kind_usage
(
cx
,
last
)
{
cx
.struct_span_lint
(
USAGE_OF_TY_TYKIND
,
path
.span
,
|
lint
|
{
lint
.build
(
"usage of `ty::TyKind`"
)
.help
(
"try using `Ty` instead"
)
.emit
();
})
}
else
{
if
ty
.span
.from_expansion
()
{
return
;
}
if
let
Some
(
t
)
=
is_ty_or_ty_ctxt
(
cx
,
ty
)
{
if
path
.segments
.len
()
>
1
{
cx
.struct_span_lint
(
USAGE_OF_QUALIFIED_TY
,
path
.span
,
|
lint
|
{
lint
.build
(
&
format!
(
"usage of qualified `ty::{}`"
,
t
))
if
lint_ty_kind_usage
(
cx
,
&
path
.res
)
{
cx
.struct_span_lint
(
USAGE_OF_TY_TYKIND
,
path
.span
,
|
lint
|
{
let
hir
=
cx
.tcx
.hir
();
match
hir
.find
(
hir
.get_parent_node
(
ty
.hir_id
))
{
Some
(
Node
::
Pat
(
Pat
{
kind
:
PatKind
::
Path
(
qpath
)
|
PatKind
::
TupleStruct
(
qpath
,
..
)
|
PatKind
::
Struct
(
qpath
,
..
),
..
}))
=>
{
if
let
QPath
::
TypeRelative
(
qpath_ty
,
..
)
=
qpath
&&
qpath_ty
.hir_id
==
ty
.hir_id
{
lint
.build
(
"usage of `ty::TyKind::<kind>`"
)
.span_suggestion
(
path
.span
,
"try using `ty::<kind>` directly"
,
"ty"
.to_string
(),
Applicability
::
MaybeIncorrect
,
// ty maybe needs an import
)
.emit
();
return
;
}
}
Some
(
Node
::
Expr
(
Expr
{
kind
:
ExprKind
::
Path
(
qpath
),
..
}))
=>
{
if
let
QPath
::
TypeRelative
(
qpath_ty
,
..
)
=
qpath
&&
qpath_ty
.hir_id
==
ty
.hir_id
{
lint
.build
(
"usage of `ty::TyKind::<kind>`"
)
.span_suggestion
(
path
.span
,
"try importing it and using it unqualified"
,
t
,
// The import probably needs to be changed
Applicability
::
MaybeIncorrect
,
"try using `ty::<kind>` directly"
,
"ty"
.to_string
(),
Applicability
::
MaybeIncorrect
,
// ty maybe needs an import
)
.emit
();
})
return
;
}
}
// Can't unify these two branches because qpath below is `&&` and above is `&`
// and `A | B` paths don't play well together with adjustments, apparently.
Some
(
Node
::
Expr
(
Expr
{
kind
:
ExprKind
::
Struct
(
qpath
,
..
),
..
}))
=>
{
if
let
QPath
::
TypeRelative
(
qpath_ty
,
..
)
=
qpath
&&
qpath_ty
.hir_id
==
ty
.hir_id
{
lint
.build
(
"usage of `ty::TyKind::<kind>`"
)
.span_suggestion
(
path
.span
,
"try using `ty::<kind>` directly"
,
"ty"
.to_string
(),
Applicability
::
MaybeIncorrect
,
// ty maybe needs an import
)
.emit
();
return
;
}
}
_
=>
{}
}
lint
.build
(
"usage of `ty::TyKind`"
)
.help
(
"try using `Ty` instead"
)
.emit
();
})
}
else
if
!
ty
.span
.from_expansion
()
&&
let
Some
(
t
)
=
is_ty_or_ty_ctxt
(
cx
,
&
path
)
{
if
path
.segments
.len
()
>
1
{
cx
.struct_span_lint
(
USAGE_OF_QUALIFIED_TY
,
path
.span
,
|
lint
|
{
lint
.build
(
&
format!
(
"usage of qualified `ty::{}`"
,
t
))
.span_suggestion
(
path
.span
,
"try importing it and using it unqualified"
,
t
,
// The import probably needs to be changed
Applicability
::
MaybeIncorrect
,
)
.emit
();
})
}
}
}
...
...
@@ -180,42 +240,37 @@ fn check_ty(&mut self, cx: &LateContext<'_>, ty: &'tcx Ty<'tcx>) {
}
}
fn
lint_ty_kind_usage
(
cx
:
&
LateContext
<
'_
>
,
segment
:
&
PathSegment
<
'_
>
)
->
bool
{
if
let
Some
(
res
)
=
segment
.res
{
if
let
Some
(
did
)
=
res
.opt_def_id
()
{
return
cx
.tcx
.is_diagnostic_item
(
sym
::
TyKind
,
did
);
}
fn
lint_ty_kind_usage
(
cx
:
&
LateContext
<
'_
>
,
res
:
&
Res
)
->
bool
{
if
let
Some
(
did
)
=
res
.opt_def_id
()
{
cx
.tcx
.is_diagnostic_item
(
sym
::
TyKind
,
did
)
||
cx
.tcx
.is_diagnostic_item
(
sym
::
IrTyKind
,
did
)
}
else
{
false
}
false
}
fn
is_ty_or_ty_ctxt
(
cx
:
&
LateContext
<
'_
>
,
ty
:
&
Ty
<
'_
>
)
->
Option
<
String
>
{
if
let
TyKind
::
Path
(
QPath
::
Resolved
(
_
,
path
))
=
&
ty
.kind
{
match
path
.res
{
Res
::
Def
(
_
,
def_id
)
=>
{
if
let
Some
(
name
@
(
sym
::
Ty
|
sym
::
TyCtxt
))
=
cx
.tcx
.get_diagnostic_name
(
def_id
)
{
return
Some
(
format!
(
"{}{}"
,
name
,
gen_args
(
path
.segments
.last
()
.unwrap
())));
}
fn
is_ty_or_ty_ctxt
(
cx
:
&
LateContext
<
'_
>
,
path
:
&
Path
<
'_
>
)
->
Option
<
String
>
{
match
&
path
.res
{
Res
::
Def
(
_
,
def_id
)
=>
{
if
let
Some
(
name
@
(
sym
::
Ty
|
sym
::
TyCtxt
))
=
cx
.tcx
.get_diagnostic_name
(
*
def_id
)
{
return
Some
(
format!
(
"{}{}"
,
name
,
gen_args
(
path
.segments
.last
()
.unwrap
())));
}
// Only lint on `&Ty` and `&TyCtxt` if it is used outside of a trait.
Res
::
SelfTy
{
trait_
:
None
,
alias_to
:
Some
((
did
,
_
))
}
=>
{
if
let
ty
::
Adt
(
adt
,
substs
)
=
cx
.tcx
.type_of
(
did
)
.kind
()
{
if
let
Some
(
name
@
(
sym
::
Ty
|
sym
::
TyCtxt
))
=
cx
.tcx
.get_diagnostic_name
(
adt
.did
())
{
// NOTE: This path is currently unreachable as `Ty<'tcx>` is
// defined as a type alias meaning that `impl<'tcx> Ty<'tcx>`
// is not actually allowed.
//
// I(@lcnr) still kept this branch in so we don't miss this
// if we ever change it in the future.
return
Some
(
format!
(
"{}<{}>"
,
name
,
substs
[
0
]));
}
}
// Only lint on `&Ty` and `&TyCtxt` if it is used outside of a trait.
Res
::
SelfTy
{
trait_
:
None
,
alias_to
:
Some
((
did
,
_
))
}
=>
{
if
let
ty
::
Adt
(
adt
,
substs
)
=
cx
.tcx
.type_of
(
did
)
.kind
()
{
if
let
Some
(
name
@
(
sym
::
Ty
|
sym
::
TyCtxt
))
=
cx
.tcx
.get_diagnostic_name
(
adt
.did
())
{
// NOTE: This path is currently unreachable as `Ty<'tcx>` is
// defined as a type alias meaning that `impl<'tcx> Ty<'tcx>`
// is not actually allowed.
//
// I(@lcnr) still kept this branch in so we don't miss this
// if we ever change it in the future.
return
Some
(
format!
(
"{}<{}>"
,
name
,
substs
[
0
]));
}
}
_
=>
(),
}
_
=>
(),
}
None
...
...
compiler/rustc_middle/src/ty/context.rs
浏览文件 @
34e05812
...
...
@@ -94,6 +94,7 @@ pub struct TyInterner<'tcx> {
pub
tcx
:
TyCtxt
<
'tcx
>
,
}
/*
/// We don't ever actually need this. It's only required for derives.
impl<'tcx> Hash for TyInterner<'tcx> {
fn hash<H: Hasher>(&self, _state: &mut H) {}
...
...
@@ -128,6 +129,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "TyInterner")
}
}
*/
#[allow(rustc::usage_of_ty_tykind)]
impl
<
'tcx
>
Interner
for
TyInterner
<
'tcx
>
{
...
...
compiler/rustc_middle/src/ty/fast_reject.rs
浏览文件 @
34e05812
...
...
@@ -207,10 +207,10 @@ pub struct DeepRejectCtxt {
}
impl
DeepRejectCtxt
{
pub
fn
generic_args_may_unify
(
pub
fn
generic_args_may_unify
<
'tcx
>
(
self
,
obligation_arg
:
ty
::
GenericArg
<
'
_
>
,
impl_arg
:
ty
::
GenericArg
<
'
_
>
,
obligation_arg
:
ty
::
GenericArg
<
'
tcx
>
,
impl_arg
:
ty
::
GenericArg
<
'
tcx
>
,
)
->
bool
{
match
(
obligation_arg
.unpack
(),
impl_arg
.unpack
())
{
// We don't fast reject based on regions for now.
...
...
@@ -225,7 +225,7 @@ pub fn generic_args_may_unify(
}
}
pub
fn
types_may_unify
(
self
,
obligation_ty
:
Ty
<
'_
>
,
impl_ty
:
Ty
<
'_
>
)
->
bool
{
pub
fn
types_may_unify
<
'tcx
>
(
self
,
obligation_ty
:
Ty
<
'tcx
>
,
impl_ty
:
Ty
<
'tcx
>
)
->
bool
{
match
impl_ty
.kind
()
{
// Start by checking whether the type in the impl may unify with
// pretty much everything. Just return `true` in that case.
...
...
compiler/rustc_middle/src/ty/mod.rs
浏览文件 @
34e05812
...
...
@@ -449,13 +449,13 @@ pub(crate) struct TyS<'tcx> {
}
// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
//
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//
static_assert_size!(TyS<'_>, 40);
#[cfg(all(target_arch
=
"x86_64"
,
target_pointer_width
=
"64"
))]
static_assert_size!
(
TyS
<
'_
>
,
40
);
// We are actually storing a stable hash cache next to the type, so let's
// also check the full size
//
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//
static_assert_size!(WithStableHash<TyS<'_>>, 56);
#[cfg(all(target_arch
=
"x86_64"
,
target_pointer_width
=
"64"
))]
static_assert_size!
(
WithStableHash
<
TyS
<
'_
>>
,
56
);
/// Use this rather than `TyS`, whenever possible.
#[derive(Copy,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
HashStable)]
...
...
compiler/rustc_middle/src/ty/sty.rs
浏览文件 @
34e05812
...
...
@@ -27,9 +27,12 @@
use
std
::
ops
::{
ControlFlow
,
Deref
,
Range
};
use
ty
::
util
::
IntTypeExt
;
use
rustc_type_ir
::
sty
::
TyKind
::
*
;
use
rustc_type_ir
::
TyKind
as
IrTyKind
;
// Re-export the `TyKind` from `rustc_type_ir` here for convenience
#[rustc_diagnostic_item
=
"TyKind"
]
pub
type
TyKind
<
'tcx
>
=
IrTyKind
<
ty
::
TyInterner
<
'tcx
>>
;
use
rustc_type_ir
::
sty
::
TyKind
::
*
;
#[derive(Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Debug,
TyEncodable,
TyDecodable)]
#[derive(HashStable,
TypeFoldable,
Lift)]
...
...
@@ -80,205 +83,6 @@ pub fn is_named(&self) -> bool {
}
}
/*
/// Defines the kinds of types used by the type system.
///
/// Types written by the user start out as [hir::TyKind](rustc_hir::TyKind) and get
/// converted to this representation using `AstConv::ast_ty_to_ty`.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable, Debug)]
#[derive(HashStable)]
#[rustc_diagnostic_item = "TyKind"]
pub enum TyKind<'tcx> {
/// The primitive boolean type. Written as `bool`.
Bool,
/// The primitive character type; holds a Unicode scalar value
/// (a non-surrogate code point). Written as `char`.
Char,
/// A primitive signed integer type. For example, `i32`.
Int(ty::IntTy),
/// A primitive unsigned integer type. For example, `u32`.
Uint(ty::UintTy),
/// A primitive floating-point type. For example, `f64`.
Float(ty::FloatTy),
/// Algebraic data types (ADT). For example: structures, enumerations and unions.
///
/// For example, the type `List<i32>` would be represented using the `AdtDef`
/// for `struct List<T>` and the substs `[i32]`.
///
/// Note that generic parameters in fields only get lazily substituted
/// by using something like `adt_def.all_fields().map(|field| field.ty(tcx, substs))`.
Adt(AdtDef<'tcx>, SubstsRef<'tcx>),
/// An unsized FFI type that is opaque to Rust. Written as `extern type T`.
Foreign(DefId),
/// The pointee of a string slice. Written as `str`.
Str,
/// An array with the given length. Written as `[T; N]`.
Array(Ty<'tcx>, ty::Const<'tcx>),
/// The pointee of an array slice. Written as `[T]`.
Slice(Ty<'tcx>),
/// A raw pointer. Written as `*mut T` or `*const T`
RawPtr(TypeAndMut<'tcx>),
/// A reference; a pointer with an associated lifetime. Written as
/// `&'a mut T` or `&'a T`.
Ref(Region<'tcx>, Ty<'tcx>, hir::Mutability),
/// The anonymous type of a function declaration/definition. Each
/// function has a unique type.
///
/// For the function `fn foo() -> i32 { 3 }` this type would be
/// shown to the user as `fn() -> i32 {foo}`.
///
/// For example the type of `bar` here:
/// ```rust
/// fn foo() -> i32 { 1 }
/// let bar = foo; // bar: fn() -> i32 {foo}
/// ```
FnDef(DefId, SubstsRef<'tcx>),
/// A pointer to a function. Written as `fn() -> i32`.
///
/// Note that both functions and closures start out as either
/// [FnDef] or [Closure] which can be then be coerced to this variant.
///
/// For example the type of `bar` here:
///
/// ```rust
/// fn foo() -> i32 { 1 }
/// let bar: fn() -> i32 = foo;
/// ```
FnPtr(PolyFnSig<'tcx>),
/// A trait object. Written as `dyn for<'b> Trait<'b, Assoc = u32> + Send + 'a`.
Dynamic(&'tcx List<Binder<'tcx, ExistentialPredicate<'tcx>>>, ty::Region<'tcx>),
/// The anonymous type of a closure. Used to represent the type of `|a| a`.
///
/// Closure substs contain both the - potentially substituted - generic parameters
/// of its parent and some synthetic parameters. See the documentation for
/// [ClosureSubsts] for more details.
Closure(DefId, SubstsRef<'tcx>),
/// The anonymous type of a generator. Used to represent the type of
/// `|a| yield a`.
///
/// For more info about generator substs, visit the documentation for
/// [GeneratorSubsts].
Generator(DefId, SubstsRef<'tcx>, hir::Movability),
/// A type representing the types stored inside a generator.
/// This should only appear as part of the [GeneratorSubsts].
///
/// Note that the captured variables for generators are stored separately
/// using a tuple in the same way as for closures.
///
/// Unlike upvars, the witness can reference lifetimes from
/// inside of the generator itself. To deal with them in
/// the type of the generator, we convert them to higher ranked
/// lifetimes bound by the witness itself.
///
/// Looking at the following example, the witness for this generator
/// may end up as something like `for<'a> [Vec<i32>, &'a Vec<i32>]`:
///
/// ```ignore UNSOLVED (ask @compiler-errors, should this error? can we just swap the yields?)
/// #![feature(generators)]
/// |a| {
/// let x = &vec![3];
/// yield a;
/// yield x[0];
/// }
/// # ;
/// ```
GeneratorWitness(Binder<'tcx, &'tcx List<Ty<'tcx>>>),
/// The never type `!`.
Never,
/// A tuple type. For example, `(i32, bool)`.
Tuple(&'tcx List<Ty<'tcx>>),
/// The projection of an associated type. For example,
/// `<T as Trait<..>>::N`.
Projection(ProjectionTy<'tcx>),
/// Opaque (`impl Trait`) type found in a return type.
///
/// The `DefId` comes either from
/// * the `impl Trait` ast::Ty node,
/// * or the `type Foo = impl Trait` declaration
///
/// For RPIT the substitutions are for the generics of the function,
/// while for TAIT it is used for the generic parameters of the alias.
///
/// During codegen, `tcx.type_of(def_id)` can be used to get the underlying type.
Opaque(DefId, SubstsRef<'tcx>),
/// A type parameter; for example, `T` in `fn f<T>(x: T) {}`.
Param(ParamTy),
/// Bound type variable, used to represent the `'a` in `for<'a> fn(&'a ())`.
///
/// For canonical queries, we replace inference variables with bound variables,
/// so e.g. when checking whether `&'_ (): Trait<_>` holds, we canonicalize that to
/// `for<'a, T> &'a (): Trait<T>` and then convert the introduced bound variables
/// back to inference variables in a new inference context when inside of the query.
///
/// See the `rustc-dev-guide` for more details about
/// [higher-ranked trait bounds][1] and [canonical queries][2].
///
/// [1]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
/// [2]: https://rustc-dev-guide.rust-lang.org/traits/canonical-queries.html
Bound(ty::DebruijnIndex, BoundTy),
/// A placeholder type, used during higher ranked subtyping to instantiate
/// bound variables.
Placeholder(ty::PlaceholderType),
/// A type variable used during type checking.
///
/// Similar to placeholders, inference variables also live in a universe to
/// correctly deal with higher ranked types. Though unlike placeholders,
/// that universe is stored in the `InferCtxt` instead of directly
/// inside of the type.
Infer(InferTy),
/// A placeholder for a type which could not be computed; this is
/// propagated to avoid useless error messages.
Error(DelaySpanBugEmitted),
}
*/
/*
impl<'tcx> TyKind<'tcx> {
#[inline]
pub fn is_primitive(&self) -> bool {
matches!(self, Bool | Char | Int(_) | Uint(_) | Float(_))
}
/// Get the article ("a" or "an") to use with this type.
pub fn article(&self) -> &'static str {
match self {
Int(_) | Float(_) | Array(_, _) => "an",
Adt(def, _) if def.is_enum() => "an",
// This should never happen, but ICEing and causing the user's code
// to not compile felt too harsh.
Error(_) => "a",
_ => "a",
}
}
}
*/
pub
trait
Article
{
fn
article
(
&
self
)
->
&
'static
str
;
}
...
...
compiler/rustc_middle/src/ty/vtable.rs
浏览文件 @
34e05812
...
...
@@ -36,8 +36,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
pub
const
fn
common_vtable_entries
<
'tcx
>
()
->
&
'tcx
[
VtblEntry
<
'tcx
>
]
{
&
[
VtblEntry
::
MetadataDropInPlace
,
VtblEntry
::
MetadataSize
,
VtblEntry
::
MetadataAlign
]
// Needs to be associated with the `'tcx` lifetime
impl
<
'tcx
>
TyCtxt
<
'tcx
>
{
pub
const
COMMON_VTABLE_ENTRIES
:
&
'tcx
[
VtblEntry
<
'tcx
>
]
=
&
[
VtblEntry
::
MetadataDropInPlace
,
VtblEntry
::
MetadataSize
,
VtblEntry
::
MetadataAlign
];
}
pub
const
COMMON_VTABLE_ENTRIES_DROPINPLACE
:
usize
=
0
;
...
...
@@ -58,7 +60,7 @@ pub(super) fn vtable_allocation_provider<'tcx>(
tcx
.vtable_entries
(
trait_ref
)
}
else
{
common_vtable_entries
()
TyCtxt
::
COMMON_VTABLE_ENTRIES
};
let
layout
=
tcx
...
...
compiler/rustc_span/src/symbol.rs
浏览文件 @
34e05812
...
...
@@ -205,6 +205,7 @@
IntoIterator
,
IoRead
,
IoWrite
,
IrTyKind
,
Is
,
ItemContext
,
Iterator
,
...
...
compiler/rustc_trait_selection/src/traits/mod.rs
浏览文件 @
34e05812
...
...
@@ -32,9 +32,7 @@
use
rustc_hir
::
lang_items
::
LangItem
;
use
rustc_middle
::
ty
::
fold
::
TypeFoldable
;
use
rustc_middle
::
ty
::
subst
::{
InternalSubsts
,
SubstsRef
};
use
rustc_middle
::
ty
::{
self
,
common_vtable_entries
,
GenericParamDefKind
,
ToPredicate
,
Ty
,
TyCtxt
,
VtblEntry
,
};
use
rustc_middle
::
ty
::{
self
,
GenericParamDefKind
,
ToPredicate
,
Ty
,
TyCtxt
,
VtblEntry
};
use
rustc_span
::{
sym
,
Span
};
use
smallvec
::
SmallVec
;
...
...
@@ -695,7 +693,7 @@ fn vtable_entries<'tcx>(
let
vtable_segment_callback
=
|
segment
|
->
ControlFlow
<
()
>
{
match
segment
{
VtblSegment
::
MetadataDSA
=>
{
entries
.extend
(
common_vtable_entries
()
);
entries
.extend
(
TyCtxt
::
COMMON_VTABLE_ENTRIES
);
}
VtblSegment
::
TraitOwnEntries
{
trait_ref
,
emit_vptr
}
=>
{
let
existential_trait_ref
=
trait_ref
...
...
@@ -785,7 +783,7 @@ fn vtable_trait_first_method_offset<'tcx>(
move
|
segment
|
{
match
segment
{
VtblSegment
::
MetadataDSA
=>
{
vtable_base
+=
common_vtable_entries
()
.len
();
vtable_base
+=
TyCtxt
::
COMMON_VTABLE_ENTRIES
.len
();
}
VtblSegment
::
TraitOwnEntries
{
trait_ref
,
emit_vptr
}
=>
{
if
tcx
.erase_regions
(
trait_ref
)
==
trait_to_be_found_erased
{
...
...
compiler/rustc_trait_selection/src/traits/select/confirmation.rs
浏览文件 @
34e05812
...
...
@@ -12,7 +12,7 @@
use
rustc_infer
::
infer
::
InferOk
;
use
rustc_infer
::
infer
::
LateBoundRegionConversionTime
::
HigherRankedType
;
use
rustc_middle
::
ty
::
subst
::{
GenericArg
,
GenericArgKind
,
InternalSubsts
,
Subst
,
SubstsRef
};
use
rustc_middle
::
ty
::{
self
,
EarlyBinder
,
GenericParamDefKind
,
Ty
};
use
rustc_middle
::
ty
::{
self
,
EarlyBinder
,
GenericParamDefKind
,
Ty
,
TyCtxt
};
use
rustc_middle
::
ty
::{
ToPolyTraitRef
,
ToPredicate
};
use
rustc_span
::
def_id
::
DefId
;
...
...
@@ -834,7 +834,7 @@ fn confirm_trait_upcasting_unsize_candidate(
move
|
segment
|
{
match
segment
{
VtblSegment
::
MetadataDSA
=>
{
vptr_offset
+=
ty
::
common_vtable_entries
()
.len
();
vptr_offset
+=
TyCtxt
::
COMMON_VTABLE_ENTRIES
.len
();
}
VtblSegment
::
TraitOwnEntries
{
trait_ref
,
emit_vptr
}
=>
{
vptr_offset
+=
util
::
count_own_vtable_entries
(
tcx
,
trait_ref
);
...
...
compiler/rustc_type_ir/src/lib.rs
浏览文件 @
34e05812
...
...
@@ -21,8 +21,6 @@
pub
use
codec
::
*
;
pub
use
sty
::
*
;
extern
crate
self
as
rustc_type_ir
;
pub
trait
Interner
{
type
AdtDef
:
Clone
+
Debug
+
Hash
+
PartialEq
+
Eq
+
PartialOrd
+
Ord
;
type
SubstsRef
:
Clone
+
Debug
+
Hash
+
PartialEq
+
Eq
+
PartialOrd
+
Ord
;
...
...
compiler/rustc_type_ir/src/sty.rs
浏览文件 @
34e05812
此差异已折叠。
点击以展开。
src/test/run-make-fulldeps/obtain-borrowck/driver.rs
浏览文件 @
34e05812
...
...
@@ -154,7 +154,7 @@ fn get_bodies<'tcx>(tcx: TyCtxt<'tcx>) -> Vec<(String, BodyWithBorrowckFacts<'tc
// SAFETY: For soundness we need to ensure that the bodies have
// the same lifetime (`'tcx`), which they had before they were
// stored in the thread local.
(
def_path
.to_string_no_crate_verbose
(),
body
)
(
def_path
.to_string_no_crate_verbose
(),
unsafe
{
std
::
mem
::
transmute
(
body
)
}
)
})
.collect
()
})
...
...
src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs
浏览文件 @
34e05812
...
...
@@ -3,41 +3,43 @@
#![feature(rustc_private)]
extern
crate
rustc_middle
;
extern
crate
rustc_type_ir
;
use
rustc_middle
::
ty
::{
self
,
Ty
,
TyKind
};
use
rustc_type_ir
::{
Interner
,
TyKind
as
IrTyKind
};
#[deny(rustc::usage_of_ty_tykind)]
fn
main
()
{
let
kind
=
TyKind
::
Bool
;
//~ ERROR usage of `ty::TyKind::<kind>`
match
kind
{
TyKind
::
Bool
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Char
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Int
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Uint
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Float
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Adt
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Foreign
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Str
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Array
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Slice
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
RawPtr
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Ref
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
FnDef
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
FnPtr
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Dynamic
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Closure
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Generator
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Bool
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Char
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Int
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Uint
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Float
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Adt
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Foreign
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Str
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Array
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Slice
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
RawPtr
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Ref
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
FnDef
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
FnPtr
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Dynamic
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Closure
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Generator
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
GeneratorWitness
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Never
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Tuple
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Projection
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Opaque
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Param
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Bound
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Placeholder
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Infer
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Error
(
_
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Never
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Tuple
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Projection
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Opaque
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Param
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Bound
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Placeholder
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Infer
(
..
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
TyKind
::
Error
(
_
)
=>
(),
//~ ERROR usage of `ty::TyKind::<kind>`
}
if
let
ty
::
Int
(
int_ty
)
=
kind
{}
...
...
@@ -45,4 +47,10 @@ fn main() {
if
let
TyKind
::
Int
(
int_ty
)
=
kind
{}
//~ ERROR usage of `ty::TyKind::<kind>`
fn
ty_kind
(
ty_bad
:
TyKind
<
'_
>
,
ty_good
:
Ty
<
'_
>
)
{}
//~ ERROR usage of `ty::TyKind`
fn
ir_ty_kind
<
I
:
Interner
>
(
bad
:
IrTyKind
<
I
>
)
->
IrTyKind
<
I
>
{
//~^ ERROR usage of `ty::TyKind`
//~| ERROR usage of `ty::TyKind`
IrTyKind
::
Bool
//~ ERROR usage of `ty::TyKind::<kind>`
}
}
src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr
浏览文件 @
34e05812
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:1
1
:16
--> $DIR/ty_tykind_usage.rs:1
3
:16
|
LL | let kind = TyKind::Bool;
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
|
note: the lint level is defined here
--> $DIR/ty_tykind_usage.rs:
9
:8
--> $DIR/ty_tykind_usage.rs:
11
:8
|
LL | #[deny(rustc::usage_of_ty_tykind)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:1
4
:9
--> $DIR/ty_tykind_usage.rs:1
6
:9
|
LL | TyKind::Bool => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:1
5
:9
--> $DIR/ty_tykind_usage.rs:1
7
:9
|
LL | TyKind::Char => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:1
6
:9
--> $DIR/ty_tykind_usage.rs:1
8
:9
|
LL | TyKind::Int(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:1
7
:9
--> $DIR/ty_tykind_usage.rs:1
9
:9
|
LL | TyKind::Uint(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:
18
:9
--> $DIR/ty_tykind_usage.rs:
20
:9
|
LL | TyKind::Float(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:
19
:9
--> $DIR/ty_tykind_usage.rs:
21
:9
|
LL | TyKind::Adt(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:2
0
:9
--> $DIR/ty_tykind_usage.rs:2
2
:9
|
LL | TyKind::Foreign(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:2
1
:9
--> $DIR/ty_tykind_usage.rs:2
3
:9
|
LL | TyKind::Str => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:2
2
:9
--> $DIR/ty_tykind_usage.rs:2
4
:9
|
LL | TyKind::Array(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:2
3
:9
--> $DIR/ty_tykind_usage.rs:2
5
:9
|
LL | TyKind::Slice(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:2
4
:9
--> $DIR/ty_tykind_usage.rs:2
6
:9
|
LL | TyKind::RawPtr(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:2
5
:9
--> $DIR/ty_tykind_usage.rs:2
7
:9
|
LL | TyKind::Ref(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:2
6
:9
--> $DIR/ty_tykind_usage.rs:2
8
:9
|
LL | TyKind::FnDef(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:2
7
:9
--> $DIR/ty_tykind_usage.rs:2
9
:9
|
LL | TyKind::FnPtr(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:
28
:9
--> $DIR/ty_tykind_usage.rs:
30
:9
|
LL | TyKind::Dynamic(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:
29
:9
--> $DIR/ty_tykind_usage.rs:
31
:9
|
LL | TyKind::Closure(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:3
0
:9
--> $DIR/ty_tykind_usage.rs:3
2
:9
|
LL | TyKind::Generator(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:3
1
:9
--> $DIR/ty_tykind_usage.rs:3
3
:9
|
LL | TyKind::GeneratorWitness(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:3
2
:9
--> $DIR/ty_tykind_usage.rs:3
4
:9
|
LL | TyKind::Never => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:3
3
:9
--> $DIR/ty_tykind_usage.rs:3
5
:9
|
LL | TyKind::Tuple(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:3
4
:9
--> $DIR/ty_tykind_usage.rs:3
6
:9
|
LL | TyKind::Projection(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:3
5
:9
--> $DIR/ty_tykind_usage.rs:3
7
:9
|
LL | TyKind::Opaque(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:3
6
:9
--> $DIR/ty_tykind_usage.rs:3
8
:9
|
LL | TyKind::Param(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:3
7
:9
--> $DIR/ty_tykind_usage.rs:3
9
:9
|
LL | TyKind::Bound(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:
38
:9
--> $DIR/ty_tykind_usage.rs:
40
:9
|
LL | TyKind::Placeholder(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:
39
:9
--> $DIR/ty_tykind_usage.rs:
41
:9
|
LL | TyKind::Infer(..) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:4
0
:9
--> $DIR/ty_tykind_usage.rs:4
2
:9
|
LL | TyKind::Error(_) => (),
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:4
5
:12
--> $DIR/ty_tykind_usage.rs:4
7
:12
|
LL | if let TyKind::Int(int_ty) = kind {}
| ^^^^^^ help: try using
ty::<kind>
directly: `ty`
| ^^^^^^ help: try using
`ty::<kind>`
directly: `ty`
error: usage of `ty::TyKind`
--> $DIR/ty_tykind_usage.rs:4
7
:24
--> $DIR/ty_tykind_usage.rs:4
9
:24
|
LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {}
| ^^^^^^^^^^
|
= help: try using `Ty` instead
error: aborting due to 30 previous errors
error: usage of `ty::TyKind`
--> $DIR/ty_tykind_usage.rs:51:37
|
LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> {
| ^^^^^^^^^^^
|
= help: try using `Ty` instead
error: usage of `ty::TyKind`
--> $DIR/ty_tykind_usage.rs:51:53
|
LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> {
| ^^^^^^^^^^^
|
= help: try using `Ty` instead
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:54:9
|
LL | IrTyKind::Bool
| --------^^^^^^
| |
| help: try using `ty::<kind>` directly: `ty`
error: aborting due to 33 previous errors
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录