Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5dabc3b3
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,发现更多精彩内容 >>
未验证
提交
5dabc3b3
编写于
1月 04, 2020
作者:
D
Dylan DPC
提交者:
GitHub
1月 04, 2020
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #67775 - mental32:master, r=Dylan-DPC
Make "use $crate" a hard error Closes #37390
上级
3c87772a
c818f4c8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
25 deletion
+15
-25
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/build_reduced_graph.rs
+1
-5
src/test/ui/dollar-crate/dollar-crate-is-keyword.rs
src/test/ui/dollar-crate/dollar-crate-is-keyword.rs
+2
-3
src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr
src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr
+6
-10
src/test/ui/imports/import-crate-var.rs
src/test/ui/imports/import-crate-var.rs
+1
-3
src/test/ui/imports/import-crate-var.stderr
src/test/ui/imports/import-crate-var.stderr
+5
-4
未找到文件。
src/librustc_resolve/build_reduced_graph.rs
浏览文件 @
5dabc3b3
...
...
@@ -472,11 +472,7 @@ fn build_reduced_graph_for_use_tree(
self
.r
.session
.struct_span_warn
(
item
.span
,
"`$crate` may not be imported"
)
.note
(
"`use $crate;` was erroneously allowed and
\
will become a hard error in a future release"
,
)
.struct_span_err
(
item
.span
,
"`$crate` may not be imported"
)
.emit
();
}
}
...
...
src/test/ui/dollar-crate/dollar-crate-is-keyword.rs
浏览文件 @
5dabc3b3
...
...
@@ -6,10 +6,9 @@ mod foo {
struct
$crate
{}
//~ ERROR expected identifier, found reserved identifier `$crate`
}
use
$crate
;
// OK
//~^ WARN `$crate` may not be imported
use
$crate
;
//~ ERROR `$crate` may not be imported
use
$crate
as
$crate
;
//~ ERROR expected identifier, found reserved identifier `$crate`
//~^ WARN
`$crate` may not be imported
//~^ ERROR
`$crate` may not be imported
}
}
...
...
src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr
浏览文件 @
5dabc3b3
...
...
@@ -8,7 +8,7 @@ LL | m!();
| ----- in this macro invocation
error: expected identifier, found reserved identifier `$crate`
--> $DIR/dollar-crate-is-keyword.rs:1
1
:23
--> $DIR/dollar-crate-is-keyword.rs:1
0
:23
|
LL | use $crate as $crate;
| ^^^^^^ expected identifier, found reserved identifier
...
...
@@ -16,27 +16,23 @@ LL | use $crate as $crate;
LL | m!();
| ----- in this macro invocation
warning
: `$crate` may not be imported
error
: `$crate` may not be imported
--> $DIR/dollar-crate-is-keyword.rs:9:9
|
LL | use $crate;
// OK
LL | use $crate;
| ^^^^^^^^^^^
...
LL | m!();
| ----- in this macro invocation
|
= note: `use $crate;` was erroneously allowed and will become a hard error in a future release
warning
: `$crate` may not be imported
--> $DIR/dollar-crate-is-keyword.rs:1
1
:9
error
: `$crate` may not be imported
--> $DIR/dollar-crate-is-keyword.rs:1
0
:9
|
LL | use $crate as $crate;
| ^^^^^^^^^^^^^^^^^^^^^
...
LL | m!();
| ----- in this macro invocation
|
= note: `use $crate;` was erroneously allowed and will become a hard error in a future release
error: aborting due to
2
previous errors
error: aborting due to
4
previous errors
src/test/ui/imports/import-crate-var.rs
浏览文件 @
5dabc3b3
// check-pass
// aux-build:import_crate_var.rs
#[macro_use]
extern
crate
import_crate_var
;
fn
main
()
{
m!
();
//~^ WARN `$crate` may not be imported
//~| NOTE `use $crate;` was erroneously allowed and will become a hard error
//~^ ERROR `$crate` may not be imported
}
src/test/ui/imports/import-crate-var.stderr
浏览文件 @
5dabc3b3
warning
: `$crate` may not be imported
--> $DIR/import-crate-var.rs:
7
:5
error
: `$crate` may not be imported
--> $DIR/import-crate-var.rs:
6
:5
|
LL | m!();
| ^^^^^
|
= note: `use $crate;` was erroneously allowed and will become a hard error in a future release
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录