Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2d1d4d19
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,发现更多精彩内容 >>
提交
2d1d4d19
编写于
9月 25, 2016
作者:
B
bors
提交者:
GitHub
9月 25, 2016
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #36713 - TimNN:fix-36708, r=arielb1
don't unwrap non-local span Fixes #36708.
上级
d6dc3390
47b918d5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
66 addition
and
18 deletion
+66
-18
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/compare_method.rs
+28
-18
src/test/compile-fail/auxiliary/issue-36708.rs
src/test/compile-fail/auxiliary/issue-36708.rs
+15
-0
src/test/compile-fail/issue-36708.rs
src/test/compile-fail/issue-36708.rs
+23
-0
未找到文件。
src/librustc_typeck/check/compare_method.rs
浏览文件 @
2d1d4d19
...
...
@@ -110,30 +110,40 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
_
=>
bug!
(
"{:?} is not a method"
,
impl_m
)
};
struct_span_err!
(
tcx
.sess
,
span
,
E0049
,
let
mut
err
=
struct_span_err!
(
tcx
.sess
,
span
,
E0049
,
"method `{}` has {} type parameter{}
\
but its trait declaration has {} type parameter{}"
,
trait_m
.name
,
num_impl_m_type_params
,
if
num_impl_m_type_params
==
1
{
""
}
else
{
"s"
},
num_trait_m_type_params
,
if
num_trait_m_type_params
==
1
{
""
}
else
{
"s"
})
.span_label
(
trait_item_span
.unwrap
(),
&
format!
(
"expected {}"
,
&
if
num_trait_m_type_params
!=
1
{
format!
(
"{} type parameters"
,
num_trait_m_type_params
)
}
else
{
format!
(
"{} type parameter"
,
num_trait_m_type_params
)
}))
.span_label
(
span
,
&
format!
(
"found {}"
,
&
if
num_impl_m_type_params
!=
1
{
format!
(
"{} type parameters"
,
num_impl_m_type_params
)
}
else
{
format!
(
"1 type parameter"
)
}))
.emit
();
if
num_trait_m_type_params
==
1
{
""
}
else
{
"s"
});
let
mut
suffix
=
None
;
if
let
Some
(
span
)
=
trait_item_span
{
err
.span_label
(
span
,
&
format!
(
"expected {}"
,
&
if
num_trait_m_type_params
!=
1
{
format!
(
"{} type parameters"
,
num_trait_m_type_params
)
}
else
{
format!
(
"{} type parameter"
,
num_trait_m_type_params
)
}));
}
else
{
suffix
=
Some
(
format!
(
", expected {}"
,
num_trait_m_type_params
));
}
err
.span_label
(
span
,
&
format!
(
"found {}{}"
,
&
if
num_impl_m_type_params
!=
1
{
format!
(
"{} type parameters"
,
num_impl_m_type_params
)
}
else
{
format!
(
"1 type parameter"
)
},
suffix
.as_ref
()
.map
(|
s
|
&
s
[
..
])
.unwrap_or
(
""
)));
err
.emit
();
return
;
}
...
...
src/test/compile-fail/auxiliary/issue-36708.rs
0 → 100644
浏览文件 @
2d1d4d19
// 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.
#![crate_type
=
"lib"
]
pub
trait
Foo
{
fn
foo
();
}
src/test/compile-fail/issue-36708.rs
0 → 100644
浏览文件 @
2d1d4d19
// 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.
// aux-build:issue-36708.rs
extern
crate
issue_36708
as
lib
;
struct
Bar
;
impl
lib
::
Foo
for
Bar
{
fn
foo
<
T
>
()
{}
//~^ ERROR E0049
//~| NOTE found 1 type parameter, expected 0
}
fn
main
()
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录