Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0d7e6cf9
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,发现更多精彩内容 >>
未验证
提交
0d7e6cf9
编写于
4月 18, 2017
作者:
F
Freyskeyd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refac Move levenchstein before context dependent check
Signed-off-by:
N
Freyskeyd
<
simon.paitrault@gmail.com
>
上级
0777c757
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
65 addition
and
14 deletion
+65
-14
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+11
-7
src/test/ui/resolve/issue-39226.rs
src/test/ui/resolve/issue-39226.rs
+24
-0
src/test/ui/resolve/issue-39226.stderr
src/test/ui/resolve/issue-39226.stderr
+11
-0
src/test/ui/resolve/issue-5035.stderr
src/test/ui/resolve/issue-5035.stderr
+4
-1
src/test/ui/resolve/privacy-struct-ctor.stderr
src/test/ui/resolve/privacy-struct-ctor.stderr
+1
-0
src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr
...st/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr
+6
-4
src/test/ui/resolve/tuple-struct-alias.stderr
src/test/ui/resolve/tuple-struct-alias.stderr
+8
-2
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
0d7e6cf9
...
@@ -2312,6 +2312,14 @@ fn smart_resolve_path_fragment(&mut self,
...
@@ -2312,6 +2312,14 @@ fn smart_resolve_path_fragment(&mut self,
}
}
}
}
let
mut
levenshtein_worked
=
false
;
// Try Levenshtein.
if
let
Some
(
candidate
)
=
this
.lookup_typo_candidate
(
path
,
ns
,
is_expected
)
{
err
.span_label
(
ident_span
,
&
format!
(
"did you mean `{}`?"
,
candidate
));
levenshtein_worked
=
true
;
}
// Try context dependent help if relaxed lookup didn't work.
// Try context dependent help if relaxed lookup didn't work.
if
let
Some
(
def
)
=
def
{
if
let
Some
(
def
)
=
def
{
match
(
def
,
source
)
{
match
(
def
,
source
)
{
...
@@ -2354,14 +2362,10 @@ fn smart_resolve_path_fragment(&mut self,
...
@@ -2354,14 +2362,10 @@ fn smart_resolve_path_fragment(&mut self,
}
}
}
}
// Try Levenshtein if nothing else worked.
if
let
Some
(
candidate
)
=
this
.lookup_typo_candidate
(
path
,
ns
,
is_expected
)
{
err
.span_label
(
ident_span
,
&
format!
(
"did you mean `{}`?"
,
candidate
));
return
err
;
}
// Fallback label.
// Fallback label.
if
!
levenshtein_worked
{
err
.span_label
(
base_span
,
&
fallback_label
);
err
.span_label
(
base_span
,
&
fallback_label
);
}
err
err
};
};
let
report_errors
=
|
this
:
&
mut
Self
,
def
:
Option
<
Def
>
|
{
let
report_errors
=
|
this
:
&
mut
Self
,
def
:
Option
<
Def
>
|
{
...
...
src/test/ui/resolve/issue-39226.rs
0 → 100644
浏览文件 @
0d7e6cf9
// Copyright 2014 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
Handle
{}
struct
Something
{
handle
:
Handle
}
fn
main
()
{
let
handle
:
Handle
=
Handle
{};
let
s
:
Something
=
Something
{
handle
:
Handle
//~^ ERROR cannot find value `Handle` in this scope
//~| NOTE did you mean `handle`?
};
}
src/test/ui/resolve/issue-39226.stderr
0 → 100644
浏览文件 @
0d7e6cf9
error[E0423]: expected value, found struct `Handle`
--> $DIR/issue-39226.rs:20:17
|
20 | handle: Handle
| ^^^^^^
| |
| did you mean `handle`?
| did you mean `Handle { /* fields */ }`?
error: aborting due to previous error
src/test/ui/resolve/issue-5035.stderr
浏览文件 @
0d7e6cf9
...
@@ -8,7 +8,10 @@ error[E0404]: expected trait, found type alias `K`
...
@@ -8,7 +8,10 @@ error[E0404]: expected trait, found type alias `K`
--> $DIR/issue-5035.rs:13:6
--> $DIR/issue-5035.rs:13:6
|
|
13 | impl K for isize {} //~ ERROR expected trait, found type alias `K`
13 | impl K for isize {} //~ ERROR expected trait, found type alias `K`
| ^ type aliases cannot be used for traits
| ^
| |
| type aliases cannot be used for traits
| did you mean `I`?
error: cannot continue compilation due to previous error
error: cannot continue compilation due to previous error
src/test/ui/resolve/privacy-struct-ctor.stderr
浏览文件 @
0d7e6cf9
...
@@ -5,6 +5,7 @@ error[E0423]: expected value, found struct `Z`
...
@@ -5,6 +5,7 @@ error[E0423]: expected value, found struct `Z`
| ^
| ^
| |
| |
| did you mean `Z { /* fields */ }`?
| did you mean `Z { /* fields */ }`?
| did you mean `S`?
| constructor is not visible here due to private fields
| constructor is not visible here due to private fields
|
|
= help: possible better candidate is found in another module, you can import it into scope:
= help: possible better candidate is found in another module, you can import it into scope:
...
...
src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr
浏览文件 @
0d7e6cf9
...
@@ -26,8 +26,9 @@ error[E0423]: expected value, found module `a::b`
...
@@ -26,8 +26,9 @@ error[E0423]: expected value, found module `a::b`
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:45:5
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:45:5
|
|
45 | a::b.J
45 | a::b.J
| ^^^^--
| ^^^---
| |
| | |
| | did you mean `I`?
| did you mean `a::b::J`?
| did you mean `a::b::J`?
error[E0423]: expected value, found module `a`
error[E0423]: expected value, found module `a`
...
@@ -50,8 +51,9 @@ error[E0423]: expected value, found module `a::b`
...
@@ -50,8 +51,9 @@ error[E0423]: expected value, found module `a::b`
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:61:5
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:61:5
|
|
61 | a::b.f()
61 | a::b.f()
| ^^^^----
| ^^^-----
| |
| | |
| | did you mean `I`?
| did you mean `a::b::f(...)`?
| did you mean `a::b::f(...)`?
error[E0423]: expected value, found module `a::b`
error[E0423]: expected value, found module `a::b`
...
...
src/test/ui/resolve/tuple-struct-alias.stderr
浏览文件 @
0d7e6cf9
...
@@ -14,13 +14,19 @@ error[E0423]: expected function, found type alias `A`
...
@@ -14,13 +14,19 @@ error[E0423]: expected function, found type alias `A`
--> $DIR/tuple-struct-alias.rs:24:13
--> $DIR/tuple-struct-alias.rs:24:13
|
|
24 | let s = A(0, 1);
24 | let s = A(0, 1);
| ^ did you mean `A { /* fields */ }`?
| ^
| |
| did you mean `S`?
| did you mean `A { /* fields */ }`?
error[E0532]: expected tuple struct/variant, found type alias `A`
error[E0532]: expected tuple struct/variant, found type alias `A`
--> $DIR/tuple-struct-alias.rs:26:9
--> $DIR/tuple-struct-alias.rs:26:9
|
|
26 | A(..) => {}
26 | A(..) => {}
| ^ did you mean `A { /* fields */ }`?
| ^
| |
| did you mean `S`?
| did you mean `A { /* fields */ }`?
error: aborting due to 4 previous errors
error: aborting due to 4 previous errors
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录