Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2249d653
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,发现更多精彩内容 >>
提交
2249d653
编写于
5月 23, 2018
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"crate-ify" paths that begin with a renamed crate
上级
27649b70
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
277 addition
and
1 deletion
+277
-1
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+3
-1
src/test/ui/rust-2018/extern-crate-idiomatic.fixed
src/test/ui/rust-2018/extern-crate-idiomatic.fixed
+28
-0
src/test/ui/rust-2018/extern-crate-idiomatic.rs
src/test/ui/rust-2018/extern-crate-idiomatic.rs
+28
-0
src/test/ui/rust-2018/extern-crate-referenced-by-self-path.fixed
...t/ui/rust-2018/extern-crate-referenced-by-self-path.fixed
+28
-0
src/test/ui/rust-2018/extern-crate-referenced-by-self-path.rs
...test/ui/rust-2018/extern-crate-referenced-by-self-path.rs
+28
-0
src/test/ui/rust-2018/extern-crate-rename.fixed
src/test/ui/rust-2018/extern-crate-rename.fixed
+29
-0
src/test/ui/rust-2018/extern-crate-rename.rs
src/test/ui/rust-2018/extern-crate-rename.rs
+29
-0
src/test/ui/rust-2018/extern-crate-rename.stderr
src/test/ui/rust-2018/extern-crate-rename.stderr
+16
-0
src/test/ui/rust-2018/extern-crate-submod.fixed
src/test/ui/rust-2018/extern-crate-submod.fixed
+36
-0
src/test/ui/rust-2018/extern-crate-submod.rs
src/test/ui/rust-2018/extern-crate-submod.rs
+36
-0
src/test/ui/rust-2018/extern-crate-submod.stderr
src/test/ui/rust-2018/extern-crate-submod.stderr
+16
-0
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
2249d653
...
...
@@ -3533,7 +3533,9 @@ fn lint_if_path_starts_with_module(
// warning, this looks all good!
if
let
Some
(
binding
)
=
second_binding
{
if
let
NameBindingKind
::
Import
{
directive
:
d
,
..
}
=
binding
.kind
{
if
let
ImportDirectiveSubclass
::
ExternCrate
(
..
)
=
d
.subclass
{
// Careful: we still want to rewrite paths from
// renamed extern crates.
if
let
ImportDirectiveSubclass
::
ExternCrate
(
None
)
=
d
.subclass
{
return
}
}
...
...
src/test/ui/rust-2018/extern-crate-idiomatic.fixed
0 → 100644
浏览文件 @
2249d653
// 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.
// run-pass
// aux-build:edition-lint-paths.rs
// run-rustfix
// The "normal case". Ideally we would remove the `extern crate` here,
// but we don't.
#![feature(rust_2018_preview)]
#![deny(absolute_path_not_starting_with_crate)]
extern crate edition_lint_paths;
use edition_lint_paths::foo;
fn main() {
foo();
}
src/test/ui/rust-2018/extern-crate-idiomatic.rs
0 → 100644
浏览文件 @
2249d653
// 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.
// run-pass
// aux-build:edition-lint-paths.rs
// run-rustfix
// The "normal case". Ideally we would remove the `extern crate` here,
// but we don't.
#![feature(rust_2018_preview)]
#![deny(absolute_path_not_starting_with_crate)]
extern
crate
edition_lint_paths
;
use
edition_lint_paths
::
foo
;
fn
main
()
{
foo
();
}
src/test/ui/rust-2018/extern-crate-referenced-by-self-path.fixed
0 → 100644
浏览文件 @
2249d653
// 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.
// run-pass
// aux-build:edition-lint-paths.rs
// run-rustfix
// Oddball: `edition_lint_paths` is accessed via this `self` path
// rather than being accessed directly. Unless we rewrite that path,
// we can't drop the extern crate.
#![feature(rust_2018_preview)]
#![deny(absolute_path_not_starting_with_crate)]
extern crate edition_lint_paths;
use self::edition_lint_paths::foo;
fn main() {
foo();
}
src/test/ui/rust-2018/extern-crate-referenced-by-self-path.rs
0 → 100644
浏览文件 @
2249d653
// 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.
// run-pass
// aux-build:edition-lint-paths.rs
// run-rustfix
// Oddball: `edition_lint_paths` is accessed via this `self` path
// rather than being accessed directly. Unless we rewrite that path,
// we can't drop the extern crate.
#![feature(rust_2018_preview)]
#![deny(absolute_path_not_starting_with_crate)]
extern
crate
edition_lint_paths
;
use
self
::
edition_lint_paths
::
foo
;
fn
main
()
{
foo
();
}
src/test/ui/rust-2018/extern-crate-rename.fixed
0 → 100644
浏览文件 @
2249d653
// 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.
// aux-build:edition-lint-paths.rs
// run-rustfix
// Oddball: crate is renamed, making it harder for us to rewrite
// paths. We don't (and we leave the `extern crate` in place).
#![feature(rust_2018_preview)]
#![deny(absolute_path_not_starting_with_crate)]
extern crate edition_lint_paths as my_crate;
use crate::my_crate::foo;
//~^ ERROR absolute paths must start
//~| WARNING this was previously accepted
fn main() {
foo();
}
src/test/ui/rust-2018/extern-crate-rename.rs
0 → 100644
浏览文件 @
2249d653
// 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.
// aux-build:edition-lint-paths.rs
// run-rustfix
// Oddball: crate is renamed, making it harder for us to rewrite
// paths. We don't (and we leave the `extern crate` in place).
#![feature(rust_2018_preview)]
#![deny(absolute_path_not_starting_with_crate)]
extern
crate
edition_lint_paths
as
my_crate
;
use
my_crate
::
foo
;
//~^ ERROR absolute paths must start
//~| WARNING this was previously accepted
fn
main
()
{
foo
();
}
src/test/ui/rust-2018/extern-crate-rename.stderr
0 → 100644
浏览文件 @
2249d653
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/extern-crate-rename.rs:22:5
|
LL | use my_crate::foo;
| ^^^^^^^^^^^^^ help: use `crate`: `crate::my_crate::foo`
|
note: lint level defined here
--> $DIR/extern-crate-rename.rs:18:9
|
LL | #![deny(absolute_path_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue TBD
error: aborting due to previous error
src/test/ui/rust-2018/extern-crate-submod.fixed
0 → 100644
浏览文件 @
2249d653
// 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.
// aux-build:edition-lint-paths.rs
// run-rustfix
// Oddball: extern crate appears in a submodule, making it harder for
// us to rewrite paths. We don't (and we leave the `extern crate` in
// place).
#![feature(rust_2018_preview)]
#![deny(absolute_path_not_starting_with_crate)]
mod m {
// Because this extern crate does not appear at the root, we
// ignore it altogether.
pub extern crate edition_lint_paths;
}
// And we don't being smart about paths like this, even though you
// *could* rewrite it to `use edition_lint_paths::foo`
use crate::m::edition_lint_paths::foo;
//~^ ERROR absolute paths must start
//~| WARNING this was previously accepted
fn main() {
foo();
}
src/test/ui/rust-2018/extern-crate-submod.rs
0 → 100644
浏览文件 @
2249d653
// 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.
// aux-build:edition-lint-paths.rs
// run-rustfix
// Oddball: extern crate appears in a submodule, making it harder for
// us to rewrite paths. We don't (and we leave the `extern crate` in
// place).
#![feature(rust_2018_preview)]
#![deny(absolute_path_not_starting_with_crate)]
mod
m
{
// Because this extern crate does not appear at the root, we
// ignore it altogether.
pub
extern
crate
edition_lint_paths
;
}
// And we don't being smart about paths like this, even though you
// *could* rewrite it to `use edition_lint_paths::foo`
use
m
::
edition_lint_paths
::
foo
;
//~^ ERROR absolute paths must start
//~| WARNING this was previously accepted
fn
main
()
{
foo
();
}
src/test/ui/rust-2018/extern-crate-submod.stderr
0 → 100644
浏览文件 @
2249d653
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/extern-crate-submod.rs:29:5
|
LL | use m::edition_lint_paths::foo;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::m::edition_lint_paths::foo`
|
note: lint level defined here
--> $DIR/extern-crate-submod.rs:19:9
|
LL | #![deny(absolute_path_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue TBD
error: aborting due to previous error
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录