Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
62930d31
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,发现更多精彩内容 >>
提交
62930d31
编写于
2月 23, 2020
作者:
M
Mazdak Farrokhzad
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
parse/ast: move `Defaultness` into variants.
上级
842027f3
变更
33
展开全部
隐藏空白更改
内联
并排
Showing
33 changed file
with
630 addition
and
359 deletion
+630
-359
src/librustc_ast_lowering/item.rs
src/librustc_ast_lowering/item.rs
+24
-24
src/librustc_ast_lowering/lib.rs
src/librustc_ast_lowering/lib.rs
+2
-2
src/librustc_ast_passes/ast_validation.rs
src/librustc_ast_passes/ast_validation.rs
+16
-11
src/librustc_ast_passes/feature_gate.rs
src/librustc_ast_passes/feature_gate.rs
+4
-4
src/librustc_ast_pretty/pprust.rs
src/librustc_ast_pretty/pprust.rs
+14
-17
src/librustc_builtin_macros/deriving/generic/mod.rs
src/librustc_builtin_macros/deriving/generic/mod.rs
+3
-3
src/librustc_builtin_macros/global_allocator.rs
src/librustc_builtin_macros/global_allocator.rs
+2
-1
src/librustc_builtin_macros/global_asm.rs
src/librustc_builtin_macros/global_asm.rs
+0
-1
src/librustc_builtin_macros/test.rs
src/librustc_builtin_macros/test.rs
+3
-2
src/librustc_builtin_macros/test_harness.rs
src/librustc_builtin_macros/test_harness.rs
+4
-4
src/librustc_expand/build.rs
src/librustc_expand/build.rs
+2
-2
src/librustc_expand/expand.rs
src/librustc_expand/expand.rs
+0
-1
src/librustc_expand/placeholders.rs
src/librustc_expand/placeholders.rs
+0
-5
src/librustc_interface/util.rs
src/librustc_interface/util.rs
+2
-2
src/librustc_lint/builtin.rs
src/librustc_lint/builtin.rs
+1
-1
src/librustc_metadata/rmeta/decoder/cstore_impl.rs
src/librustc_metadata/rmeta/decoder/cstore_impl.rs
+0
-1
src/librustc_parse/parser/item.rs
src/librustc_parse/parser/item.rs
+32
-32
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/build_reduced_graph.rs
+2
-2
src/librustc_resolve/def_collector.rs
src/librustc_resolve/def_collector.rs
+2
-2
src/librustc_resolve/late.rs
src/librustc_resolve/late.rs
+12
-10
src/librustc_save_analysis/dump_visitor.rs
src/librustc_save_analysis/dump_visitor.rs
+13
-12
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/lib.rs
+5
-4
src/librustc_save_analysis/sig.rs
src/librustc_save_analysis/sig.rs
+4
-4
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+17
-11
src/libsyntax/mut_visit.rs
src/libsyntax/mut_visit.rs
+9
-10
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+8
-8
src/test/ui/ast-json/ast-json-output.stdout
src/test/ui/ast-json/ast-json-output.stdout
+1
-1
src/test/ui/parser/assoc-static-semantic-fail.rs
src/test/ui/parser/assoc-static-semantic-fail.rs
+6
-2
src/test/ui/parser/assoc-static-semantic-fail.stderr
src/test/ui/parser/assoc-static-semantic-fail.stderr
+63
-31
src/test/ui/parser/assoc-static-syntactic-fail.rs
src/test/ui/parser/assoc-static-syntactic-fail.rs
+6
-0
src/test/ui/parser/assoc-static-syntactic-fail.stderr
src/test/ui/parser/assoc-static-syntactic-fail.stderr
+58
-10
src/test/ui/parser/default-on-wrong-item-kind.rs
src/test/ui/parser/default-on-wrong-item-kind.rs
+62
-62
src/test/ui/parser/default-on-wrong-item-kind.stderr
src/test/ui/parser/default-on-wrong-item-kind.stderr
+253
-77
未找到文件。
src/librustc_ast_lowering/item.rs
浏览文件 @
62930d31
...
...
@@ -173,7 +173,7 @@ pub(super) fn lower_mod(&mut self, m: &Mod) -> hir::Mod<'hir> {
}
ids
}
ItemKind
::
Const
(
ref
ty
,
..
)
=>
{
ItemKind
::
Const
(
_
,
ref
ty
,
..
)
=>
{
let
mut
ids
=
smallvec!
[
i
.id
];
if
self
.sess
.features_untracked
()
.impl_trait_in_bindings
{
let
mut
visitor
=
ImplTraitTypeIdVisitor
{
ids
:
&
mut
ids
};
...
...
@@ -264,11 +264,11 @@ fn lower_item_kind(
let
(
ty
,
body_id
)
=
self
.lower_const_item
(
t
,
span
,
e
.as_deref
());
hir
::
ItemKind
::
Static
(
ty
,
m
,
body_id
)
}
ItemKind
::
Const
(
ref
t
,
ref
e
)
=>
{
ItemKind
::
Const
(
_
,
ref
t
,
ref
e
)
=>
{
let
(
ty
,
body_id
)
=
self
.lower_const_item
(
t
,
span
,
e
.as_deref
());
hir
::
ItemKind
::
Const
(
ty
,
body_id
)
}
ItemKind
::
Fn
(
FnSig
{
ref
decl
,
header
},
ref
generics
,
ref
body
)
=>
{
ItemKind
::
Fn
(
_
,
FnSig
{
ref
decl
,
header
},
ref
generics
,
ref
body
)
=>
{
let
fn_def_id
=
self
.resolver
.definitions
()
.local_def_id
(
id
);
self
.with_new_scopes
(|
this
|
{
this
.current_item
=
Some
(
ident
.span
);
...
...
@@ -297,16 +297,16 @@ fn lower_item_kind(
ItemKind
::
Mod
(
ref
m
)
=>
hir
::
ItemKind
::
Mod
(
self
.lower_mod
(
m
)),
ItemKind
::
ForeignMod
(
ref
nm
)
=>
hir
::
ItemKind
::
ForeignMod
(
self
.lower_foreign_mod
(
nm
)),
ItemKind
::
GlobalAsm
(
ref
ga
)
=>
hir
::
ItemKind
::
GlobalAsm
(
self
.lower_global_asm
(
ga
)),
ItemKind
::
TyAlias
(
ref
generics
,
_
,
Some
(
ref
ty
))
=>
match
ty
.kind
.opaque_top_hack
()
{
ItemKind
::
TyAlias
(
_
,
ref
gen
,
_
,
Some
(
ref
ty
))
=>
match
ty
.kind
.opaque_top_hack
()
{
None
=>
{
let
ty
=
self
.lower_ty
(
ty
,
ImplTraitContext
::
disallowed
());
let
generics
=
self
.lower_generics
(
gen
erics
,
ImplTraitContext
::
disallowed
());
let
generics
=
self
.lower_generics
(
gen
,
ImplTraitContext
::
disallowed
());
hir
::
ItemKind
::
TyAlias
(
ty
,
generics
)
}
Some
(
bounds
)
=>
{
let
ctx
=
||
ImplTraitContext
::
OpaqueTy
(
None
,
hir
::
OpaqueTyOrigin
::
Misc
);
let
ty
=
hir
::
OpaqueTy
{
generics
:
self
.lower_generics
(
gen
erics
,
ctx
()),
generics
:
self
.lower_generics
(
gen
,
ctx
()),
bounds
:
self
.lower_param_bounds
(
bounds
,
ctx
()),
impl_trait_fn
:
None
,
origin
:
hir
::
OpaqueTyOrigin
::
TypeAlias
,
...
...
@@ -314,7 +314,7 @@ fn lower_item_kind(
hir
::
ItemKind
::
OpaqueTy
(
ty
)
}
},
ItemKind
::
TyAlias
(
ref
generics
,
_
,
None
)
=>
{
ItemKind
::
TyAlias
(
_
,
ref
generics
,
_
,
None
)
=>
{
let
ty
=
self
.arena
.alloc
(
self
.ty
(
span
,
hir
::
TyKind
::
Err
));
let
generics
=
self
.lower_generics
(
generics
,
ImplTraitContext
::
disallowed
());
hir
::
ItemKind
::
TyAlias
(
ty
,
generics
)
...
...
@@ -654,7 +654,7 @@ fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
ident
:
i
.ident
,
attrs
:
self
.lower_attrs
(
&
i
.attrs
),
kind
:
match
i
.kind
{
ForeignItemKind
::
Fn
(
ref
sig
,
ref
generics
,
_
)
=>
{
ForeignItemKind
::
Fn
(
_
,
ref
sig
,
ref
generics
,
_
)
=>
{
let
fdec
=
&
sig
.decl
;
let
(
generics
,
(
fn_dec
,
fn_args
))
=
self
.add_in_band_defs
(
generics
,
...
...
@@ -675,7 +675,7 @@ fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
let
ty
=
self
.lower_ty
(
t
,
ImplTraitContext
::
disallowed
());
hir
::
ForeignItemKind
::
Static
(
ty
,
m
)
}
ForeignItemKind
::
Const
(
ref
t
,
_
)
=>
{
ForeignItemKind
::
Const
(
_
,
ref
t
,
_
)
=>
{
// For recovery purposes.
let
ty
=
self
.lower_ty
(
t
,
ImplTraitContext
::
disallowed
());
hir
::
ForeignItemKind
::
Static
(
ty
,
Mutability
::
Not
)
...
...
@@ -758,24 +758,24 @@ fn lower_trait_item(&mut self, i: &AssocItem) -> hir::TraitItem<'hir> {
let
(
generics
,
kind
)
=
match
i
.kind
{
AssocItemKind
::
Static
(
ref
ty
,
_
,
ref
default
)
// Let's pretend this is a `const`.
|
AssocItemKind
::
Const
(
ref
ty
,
ref
default
)
=>
{
|
AssocItemKind
::
Const
(
_
,
ref
ty
,
ref
default
)
=>
{
let
ty
=
self
.lower_ty
(
ty
,
ImplTraitContext
::
disallowed
());
let
body
=
default
.as_ref
()
.map
(|
x
|
self
.lower_const_body
(
i
.span
,
Some
(
x
)));
(
hir
::
Generics
::
empty
(),
hir
::
TraitItemKind
::
Const
(
ty
,
body
))
}
AssocItemKind
::
Fn
(
ref
sig
,
ref
generics
,
None
)
=>
{
AssocItemKind
::
Fn
(
_
,
ref
sig
,
ref
generics
,
None
)
=>
{
let
names
=
self
.lower_fn_params_to_names
(
&
sig
.decl
);
let
(
generics
,
sig
)
=
self
.lower_method_sig
(
generics
,
sig
,
trait_item_def_id
,
false
,
None
);
(
generics
,
hir
::
TraitItemKind
::
Method
(
sig
,
hir
::
TraitMethod
::
Required
(
names
)))
}
AssocItemKind
::
Fn
(
ref
sig
,
ref
generics
,
Some
(
ref
body
))
=>
{
AssocItemKind
::
Fn
(
_
,
ref
sig
,
ref
generics
,
Some
(
ref
body
))
=>
{
let
body_id
=
self
.lower_fn_body_block
(
i
.span
,
&
sig
.decl
,
Some
(
body
));
let
(
generics
,
sig
)
=
self
.lower_method_sig
(
generics
,
sig
,
trait_item_def_id
,
false
,
None
);
(
generics
,
hir
::
TraitItemKind
::
Method
(
sig
,
hir
::
TraitMethod
::
Provided
(
body_id
)))
}
AssocItemKind
::
TyAlias
(
ref
generics
,
ref
bounds
,
ref
default
)
=>
{
AssocItemKind
::
TyAlias
(
_
,
ref
generics
,
ref
bounds
,
ref
default
)
=>
{
let
ty
=
default
.as_ref
()
.map
(|
x
|
self
.lower_ty
(
x
,
ImplTraitContext
::
disallowed
()));
let
generics
=
self
.lower_generics
(
generics
,
ImplTraitContext
::
disallowed
());
let
kind
=
hir
::
TraitItemKind
::
Type
(
...
...
@@ -801,11 +801,11 @@ fn lower_trait_item(&mut self, i: &AssocItem) -> hir::TraitItem<'hir> {
fn
lower_trait_item_ref
(
&
mut
self
,
i
:
&
AssocItem
)
->
hir
::
TraitItemRef
{
let
(
kind
,
has_default
)
=
match
&
i
.kind
{
AssocItemKind
::
Static
(
_
,
_
,
default
)
// Let's pretend this is a `const` for recovery.
|
AssocItemKind
::
Const
(
_
,
default
)
=>
{
|
AssocItemKind
::
Const
(
_
,
_
,
default
)
=>
{
(
hir
::
AssocItemKind
::
Const
,
default
.is_some
())
}
AssocItemKind
::
TyAlias
(
_
,
_
,
default
)
=>
(
hir
::
AssocItemKind
::
Type
,
default
.is_some
()),
AssocItemKind
::
Fn
(
sig
,
_
,
default
)
=>
{
AssocItemKind
::
TyAlias
(
_
,
_
,
_
,
default
)
=>
(
hir
::
AssocItemKind
::
Type
,
default
.is_some
()),
AssocItemKind
::
Fn
(
_
,
sig
,
_
,
default
)
=>
{
(
hir
::
AssocItemKind
::
Method
{
has_self
:
sig
.decl
.has_self
()
},
default
.is_some
())
}
AssocItemKind
::
Macro
(
..
)
=>
unimplemented!
(),
...
...
@@ -823,15 +823,15 @@ fn expr_err(&mut self, span: Span) -> hir::Expr<'hir> {
fn
lower_impl_item
(
&
mut
self
,
i
:
&
AssocItem
)
->
hir
::
ImplItem
<
'hir
>
{
let
impl_item_def_id
=
self
.resolver
.definitions
()
.local_def_id
(
i
.id
);
let
(
generics
,
kind
)
=
match
i
.kind
{
AssocItemKind
::
Static
(
ref
ty
,
_
,
ref
expr
)
|
AssocItemKind
::
Const
(
ref
ty
,
ref
expr
)
=>
{
let
(
generics
,
kind
)
=
match
&
i
.kind
{
AssocItemKind
::
Static
(
ty
,
_
,
expr
)
|
AssocItemKind
::
Const
(
_
,
ty
,
expr
)
=>
{
let
ty
=
self
.lower_ty
(
ty
,
ImplTraitContext
::
disallowed
());
(
hir
::
Generics
::
empty
(),
hir
::
ImplItemKind
::
Const
(
ty
,
self
.lower_const_body
(
i
.span
,
expr
.as_deref
())),
)
}
AssocItemKind
::
Fn
(
ref
sig
,
ref
generics
,
ref
body
)
=>
{
AssocItemKind
::
Fn
(
_
,
sig
,
generics
,
body
)
=>
{
self
.current_item
=
Some
(
i
.span
);
let
asyncness
=
sig
.header.asyncness
;
let
body_id
=
...
...
@@ -847,7 +847,7 @@ fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem<'hir> {
(
generics
,
hir
::
ImplItemKind
::
Method
(
sig
,
body_id
))
}
AssocItemKind
::
TyAlias
(
ref
generics
,
_
,
ref
ty
)
=>
{
AssocItemKind
::
TyAlias
(
_
,
generics
,
_
,
ty
)
=>
{
let
generics
=
self
.lower_generics
(
generics
,
ImplTraitContext
::
disallowed
());
let
kind
=
match
ty
{
None
=>
{
...
...
@@ -876,7 +876,7 @@ fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem<'hir> {
attrs
:
self
.lower_attrs
(
&
i
.attrs
),
generics
,
vis
:
self
.lower_visibility
(
&
i
.vis
,
None
),
defaultness
:
self
.lower_defaultness
(
i
.
defaultness
,
true
/* [1] */
),
defaultness
:
self
.lower_defaultness
(
i
.
kind
.defaultness
()
,
true
/* [1] */
),
kind
,
span
:
i
.span
,
}
...
...
@@ -890,17 +890,17 @@ fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef<'hir> {
ident
:
i
.ident
,
span
:
i
.span
,
vis
:
self
.lower_visibility
(
&
i
.vis
,
Some
(
i
.id
)),
defaultness
:
self
.lower_defaultness
(
i
.
defaultness
,
true
/* [1] */
),
defaultness
:
self
.lower_defaultness
(
i
.
kind
.defaultness
()
,
true
/* [1] */
),
kind
:
match
&
i
.kind
{
AssocItemKind
::
Static
(
..
)
// Let's pretend this is a `const` for recovery.
|
AssocItemKind
::
Const
(
..
)
=>
hir
::
AssocItemKind
::
Const
,
AssocItemKind
::
TyAlias
(
_
,
_
,
ty
)
=>
{
AssocItemKind
::
TyAlias
(
..
,
ty
)
=>
{
match
ty
.as_deref
()
.and_then
(|
ty
|
ty
.kind
.opaque_top_hack
())
{
None
=>
hir
::
AssocItemKind
::
Type
,
Some
(
_
)
=>
hir
::
AssocItemKind
::
OpaqueTy
,
}
}
AssocItemKind
::
Fn
(
sig
,
_
,
_
)
=>
{
AssocItemKind
::
Fn
(
_
,
sig
,
..
)
=>
{
hir
::
AssocItemKind
::
Method
{
has_self
:
sig
.decl
.has_self
()
}
}
AssocItemKind
::
Macro
(
..
)
=>
unimplemented!
(),
...
...
src/librustc_ast_lowering/lib.rs
浏览文件 @
62930d31
...
...
@@ -462,7 +462,7 @@ fn visit_item(&mut self, item: &'tcx Item) {
ItemKind
::
Struct
(
_
,
ref
generics
)
|
ItemKind
::
Union
(
_
,
ref
generics
)
|
ItemKind
::
Enum
(
_
,
ref
generics
)
|
ItemKind
::
TyAlias
(
ref
generics
,
..
)
|
ItemKind
::
TyAlias
(
_
,
ref
generics
,
..
)
|
ItemKind
::
Trait
(
_
,
_
,
ref
generics
,
..
)
=>
{
let
def_id
=
self
.lctx.resolver
.definitions
()
.local_def_id
(
item
.id
);
let
count
=
generics
...
...
@@ -490,7 +490,7 @@ fn visit_assoc_item(&mut self, item: &'tcx AssocItem, ctxt: AssocCtxt) {
self
.lctx
.allocate_hir_id_counter
(
item
.id
);
let
owner
=
match
(
&
item
.kind
,
ctxt
)
{
// Ignore patterns in trait methods without bodies.
(
AssocItemKind
::
Fn
(
_
,
_
,
None
),
AssocCtxt
::
Trait
)
=>
None
,
(
AssocItemKind
::
Fn
(
_
,
_
,
_
,
None
),
AssocCtxt
::
Trait
)
=>
None
,
_
=>
Some
(
item
.id
),
};
self
.with_hir_id_owner
(
owner
,
|
this
|
visit
::
walk_assoc_item
(
this
,
item
,
ctxt
));
...
...
src/librustc_ast_passes/ast_validation.rs
浏览文件 @
62930d31
...
...
@@ -881,7 +881,8 @@ fn visit_item(&mut self, item: &'a Item) {
.emit
();
}
}
ItemKind
::
Fn
(
ref
sig
,
ref
generics
,
ref
body
)
=>
{
ItemKind
::
Fn
(
def
,
ref
sig
,
ref
generics
,
ref
body
)
=>
{
self
.check_defaultness
(
item
.span
,
def
);
self
.check_const_fn_const_generic
(
item
.span
,
sig
,
generics
);
if
body
.is_none
()
{
...
...
@@ -965,7 +966,8 @@ fn visit_item(&mut self, item: &'a Item) {
self
.err_handler
()
.span_err
(
item
.span
,
"unions cannot have zero fields"
);
}
}
ItemKind
::
Const
(
..
,
None
)
=>
{
ItemKind
::
Const
(
def
,
..
,
None
)
=>
{
self
.check_defaultness
(
item
.span
,
def
);
let
msg
=
"free constant item without body"
;
self
.error_item_without_body
(
item
.span
,
"constant"
,
msg
,
" = <expr>;"
);
}
...
...
@@ -973,7 +975,8 @@ fn visit_item(&mut self, item: &'a Item) {
let
msg
=
"free static item without body"
;
self
.error_item_without_body
(
item
.span
,
"static"
,
msg
,
" = <expr>;"
);
}
ItemKind
::
TyAlias
(
_
,
ref
bounds
,
ref
body
)
=>
{
ItemKind
::
TyAlias
(
def
,
_
,
ref
bounds
,
ref
body
)
=>
{
self
.check_defaultness
(
item
.span
,
def
);
if
body
.is_none
()
{
let
msg
=
"free type alias without body"
;
self
.error_item_without_body
(
item
.span
,
"type"
,
msg
,
" = <type>;"
);
...
...
@@ -988,11 +991,13 @@ fn visit_item(&mut self, item: &'a Item) {
fn
visit_foreign_item
(
&
mut
self
,
fi
:
&
'a
ForeignItem
)
{
match
&
fi
.kind
{
ForeignItemKind
::
Fn
(
sig
,
_
,
body
)
=>
{
ForeignItemKind
::
Fn
(
def
,
sig
,
_
,
body
)
=>
{
self
.check_defaultness
(
fi
.span
,
*
def
);
self
.check_foreign_fn_bodyless
(
fi
.ident
,
body
.as_deref
());
self
.check_foreign_fn_headerless
(
fi
.ident
,
fi
.span
,
sig
.header
);
}
ForeignItemKind
::
TyAlias
(
generics
,
bounds
,
body
)
=>
{
ForeignItemKind
::
TyAlias
(
def
,
generics
,
bounds
,
body
)
=>
{
self
.check_defaultness
(
fi
.span
,
*
def
);
self
.check_foreign_kind_bodyless
(
fi
.ident
,
"type"
,
body
.as_ref
()
.map
(|
b
|
b
.span
));
self
.check_type_no_bounds
(
bounds
,
"`extern` blocks"
);
self
.check_foreign_ty_genericless
(
generics
);
...
...
@@ -1233,19 +1238,19 @@ fn visit_fn(&mut self, fk: FnKind<'a>, span: Span, id: NodeId) {
}
fn
visit_assoc_item
(
&
mut
self
,
item
:
&
'a
AssocItem
,
ctxt
:
AssocCtxt
)
{
if
ctxt
==
AssocCtxt
::
Trait
{
self
.check_defaultness
(
item
.span
,
item
.
defaultness
);
if
ctxt
==
AssocCtxt
::
Trait
||
!
self
.in_trait_impl
{
self
.check_defaultness
(
item
.span
,
item
.
kind
.defaultness
()
);
}
if
ctxt
==
AssocCtxt
::
Impl
{
match
&
item
.kind
{
AssocItemKind
::
Const
(
_
,
body
)
=>
{
AssocItemKind
::
Const
(
_
,
_
,
body
)
=>
{
self
.check_impl_item_provided
(
item
.span
,
body
,
"constant"
,
" = <expr>;"
);
}
AssocItemKind
::
Fn
(
_
,
_
,
body
)
=>
{
AssocItemKind
::
Fn
(
_
,
_
,
_
,
body
)
=>
{
self
.check_impl_item_provided
(
item
.span
,
body
,
"function"
,
" { <body> }"
);
}
AssocItemKind
::
TyAlias
(
_
,
bounds
,
body
)
=>
{
AssocItemKind
::
TyAlias
(
_
,
_
,
bounds
,
body
)
=>
{
self
.check_impl_item_provided
(
item
.span
,
body
,
"type"
,
" = <type>;"
);
self
.check_type_no_bounds
(
bounds
,
"`impl`s"
);
}
...
...
@@ -1255,7 +1260,7 @@ fn visit_assoc_item(&mut self, item: &'a AssocItem, ctxt: AssocCtxt) {
if
ctxt
==
AssocCtxt
::
Trait
||
self
.in_trait_impl
{
self
.invalid_visibility
(
&
item
.vis
,
None
);
if
let
AssocItemKind
::
Fn
(
sig
,
_
,
_
)
=
&
item
.kind
{
if
let
AssocItemKind
::
Fn
(
_
,
sig
,
_
,
_
)
=
&
item
.kind
{
self
.check_trait_fn_not_const
(
sig
.header.constness
);
self
.check_trait_fn_not_async
(
item
.span
,
sig
.header.asyncness
);
}
...
...
src/librustc_ast_passes/feature_gate.rs
浏览文件 @
62930d31
...
...
@@ -372,7 +372,7 @@ fn visit_item(&mut self, i: &'a ast::Item) {
gate_feature_post!
(
&
self
,
decl_macro
,
i
.span
,
msg
);
}
ast
::
ItemKind
::
TyAlias
(
_
,
_
,
Some
(
ref
ty
))
=>
self
.check_impl_trait
(
&
ty
),
ast
::
ItemKind
::
TyAlias
(
_
,
_
,
_
,
Some
(
ref
ty
))
=>
self
.check_impl_trait
(
&
ty
),
_
=>
{}
}
...
...
@@ -543,17 +543,17 @@ fn visit_assoc_ty_constraint(&mut self, constraint: &'a AssocTyConstraint) {
}
fn
visit_assoc_item
(
&
mut
self
,
i
:
&
'a
ast
::
AssocItem
,
ctxt
:
AssocCtxt
)
{
if
let
ast
::
Defaultness
::
Default
(
_
)
=
i
.
defaultness
{
if
let
ast
::
Defaultness
::
Default
(
_
)
=
i
.
kind
.defaultness
()
{
gate_feature_post!
(
&
self
,
specialization
,
i
.span
,
"specialization is unstable"
);
}
match
i
.kind
{
ast
::
AssocItemKind
::
Fn
(
ref
sig
,
_
,
_
)
=>
{
ast
::
AssocItemKind
::
Fn
(
_
,
ref
sig
,
_
,
_
)
=>
{
if
let
(
ast
::
Const
::
Yes
(
_
),
AssocCtxt
::
Trait
)
=
(
sig
.header.constness
,
ctxt
)
{
gate_feature_post!
(
&
self
,
const_fn
,
i
.span
,
"const fn is unstable"
);
}
}
ast
::
AssocItemKind
::
TyAlias
(
ref
generics
,
_
,
ref
ty
)
=>
{
ast
::
AssocItemKind
::
TyAlias
(
_
,
ref
generics
,
_
,
ref
ty
)
=>
{
if
let
(
Some
(
_
),
AssocCtxt
::
Trait
)
=
(
ty
,
ctxt
)
{
gate_feature_post!
(
&
self
,
...
...
src/librustc_ast_pretty/pprust.rs
浏览文件 @
62930d31
...
...
@@ -1016,8 +1016,8 @@ pub fn print_type(&mut self, ty: &ast::Ty) {
}
crate
fn
print_foreign_item
(
&
mut
self
,
item
:
&
ast
::
ForeignItem
)
{
let
ast
::
Item
{
id
,
span
,
ident
,
attrs
,
kind
,
vis
,
defaultness
,
tokens
:
_
}
=
item
;
self
.print_nested_item_kind
(
*
id
,
*
span
,
*
ident
,
attrs
,
*
defaultness
,
kind
,
vis
);
let
ast
::
Item
{
id
,
span
,
ident
,
attrs
,
kind
,
vis
,
tokens
:
_
}
=
item
;
self
.print_nested_item_kind
(
*
id
,
*
span
,
*
ident
,
attrs
,
kind
,
vis
);
}
fn
print_nested_item_kind
(
...
...
@@ -1026,7 +1026,6 @@ fn print_nested_item_kind(
span
:
Span
,
ident
:
ast
::
Ident
,
attrs
:
&
[
Attribute
],
def
:
ast
::
Defaultness
,
kind
:
&
ast
::
AssocItemKind
,
vis
:
&
ast
::
Visibility
,
)
{
...
...
@@ -1035,17 +1034,18 @@ fn print_nested_item_kind(
self
.maybe_print_comment
(
span
.lo
());
self
.print_outer_attributes
(
attrs
);
match
kind
{
ast
::
ForeignItemKind
::
Fn
(
sig
,
gen
,
body
)
=>
{
self
.print_fn_full
(
sig
,
ident
,
gen
,
vis
,
def
,
body
.as_deref
(),
attrs
);
ast
::
ForeignItemKind
::
Fn
(
def
,
sig
,
gen
,
body
)
=>
{
self
.print_fn_full
(
sig
,
ident
,
gen
,
vis
,
*
def
,
body
.as_deref
(),
attrs
);
}
ast
::
ForeignItemKind
::
Const
(
ty
,
body
)
=>
{
self
.print_item_const
(
ident
,
None
,
ty
,
body
.as_deref
(),
vis
,
def
);
ast
::
ForeignItemKind
::
Const
(
def
,
ty
,
body
)
=>
{
self
.print_item_const
(
ident
,
None
,
ty
,
body
.as_deref
(),
vis
,
*
def
);
}
ast
::
ForeignItemKind
::
Static
(
ty
,
mutbl
,
body
)
=>
{
let
def
=
ast
::
Defaultness
::
Final
;
self
.print_item_const
(
ident
,
Some
(
*
mutbl
),
ty
,
body
.as_deref
(),
vis
,
def
);
}
ast
::
ForeignItemKind
::
TyAlias
(
generics
,
bounds
,
ty
)
=>
{
self
.print_associated_type
(
ident
,
generics
,
bounds
,
ty
.as_deref
(),
vis
,
def
);
ast
::
ForeignItemKind
::
TyAlias
(
def
,
generics
,
bounds
,
ty
)
=>
{
self
.print_associated_type
(
ident
,
generics
,
bounds
,
ty
.as_deref
(),
vis
,
*
def
);
}
ast
::
ForeignItemKind
::
Macro
(
m
)
=>
{
self
.print_mac
(
m
);
...
...
@@ -1146,12 +1146,10 @@ fn print_associated_type(
let
def
=
ast
::
Defaultness
::
Final
;
self
.print_item_const
(
item
.ident
,
Some
(
mutbl
),
ty
,
body
.as_deref
(),
&
item
.vis
,
def
);
}
ast
::
ItemKind
::
Const
(
ref
ty
,
ref
body
)
=>
{
let
def
=
ast
::
Defaultness
::
Final
;
ast
::
ItemKind
::
Const
(
def
,
ref
ty
,
ref
body
)
=>
{
self
.print_item_const
(
item
.ident
,
None
,
ty
,
body
.as_deref
(),
&
item
.vis
,
def
);
}
ast
::
ItemKind
::
Fn
(
ref
sig
,
ref
gen
,
ref
body
)
=>
{
let
def
=
ast
::
Defaultness
::
Final
;
ast
::
ItemKind
::
Fn
(
def
,
ref
sig
,
ref
gen
,
ref
body
)
=>
{
let
body
=
body
.as_deref
();
self
.print_fn_full
(
sig
,
item
.ident
,
gen
,
&
item
.vis
,
def
,
body
,
&
item
.attrs
);
}
...
...
@@ -1185,8 +1183,7 @@ fn print_associated_type(
self
.s
.word
(
ga
.asm
.to_string
());
self
.end
();
}
ast
::
ItemKind
::
TyAlias
(
ref
generics
,
ref
bounds
,
ref
ty
)
=>
{
let
def
=
ast
::
Defaultness
::
Final
;
ast
::
ItemKind
::
TyAlias
(
def
,
ref
generics
,
ref
bounds
,
ref
ty
)
=>
{
let
ty
=
ty
.as_deref
();
self
.print_associated_type
(
item
.ident
,
generics
,
bounds
,
ty
,
&
item
.vis
,
def
);
}
...
...
@@ -1461,8 +1458,8 @@ fn print_poly_trait_ref(&mut self, t: &ast::PolyTraitRef) {
}
crate
fn
print_assoc_item
(
&
mut
self
,
item
:
&
ast
::
AssocItem
)
{
let
ast
::
AssocItem
{
id
,
span
,
ident
,
attrs
,
defaultnes
s
,
kind
,
vis
,
tokens
:
_
}
=
item
;
self
.print_nested_item_kind
(
*
id
,
*
span
,
*
ident
,
attrs
,
*
defaultness
,
kind
,
vis
);
let
ast
::
Item
{
id
,
span
,
ident
,
attr
s
,
kind
,
vis
,
tokens
:
_
}
=
item
;
self
.print_nested_item_kind
(
*
id
,
*
span
,
*
ident
,
attrs
,
kind
,
vis
);
}
crate
fn
print_stmt
(
&
mut
self
,
st
:
&
ast
::
Stmt
)
{
...
...
src/librustc_builtin_macros/deriving/generic/mod.rs
浏览文件 @
62930d31
...
...
@@ -542,9 +542,9 @@ fn create_derived_impl(
span
:
self
.span
,
ident
,
vis
:
respan
(
self
.span
.shrink_to_lo
(),
ast
::
VisibilityKind
::
Inherited
),
defaultness
:
ast
::
Defaultness
::
Final
,
attrs
:
Vec
::
new
(),
kind
:
ast
::
AssocItemKind
::
TyAlias
(
ast
::
Defaultness
::
Final
,
Generics
::
default
(),
Vec
::
new
(),
Some
(
type_def
.to_ty
(
cx
,
self
.span
,
type_ident
,
generics
)),
...
...
@@ -968,6 +968,7 @@ fn create_method(
header
:
ast
::
FnHeader
{
unsafety
,
ext
:
ast
::
Extern
::
None
,
..
ast
::
FnHeader
::
default
()
},
decl
:
fn_decl
,
};
let
def
=
ast
::
Defaultness
::
Final
;
// Create the method.
P
(
ast
::
AssocItem
{
...
...
@@ -975,9 +976,8 @@ fn create_method(
attrs
:
self
.attributes
.clone
(),
span
:
trait_
.span
,
vis
:
respan
(
trait_lo_sp
,
ast
::
VisibilityKind
::
Inherited
),
defaultness
:
ast
::
Defaultness
::
Final
,
ident
:
method_ident
,
kind
:
ast
::
AssocItemKind
::
Fn
(
sig
,
fn_generics
,
Some
(
body_block
)),
kind
:
ast
::
AssocItemKind
::
Fn
(
def
,
sig
,
fn_generics
,
Some
(
body_block
)),
tokens
:
None
,
})
}
...
...
src/librustc_builtin_macros/global_allocator.rs
浏览文件 @
62930d31
...
...
@@ -66,7 +66,8 @@ fn allocator_fn(&self, method: &AllocatorMethod) -> Stmt {
let
decl
=
self
.cx
.fn_decl
(
abi_args
,
ast
::
FnRetTy
::
Ty
(
output_ty
));
let
header
=
FnHeader
{
unsafety
:
Unsafe
::
Yes
(
self
.span
),
..
FnHeader
::
default
()
};
let
sig
=
FnSig
{
decl
,
header
};
let
kind
=
ItemKind
::
Fn
(
sig
,
Generics
::
default
(),
Some
(
self
.cx
.block_expr
(
output_expr
)));
let
block
=
Some
(
self
.cx
.block_expr
(
output_expr
));
let
kind
=
ItemKind
::
Fn
(
ast
::
Defaultness
::
Final
,
sig
,
Generics
::
default
(),
block
);
let
item
=
self
.cx
.item
(
self
.span
,
self
.cx
.ident_of
(
&
self
.kind
.fn_name
(
method
.name
),
self
.span
),
...
...
src/librustc_builtin_macros/global_asm.rs
浏览文件 @
62930d31
...
...
@@ -30,7 +30,6 @@ pub fn expand_global_asm<'cx>(
id
:
ast
::
DUMMY_NODE_ID
,
kind
:
ast
::
ItemKind
::
GlobalAsm
(
P
(
global_asm
)),
vis
:
respan
(
sp
.shrink_to_lo
(),
ast
::
VisibilityKind
::
Inherited
),
defaultness
:
ast
::
Defaultness
::
Final
,
span
:
cx
.with_def_site_ctxt
(
sp
),
tokens
:
None
,
})]),
...
...
src/librustc_builtin_macros/test.rs
浏览文件 @
62930d31
...
...
@@ -184,6 +184,7 @@ pub fn expand_test_or_bench(
],
// const $ident: test::TestDescAndFn =
ast
::
ItemKind
::
Const
(
ast
::
Defaultness
::
Final
,
cx
.ty
(
sp
,
ast
::
TyKind
::
Path
(
None
,
test_path
(
"TestDescAndFn"
))),
// test::TestDescAndFn {
Some
(
...
...
@@ -378,7 +379,7 @@ fn test_type(cx: &ExtCtxt<'_>) -> TestType {
fn
has_test_signature
(
cx
:
&
ExtCtxt
<
'_
>
,
i
:
&
ast
::
Item
)
->
bool
{
let
has_should_panic_attr
=
attr
::
contains_name
(
&
i
.attrs
,
sym
::
should_panic
);
let
ref
sd
=
cx
.parse_sess.span_diagnostic
;
if
let
ast
::
ItemKind
::
Fn
(
ref
sig
,
ref
generics
,
_
)
=
i
.kind
{
if
let
ast
::
ItemKind
::
Fn
(
_
,
ref
sig
,
ref
generics
,
_
)
=
i
.kind
{
if
let
ast
::
Unsafe
::
Yes
(
span
)
=
sig
.header.unsafety
{
sd
.struct_span_err
(
i
.span
,
"unsafe functions cannot be used for tests"
)
.span_label
(
span
,
"`unsafe` because of this"
)
...
...
@@ -427,7 +428,7 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool {
}
fn
has_bench_signature
(
cx
:
&
ExtCtxt
<
'_
>
,
i
:
&
ast
::
Item
)
->
bool
{
let
has_sig
=
if
let
ast
::
ItemKind
::
Fn
(
ref
sig
,
_
,
_
)
=
i
.kind
{
let
has_sig
=
if
let
ast
::
ItemKind
::
Fn
(
_
,
ref
sig
,
_
,
_
)
=
i
.kind
{
// N.B., inadequate check, but we're running
// well before resolve, can't get too deep.
sig
.decl.inputs
.len
()
==
1
...
...
src/librustc_builtin_macros/test_harness.rs
浏览文件 @
62930d31
...
...
@@ -162,7 +162,7 @@ impl MutVisitor for EntryPointCleaner {
// #[allow(dead_code)] to avoid printing warnings.
let
item
=
match
entry
::
entry_point_type
(
&
item
,
self
.depth
)
{
EntryPointType
::
MainNamed
|
EntryPointType
::
MainAttr
|
EntryPointType
::
Start
=>
item
.map
(|
ast
::
Item
{
id
,
ident
,
attrs
,
kind
,
vis
,
defaultness
,
span
,
tokens
}|
{
.map
(|
ast
::
Item
{
id
,
ident
,
attrs
,
kind
,
vis
,
span
,
tokens
}|
{
let
allow_ident
=
Ident
::
new
(
sym
::
allow
,
self
.def_site
);
let
dc_nested
=
attr
::
mk_nested_word_item
(
Ident
::
from_str_and_span
(
"dead_code"
,
...
...
@@ -176,7 +176,7 @@ impl MutVisitor for EntryPointCleaner {
.chain
(
iter
::
once
(
allow_dead_code
))
.collect
();
ast
::
Item
{
id
,
ident
,
attrs
,
kind
,
vis
,
defaultness
,
span
,
tokens
}
ast
::
Item
{
id
,
ident
,
attrs
,
kind
,
vis
,
span
,
tokens
}
}),
EntryPointType
::
None
|
EntryPointType
::
OtherMain
=>
item
,
};
...
...
@@ -298,7 +298,8 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
let
decl
=
ecx
.fn_decl
(
vec!
[],
ast
::
FnRetTy
::
Ty
(
main_ret_ty
));
let
sig
=
ast
::
FnSig
{
decl
,
header
:
ast
::
FnHeader
::
default
()
};
let
main
=
ast
::
ItemKind
::
Fn
(
sig
,
ast
::
Generics
::
default
(),
Some
(
main_body
));
let
def
=
ast
::
Defaultness
::
Final
;
let
main
=
ast
::
ItemKind
::
Fn
(
def
,
sig
,
ast
::
Generics
::
default
(),
Some
(
main_body
));
// Honor the reexport_test_harness_main attribute
let
main_id
=
match
cx
.reexport_test_harness_main
{
...
...
@@ -312,7 +313,6 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
id
:
ast
::
DUMMY_NODE_ID
,
kind
:
main
,
vis
:
respan
(
sp
,
ast
::
VisibilityKind
::
Public
),
defaultness
:
ast
::
Defaultness
::
Final
,
span
:
sp
,
tokens
:
None
,
});
...
...
src/librustc_expand/build.rs
浏览文件 @
62930d31
...
...
@@ -588,7 +588,6 @@ pub fn item(
id
:
ast
::
DUMMY_NODE_ID
,
kind
,
vis
:
respan
(
span
.shrink_to_lo
(),
ast
::
VisibilityKind
::
Inherited
),
defaultness
:
ast
::
Defaultness
::
Final
,
span
,
tokens
:
None
,
})
...
...
@@ -645,7 +644,8 @@ pub fn item_const(
ty
:
P
<
ast
::
Ty
>
,
expr
:
P
<
ast
::
Expr
>
,
)
->
P
<
ast
::
Item
>
{
self
.item
(
span
,
name
,
Vec
::
new
(),
ast
::
ItemKind
::
Const
(
ty
,
Some
(
expr
)))
let
def
=
ast
::
Defaultness
::
Final
;
self
.item
(
span
,
name
,
Vec
::
new
(),
ast
::
ItemKind
::
Const
(
def
,
ty
,
Some
(
expr
)))
}
pub
fn
attribute
(
&
self
,
mi
:
ast
::
MetaItem
)
->
ast
::
Attribute
{
...
...
src/librustc_expand/expand.rs
浏览文件 @
62930d31
...
...
@@ -358,7 +358,6 @@ pub fn expand_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
ident
:
Ident
::
invalid
(),
id
:
ast
::
DUMMY_NODE_ID
,
vis
:
respan
(
krate
.span
.shrink_to_lo
(),
ast
::
VisibilityKind
::
Public
),
defaultness
:
ast
::
Defaultness
::
Final
,
tokens
:
None
,
})]);
...
...
src/librustc_expand/placeholders.rs
浏览文件 @
62930d31
...
...
@@ -26,7 +26,6 @@ fn mac_placeholder() -> ast::Mac {
let
ident
=
ast
::
Ident
::
invalid
();
let
attrs
=
Vec
::
new
();
let
vis
=
vis
.unwrap_or_else
(||
dummy_spanned
(
ast
::
VisibilityKind
::
Inherited
));
let
defaultness
=
ast
::
Defaultness
::
Final
;
let
span
=
DUMMY_SP
;
let
expr_placeholder
=
||
{
P
(
ast
::
Expr
{
...
...
@@ -47,7 +46,6 @@ fn mac_placeholder() -> ast::Mac {
span
,
ident
,
vis
,
defaultness
,
attrs
,
kind
:
ast
::
ItemKind
::
Mac
(
mac_placeholder
()),
tokens
:
None
,
...
...
@@ -59,7 +57,6 @@ fn mac_placeholder() -> ast::Mac {
vis
,
attrs
,
kind
:
ast
::
AssocItemKind
::
Macro
(
mac_placeholder
()),
defaultness
:
ast
::
Defaultness
::
Final
,
tokens
:
None
,
})]),
AstFragmentKind
::
ImplItems
=>
AstFragment
::
ImplItems
(
smallvec!
[
P
(
ast
::
AssocItem
{
...
...
@@ -69,7 +66,6 @@ fn mac_placeholder() -> ast::Mac {
vis
,
attrs
,
kind
:
ast
::
AssocItemKind
::
Macro
(
mac_placeholder
()),
defaultness
:
ast
::
Defaultness
::
Final
,
tokens
:
None
,
})]),
AstFragmentKind
::
ForeignItems
=>
{
...
...
@@ -78,7 +74,6 @@ fn mac_placeholder() -> ast::Mac {
span
,
ident
,
vis
,
defaultness
,
attrs
,
kind
:
ast
::
ForeignItemKind
::
Macro
(
mac_placeholder
()),
tokens
:
None
,
...
...
src/librustc_interface/util.rs
浏览文件 @
62930d31
...
...
@@ -677,7 +677,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
fn
visit_item_kind
(
&
mut
self
,
i
:
&
mut
ast
::
ItemKind
)
{
let
is_const
=
match
i
{
ast
::
ItemKind
::
Static
(
..
)
|
ast
::
ItemKind
::
Const
(
..
)
=>
true
,
ast
::
ItemKind
::
Fn
(
ref
sig
,
_
,
_
)
=>
Self
::
is_sig_const
(
sig
),
ast
::
ItemKind
::
Fn
(
_
,
ref
sig
,
_
,
_
)
=>
Self
::
is_sig_const
(
sig
),
_
=>
false
,
};
self
.run
(
is_const
,
|
s
|
noop_visit_item_kind
(
i
,
s
))
...
...
@@ -686,7 +686,7 @@ fn visit_item_kind(&mut self, i: &mut ast::ItemKind) {
fn
flat_map_trait_item
(
&
mut
self
,
i
:
P
<
ast
::
AssocItem
>
)
->
SmallVec
<
[
P
<
ast
::
AssocItem
>
;
1
]
>
{
let
is_const
=
match
i
.kind
{
ast
::
AssocItemKind
::
Const
(
..
)
=>
true
,
ast
::
AssocItemKind
::
Fn
(
ref
sig
,
_
,
_
)
=>
Self
::
is_sig_const
(
sig
),
ast
::
AssocItemKind
::
Fn
(
_
,
ref
sig
,
_
,
_
)
=>
Self
::
is_sig_const
(
sig
),
_
=>
false
,
};
self
.run
(
is_const
,
|
s
|
noop_flat_map_assoc_item
(
i
,
s
))
...
...
src/librustc_lint/builtin.rs
浏览文件 @
62930d31
...
...
@@ -640,7 +640,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item<'_>) {
impl
EarlyLintPass
for
AnonymousParameters
{
fn
check_trait_item
(
&
mut
self
,
cx
:
&
EarlyContext
<
'_
>
,
it
:
&
ast
::
AssocItem
)
{
match
it
.kind
{
ast
::
AssocItemKind
::
Fn
(
ref
sig
,
_
,
_
)
=>
{
ast
::
AssocItemKind
::
Fn
(
_
,
ref
sig
,
_
,
_
)
=>
{
for
arg
in
sig
.decl.inputs
.iter
()
{
match
arg
.pat.kind
{
ast
::
PatKind
::
Ident
(
_
,
ident
,
None
)
=>
{
...
...
src/librustc_metadata/rmeta/decoder/cstore_impl.rs
浏览文件 @
62930d31
...
...
@@ -464,7 +464,6 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro {
legacy
:
def
.legacy
,
}),
vis
:
source_map
::
respan
(
local_span
.shrink_to_lo
(),
ast
::
VisibilityKind
::
Inherited
),
defaultness
:
ast
::
Defaultness
::
Final
,
tokens
:
None
,
},
data
.root.edition
,
...
...
src/librustc_parse/parser/item.rs
浏览文件 @
62930d31
...
...
@@ -36,9 +36,6 @@ pub(super) fn parse_item_(
attributes_allowed
:
bool
,
)
->
PResult
<
'a
,
Option
<
P
<
Item
>>>
{
let
item
=
self
.parse_item_common
(
attrs
,
macros_allowed
,
attributes_allowed
,
|
_
|
true
)
?
;
if
let
Some
(
ref
item
)
=
item
{
self
.error_on_illegal_default
(
item
.defaultness
);
}
Ok
(
item
.map
(
P
))
}
...
...
@@ -98,9 +95,10 @@ fn parse_item_common_(
let
mut
def
=
self
.parse_defaultness
();
let
kind
=
self
.parse_item_kind
(
&
mut
attrs
,
mac_allowed
,
lo
,
&
vis
,
&
mut
def
,
req_name
)
?
;
if
let
Some
((
ident
,
kind
))
=
kind
{
self
.error_on_unconsumed_default
(
def
,
&
kind
);
let
span
=
lo
.to
(
self
.prev_span
);
let
id
=
DUMMY_NODE_ID
;
let
item
=
Item
{
ident
,
attrs
,
id
,
kind
,
vis
,
defaultness
:
def
,
span
,
tokens
:
None
};
let
item
=
Item
{
ident
,
attrs
,
id
,
kind
,
vis
,
span
,
tokens
:
None
};
return
Ok
(
Some
(
item
));
}
...
...
@@ -137,9 +135,10 @@ fn error_on_unmatched_defaultness(&self, def: Defaultness) {
}
/// Error in-case `default` was parsed in an in-appropriate context.
fn
error_on_
illegal_default
(
&
self
,
def
:
Defaultness
)
{
fn
error_on_
unconsumed_default
(
&
self
,
def
:
Defaultness
,
kind
:
&
ItemKind
)
{
if
let
Defaultness
::
Default
(
span
)
=
def
{
self
.struct_span_err
(
span
,
"item cannot be `default`"
)
let
msg
=
format!
(
"{} {} cannot be `default`"
,
kind
.article
(),
kind
.descr
());
self
.struct_span_err
(
span
,
&
msg
)
.span_label
(
span
,
"`default` because of this"
)
.note
(
"only associated `fn`, `const`, and `type` items can be `default`"
)
.emit
();
...
...
@@ -156,6 +155,8 @@ fn parse_item_kind(
def
:
&
mut
Defaultness
,
req_name
:
ReqName
,
)
->
PResult
<
'a
,
Option
<
ItemInfo
>>
{
let
mut
def
=
||
mem
::
replace
(
def
,
Defaultness
::
Final
);
let
info
=
if
self
.eat_keyword
(
kw
::
Use
)
{
// USE ITEM
let
tree
=
self
.parse_use_tree
()
?
;
...
...
@@ -164,7 +165,7 @@ fn parse_item_kind(
}
else
if
self
.check_fn_front_matter
()
{
// FUNCTION ITEM
let
(
ident
,
sig
,
generics
,
body
)
=
self
.parse_fn
(
attrs
,
req_name
)
?
;
(
ident
,
ItemKind
::
Fn
(
sig
,
generics
,
body
))
(
ident
,
ItemKind
::
Fn
(
def
(),
sig
,
generics
,
body
))
}
else
if
self
.eat_keyword
(
kw
::
Extern
)
{
if
self
.eat_keyword
(
kw
::
Crate
)
{
// EXTERN CRATE
...
...
@@ -177,11 +178,13 @@ fn parse_item_kind(
// STATIC ITEM
self
.bump
();
// `static`
let
m
=
self
.parse_mutability
();
self
.parse_item_const
(
Some
(
m
))
?
let
(
ident
,
ty
,
expr
)
=
self
.parse_item_global
(
Some
(
m
))
?
;
(
ident
,
ItemKind
::
Static
(
ty
,
m
,
expr
))
}
else
if
let
Const
::
Yes
(
const_span
)
=
self
.parse_constness
()
{
// CONST ITEM
self
.recover_const_mut
(
const_span
);
self
.parse_item_const
(
None
)
?
let
(
ident
,
ty
,
expr
)
=
self
.parse_item_global
(
None
)
?
;
(
ident
,
ItemKind
::
Const
(
def
(),
ty
,
expr
))
}
else
if
self
.check_keyword
(
kw
::
Trait
)
||
self
.check_auto_or_unsafe_trait_item
()
{
// TRAIT ITEM
self
.parse_item_trait
(
attrs
,
lo
)
?
...
...
@@ -189,13 +192,13 @@ fn parse_item_kind(
||
self
.check_keyword
(
kw
::
Unsafe
)
&&
self
.is_keyword_ahead
(
1
,
&
[
kw
::
Impl
])
{
// IMPL ITEM
self
.parse_item_impl
(
attrs
,
mem
::
replace
(
def
,
Defaultness
::
Final
))
?
self
.parse_item_impl
(
attrs
,
def
(
))
?
}
else
if
self
.eat_keyword
(
kw
::
Mod
)
{
// MODULE ITEM
self
.parse_item_mod
(
attrs
)
?
}
else
if
self
.eat_keyword
(
kw
::
Type
)
{
// TYPE ITEM
self
.parse_type_alias
()
?
self
.parse_type_alias
(
def
()
)
?
}
else
if
self
.eat_keyword
(
kw
::
Enum
)
{
// ENUM ITEM
self
.parse_item_enum
()
?
...
...
@@ -652,19 +655,19 @@ pub fn parse_trait_item(&mut self) -> PResult<'a, Option<Option<P<AssocItem>>>>
fn
parse_assoc_item
(
&
mut
self
,
req_name
:
ReqName
)
->
PResult
<
'a
,
Option
<
Option
<
P
<
AssocItem
>>>>
{
let
attrs
=
self
.parse_outer_attributes
()
?
;
let
it
=
self
.parse_item_common
(
attrs
,
true
,
false
,
req_name
)
?
;
Ok
(
it
.map
(|
Item
{
attrs
,
id
,
span
,
vis
,
ident
,
defaultness
,
kind
,
tokens
}|
{
Ok
(
it
.map
(|
Item
{
attrs
,
id
,
span
,
vis
,
ident
,
kind
,
tokens
}|
{
let
kind
=
match
kind
{
ItemKind
::
Mac
(
a
)
=>
AssocItemKind
::
Macro
(
a
),
ItemKind
::
Fn
(
a
,
b
,
c
)
=>
AssocItemKind
::
Fn
(
a
,
b
,
c
),
ItemKind
::
TyAlias
(
a
,
b
,
c
)
=>
AssocItemKind
::
TyAlias
(
a
,
b
,
c
),
ItemKind
::
Const
(
a
,
c
)
=>
AssocItemKind
::
Const
(
a
,
c
),
ItemKind
::
Fn
(
a
,
b
,
c
,
d
)
=>
AssocItemKind
::
Fn
(
a
,
b
,
c
,
d
),
ItemKind
::
TyAlias
(
a
,
b
,
c
,
d
)
=>
AssocItemKind
::
TyAlias
(
a
,
b
,
c
,
d
),
ItemKind
::
Const
(
a
,
b
,
c
)
=>
AssocItemKind
::
Const
(
a
,
b
,
c
),
ItemKind
::
Static
(
a
,
_
,
b
)
=>
{
self
.struct_span_err
(
span
,
"associated `static` items are not allowed"
)
.emit
();
AssocItemKind
::
Const
(
a
,
b
)
AssocItemKind
::
Const
(
Defaultness
::
Final
,
a
,
b
)
}
_
=>
return
self
.error_bad_item_kind
(
span
,
&
kind
,
"`trait` or `impl`"
),
};
Some
(
P
(
Item
{
attrs
,
id
,
span
,
vis
,
ident
,
defaultness
,
kind
,
tokens
}))
Some
(
P
(
Item
{
attrs
,
id
,
span
,
vis
,
ident
,
kind
,
tokens
}))
}))
}
...
...
@@ -673,7 +676,7 @@ fn parse_assoc_item(&mut self, req_name: ReqName) -> PResult<'a, Option<Option<P
/// TypeAlias = "type" Ident Generics {":" GenericBounds}? {"=" Ty}? ";" ;
/// ```
/// The `"type"` has already been eaten.
fn
parse_type_alias
(
&
mut
self
)
->
PResult
<
'a
,
(
Ident
,
ItemKind
)
>
{
fn
parse_type_alias
(
&
mut
self
,
def
:
Defaultness
)
->
PResult
<
'a
,
ItemInfo
>
{
let
ident
=
self
.parse_ident
()
?
;
let
mut
generics
=
self
.parse_generics
()
?
;
...
...
@@ -685,7 +688,7 @@ fn parse_type_alias(&mut self) -> PResult<'a, (Ident, ItemKind)> {
let
default
=
if
self
.eat
(
&
token
::
Eq
)
{
Some
(
self
.parse_ty
()
?
)
}
else
{
None
};
self
.expect_semi
()
?
;
Ok
((
ident
,
ItemKind
::
TyAlias
(
generics
,
bounds
,
default
)))
Ok
((
ident
,
ItemKind
::
TyAlias
(
def
,
generics
,
bounds
,
default
)))
}
/// Parses a `UseTree`.
...
...
@@ -843,20 +846,19 @@ pub fn parse_foreign_item(&mut self) -> PResult<'a, Option<Option<P<ForeignItem>
let
attrs
=
self
.parse_outer_attributes
()
?
;
let
item
=
self
.parse_item_common
(
attrs
,
true
,
false
,
|
_
|
true
)
?
;
Ok
(
item
.map
(|
Item
{
attrs
,
id
,
span
,
vis
,
ident
,
defaultness
,
kind
,
tokens
}|
{
self
.error_on_illegal_default
(
defaultness
);
Ok
(
item
.map
(|
Item
{
attrs
,
id
,
span
,
vis
,
ident
,
kind
,
tokens
}|
{
let
kind
=
match
kind
{
ItemKind
::
Mac
(
a
)
=>
ForeignItemKind
::
Macro
(
a
),
ItemKind
::
Fn
(
a
,
b
,
c
)
=>
ForeignItemKind
::
Fn
(
a
,
b
,
c
),
ItemKind
::
TyAlias
(
a
,
b
,
c
)
=>
ForeignItemKind
::
TyAlias
(
a
,
b
,
c
),
ItemKind
::
Fn
(
a
,
b
,
c
,
d
)
=>
ForeignItemKind
::
Fn
(
a
,
b
,
c
,
d
),
ItemKind
::
TyAlias
(
a
,
b
,
c
,
d
)
=>
ForeignItemKind
::
TyAlias
(
a
,
b
,
c
,
d
),
ItemKind
::
Static
(
a
,
b
,
c
)
=>
ForeignItemKind
::
Static
(
a
,
b
,
c
),
ItemKind
::
Const
(
a
,
b
)
=>
{
ItemKind
::
Const
(
_
,
a
,
b
)
=>
{
self
.error_on_foreign_const
(
span
,
ident
);
ForeignItemKind
::
Static
(
a
,
Mutability
::
Not
,
b
)
}
_
=>
return
self
.error_bad_item_kind
(
span
,
&
kind
,
"`extern` block"
),
};
Some
(
P
(
Item
{
attrs
,
id
,
span
,
vis
,
ident
,
defaultness
,
kind
,
tokens
}))
Some
(
P
(
Item
{
attrs
,
id
,
span
,
vis
,
ident
,
kind
,
tokens
}))
}))
}
...
...
@@ -916,7 +918,10 @@ fn recover_const_mut(&mut self, const_span: Span) {
/// `["const" | ("static" "mut"?)]` already parsed and stored in `m`.
///
/// When `m` is `"const"`, `$ident` may also be `"_"`.
fn
parse_item_const
(
&
mut
self
,
m
:
Option
<
Mutability
>
)
->
PResult
<
'a
,
ItemInfo
>
{
fn
parse_item_global
(
&
mut
self
,
m
:
Option
<
Mutability
>
,
)
->
PResult
<
'a
,
(
Ident
,
P
<
Ty
>
,
Option
<
P
<
ast
::
Expr
>>
)
>
{
let
id
=
if
m
.is_none
()
{
self
.parse_ident_or_underscore
()
}
else
{
self
.parse_ident
()
}
?
;
// Parse the type of a `const` or `static mut?` item.
...
...
@@ -929,12 +934,7 @@ fn parse_item_const(&mut self, m: Option<Mutability>) -> PResult<'a, ItemInfo> {
let
expr
=
if
self
.eat
(
&
token
::
Eq
)
{
Some
(
self
.parse_expr
()
?
)
}
else
{
None
};
self
.expect_semi
()
?
;
let
item
=
match
m
{
Some
(
m
)
=>
ItemKind
::
Static
(
ty
,
m
,
expr
),
None
=>
ItemKind
::
Const
(
ty
,
expr
),
};
Ok
((
id
,
item
))
Ok
((
id
,
ty
,
expr
))
}
/// We were supposed to parse `:` but the `:` was missing.
...
...
src/librustc_resolve/build_reduced_graph.rs
浏览文件 @
62930d31
...
...
@@ -718,7 +718,7 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
}
// These items live in the type namespace.
ItemKind
::
TyAlias
(
_
,
_
,
ref
ty
)
=>
{
ItemKind
::
TyAlias
(
_
,
_
,
_
,
ref
ty
)
=>
{
let
def_kind
=
match
ty
.as_deref
()
.and_then
(|
ty
|
ty
.kind
.opaque_top_hack
())
{
None
=>
DefKind
::
TyAlias
,
Some
(
_
)
=>
DefKind
::
OpaqueTy
,
...
...
@@ -1253,7 +1253,7 @@ fn visit_assoc_item(&mut self, item: &'b AssocItem, ctxt: AssocCtxt) {
let
(
res
,
ns
)
=
match
item
.kind
{
AssocItemKind
::
Static
(
..
)
// Let's pretend it's a `const` for recovery.
|
AssocItemKind
::
Const
(
..
)
=>
(
Res
::
Def
(
DefKind
::
AssocConst
,
item_def_id
),
ValueNS
),
AssocItemKind
::
Fn
(
ref
sig
,
_
,
_
)
=>
{
AssocItemKind
::
Fn
(
_
,
ref
sig
,
_
,
_
)
=>
{
if
sig
.decl
.has_self
()
{
self
.r.has_self
.insert
(
item_def_id
);
}
...
...
src/librustc_resolve/def_collector.rs
浏览文件 @
62930d31
...
...
@@ -117,7 +117,7 @@ fn visit_item(&mut self, i: &'a Item) {
|
ItemKind
::
ExternCrate
(
..
)
|
ItemKind
::
ForeignMod
(
..
)
|
ItemKind
::
TyAlias
(
..
)
=>
DefPathData
::
TypeNs
(
i
.ident.name
),
ItemKind
::
Fn
(
sig
,
generics
,
body
)
if
sig
.header.asyncness
.is_async
()
=>
{
ItemKind
::
Fn
(
_
,
sig
,
generics
,
body
)
if
sig
.header.asyncness
.is_async
()
=>
{
return
self
.visit_async_fn
(
i
.id
,
i
.ident.name
,
...
...
@@ -215,7 +215,7 @@ fn visit_generic_param(&mut self, param: &'a GenericParam) {
fn
visit_assoc_item
(
&
mut
self
,
i
:
&
'a
AssocItem
,
ctxt
:
visit
::
AssocCtxt
)
{
let
def_data
=
match
&
i
.kind
{
AssocItemKind
::
Fn
(
FnSig
{
header
,
decl
},
generics
,
body
)
AssocItemKind
::
Fn
(
_
,
FnSig
{
header
,
decl
},
generics
,
body
)
if
header
.asyncness
.is_async
()
=>
{
return
self
.visit_async_fn
(
...
...
src/librustc_resolve/late.rs
浏览文件 @
62930d31
...
...
@@ -437,8 +437,8 @@ fn visit_poly_trait_ref(&mut self, tref: &'ast PolyTraitRef, m: &'ast TraitBound
}
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
&
'ast
ForeignItem
)
{
match
foreign_item
.kind
{
ForeignItemKind
::
Fn
(
_
,
ref
generics
,
_
)
|
ForeignItemKind
::
TyAlias
(
ref
generics
,
..
)
=>
{
ForeignItemKind
::
Fn
(
_
,
_
,
ref
generics
,
_
)
|
ForeignItemKind
::
TyAlias
(
_
,
ref
generics
,
..
)
=>
{
self
.with_generic_param_rib
(
generics
,
ItemRibKind
(
HasGenericParams
::
Yes
),
|
this
|
{
visit
::
walk_foreign_item
(
this
,
foreign_item
);
});
...
...
@@ -797,7 +797,7 @@ fn resolve_item(&mut self, item: &'ast Item) {
debug!
(
"(resolving item) resolving {} ({:?})"
,
name
,
item
.kind
);
match
item
.kind
{
ItemKind
::
TyAlias
(
ref
generics
,
_
,
_
)
|
ItemKind
::
Fn
(
_
,
ref
generics
,
_
)
=>
{
ItemKind
::
TyAlias
(
_
,
ref
generics
,
_
,
_
)
|
ItemKind
::
Fn
(
_
,
_
,
ref
generics
,
_
)
=>
{
self
.with_generic_param_rib
(
generics
,
ItemRibKind
(
HasGenericParams
::
Yes
),
|
this
|
{
visit
::
walk_item
(
this
,
item
)
});
...
...
@@ -837,7 +837,7 @@ fn resolve_item(&mut self, item: &'ast Item) {
this
.with_trait_items
(
trait_items
,
|
this
|
{
match
&
item
.kind
{
AssocItemKind
::
Static
(
ty
,
_
,
default
)
|
AssocItemKind
::
Const
(
ty
,
default
)
=>
{
|
AssocItemKind
::
Const
(
_
,
ty
,
default
)
=>
{
this
.visit_ty
(
ty
);
// Only impose the restrictions of `ConstRibKind` for an
// actual constant expression in a provided default.
...
...
@@ -845,10 +845,10 @@ fn resolve_item(&mut self, item: &'ast Item) {
this
.with_constant_rib
(|
this
|
this
.visit_expr
(
expr
));
}
}
AssocItemKind
::
Fn
(
_
,
generics
,
_
)
=>
{
AssocItemKind
::
Fn
(
_
,
_
,
generics
,
_
)
=>
{
walk_assoc_item
(
this
,
generics
,
item
);
}
AssocItemKind
::
TyAlias
(
generics
,
_
,
_
)
=>
{
AssocItemKind
::
TyAlias
(
_
,
generics
,
_
,
_
)
=>
{
walk_assoc_item
(
this
,
generics
,
item
);
}
AssocItemKind
::
Macro
(
_
)
=>
{
...
...
@@ -878,7 +878,7 @@ fn resolve_item(&mut self, item: &'ast Item) {
});
}
ItemKind
::
Static
(
ref
ty
,
_
,
ref
expr
)
|
ItemKind
::
Const
(
ref
ty
,
ref
expr
)
=>
{
ItemKind
::
Static
(
ref
ty
,
_
,
ref
expr
)
|
ItemKind
::
Const
(
_
,
ref
ty
,
ref
expr
)
=>
{
debug!
(
"resolve_item ItemKind::Const"
);
self
.with_item_rib
(
HasGenericParams
::
No
,
|
this
|
{
this
.visit_ty
(
ty
);
...
...
@@ -1015,7 +1015,9 @@ fn with_trait_items<T>(
trait_items
.iter
()
.filter_map
(|
item
|
match
&
item
.kind
{
AssocItemKind
::
TyAlias
(
_
,
bounds
,
_
)
if
bounds
.len
()
==
0
=>
Some
(
item
.ident
),
AssocItemKind
::
TyAlias
(
_
,
_
,
bounds
,
_
)
if
bounds
.len
()
==
0
=>
{
Some
(
item
.ident
)
}
_
=>
None
,
})
.collect
(),
...
...
@@ -1125,7 +1127,7 @@ fn resolve_implementation(
visit
::
walk_assoc_item
(
this
,
item
,
AssocCtxt
::
Impl
)
});
}
AssocItemKind
::
Fn
(
_
,
generics
,
_
)
=>
{
AssocItemKind
::
Fn
(
_
,
_
,
generics
,
_
)
=>
{
// We also need a new scope for the impl item type parameters.
this
.with_generic_param_rib
(
generics
,
...
...
@@ -1148,7 +1150,7 @@ fn resolve_implementation(
},
);
}
AssocItemKind
::
TyAlias
(
generics
,
_
,
_
)
=>
{
AssocItemKind
::
TyAlias
(
_
,
generics
,
_
,
_
)
=>
{
// We also need a new scope for the impl item type parameters.
this
.with_generic_param_rib
(
generics
,
...
...
src/librustc_save_analysis/dump_visitor.rs
浏览文件 @
62930d31
...
...
@@ -1005,7 +1005,7 @@ fn process_trait_item(&mut self, trait_item: &'l ast::AssocItem, trait_id: DefId
let
vis_span
=
trait_item
.span
.shrink_to_lo
();
match
trait_item
.kind
{
ast
::
AssocItemKind
::
Static
(
ref
ty
,
_
,
ref
expr
)
|
ast
::
AssocItemKind
::
Const
(
ref
ty
,
ref
expr
)
=>
{
|
ast
::
AssocItemKind
::
Const
(
_
,
ref
ty
,
ref
expr
)
=>
{
self
.process_assoc_const
(
trait_item
.id
,
trait_item
.ident
,
...
...
@@ -1016,7 +1016,7 @@ fn process_trait_item(&mut self, trait_item: &'l ast::AssocItem, trait_id: DefId
&
trait_item
.attrs
,
);
}
ast
::
AssocItemKind
::
Fn
(
ref
sig
,
ref
generics
,
ref
body
)
=>
{
ast
::
AssocItemKind
::
Fn
(
_
,
ref
sig
,
ref
generics
,
ref
body
)
=>
{
self
.process_method
(
sig
,
body
.as_ref
()
.map
(|
x
|
&**
x
),
...
...
@@ -1027,7 +1027,7 @@ fn process_trait_item(&mut self, trait_item: &'l ast::AssocItem, trait_id: DefId
trait_item
.span
,
);
}
ast
::
AssocItemKind
::
TyAlias
(
_
,
ref
bounds
,
ref
default_ty
)
=>
{
ast
::
AssocItemKind
::
TyAlias
(
_
,
_
,
ref
bounds
,
ref
default_ty
)
=>
{
// FIXME do something with _bounds (for type refs)
let
name
=
trait_item
.ident.name
.to_string
();
let
qualname
=
format!
(
...
...
@@ -1076,7 +1076,7 @@ fn process_impl_item(&mut self, impl_item: &'l ast::AssocItem, impl_id: DefId) {
self
.process_macro_use
(
impl_item
.span
);
match
impl_item
.kind
{
ast
::
AssocItemKind
::
Static
(
ref
ty
,
_
,
ref
expr
)
|
ast
::
AssocItemKind
::
Const
(
ref
ty
,
ref
expr
)
=>
{
|
ast
::
AssocItemKind
::
Const
(
_
,
ref
ty
,
ref
expr
)
=>
{
self
.process_assoc_const
(
impl_item
.id
,
impl_item
.ident
,
...
...
@@ -1087,7 +1087,7 @@ fn process_impl_item(&mut self, impl_item: &'l ast::AssocItem, impl_id: DefId) {
&
impl_item
.attrs
,
);
}
ast
::
AssocItemKind
::
Fn
(
ref
sig
,
ref
generics
,
ref
body
)
=>
{
ast
::
AssocItemKind
::
Fn
(
_
,
ref
sig
,
ref
generics
,
ref
body
)
=>
{
self
.process_method
(
sig
,
body
.as_deref
(),
...
...
@@ -1098,8 +1098,8 @@ fn process_impl_item(&mut self, impl_item: &'l ast::AssocItem, impl_id: DefId) {
impl_item
.span
,
);
}
ast
::
AssocItemKind
::
TyAlias
(
_
,
_
,
None
)
=>
{}
ast
::
AssocItemKind
::
TyAlias
(
_
,
_
,
Some
(
ref
ty
))
=>
{
ast
::
AssocItemKind
::
TyAlias
(
_
,
_
,
_
,
None
)
=>
{}
ast
::
AssocItemKind
::
TyAlias
(
_
,
_
,
_
,
Some
(
ref
ty
))
=>
{
// FIXME: uses of the assoc type should ideally point to this
// 'def' and the name here should be a ref to the def in the
// trait.
...
...
@@ -1292,11 +1292,11 @@ fn visit_item(&mut self, item: &'l ast::Item) {
);
}
}
Fn
(
ref
sig
,
ref
ty_params
,
ref
body
)
=>
{
Fn
(
_
,
ref
sig
,
ref
ty_params
,
ref
body
)
=>
{
self
.process_fn
(
item
,
&
sig
.decl
,
&
sig
.header
,
ty_params
,
body
.as_deref
())
}
Static
(
ref
typ
,
_
,
ref
e
)
=>
self
.process_static_or_const_item
(
item
,
typ
,
e
.as_deref
()),
Const
(
ref
typ
,
ref
e
)
=>
self
.process_static_or_const_item
(
item
,
typ
,
e
.as_deref
()),
Const
(
_
,
ref
typ
,
ref
e
)
=>
self
.process_static_or_const_item
(
item
,
typ
,
e
.as_deref
()),
Struct
(
ref
def
,
ref
ty_params
)
|
Union
(
ref
def
,
ref
ty_params
)
=>
{
self
.process_struct
(
item
,
def
,
ty_params
)
}
...
...
@@ -1311,7 +1311,7 @@ fn visit_item(&mut self, item: &'l ast::Item) {
self
.process_mod
(
item
);
visit
::
walk_mod
(
self
,
m
);
}
TyAlias
(
ref
ty_params
,
_
,
ref
ty
)
=>
{
TyAlias
(
_
,
ref
ty_params
,
_
,
ref
ty
)
=>
{
let
qualname
=
format!
(
"::{}"
,
self
.tcx
.def_path_str
(
self
.tcx
.hir
()
.local_def_id_from_node_id
(
item
.id
))
...
...
@@ -1520,7 +1520,7 @@ fn visit_foreign_item(&mut self, item: &'l ast::ForeignItem) {
let
access
=
access_from!
(
self
.save_ctxt
,
item
,
hir_id
);
match
item
.kind
{
ast
::
ForeignItemKind
::
Fn
(
ref
sig
,
ref
generics
,
_
)
=>
{
ast
::
ForeignItemKind
::
Fn
(
_
,
ref
sig
,
ref
generics
,
_
)
=>
{
let
decl
=
&
sig
.decl
;
if
let
Some
(
fn_data
)
=
self
.save_ctxt
.get_extern_item_data
(
item
)
{
down_cast_data!
(
fn_data
,
DefData
,
item
.span
);
...
...
@@ -1537,7 +1537,8 @@ fn visit_foreign_item(&mut self, item: &'l ast::ForeignItem) {
self
.visit_ty
(
&
ret_ty
);
}
}
ast
::
ForeignItemKind
::
Const
(
ref
ty
,
_
)
|
ast
::
ForeignItemKind
::
Static
(
ref
ty
,
_
,
_
)
=>
{
ast
::
ForeignItemKind
::
Const
(
_
,
ref
ty
,
_
)
|
ast
::
ForeignItemKind
::
Static
(
ref
ty
,
_
,
_
)
=>
{
if
let
Some
(
var_data
)
=
self
.save_ctxt
.get_extern_item_data
(
item
)
{
down_cast_data!
(
var_data
,
DefData
,
item
.span
);
self
.dumper
.dump_def
(
&
access
,
var_data
);
...
...
src/librustc_save_analysis/lib.rs
浏览文件 @
62930d31
...
...
@@ -133,7 +133,7 @@ pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option<Data> {
self
.tcx
.def_path_str
(
self
.tcx
.hir
()
.local_def_id_from_node_id
(
item
.id
))
);
match
item
.kind
{
ast
::
ForeignItemKind
::
Fn
(
ref
sig
,
ref
generics
,
_
)
=>
{
ast
::
ForeignItemKind
::
Fn
(
_
,
ref
sig
,
ref
generics
,
_
)
=>
{
filter!
(
self
.span_utils
,
item
.ident.span
);
Some
(
Data
::
DefData
(
Def
{
...
...
@@ -151,7 +151,8 @@ pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option<Data> {
attributes
:
lower_attributes
(
item
.attrs
.clone
(),
self
),
}))
}
ast
::
ForeignItemKind
::
Const
(
ref
ty
,
_
)
|
ast
::
ForeignItemKind
::
Static
(
ref
ty
,
_
,
_
)
=>
{
ast
::
ForeignItemKind
::
Const
(
_
,
ref
ty
,
_
)
|
ast
::
ForeignItemKind
::
Static
(
ref
ty
,
_
,
_
)
=>
{
filter!
(
self
.span_utils
,
item
.ident.span
);
let
id
=
id_from_node_id
(
item
.id
,
self
);
...
...
@@ -180,7 +181,7 @@ pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option<Data> {
pub
fn
get_item_data
(
&
self
,
item
:
&
ast
::
Item
)
->
Option
<
Data
>
{
match
item
.kind
{
ast
::
ItemKind
::
Fn
(
ref
sig
,
..
,
ref
generics
,
_
)
=>
{
ast
::
ItemKind
::
Fn
(
_
,
ref
sig
,
..
,
ref
generics
,
_
)
=>
{
let
qualname
=
format!
(
"::{}"
,
self
.tcx
.def_path_str
(
self
.tcx
.hir
()
.local_def_id_from_node_id
(
item
.id
))
...
...
@@ -227,7 +228,7 @@ pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
attributes
:
lower_attributes
(
item
.attrs
.clone
(),
self
),
}))
}
ast
::
ItemKind
::
Const
(
ref
typ
,
_
)
=>
{
ast
::
ItemKind
::
Const
(
_
,
ref
typ
,
_
)
=>
{
let
qualname
=
format!
(
"::{}"
,
self
.tcx
.def_path_str
(
self
.tcx
.hir
()
.local_def_id_from_node_id
(
item
.id
))
...
...
src/librustc_save_analysis/sig.rs
浏览文件 @
62930d31
...
...
@@ -345,7 +345,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_,
Ok
(
extend_sig
(
ty
,
text
,
defs
,
vec!
[]))
}
ast
::
ItemKind
::
Const
(
ref
ty
,
ref
expr
)
=>
{
ast
::
ItemKind
::
Const
(
_
,
ref
ty
,
ref
expr
)
=>
{
let
mut
text
=
"const "
.to_owned
();
let
name
=
self
.ident
.to_string
();
let
defs
=
vec!
[
SigElement
{
...
...
@@ -369,7 +369,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_,
Ok
(
extend_sig
(
ty
,
text
,
defs
,
vec!
[]))
}
ast
::
ItemKind
::
Fn
(
ast
::
FnSig
{
ref
decl
,
header
},
ref
generics
,
_
)
=>
{
ast
::
ItemKind
::
Fn
(
_
,
ast
::
FnSig
{
ref
decl
,
header
},
ref
generics
,
_
)
=>
{
let
mut
text
=
String
::
new
();
if
let
ast
::
Const
::
Yes
(
_
)
=
header
.constness
{
text
.push_str
(
"const "
);
...
...
@@ -423,7 +423,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_,
Ok
(
Signature
{
text
,
defs
,
refs
:
vec!
[]
})
}
ast
::
ItemKind
::
TyAlias
(
ref
generics
,
_
,
ref
ty
)
=>
{
ast
::
ItemKind
::
TyAlias
(
_
,
ref
generics
,
_
,
ref
ty
)
=>
{
let
text
=
"type "
.to_owned
();
let
mut
sig
=
name_and_generics
(
text
,
offset
,
generics
,
self
.id
,
self
.ident
,
scx
)
?
;
...
...
@@ -732,7 +732,7 @@ impl Sig for ast::ForeignItem {
fn
make
(
&
self
,
offset
:
usize
,
_
parent_id
:
Option
<
NodeId
>
,
scx
:
&
SaveContext
<
'_
,
'_
>
)
->
Result
{
let
id
=
Some
(
self
.id
);
match
self
.kind
{
ast
::
ForeignItemKind
::
Fn
(
ref
sig
,
ref
generics
,
_
)
=>
{
ast
::
ForeignItemKind
::
Fn
(
_
,
ref
sig
,
ref
generics
,
_
)
=>
{
let
decl
=
&
sig
.decl
;
let
mut
text
=
String
::
new
();
text
.push_str
(
"fn "
);
...
...
src/libsyntax/ast.rs
浏览文件 @
62930d31
...
...
@@ -2421,9 +2421,6 @@ pub struct Item<K = ItemKind> {
/// The name of the item.
/// It might be a dummy name in case of anonymous items.
pub
ident
:
Ident
,
/// The `default`ness of this item.
/// This should only occur in syntactically well-formed code in associated contexts.
pub
defaultness
:
Defaultness
,
pub
kind
:
K
,
...
...
@@ -2509,11 +2506,11 @@ pub enum ItemKind {
/// A constant item (`const`).
///
/// E.g., `const FOO: i32 = 42;`.
Const
(
P
<
Ty
>
,
Option
<
P
<
Expr
>>
),
Const
(
Defaultness
,
P
<
Ty
>
,
Option
<
P
<
Expr
>>
),
/// A function declaration (`fn`).
///
/// E.g., `fn foo(bar: usize) -> usize { .. }`.
Fn
(
FnSig
,
Generics
,
Option
<
P
<
Block
>>
),
Fn
(
Defaultness
,
FnSig
,
Generics
,
Option
<
P
<
Block
>>
),
/// A module declaration (`mod`).
///
/// E.g., `mod foo;` or `mod foo { .. }`.
...
...
@@ -2527,7 +2524,7 @@ pub enum ItemKind {
/// A type alias (`type`).
///
/// E.g., `type Foo = Bar<u8>;`.
TyAlias
(
Generics
,
GenericBounds
,
Option
<
P
<
Ty
>>
),
TyAlias
(
Defaultness
,
Generics
,
GenericBounds
,
Option
<
P
<
Ty
>>
),
/// An enum definition (`enum`).
///
/// E.g., `enum Foo<A, B> { C<A>, D<B> }`.
...
...
@@ -2607,8 +2604,8 @@ pub fn descr(&self) -> &str {
pub
fn
generics
(
&
self
)
->
Option
<&
Generics
>
{
match
self
{
Self
::
Fn
(
_
,
generics
,
_
)
|
Self
::
TyAlias
(
generics
,
..
)
Self
::
Fn
(
_
,
_
,
generics
,
_
)
|
Self
::
TyAlias
(
_
,
generics
,
..
)
|
Self
::
Enum
(
_
,
generics
)
|
Self
::
Struct
(
_
,
generics
)
|
Self
::
Union
(
_
,
generics
)
...
...
@@ -2640,13 +2637,22 @@ pub fn generics(&self) -> Option<&Generics> {
pub
enum
AssocItemKind
{
/// A constant, `const $ident: $ty $def?;` where `def ::= "=" $expr? ;`.
/// If `def` is parsed, then the constant is provided, and otherwise required.
Const
(
P
<
Ty
>
,
Option
<
P
<
Expr
>>
),
Const
(
Defaultness
,
P
<
Ty
>
,
Option
<
P
<
Expr
>>
),
/// A static item (`static FOO: u8`).
Static
(
P
<
Ty
>
,
Mutability
,
Option
<
P
<
Expr
>>
),
/// A function.
Fn
(
FnSig
,
Generics
,
Option
<
P
<
Block
>>
),
Fn
(
Defaultness
,
FnSig
,
Generics
,
Option
<
P
<
Block
>>
),
/// A type.
TyAlias
(
Generics
,
GenericBounds
,
Option
<
P
<
Ty
>>
),
TyAlias
(
Defaultness
,
Generics
,
GenericBounds
,
Option
<
P
<
Ty
>>
),
/// A macro expanding to items.
Macro
(
Mac
),
}
impl
AssocItemKind
{
pub
fn
defaultness
(
&
self
)
->
Defaultness
{
match
*
self
{
Self
::
Const
(
def
,
..
)
|
Self
::
Fn
(
def
,
..
)
|
Self
::
TyAlias
(
def
,
..
)
=>
def
,
Self
::
Macro
(
..
)
|
Self
::
Static
(
..
)
=>
Defaultness
::
Final
,
}
}
}
src/libsyntax/mut_visit.rs
浏览文件 @
62930d31
...
...
@@ -890,11 +890,11 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
match
kind
{
ItemKind
::
ExternCrate
(
_
orig_name
)
=>
{}
ItemKind
::
Use
(
use_tree
)
=>
vis
.visit_use_tree
(
use_tree
),
ItemKind
::
Static
(
ty
,
_
,
expr
)
|
ItemKind
::
Const
(
ty
,
expr
)
=>
{
ItemKind
::
Static
(
ty
,
_
,
expr
)
|
ItemKind
::
Const
(
_
,
ty
,
expr
)
=>
{
vis
.visit_ty
(
ty
);
visit_opt
(
expr
,
|
expr
|
vis
.visit_expr
(
expr
));
}
ItemKind
::
Fn
(
sig
,
generics
,
body
)
=>
{
ItemKind
::
Fn
(
_
,
sig
,
generics
,
body
)
=>
{
visit_fn_sig
(
sig
,
vis
);
vis
.visit_generics
(
generics
);
visit_opt
(
body
,
|
body
|
vis
.visit_block
(
body
));
...
...
@@ -902,7 +902,7 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
ItemKind
::
Mod
(
m
)
=>
vis
.visit_mod
(
m
),
ItemKind
::
ForeignMod
(
nm
)
=>
vis
.visit_foreign_mod
(
nm
),
ItemKind
::
GlobalAsm
(
_
ga
)
=>
{}
ItemKind
::
TyAlias
(
generics
,
bounds
,
ty
)
=>
{
ItemKind
::
TyAlias
(
_
,
generics
,
bounds
,
ty
)
=>
{
vis
.visit_generics
(
generics
);
visit_bounds
(
bounds
,
vis
);
visit_opt
(
ty
,
|
ty
|
vis
.visit_ty
(
ty
));
...
...
@@ -948,7 +948,7 @@ pub fn noop_flat_map_assoc_item<T: MutVisitor>(
mut
item
:
P
<
AssocItem
>
,
visitor
:
&
mut
T
,
)
->
SmallVec
<
[
P
<
AssocItem
>
;
1
]
>
{
let
Item
{
id
,
ident
,
vis
,
defaultness
:
_
,
attrs
,
kind
,
span
,
tokens
:
_
}
=
item
.deref_mut
();
let
Item
{
id
,
ident
,
vis
,
attrs
,
kind
,
span
,
tokens
:
_
}
=
item
.deref_mut
();
walk_nested_item
(
visitor
,
id
,
span
,
ident
,
vis
,
attrs
,
kind
);
smallvec!
[
item
]
}
...
...
@@ -967,16 +967,16 @@ pub fn walk_nested_item(
visitor
.visit_vis
(
vis
);
visit_attrs
(
attrs
,
visitor
);
match
kind
{
AssocItemKind
::
Const
(
ty
,
expr
)
|
AssocItemKind
::
Static
(
ty
,
_
,
expr
)
=>
{
AssocItemKind
::
Const
(
_
,
ty
,
expr
)
|
AssocItemKind
::
Static
(
ty
,
_
,
expr
)
=>
{
visitor
.visit_ty
(
ty
);
visit_opt
(
expr
,
|
expr
|
visitor
.visit_expr
(
expr
));
}
AssocItemKind
::
Fn
(
sig
,
generics
,
body
)
=>
{
AssocItemKind
::
Fn
(
_
,
sig
,
generics
,
body
)
=>
{
visitor
.visit_generics
(
generics
);
visit_fn_sig
(
sig
,
visitor
);
visit_opt
(
body
,
|
body
|
visitor
.visit_block
(
body
));
}
AssocItemKind
::
TyAlias
(
generics
,
bounds
,
ty
)
=>
{
AssocItemKind
::
TyAlias
(
_
,
generics
,
bounds
,
ty
)
=>
{
visitor
.visit_generics
(
generics
);
visit_bounds
(
bounds
,
visitor
);
visit_opt
(
ty
,
|
ty
|
visitor
.visit_ty
(
ty
));
...
...
@@ -1003,7 +1003,6 @@ pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
attrs
,
id
:
DUMMY_NODE_ID
,
vis
:
respan
(
span
.shrink_to_lo
(),
VisibilityKind
::
Public
),
defaultness
:
Defaultness
::
Final
,
span
,
kind
:
ItemKind
::
Mod
(
module
),
tokens
:
None
,
...
...
@@ -1031,7 +1030,7 @@ pub fn noop_flat_map_item<T: MutVisitor>(
mut
item
:
P
<
Item
>
,
visitor
:
&
mut
T
,
)
->
SmallVec
<
[
P
<
Item
>
;
1
]
>
{
let
Item
{
ident
,
attrs
,
id
,
kind
,
vis
,
defaultness
:
_
,
span
,
tokens
:
_
}
=
item
.deref_mut
();
let
Item
{
ident
,
attrs
,
id
,
kind
,
vis
,
span
,
tokens
:
_
}
=
item
.deref_mut
();
visitor
.visit_ident
(
ident
);
visit_attrs
(
attrs
,
visitor
);
visitor
.visit_id
(
id
);
...
...
@@ -1049,7 +1048,7 @@ pub fn noop_flat_map_foreign_item<T: MutVisitor>(
mut
item
:
P
<
ForeignItem
>
,
visitor
:
&
mut
T
,
)
->
SmallVec
<
[
P
<
ForeignItem
>
;
1
]
>
{
let
Item
{
ident
,
attrs
,
id
,
kind
,
vis
,
defaultness
:
_
,
span
,
tokens
:
_
}
=
item
.deref_mut
();
let
Item
{
ident
,
attrs
,
id
,
kind
,
vis
,
span
,
tokens
:
_
}
=
item
.deref_mut
();
walk_nested_item
(
visitor
,
id
,
span
,
ident
,
vis
,
attrs
,
kind
);
smallvec!
[
item
]
}
...
...
src/libsyntax/visit.rs
浏览文件 @
62930d31
...
...
@@ -298,11 +298,11 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
}
}
ItemKind
::
Use
(
ref
use_tree
)
=>
visitor
.visit_use_tree
(
use_tree
,
item
.id
,
false
),
ItemKind
::
Static
(
ref
typ
,
_
,
ref
expr
)
|
ItemKind
::
Const
(
ref
typ
,
ref
expr
)
=>
{
ItemKind
::
Static
(
ref
typ
,
_
,
ref
expr
)
|
ItemKind
::
Const
(
_
,
ref
typ
,
ref
expr
)
=>
{
visitor
.visit_ty
(
typ
);
walk_list!
(
visitor
,
visit_expr
,
expr
);
}
ItemKind
::
Fn
(
ref
sig
,
ref
generics
,
ref
body
)
=>
{
ItemKind
::
Fn
(
_
,
ref
sig
,
ref
generics
,
ref
body
)
=>
{
visitor
.visit_generics
(
generics
);
let
kind
=
FnKind
::
Fn
(
FnCtxt
::
Free
,
item
.ident
,
sig
,
&
item
.vis
,
body
.as_deref
());
visitor
.visit_fn
(
kind
,
item
.span
,
item
.id
)
...
...
@@ -312,7 +312,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
walk_list!
(
visitor
,
visit_foreign_item
,
&
foreign_module
.items
);
}
ItemKind
::
GlobalAsm
(
ref
ga
)
=>
visitor
.visit_global_asm
(
ga
),
ItemKind
::
TyAlias
(
ref
generics
,
ref
bounds
,
ref
ty
)
=>
{
ItemKind
::
TyAlias
(
_
,
ref
generics
,
ref
bounds
,
ref
ty
)
=>
{
visitor
.visit_generics
(
generics
);
walk_list!
(
visitor
,
visit_param_bound
,
bounds
);
walk_list!
(
visitor
,
visit_ty
,
ty
);
...
...
@@ -526,7 +526,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) {
}
pub
fn
walk_foreign_item
<
'a
,
V
:
Visitor
<
'a
>>
(
visitor
:
&
mut
V
,
item
:
&
'a
ForeignItem
)
{
let
ForeignItem
{
id
,
span
,
ident
,
vis
,
defaultness
:
_
,
attrs
,
kind
,
tokens
:
_
}
=
item
;
let
Item
{
id
,
span
,
ident
,
vis
,
attrs
,
kind
,
tokens
:
_
}
=
item
;
walk_nested_item
(
visitor
,
*
id
,
*
span
,
*
ident
,
vis
,
attrs
,
kind
,
FnCtxt
::
Foreign
);
}
...
...
@@ -610,7 +610,7 @@ pub fn walk_fn<'a, V: Visitor<'a>>(visitor: &mut V, kind: FnKind<'a>, _span: Spa
}
pub
fn
walk_assoc_item
<
'a
,
V
:
Visitor
<
'a
>>
(
visitor
:
&
mut
V
,
item
:
&
'a
AssocItem
,
ctxt
:
AssocCtxt
)
{
let
AssocItem
{
id
,
span
,
ident
,
vis
,
attrs
,
kind
,
tokens
:
_
,
defaultnes
s
:
_
}
=
item
;
let
Item
{
id
,
span
,
ident
,
vis
,
attrs
,
kind
,
token
s
:
_
}
=
item
;
walk_nested_item
(
visitor
,
*
id
,
*
span
,
*
ident
,
vis
,
attrs
,
kind
,
FnCtxt
::
Assoc
(
ctxt
));
}
...
...
@@ -628,16 +628,16 @@ fn walk_nested_item<'a, V: Visitor<'a>>(
visitor
.visit_ident
(
ident
);
walk_list!
(
visitor
,
visit_attribute
,
attrs
);
match
kind
{
AssocItemKind
::
Const
(
ty
,
expr
)
|
AssocItemKind
::
Static
(
ty
,
_
,
expr
)
=>
{
AssocItemKind
::
Const
(
_
,
ty
,
expr
)
|
AssocItemKind
::
Static
(
ty
,
_
,
expr
)
=>
{
visitor
.visit_ty
(
ty
);
walk_list!
(
visitor
,
visit_expr
,
expr
);
}
AssocItemKind
::
Fn
(
sig
,
generics
,
body
)
=>
{
AssocItemKind
::
Fn
(
_
,
sig
,
generics
,
body
)
=>
{
visitor
.visit_generics
(
generics
);
let
kind
=
FnKind
::
Fn
(
ctxt
,
ident
,
sig
,
vis
,
body
.as_deref
());
visitor
.visit_fn
(
kind
,
span
,
id
);
}
AssocItemKind
::
TyAlias
(
generics
,
bounds
,
ty
)
=>
{
AssocItemKind
::
TyAlias
(
_
,
generics
,
bounds
,
ty
)
=>
{
visitor
.visit_generics
(
generics
);
walk_list!
(
visitor
,
visit_param_bound
,
bounds
);
walk_list!
(
visitor
,
visit_ty
,
ty
);
...
...
src/test/ui/ast-json/ast-json-output.stdout
浏览文件 @
62930d31
{"module":{"inner":{"lo":0,"hi":0},"items":[{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"core","span":{"lo":0,"hi":0}},"
defaultness":"Final","
kind":{"variant":"ExternCrate","fields":[null]},"tokens":{"_field0":[[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["extern",false]},"span":{"lo":0,"hi":0}}]},"NonJoint"],[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["crate",false]},"span":{"lo":0,"hi":0}}]},"NonJoint"],[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["core",false]},"span":{"lo":0,"hi":0}}]},"NonJoint"],[{"variant":"Token","fields":[{"kind":"Semi","span":{"lo":0,"hi":0}}]},"NonJoint"]]}}],"inline":true},"attrs":[],"span":{"lo":0,"hi":0},"proc_macros":[]}
{"module":{"inner":{"lo":0,"hi":0},"items":[{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":{"_field0":[[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["extern",false]},"span":{"lo":0,"hi":0}}]},"NonJoint"],[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["crate",false]},"span":{"lo":0,"hi":0}}]},"NonJoint"],[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["core",false]},"span":{"lo":0,"hi":0}}]},"NonJoint"],[{"variant":"Token","fields":[{"kind":"Semi","span":{"lo":0,"hi":0}}]},"NonJoint"]]}}],"inline":true},"attrs":[],"span":{"lo":0,"hi":0},"proc_macros":[]}
src/test/ui/parser/assoc-static-semantic-fail.rs
浏览文件 @
62930d31
...
...
@@ -13,9 +13,11 @@ impl S {
//~| ERROR associated constant in `impl` without body
default
static
IC
:
u8
=
0
;
//~^ ERROR associated `static` items are not allowed
//~| ERROR a static item cannot be `default`
pub
(
crate
)
default
static
ID
:
u8
;
//~^ ERROR associated `static` items are not allowed
//~| ERROR associated constant in `impl` without body
//~| ERROR a static item cannot be `default`
}
trait
T
{
...
...
@@ -25,11 +27,11 @@ trait T {
//~^ ERROR associated `static` items are not allowed
default
static
TC
:
u8
=
0
;
//~^ ERROR associated `static` items are not allowed
//~| ERROR
`default` is only allowed on items in
//~| ERROR
a static item cannot be `default`
pub
(
crate
)
default
static
TD
:
u8
;
//~^ ERROR associated `static` items are not allowed
//~| ERROR `default` is only allowed on items in
//~| ERROR unnecessary visibility qualifier
//~| ERROR a static item cannot be `default`
}
impl
T
for
S
{
...
...
@@ -40,8 +42,10 @@ impl T for S {
//~| ERROR associated constant in `impl` without body
default
static
TC
:
u8
=
0
;
//~^ ERROR associated `static` items are not allowed
//~| ERROR a static item cannot be `default`
pub
default
static
TD
:
u8
;
//~^ ERROR associated `static` items are not allowed
//~| ERROR associated constant in `impl` without body
//~| ERROR unnecessary visibility qualifier
//~| ERROR a static item cannot be `default`
}
src/test/ui/parser/assoc-static-semantic-fail.stderr
浏览文件 @
62930d31
...
...
@@ -10,62 +10,110 @@ error: associated `static` items are not allowed
LL | static IB: u8;
| ^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-semantic-fail.rs:14:5
|
LL | default static IC: u8 = 0;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-semantic-fail.rs:14:5
|
LL | default static IC: u8 = 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-semantic-fail.rs:17:16
|
LL | pub(crate) default static ID: u8;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-semantic-fail.rs:1
6
:5
--> $DIR/assoc-static-semantic-fail.rs:1
7
:5
|
LL | pub(crate) default static ID: u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: associated `static` items are not allowed
--> $DIR/assoc-static-semantic-fail.rs:2
2
:5
--> $DIR/assoc-static-semantic-fail.rs:2
4
:5
|
LL | static TA: u8 = 0;
| ^^^^^^^^^^^^^^^^^^
error: associated `static` items are not allowed
--> $DIR/assoc-static-semantic-fail.rs:2
4
:5
--> $DIR/assoc-static-semantic-fail.rs:2
6
:5
|
LL | static TB: u8;
| ^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-semantic-fail.rs:28:5
|
LL | default static TC: u8 = 0;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-semantic-fail.rs:2
6
:5
--> $DIR/assoc-static-semantic-fail.rs:2
8
:5
|
LL | default static TC: u8 = 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-semantic-fail.rs:31:16
|
LL | pub(crate) default static TD: u8;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-semantic-fail.rs:
29
:5
--> $DIR/assoc-static-semantic-fail.rs:
31
:5
|
LL | pub(crate) default static TD: u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: associated `static` items are not allowed
--> $DIR/assoc-static-semantic-fail.rs:3
6
:5
--> $DIR/assoc-static-semantic-fail.rs:3
8
:5
|
LL | static TA: u8 = 0;
| ^^^^^^^^^^^^^^^^^^
error: associated `static` items are not allowed
--> $DIR/assoc-static-semantic-fail.rs:
38
:5
--> $DIR/assoc-static-semantic-fail.rs:
40
:5
|
LL | static TB: u8;
| ^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-semantic-fail.rs:43:5
|
LL | default static TC: u8 = 0;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-semantic-fail.rs:4
1
:5
--> $DIR/assoc-static-semantic-fail.rs:4
3
:5
|
LL | default static TC: u8 = 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-semantic-fail.rs:46:9
|
LL | pub default static TD: u8;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-semantic-fail.rs:4
3
:5
--> $DIR/assoc-static-semantic-fail.rs:4
6
:5
|
LL | pub default static TD: u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
...
...
@@ -79,37 +127,21 @@ LL | static IB: u8;
| help: provide a definition for the constant: `= <expr>;`
error: associated constant in `impl` without body
--> $DIR/assoc-static-semantic-fail.rs:1
6
:5
--> $DIR/assoc-static-semantic-fail.rs:1
7
:5
|
LL | pub(crate) default static ID: u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| |
| help: provide a definition for the constant: `= <expr>;`
error: `default` is only allowed on items in `impl` definitions
--> $DIR/assoc-static-semantic-fail.rs:26:5
|
LL | default static TC: u8 = 0;
| -------^^^^^^^^^^^^^^^^^^^
| |
| `default` because of this
error: `default` is only allowed on items in `impl` definitions
--> $DIR/assoc-static-semantic-fail.rs:29:5
|
LL | pub(crate) default static TD: u8;
| ^^^^^^^^^^^-------^^^^^^^^^^^^^^^
| |
| `default` because of this
error[E0449]: unnecessary visibility qualifier
--> $DIR/assoc-static-semantic-fail.rs:
29
:5
--> $DIR/assoc-static-semantic-fail.rs:
31
:5
|
LL | pub(crate) default static TD: u8;
| ^^^^^^^^^^
error: associated constant in `impl` without body
--> $DIR/assoc-static-semantic-fail.rs:
38
:5
--> $DIR/assoc-static-semantic-fail.rs:
40
:5
|
LL | static TB: u8;
| ^^^^^^^^^^^^^-
...
...
@@ -117,7 +149,7 @@ LL | static TB: u8;
| help: provide a definition for the constant: `= <expr>;`
error: associated constant in `impl` without body
--> $DIR/assoc-static-semantic-fail.rs:4
3
:5
--> $DIR/assoc-static-semantic-fail.rs:4
6
:5
|
LL | pub default static TD: u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^-
...
...
@@ -125,11 +157,11 @@ LL | pub default static TD: u8;
| help: provide a definition for the constant: `= <expr>;`
error[E0449]: unnecessary visibility qualifier
--> $DIR/assoc-static-semantic-fail.rs:4
3
:5
--> $DIR/assoc-static-semantic-fail.rs:4
6
:5
|
LL | pub default static TD: u8;
| ^^^ `pub` not permitted here because it's implied
error: aborting due to 2
0
previous errors
error: aborting due to 2
4
previous errors
For more information about this error, try `rustc --explain E0449`.
src/test/ui/parser/assoc-static-syntactic-fail.rs
浏览文件 @
62930d31
...
...
@@ -7,7 +7,9 @@ impl S {
static
IA
:
u8
=
0
;
//~ ERROR associated `static` items are not allowed
static
IB
:
u8
;
//~ ERROR associated `static` items are not allowed
default
static
IC
:
u8
=
0
;
//~ ERROR associated `static` items are not allowed
//~^ ERROR a static item cannot be `default`
pub
(
crate
)
default
static
ID
:
u8
;
//~ ERROR associated `static` items are not allowed
//~^ ERROR a static item cannot be `default`
}
#[cfg(FALSE)]
...
...
@@ -15,7 +17,9 @@ trait T {
static
TA
:
u8
=
0
;
//~ ERROR associated `static` items are not allowed
static
TB
:
u8
;
//~ ERROR associated `static` items are not allowed
default
static
TC
:
u8
=
0
;
//~ ERROR associated `static` items are not allowed
//~^ ERROR a static item cannot be `default`
pub
(
crate
)
default
static
TD
:
u8
;
//~ ERROR associated `static` items are not allowed
//~^ ERROR a static item cannot be `default`
}
#[cfg(FALSE)]
...
...
@@ -23,5 +27,7 @@ impl T for S {
static
TA
:
u8
=
0
;
//~ ERROR associated `static` items are not allowed
static
TB
:
u8
;
//~ ERROR associated `static` items are not allowed
default
static
TC
:
u8
=
0
;
//~ ERROR associated `static` items are not allowed
//~^ ERROR a static item cannot be `default`
pub
default
static
TD
:
u8
;
//~ ERROR associated `static` items are not allowed
//~^ ERROR a static item cannot be `default`
}
src/test/ui/parser/assoc-static-syntactic-fail.stderr
浏览文件 @
62930d31
...
...
@@ -10,65 +10,113 @@ error: associated `static` items are not allowed
LL | static IB: u8;
| ^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-syntactic-fail.rs:9:5
|
LL | default static IC: u8 = 0;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-syntactic-fail.rs:9:5
|
LL | default static IC: u8 = 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-syntactic-fail.rs:11:16
|
LL | pub(crate) default static ID: u8;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-syntactic-fail.rs:1
0
:5
--> $DIR/assoc-static-syntactic-fail.rs:1
1
:5
|
LL | pub(crate) default static ID: u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: associated `static` items are not allowed
--> $DIR/assoc-static-syntactic-fail.rs:1
5
:5
--> $DIR/assoc-static-syntactic-fail.rs:1
7
:5
|
LL | static TA: u8 = 0;
| ^^^^^^^^^^^^^^^^^^
error: associated `static` items are not allowed
--> $DIR/assoc-static-syntactic-fail.rs:1
6
:5
--> $DIR/assoc-static-syntactic-fail.rs:1
8
:5
|
LL | static TB: u8;
| ^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-syntactic-fail.rs:19:5
|
LL | default static TC: u8 = 0;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-syntactic-fail.rs:1
7
:5
--> $DIR/assoc-static-syntactic-fail.rs:1
9
:5
|
LL | default static TC: u8 = 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-syntactic-fail.rs:21:16
|
LL | pub(crate) default static TD: u8;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-syntactic-fail.rs:
18
:5
--> $DIR/assoc-static-syntactic-fail.rs:
21
:5
|
LL | pub(crate) default static TD: u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: associated `static` items are not allowed
--> $DIR/assoc-static-syntactic-fail.rs:2
3
:5
--> $DIR/assoc-static-syntactic-fail.rs:2
7
:5
|
LL | static TA: u8 = 0;
| ^^^^^^^^^^^^^^^^^^
error: associated `static` items are not allowed
--> $DIR/assoc-static-syntactic-fail.rs:2
4
:5
--> $DIR/assoc-static-syntactic-fail.rs:2
8
:5
|
LL | static TB: u8;
| ^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-syntactic-fail.rs:29:5
|
LL | default static TC: u8 = 0;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-syntactic-fail.rs:2
5
:5
--> $DIR/assoc-static-syntactic-fail.rs:2
9
:5
|
LL | default static TC: u8 = 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a static item cannot be `default`
--> $DIR/assoc-static-syntactic-fail.rs:31:9
|
LL | pub default static TD: u8;
| ^^^^^^^ `default` because of this
|
= note: only associated `fn`, `const`, and `type` items can be `default`
error: associated `static` items are not allowed
--> $DIR/assoc-static-syntactic-fail.rs:
26
:5
--> $DIR/assoc-static-syntactic-fail.rs:
31
:5
|
LL | pub default static TD: u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 1
2
previous errors
error: aborting due to 1
8
previous errors
src/test/ui/parser/default-on-wrong-item-kind.rs
浏览文件 @
62930d31
...
...
@@ -6,135 +6,135 @@ fn main() {}
#[cfg(FALSE)]
mod
free_items
{
default
extern
crate
foo
;
//~ ERROR
item
cannot be `default`
default
use
foo
;
//~ ERROR
item
cannot be `default`
default
static
foo
:
u8
;
//~ ERROR item cannot be `default`
default
const
foo
:
u8
;
//~ ERROR item cannot be `default`
default
fn
foo
();
//~ ERROR item cannot be `default`
default
mod
foo
{}
//~ ERROR
item
cannot be `default`
default
extern
"C"
{}
//~ ERROR
item
cannot be `default`
default
type
foo
=
u8
;
//~ ERROR item cannot be `default`
default
enum
foo
{}
//~ ERROR
ite
m cannot be `default`
default
struct
foo
{}
//~ ERROR
item
cannot be `default`
default
union
foo
{}
//~ ERROR
item
cannot be `default`
default
trait
foo
{}
//~ ERROR
item
cannot be `default`
default
trait
foo
=
Ord
;
//~ ERROR
item
cannot be `default`
default
extern
crate
foo
;
//~ ERROR
an extern crate
cannot be `default`
default
use
foo
;
//~ ERROR
a `use` import
cannot be `default`
default
static
foo
:
u8
;
//~ ERROR
a static
item cannot be `default`
default
const
foo
:
u8
;
default
fn
foo
();
default
mod
foo
{}
//~ ERROR
a module
cannot be `default`
default
extern
"C"
{}
//~ ERROR
an extern block
cannot be `default`
default
type
foo
=
u8
;
default
enum
foo
{}
//~ ERROR
an enu
m cannot be `default`
default
struct
foo
{}
//~ ERROR
a struct
cannot be `default`
default
union
foo
{}
//~ ERROR
a union
cannot be `default`
default
trait
foo
{}
//~ ERROR
a trait
cannot be `default`
default
trait
foo
=
Ord
;
//~ ERROR
a trait alias
cannot be `default`
default
impl
foo
{}
default!
();
default
::
foo
::
bar!
();
default
default!
();
//~ ERROR
item
cannot be `default`
default
default
::
foo
::
bar!
();
//~ ERROR
item
cannot be `default`
default
macro
foo
{}
//~ ERROR
item
cannot be `default`
default
macro_rules!
foo
{}
//~ ERROR
item
cannot be `default`
default
default!
();
//~ ERROR
an item macro invocation
cannot be `default`
default
default
::
foo
::
bar!
();
//~ ERROR
an item macro invocation
cannot be `default`
default
macro
foo
{}
//~ ERROR
a macro definition
cannot be `default`
default
macro_rules!
foo
{}
//~ ERROR
a macro definition
cannot be `default`
}
#[cfg(FALSE)]
extern
"C"
{
default
extern
crate
foo
;
//~ ERROR
item
cannot be `default`
default
extern
crate
foo
;
//~ ERROR
an extern crate
cannot be `default`
//~^ ERROR extern crate not supported in `extern` block
default
use
foo
;
//~ ERROR
item
cannot be `default`
default
use
foo
;
//~ ERROR
a `use` import
cannot be `default`
//~^ ERROR `use` import not supported in `extern` block
default
static
foo
:
u8
;
//~ ERROR item cannot be `default`
default
const
foo
:
u8
;
//~ ERROR item cannot be `default`
default
static
foo
:
u8
;
//~ ERROR
a static
item cannot be `default`
default
const
foo
:
u8
;
//~^ ERROR extern items cannot be `const`
default
fn
foo
();
//~ ERROR item cannot be `default`
default
mod
foo
{}
//~ ERROR
item
cannot be `default`
default
fn
foo
();
default
mod
foo
{}
//~ ERROR
a module
cannot be `default`
//~^ ERROR module not supported in `extern` block
default
extern
"C"
{}
//~ ERROR
item
cannot be `default`
default
extern
"C"
{}
//~ ERROR
an extern block
cannot be `default`
//~^ ERROR extern block not supported in `extern` block
default
type
foo
=
u8
;
//~ ERROR item cannot be `default`
default
enum
foo
{}
//~ ERROR
ite
m cannot be `default`
default
type
foo
=
u8
;
default
enum
foo
{}
//~ ERROR
an enu
m cannot be `default`
//~^ ERROR enum not supported in `extern` block
default
struct
foo
{}
//~ ERROR
item
cannot be `default`
default
struct
foo
{}
//~ ERROR
a struct
cannot be `default`
//~^ ERROR struct not supported in `extern` block
default
union
foo
{}
//~ ERROR
item
cannot be `default`
default
union
foo
{}
//~ ERROR
a union
cannot be `default`
//~^ ERROR union not supported in `extern` block
default
trait
foo
{}
//~ ERROR
item
cannot be `default`
default
trait
foo
{}
//~ ERROR
a trait
cannot be `default`
//~^ ERROR trait not supported in `extern` block
default
trait
foo
=
Ord
;
//~ ERROR
item
cannot be `default`
default
trait
foo
=
Ord
;
//~ ERROR
a trait alias
cannot be `default`
//~^ ERROR trait alias not supported in `extern` block
default
impl
foo
{}
//~^ ERROR implementation not supported in `extern` block
default!
();
default
::
foo
::
bar!
();
default
default!
();
//~ ERROR
item
cannot be `default`
default
default
::
foo
::
bar!
();
//~ ERROR
item
cannot be `default`
default
macro
foo
{}
//~ ERROR
item
cannot be `default`
default
default!
();
//~ ERROR
an item macro invocation
cannot be `default`
default
default
::
foo
::
bar!
();
//~ ERROR
an item macro invocation
cannot be `default`
default
macro
foo
{}
//~ ERROR
a macro definition
cannot be `default`
//~^ ERROR macro definition not supported in `extern` block
default
macro_rules!
foo
{}
//~ ERROR
item
cannot be `default`
default
macro_rules!
foo
{}
//~ ERROR
a macro definition
cannot be `default`
//~^ ERROR macro definition not supported in `extern` block
}
#[cfg(FALSE)]
impl
S
{
default
extern
crate
foo
;
default
extern
crate
foo
;
//~ ERROR an extern crate cannot be `default`
//~^ ERROR extern crate not supported in `trait` or `impl`
default
use
foo
;
default
use
foo
;
//~ ERROR a `use` import cannot be `default`
//~^ ERROR `use` import not supported in `trait` or `impl`
default
static
foo
:
u8
;
default
static
foo
:
u8
;
//~ ERROR a static item cannot be `default`
//~^ ERROR associated `static` items are not allowed
default
const
foo
:
u8
;
default
fn
foo
();
default
mod
foo
{}
default
mod
foo
{}
//~ ERROR a module cannot be `default`
//~^ ERROR module not supported in `trait` or `impl`
default
extern
"C"
{}
default
extern
"C"
{}
//~ ERROR an extern block cannot be `default`
//~^ ERROR extern block not supported in `trait` or `impl`
default
type
foo
=
u8
;
default
enum
foo
{}
default
enum
foo
{}
//~ ERROR an enum cannot be `default`
//~^ ERROR enum not supported in `trait` or `impl`
default
struct
foo
{}
default
struct
foo
{}
//~ ERROR a struct cannot be `default`
//~^ ERROR struct not supported in `trait` or `impl`
default
union
foo
{}
default
union
foo
{}
//~ ERROR a union cannot be `default`
//~^ ERROR union not supported in `trait` or `impl`
default
trait
foo
{}
default
trait
foo
{}
//~ ERROR a trait cannot be `default`
//~^ ERROR trait not supported in `trait` or `impl`
default
trait
foo
=
Ord
;
default
trait
foo
=
Ord
;
//~ ERROR a trait alias cannot be `default`
//~^ ERROR trait alias not supported in `trait` or `impl`
default
impl
foo
{}
//~^ ERROR implementation not supported in `trait` or `impl`
default!
();
default
::
foo
::
bar!
();
default
default!
();
default
default
::
foo
::
bar!
();
default
macro
foo
{}
default
default!
();
//~ ERROR an item macro invocation cannot be `default`
default
default
::
foo
::
bar!
();
//~ ERROR an item macro invocation cannot be `default`
default
macro
foo
{}
//~ ERROR a macro definition cannot be `default`
//~^ ERROR macro definition not supported in `trait` or `impl`
default
macro_rules!
foo
{}
default
macro_rules!
foo
{}
//~ ERROR a macro definition cannot be `default`
//~^ ERROR macro definition not supported in `trait` or `impl`
}
#[cfg(FALSE)]
trait
T
{
default
extern
crate
foo
;
default
extern
crate
foo
;
//~ ERROR an extern crate cannot be `default`
//~^ ERROR extern crate not supported in `trait` or `impl`
default
use
foo
;
default
use
foo
;
//~ ERROR a `use` import cannot be `default`
//~^ ERROR `use` import not supported in `trait` or `impl`
default
static
foo
:
u8
;
default
static
foo
:
u8
;
//~ ERROR a static item cannot be `default`
//~^ ERROR associated `static` items are not allowed
default
const
foo
:
u8
;
default
fn
foo
();
default
mod
foo
{}
default
mod
foo
{}
//~ ERROR a module cannot be `default`
//~^ ERROR module not supported in `trait` or `impl`
default
extern
"C"
{}
default
extern
"C"
{}
//~ ERROR an extern block cannot be `default`
//~^ ERROR extern block not supported in `trait` or `impl`
default
type
foo
=
u8
;
default
enum
foo
{}
default
enum
foo
{}
//~ ERROR an enum cannot be `default`
//~^ ERROR enum not supported in `trait` or `impl`
default
struct
foo
{}
default
struct
foo
{}
//~ ERROR a struct cannot be `default`
//~^ ERROR struct not supported in `trait` or `impl`
default
union
foo
{}
default
union
foo
{}
//~ ERROR a union cannot be `default`
//~^ ERROR union not supported in `trait` or `impl`
default
trait
foo
{}
default
trait
foo
{}
//~ ERROR a trait cannot be `default`
//~^ ERROR trait not supported in `trait` or `impl`
default
trait
foo
=
Ord
;
default
trait
foo
=
Ord
;
//~ ERROR a trait alias cannot be `default`
//~^ ERROR trait alias not supported in `trait` or `impl`
default
impl
foo
{}
//~^ ERROR implementation not supported in `trait` or `impl`
default!
();
default
::
foo
::
bar!
();
default
default!
();
default
default
::
foo
::
bar!
();
default
macro
foo
{}
default
default!
();
//~ ERROR an item macro invocation cannot be `default`
default
default
::
foo
::
bar!
();
//~ ERROR an item macro invocation cannot be `default`
default
macro
foo
{}
//~ ERROR a macro definition cannot be `default`
//~^ ERROR macro definition not supported in `trait` or `impl`
default
macro_rules!
foo
{}
default
macro_rules!
foo
{}
//~ ERROR a macro definition cannot be `default`
//~^ ERROR macro definition not supported in `trait` or `impl`
}
src/test/ui/parser/default-on-wrong-item-kind.stderr
浏览文件 @
62930d31
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录