Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
a7b3eed7
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,发现更多精彩内容 >>
提交
a7b3eed7
编写于
9月 15, 2015
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #28395 - ebfull:fix-associated-item-resolution, r=arielb1
Fixes #28344
上级
f3e6d315
4fec6793
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
94 addition
and
12 deletion
+94
-12
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+43
-12
src/test/compile-fail/issue-28344.rs
src/test/compile-fail/issue-28344.rs
+21
-0
src/test/compile-fail/unspecified-self-in-trait-ref.rs
src/test/compile-fail/unspecified-self-in-trait-ref.rs
+30
-0
未找到文件。
src/librustc_typeck/astconv.rs
浏览文件 @
a7b3eed7
...
...
@@ -407,18 +407,13 @@ fn create_substs_for_ast_path<'tcx>(
.take_while
(|
x
|
x
.default
.is_none
())
.count
();
// Fill with `ty_infer` if no params were specified, as long as
// they were optional (e.g. paths inside expressions).
let
mut
type_substs
=
if
param_mode
==
PathParamMode
::
Optional
&&
types_provided
.is_empty
()
{
let
mut
substs
=
region_substs
.clone
();
ty_param_defs
.iter
()
.map
(|
p
|
this
.ty_infer
(
Some
(
p
.clone
()),
Some
(
&
mut
substs
),
Some
(
TypeSpace
),
span
))
.collect
()
}
else
{
types_provided
};
let
mut
type_substs
=
get_type_substs_for_defs
(
this
,
span
,
types_provided
,
param_mode
,
ty_param_defs
,
region_substs
.clone
(),
self_ty
);
let
supplied_ty_param_count
=
type_substs
.len
();
check_type_argument_count
(
this
.tcx
(),
span
,
supplied_ty_param_count
,
...
...
@@ -482,6 +477,42 @@ fn create_substs_for_ast_path<'tcx>(
substs
}
/// Returns types_provided if it is not empty, otherwise populating the
/// type parameters with inference variables as appropriate.
fn
get_type_substs_for_defs
<
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
span
:
Span
,
types_provided
:
Vec
<
Ty
<
'tcx
>>
,
param_mode
:
PathParamMode
,
ty_param_defs
:
&
[
ty
::
TypeParameterDef
<
'tcx
>
],
mut
substs
:
Substs
<
'tcx
>
,
self_ty
:
Option
<
Ty
<
'tcx
>>
)
->
Vec
<
Ty
<
'tcx
>>
{
fn
default_type_parameter
<
'tcx
>
(
p
:
&
ty
::
TypeParameterDef
<
'tcx
>
,
self_ty
:
Option
<
Ty
<
'tcx
>>
)
->
Option
<
ty
::
TypeParameterDef
<
'tcx
>>
{
if
let
Some
(
ref
default
)
=
p
.default
{
if
self_ty
.is_none
()
&&
default
.has_self_ty
()
{
// There is no suitable inference default for a type parameter
// that references self with no self-type provided.
return
None
;
}
}
Some
(
p
.clone
())
}
if
param_mode
==
PathParamMode
::
Optional
&&
types_provided
.is_empty
()
{
ty_param_defs
.iter
()
.map
(|
p
|
this
.ty_infer
(
default_type_parameter
(
p
,
self_ty
),
Some
(
&
mut
substs
),
Some
(
TypeSpace
),
span
))
.collect
()
}
else
{
types_provided
}
}
struct
ConvertedBinding
<
'tcx
>
{
item_name
:
ast
::
Name
,
ty
:
Ty
<
'tcx
>
,
...
...
src/test/compile-fail/issue-28344.rs
0 → 100644
浏览文件 @
a7b3eed7
// Copyright 2015 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.
use
std
::
ops
::
BitXor
;
fn
main
()
{
let
x
:
u8
=
BitXor
::
bitor
(
0
as
u8
,
0
as
u8
);
//~^ ERROR must be specified
//~| no associated item named
let
g
=
BitXor
::
bitor
;
//~^ ERROR must be specified
//~| no associated item named
}
\ No newline at end of file
src/test/compile-fail/unspecified-self-in-trait-ref.rs
0 → 100644
浏览文件 @
a7b3eed7
// Copyright 2015 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.
pub
trait
Foo
<
A
=
Self
>
{
fn
foo
();
}
pub
trait
Bar
<
X
=
usize
,
A
=
Self
>
{
fn
foo
();
}
fn
main
()
{
let
a
=
Foo
::
lol
();
//~^ ERROR no associated item named
let
b
=
Foo
::
<
_
>
::
lol
();
//~^ ERROR no associated item named
let
c
=
Bar
::
lol
();
//~^ ERROR no associated item named
let
d
=
Bar
::
<
usize
,
_
>
::
lol
();
//~^ ERROR no associated item named
let
e
=
Bar
::
<
usize
>
::
lol
();
//~^ ERROR must be explicitly specified
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录