Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0a33de04
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,发现更多精彩内容 >>
提交
0a33de04
编写于
9月 06, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc_resolve: inject `uniform_paths` canaries regardless of the feature-gate, on Rust 2018.
上级
fb945f0e
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
237 addition
and
7 deletion
+237
-7
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/build_reduced_graph.rs
+1
-1
src/librustc_resolve/resolve_imports.rs
src/librustc_resolve/resolve_imports.rs
+19
-5
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.rs
...8/uniform-paths-forward-compat/ambiguity-macros-nested.rs
+29
-0
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.stderr
...iform-paths-forward-compat/ambiguity-macros-nested.stderr
+16
-0
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.rs
...ust-2018/uniform-paths-forward-compat/ambiguity-macros.rs
+27
-0
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.stderr
...2018/uniform-paths-forward-compat/ambiguity-macros.stderr
+16
-0
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.rs
...ust-2018/uniform-paths-forward-compat/ambiguity-nested.rs
+24
-0
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.stderr
...2018/uniform-paths-forward-compat/ambiguity-nested.stderr
+16
-0
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.rs
...st/ui/rust-2018/uniform-paths-forward-compat/ambiguity.rs
+20
-0
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.stderr
...i/rust-2018/uniform-paths-forward-compat/ambiguity.stderr
+16
-0
src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.rs
...-2018/uniform-paths-forward-compat/block-scoped-shadow.rs
+21
-0
src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.stderr
...8/uniform-paths-forward-compat/block-scoped-shadow.stderr
+31
-0
src/tools/rls
src/tools/rls
+1
-1
未找到文件。
src/librustc_resolve/build_reduced_graph.rs
浏览文件 @
0a33de04
...
...
@@ -194,7 +194,7 @@ fn build_reduced_graph_for_use_tree(
// ergonomically unacceptable.
let
emit_uniform_paths_canary
=
!
uniform_paths_canary_emitted
&&
uniform_paths
&&
self
.session
.rust_2018
()
&&
starts_with_non_keyword
;
if
emit_uniform_paths_canary
{
let
source
=
prefix_start
.unwrap
();
...
...
src/librustc_resolve/resolve_imports.rs
浏览文件 @
0a33de04
...
...
@@ -705,6 +705,7 @@ struct UniformPathsCanaryResult {
}
}
let
uniform_paths_feature
=
self
.session
.features_untracked
()
.uniform_paths
;
for
((
span
,
_
),
(
name
,
results
))
in
uniform_paths_canaries
{
self
.per_ns
(|
this
,
ns
|
{
let
results
=
&
results
[
ns
];
...
...
@@ -736,15 +737,24 @@ struct UniformPathsCanaryResult {
suggestion_choices
.push_str
(
" or "
);
}
write!
(
suggestion_choices
,
"`self::{}`"
,
name
);
err
.span_label
(
span
,
format!
(
"can refer to `self::{}`"
,
name
));
if
uniform_paths_feature
{
err
.span_label
(
span
,
format!
(
"can refer to `self::{}`"
,
name
));
}
else
{
err
.span_label
(
span
,
format!
(
"may refer to `self::{}` in the future"
,
name
));
}
}
for
&
span
in
&
results
.block_scopes
{
err
.span_label
(
span
,
format!
(
"shadowed by block-scoped `{}`"
,
name
));
}
err
.help
(
&
format!
(
"write {} explicitly instead"
,
suggestion_choices
));
err
.note
(
"relative `use` paths enabled by `#![feature(uniform_paths)]`"
);
if
uniform_paths_feature
{
err
.note
(
"relative `use` paths enabled by `#![feature(uniform_paths)]`"
);
}
else
{
err
.note
(
"in the future, `#![feature(uniform_paths)]` may become the default"
);
}
err
.emit
();
});
}
...
...
@@ -930,11 +940,15 @@ fn finalize_import(&mut self, directive: &'b ImportDirective<'b>) -> Option<(Spa
_
=>
unreachable!
(),
};
// Do not record uses from canaries, to avoid interfering with other
// diagnostics or suggestions that rely on some items not being used.
let
record_used
=
!
directive
.is_uniform_paths_canary
;
let
mut
all_ns_err
=
true
;
self
.per_ns
(|
this
,
ns
|
if
!
type_ns_only
||
ns
==
TypeNS
{
if
let
Ok
(
binding
)
=
result
[
ns
]
.get
()
{
all_ns_err
=
false
;
if
this
.record_use
(
ident
,
ns
,
binding
)
{
if
record_used
&&
this
.record_use
(
ident
,
ns
,
binding
)
{
if
let
ModuleOrUniformRoot
::
Module
(
module
)
=
module
{
this
.resolution
(
module
,
ident
,
ns
)
.borrow_mut
()
.binding
=
Some
(
this
.dummy_binding
);
...
...
@@ -946,7 +960,7 @@ fn finalize_import(&mut self, directive: &'b ImportDirective<'b>) -> Option<(Spa
if
all_ns_err
{
let
mut
all_ns_failed
=
true
;
self
.per_ns
(|
this
,
ns
|
if
!
type_ns_only
||
ns
==
TypeNS
{
match
this
.resolve_ident_in_module
(
module
,
ident
,
ns
,
true
,
span
)
{
match
this
.resolve_ident_in_module
(
module
,
ident
,
ns
,
record_used
,
span
)
{
Ok
(
_
)
=>
all_ns_failed
=
false
,
_
=>
{}
}
...
...
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.rs
0 → 100644
浏览文件 @
0a33de04
// 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.
// edition:2018
// This test is similar to `ambiguity-macros.rs`, but nested in a module.
mod
foo
{
pub
use
std
::
io
;
//~^ ERROR `std` import is ambiguous
macro_rules!
m
{
()
=>
{
mod
std
{
pub
struct
io
;
}
}
}
m!
();
}
fn
main
()
{}
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.stderr
0 → 100644
浏览文件 @
0a33de04
error: `std` import is ambiguous
--> $DIR/ambiguity-macros-nested.rs:16:13
|
LL | pub use std::io;
| ^^^ can refer to external crate `::std`
...
LL | / mod std {
LL | | pub struct io;
LL | | }
| |_____________- may refer to `self::std` in the future
|
= help: write `::std` or `self::std` explicitly instead
= note: in the future, `#![feature(uniform_paths)]` may become the default
error: aborting due to previous error
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.rs
0 → 100644
浏览文件 @
0a33de04
// 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.
// edition:2018
// This test is similar to `ambiguity.rs`, but with macros defining local items.
use
std
::
io
;
//~^ ERROR `std` import is ambiguous
macro_rules!
m
{
()
=>
{
mod
std
{
pub
struct
io
;
}
}
}
m!
();
fn
main
()
{}
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.stderr
0 → 100644
浏览文件 @
0a33de04
error: `std` import is ambiguous
--> $DIR/ambiguity-macros.rs:15:5
|
LL | use std::io;
| ^^^ can refer to external crate `::std`
...
LL | / mod std {
LL | | pub struct io;
LL | | }
| |_________- may refer to `self::std` in the future
|
= help: write `::std` or `self::std` explicitly instead
= note: in the future, `#![feature(uniform_paths)]` may become the default
error: aborting due to previous error
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.rs
0 → 100644
浏览文件 @
0a33de04
// 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.
// edition:2018
// This test is similar to `ambiguity.rs`, but nested in a module.
mod
foo
{
pub
use
std
::
io
;
//~^ ERROR `std` import is ambiguous
mod
std
{
pub
struct
io
;
}
}
fn
main
()
{}
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.stderr
0 → 100644
浏览文件 @
0a33de04
error: `std` import is ambiguous
--> $DIR/ambiguity-nested.rs:16:13
|
LL | pub use std::io;
| ^^^ can refer to external crate `::std`
...
LL | / mod std {
LL | | pub struct io;
LL | | }
| |_____- may refer to `self::std` in the future
|
= help: write `::std` or `self::std` explicitly instead
= note: in the future, `#![feature(uniform_paths)]` may become the default
error: aborting due to previous error
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.rs
0 → 100644
浏览文件 @
0a33de04
// 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.
// edition:2018
use
std
::
io
;
//~^ ERROR `std` import is ambiguous
mod
std
{
pub
struct
io
;
}
fn
main
()
{}
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.stderr
0 → 100644
浏览文件 @
0a33de04
error: `std` import is ambiguous
--> $DIR/ambiguity.rs:13:5
|
LL | use std::io;
| ^^^ can refer to external crate `::std`
...
LL | / mod std {
LL | | pub struct io;
LL | | }
| |_- may refer to `self::std` in the future
|
= help: write `::std` or `self::std` explicitly instead
= note: in the future, `#![feature(uniform_paths)]` may become the default
error: aborting due to previous error
src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.rs
0 → 100644
浏览文件 @
0a33de04
// 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.
// edition:2018
struct
std
;
fn
main
()
{
fn
std
()
{}
enum
std
{}
use
std
as
foo
;
//~^ ERROR `std` import is ambiguous
//~| ERROR `std` import is ambiguous
}
src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.stderr
0 → 100644
浏览文件 @
0a33de04
error: `std` import is ambiguous
--> $DIR/block-scoped-shadow.rs:18:9
|
LL | struct std;
| ----------- may refer to `self::std` in the future
...
LL | enum std {}
| ----------- shadowed by block-scoped `std`
LL | use std as foo;
| ^^^ can refer to external crate `::std`
|
= help: write `::std` or `self::std` explicitly instead
= note: in the future, `#![feature(uniform_paths)]` may become the default
error: `std` import is ambiguous
--> $DIR/block-scoped-shadow.rs:18:9
|
LL | struct std;
| ----------- may refer to `self::std` in the future
...
LL | fn std() {}
| ----------- shadowed by block-scoped `std`
LL | enum std {}
LL | use std as foo;
| ^^^
|
= help: write `self::std` explicitly instead
= note: in the future, `#![feature(uniform_paths)]` may become the default
error: aborting due to 2 previous errors
rls
@
fa922de1
比较
5b5cd9d4
...
fa922de1
Subproject commit
5b5cd9d45719414196e254ec17baa598acc8cd2
5
Subproject commit
fa922de1e5e1f02b576b7a5aa6ded16935693ec
5
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录