Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8a38928b
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,发现更多精彩内容 >>
提交
8a38928b
编写于
9月 15, 2016
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address comments + Fix rebase
上级
eada951f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
58 addition
and
51 deletion
+58
-51
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+0
-28
src/librustc_const_eval/pattern.rs
src/librustc_const_eval/pattern.rs
+1
-1
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+5
-11
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+5
-5
src/test/compile-fail/struct-path-associated-type.rs
src/test/compile-fail/struct-path-associated-type.rs
+3
-3
src/test/compile-fail/struct-path-self-type-mismatch.rs
src/test/compile-fail/struct-path-self-type-mismatch.rs
+38
-0
src/test/compile-fail/struct-path-self.rs
src/test/compile-fail/struct-path-self.rs
+3
-3
src/test/run-pass/issue-22546.rs
src/test/run-pass/issue-22546.rs
+3
-0
未找到文件。
src/librustc/util/ppaux.rs
浏览文件 @
8a38928b
...
...
@@ -802,34 +802,6 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
impl
<
'tcx
>
ty
::
TypeVariants
<
'tcx
>
{
pub
fn
descr
(
&
self
)
->
&
'static
str
{
match
*
self
{
TyInt
(
..
)
|
TyUint
(
..
)
|
TyFloat
(
..
)
|
TyBool
|
TyChar
|
TyStr
=>
"builtin type"
,
TyRawPtr
(
..
)
=>
"pointer"
,
TyRef
(
..
)
=>
"reference"
,
TyTuple
(
..
)
=>
"tuple"
,
TyFnDef
(
..
)
=>
"function type"
,
TyFnPtr
(
..
)
=>
"function pointer"
,
TyArray
(
..
)
=>
"array"
,
TySlice
(
..
)
=>
"slice"
,
TyParam
(
..
)
=>
"type parameter"
,
TyProjection
(
..
)
=>
"associated type"
,
TyTrait
(
..
)
=>
"trait type"
,
TyClosure
(
..
)
=>
"closure type"
,
TyBox
(
..
)
=>
"struct"
,
TyAdt
(
def
,
..
)
=>
match
def
.adt_kind
()
{
ty
::
AdtKind
::
Struct
=>
"struct"
,
ty
::
AdtKind
::
Union
=>
"union"
,
ty
::
AdtKind
::
Enum
=>
"enum"
,
},
TyInfer
(
..
)
|
TyAnon
(
..
)
|
TyNever
|
TyError
=>
"type"
,
}
}
}
impl
<
'tcx
>
fmt
::
Display
for
ty
::
TypeVariants
<
'tcx
>
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
match
*
self
{
...
...
src/librustc_const_eval/pattern.rs
浏览文件 @
8a38928b
...
...
@@ -436,7 +436,7 @@ fn lower_variant_or_leaf(
}
Def
::
Struct
(
..
)
|
Def
::
StructCtor
(
..
)
|
Def
::
Union
(
..
)
|
Def
::
TyAlias
(
..
)
|
Def
::
AssociatedTy
(
..
)
=>
{
Def
::
TyAlias
(
..
)
|
Def
::
AssociatedTy
(
..
)
|
Def
::
SelfTy
(
..
)
=>
{
PatternKind
::
Leaf
{
subpatterns
:
subpatterns
}
}
...
...
src/librustc_typeck/astconv.rs
浏览文件 @
8a38928b
...
...
@@ -1520,17 +1520,11 @@ fn base_def_to_ty(&self,
// Convert "variant type" as if it were a real type.
// The resulting `Ty` is type of the variant's enum for now.
tcx
.prohibit_type_params
(
base_segments
.split_last
()
.unwrap
()
.1
);
let
mut
ty
=
self
.ast_path_to_ty
(
rscope
,
span
,
param_mode
,
tcx
.parent_def_id
(
did
)
.unwrap
(),
base_segments
.last
()
.unwrap
());
if
ty
.is_fn
()
{
// Tuple variants have fn type even in type namespace,
// extract true variant type from it.
ty
=
tcx
.no_late_bound_regions
(
&
ty
.fn_ret
())
.unwrap
();
}
ty
self
.ast_path_to_ty
(
rscope
,
span
,
param_mode
,
tcx
.parent_def_id
(
did
)
.unwrap
(),
base_segments
.last
()
.unwrap
())
}
Def
::
TyParam
(
did
)
=>
{
tcx
.prohibit_type_params
(
base_segments
);
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
8a38928b
...
...
@@ -3216,9 +3216,9 @@ fn check_struct_fields_on_error(&self,
}
pub
fn
check_struct_path
(
&
self
,
path
:
&
hir
::
Path
,
node_id
:
ast
::
NodeId
)
->
Option
<
(
ty
::
VariantDef
<
'tcx
>
,
Ty
<
'tcx
>
)
>
{
path
:
&
hir
::
Path
,
node_id
:
ast
::
NodeId
)
->
Option
<
(
ty
::
VariantDef
<
'tcx
>
,
Ty
<
'tcx
>
)
>
{
let
(
def
,
ty
)
=
self
.finish_resolving_struct_path
(
path
,
node_id
);
let
variant
=
match
def
{
Def
::
Err
=>
{
...
...
@@ -3263,8 +3263,8 @@ pub fn check_struct_path(&self,
Some
((
variant
,
ty
))
}
else
{
struct_span_err!
(
self
.tcx.sess
,
path
.span
,
E0071
,
"expected struct, variant or union type, found {}
`{}`
"
,
ty
.s
ty
.descr
(),
ty
)
"expected struct, variant or union type, found {}"
,
ty
.s
ort_string
(
self
.tcx
)
)
.span_label
(
path
.span
,
&
format!
(
"not a struct"
))
.emit
();
None
...
...
src/test/compile-fail/struct-path-associated-type.rs
浏览文件 @
8a38928b
...
...
@@ -20,13 +20,13 @@ impl Tr for S {
fn
f
<
T
:
Tr
>
()
{
let
s
=
T
::
A
{};
//~^ ERROR expected struct, variant or union type, found associated type
`<T as Tr>::A`
//~^ ERROR expected struct, variant or union type, found associated type
let
z
=
T
::
A
::
<
u8
>
{};
//~^ ERROR expected struct, variant or union type, found associated type
`<T as Tr>::A`
//~^ ERROR expected struct, variant or union type, found associated type
//~| ERROR type parameters are not allowed on this type
match
S
{
T
::
A
{}
=>
{}
//~^ ERROR expected struct, variant or union type, found associated type
`<T as Tr>::A`
//~^ ERROR expected struct, variant or union type, found associated type
}
}
...
...
src/test/compile-fail/struct-path-self-type-mismatch.rs
0 → 100644
浏览文件 @
8a38928b
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
Foo
<
A
>
{
inner
:
A
}
trait
Bar
{
fn
bar
();
}
impl
Bar
for
Foo
<
i32
>
{
fn
bar
()
{
Self
{
inner
:
1.5f32
};
//~ ERROR mismatched types
//~^ NOTE expected i32, found f32
}
}
impl
<
T
>
Foo
<
T
>
{
fn
new
<
U
>
(
u
:
U
)
->
Foo
<
U
>
{
Self
{
//~^ ERROR mismatched types
//~| expected type parameter, found a different type parameter
//~| expected type `Foo<U>`
//~| found type `Foo<T>`
inner
:
u
//~^ ERROR mismatched types
//~| expected type parameter, found a different type parameter
//~| expected type `T`
//~| found type `U`
}
}
}
fn
main
()
{}
src/test/compile-fail/struct-path-self.rs
浏览文件 @
8a38928b
...
...
@@ -13,13 +13,13 @@
trait
Tr
{
fn
f
()
{
let
s
=
Self
{};
//~^ ERROR expected struct, variant or union type, found
type parameter `Self`
//~^ ERROR expected struct, variant or union type, found
Self
let
z
=
Self
::
<
u8
>
{};
//~^ ERROR expected struct, variant or union type, found
type parameter `Self`
//~^ ERROR expected struct, variant or union type, found
Self
//~| ERROR type parameters are not allowed on this type
match
s
{
Self
{
..
}
=>
{}
//~^ ERROR expected struct, variant or union type, found
type parameter `Self`
//~^ ERROR expected struct, variant or union type, found
Self
}
}
}
...
...
src/test/run-pass/issue-22546.rs
浏览文件 @
8a38928b
...
...
@@ -54,4 +54,7 @@ fn main() {
if
let
None
::
<
u8
>
{
..
}
=
Some
(
8
)
{
panic!
();
}
if
let
Option
::
None
::
<
u8
>
{
..
}
=
Some
(
8
)
{
panic!
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录