Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
73f6f5e0
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,发现更多精彩内容 >>
提交
73f6f5e0
编写于
4月 03, 2017
作者:
E
Esteban Küber
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Sort enum suggestions
上级
b946ecd0
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
10 addition
and
8 deletion
+10
-8
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+8
-6
src/test/ui/did_you_mean/issue-35675.stderr
src/test/ui/did_you_mean/issue-35675.stderr
+2
-2
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
73f6f5e0
...
...
@@ -2273,15 +2273,17 @@ fn smart_resolve_path_fragment(&mut self,
show_candidates
(
&
mut
err
,
&
candidates
,
def
.is_some
());
}
else
if
is_expected
(
Def
::
Enum
(
DefId
::
local
(
CRATE_DEF_INDEX
)))
{
let
enum_candidates
=
this
.lookup_import_candidates
(
name
,
ns
,
is_enum_variant
);
for
suggestion
in
enum_candidates
{
let
(
variant_path
,
enum_path
)
=
import_candidate_to_paths
(
&
suggestion
);
let
mut
enum_candidates
=
enum_candidates
.iter
()
.map
(|
suggestion
|
import_candidate_to_paths
(
&
suggestion
))
.collect
::
<
Vec
<
_
>>
();
enum_candidates
.sort
();
for
(
sp
,
variant_path
,
enum_path
)
in
enum_candidates
{
let
msg
=
format!
(
"there is an enum variant `{}`, did you mean to use `{}`?"
,
variant_path
,
enum_path
);
if
s
uggestion
.path.span
==
DUMMY_SP
{
if
s
p
==
DUMMY_SP
{
err
.help
(
&
msg
);
}
else
{
err
.span_help
(
s
uggestion
.path.span
,
&
msg
);
err
.span_help
(
s
p
,
&
msg
);
}
}
}
...
...
@@ -3437,7 +3439,7 @@ fn path_names_to_string(path: &Path) -> String {
}
/// Get the path for an enum and the variant from an `ImportSuggestion` for an enum variant.
fn
import_candidate_to_paths
(
suggestion
:
&
ImportSuggestion
)
->
(
String
,
String
)
{
fn
import_candidate_to_paths
(
suggestion
:
&
ImportSuggestion
)
->
(
S
pan
,
S
tring
,
String
)
{
let
variant_path
=
&
suggestion
.path
;
let
variant_path_string
=
path_names_to_string
(
variant_path
);
...
...
@@ -3448,7 +3450,7 @@ fn import_candidate_to_paths(suggestion: &ImportSuggestion) -> (String, String)
};
let
enum_path_string
=
path_names_to_string
(
&
enum_path
);
(
variant_path_string
,
enum_path_string
)
(
suggestion
.path.span
,
variant_path_string
,
enum_path_string
)
}
...
...
src/test/ui/did_you_mean/issue-35675.stderr
浏览文件 @
73f6f5e0
...
...
@@ -46,8 +46,8 @@ error[E0573]: expected type, found variant `Ok`
24 | fn foo() -> Ok {
| ^^ not a type
|
= help: there is an enum variant `std::result::Result::Ok`, did you mean to use `std::result::Result`?
= help: there is an enum variant `std::prelude::v1::Ok`, did you mean to use `std::prelude::v1`?
= help: there is an enum variant `std::prelude::v1::Result::Ok`, did you mean to use `std::prelude::v1::Result`?
error[E0412]: cannot find type `Variant3` in this scope
--> $DIR/issue-35675.rs:28:13
...
...
@@ -67,8 +67,8 @@ error[E0573]: expected type, found variant `Some`
31 | fn qux() -> Some {
| ^^^^ not a type
|
= help: there is an enum variant `std::prelude::v1::Some`, did you mean to use `std::prelude::v1`?
= help: there is an enum variant `std::prelude::v1::Option::Some`, did you mean to use `std::prelude::v1::Option`?
= help: there is an enum variant `std::prelude::v1::Some`, did you mean to use `std::prelude::v1`?
error: aborting due to 7 previous errors
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录