Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e684525c
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e684525c
编写于
1月 26, 2018
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fix-regression' of
https://github.com/estebank/rust
into rollup
上级
1dc85768
6006b67e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
86 addition
and
41 deletion
+86
-41
src/librustc/traits/error_reporting.rs
src/librustc/traits/error_reporting.rs
+49
-41
src/test/ui/issue-47706.rs
src/test/ui/issue-47706.rs
+24
-0
src/test/ui/issue-47706.stderr
src/test/ui/issue-47706.stderr
+13
-0
未找到文件。
src/librustc/traits/error_reporting.rs
浏览文件 @
e684525c
...
...
@@ -794,48 +794,56 @@ fn suggest_borrow_on_unsized_slice(&self,
}
fn
get_fn_like_arguments
(
&
self
,
node
:
hir
::
map
::
Node
)
->
(
Span
,
Vec
<
ArgKind
>
)
{
if
let
hir
::
map
::
NodeExpr
(
&
hir
::
Expr
{
node
:
hir
::
ExprClosure
(
_
,
ref
_
decl
,
id
,
span
,
_
),
..
})
=
node
{
(
self
.tcx.sess
.codemap
()
.def_span
(
span
),
self
.tcx.hir
.body
(
id
)
.arguments
.iter
()
.map
(|
arg
|
{
if
let
hir
::
Pat
{
node
:
hir
::
PatKind
::
Tuple
(
args
,
_
),
span
,
..
}
=
arg
.pat
.clone
()
.into_inner
()
{
ArgKind
::
Tuple
(
match
node
{
hir
::
map
::
NodeExpr
(
&
hir
::
Expr
{
node
:
hir
::
ExprClosure
(
_
,
ref
_
decl
,
id
,
span
,
_
),
..
})
=>
{
(
self
.tcx.sess
.codemap
()
.def_span
(
span
),
self
.tcx.hir
.body
(
id
)
.arguments
.iter
()
.map
(|
arg
|
{
if
let
hir
::
Pat
{
node
:
hir
::
PatKind
::
Tuple
(
args
,
_
),
span
,
args
.iter
()
.map
(|
pat
|
{
let
snippet
=
self
.tcx.sess
.codemap
()
.span_to_snippet
(
pat
.span
)
.unwrap
();
(
snippet
,
"_"
.to_owned
())
})
.collect
::
<
Vec
<
_
>>
(),
)
}
else
{
let
name
=
self
.tcx.sess
.codemap
()
.span_to_snippet
(
arg
.pat.span
)
.unwrap
();
ArgKind
::
Arg
(
name
,
"_"
.to_owned
())
}
})
.collect
::
<
Vec
<
ArgKind
>>
())
}
else
if
let
hir
::
map
::
NodeItem
(
&
hir
::
Item
{
span
,
node
:
hir
::
ItemFn
(
ref
decl
,
..
),
..
})
=
node
{
(
self
.tcx.sess
.codemap
()
.def_span
(
span
),
decl
.inputs
.iter
()
.map
(|
arg
|
match
arg
.clone
()
.into_inner
()
.node
{
hir
::
TyTup
(
ref
tys
)
=>
ArgKind
::
Tuple
(
arg
.span
,
tys
.iter
()
.map
(|
_
|
(
"_"
.to_owned
(),
"_"
.to_owned
()))
.collect
::
<
Vec
<
_
>>
(),
),
_
=>
ArgKind
::
Arg
(
"_"
.to_owned
(),
"_"
.to_owned
())
})
.collect
::
<
Vec
<
ArgKind
>>
())
}
else
{
panic!
(
"non-FnLike node found: {:?}"
,
node
);
..
}
=
arg
.pat
.clone
()
.into_inner
()
{
ArgKind
::
Tuple
(
span
,
args
.iter
()
.map
(|
pat
|
{
let
snippet
=
self
.tcx.sess
.codemap
()
.span_to_snippet
(
pat
.span
)
.unwrap
();
(
snippet
,
"_"
.to_owned
())
})
.collect
::
<
Vec
<
_
>>
(),
)
}
else
{
let
name
=
self
.tcx.sess
.codemap
()
.span_to_snippet
(
arg
.pat.span
)
.unwrap
();
ArgKind
::
Arg
(
name
,
"_"
.to_owned
())
}
})
.collect
::
<
Vec
<
ArgKind
>>
())
}
hir
::
map
::
NodeItem
(
&
hir
::
Item
{
span
,
node
:
hir
::
ItemFn
(
ref
decl
,
..
),
..
})
|
hir
::
map
::
NodeImplItem
(
&
hir
::
ImplItem
{
span
,
node
:
hir
::
ImplItemKind
::
Method
(
hir
::
MethodSig
{
ref
decl
,
..
},
_
),
..
})
=>
{
(
self
.tcx.sess
.codemap
()
.def_span
(
span
),
decl
.inputs
.iter
()
.map
(|
arg
|
match
arg
.clone
()
.into_inner
()
.node
{
hir
::
TyTup
(
ref
tys
)
=>
ArgKind
::
Tuple
(
arg
.span
,
tys
.iter
()
.map
(|
_
|
(
"_"
.to_owned
(),
"_"
.to_owned
()))
.collect
::
<
Vec
<
_
>>
(),
),
_
=>
ArgKind
::
Arg
(
"_"
.to_owned
(),
"_"
.to_owned
())
})
.collect
::
<
Vec
<
ArgKind
>>
())
}
_
=>
panic!
(
"non-FnLike node found: {:?}"
,
node
),
}
}
...
...
src/test/ui/issue-47706.rs
0 → 100644
浏览文件 @
e684525c
// Copyright 2018 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
struct
Foo
{
foo
:
Option
<
i32
>
,
}
impl
Foo
{
pub
fn
new
(
foo
:
Option
<
i32
>
,
_
:
())
->
Foo
{
Foo
{
foo
}
}
pub
fn
map
(
self
)
->
Option
<
Foo
>
{
self
.foo
.map
(
Foo
::
new
)
}
//~^^ ERROR function is expected to take 1 argument, but it takes 2 arguments [E0593]
}
src/test/ui/issue-47706.stderr
0 → 100644
浏览文件 @
e684525c
error[E0601]: main function not found
error[E0593]: function is expected to take 1 argument, but it takes 2 arguments
--> $DIR/issue-47706.rs:21:18
|
16 | pub fn new(foo: Option<i32>, _: ()) -> Foo {
| ------------------------------------------ takes 2 arguments
...
21 | self.foo.map(Foo::new)
| ^^^ expected function that takes 1 argument
error: aborting due to 2 previous errors
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录