Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
73867365
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,发现更多精彩内容 >>
提交
73867365
编写于
5月 04, 2020
作者:
M
mibac138
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Suggest to add missing feature when using gated const features
上级
d626e4da
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
70 addition
and
0 deletion
+70
-0
src/librustc_mir/transform/check_consts/ops.rs
src/librustc_mir/transform/check_consts/ops.rs
+3
-0
src/test/ui/check-static-values-constraints.stderr
src/test/ui/check-static-values-constraints.stderr
+14
-0
src/test/ui/const-suggest-feature.rs
src/test/ui/const-suggest-feature.rs
+9
-0
src/test/ui/const-suggest-feature.stderr
src/test/ui/const-suggest-feature.stderr
+21
-0
src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr
.../const-eval/assign-to-static-within-other-static-2.stderr
+2
-0
src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr
...test/ui/consts/const-eval/mod-static-with-const-fn.stderr
+2
-0
src/test/ui/consts/const_let_assign3.stderr
src/test/ui/consts/const_let_assign3.stderr
+4
-0
src/test/ui/consts/projection_qualif.stock.stderr
src/test/ui/consts/projection_qualif.stock.stderr
+2
-0
src/test/ui/consts/static_mut_containing_mut_ref2.stock.stderr
...est/ui/consts/static_mut_containing_mut_ref2.stock.stderr
+2
-0
src/test/ui/error-codes/E0010-teach.stderr
src/test/ui/error-codes/E0010-teach.stderr
+1
-0
src/test/ui/error-codes/E0010.stderr
src/test/ui/error-codes/E0010.stderr
+2
-0
src/test/ui/error-codes/E0017.stderr
src/test/ui/error-codes/E0017.stderr
+2
-0
src/test/ui/error-codes/E0388.stderr
src/test/ui/error-codes/E0388.stderr
+2
-0
src/test/ui/issues/issue-7364.stderr
src/test/ui/issues/issue-7364.stderr
+2
-0
src/test/ui/static/static-mut-not-constant.stderr
src/test/ui/static/static-mut-not-constant.stderr
+2
-0
未找到文件。
src/librustc_mir/transform/check_consts/ops.rs
浏览文件 @
73867365
...
...
@@ -39,6 +39,9 @@ fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
"{} contains unimplemented expression type"
,
ccx
.const_kind
()
);
if
let
Some
(
feat
)
=
Self
::
feature_gate
()
{
err
.help
(
&
format!
(
"add `#![feature({})]` to the crate attributes to enable"
,
feat
));
}
if
ccx
.tcx.sess
.teach
(
&
err
.get_code
()
.unwrap
())
{
err
.note
(
"A function call isn't allowed in the const's initialization expression
\
...
...
src/test/ui/check-static-values-constraints.stderr
浏览文件 @
73867365
...
...
@@ -18,6 +18,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | static STATIC11: Box<MyOwned> = box MyOwned;
| ^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
--> $DIR/check-static-values-constraints.rs:90:32
...
...
@@ -36,6 +38,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | box MyOwned,
| ^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:97:5
...
...
@@ -48,6 +52,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | box MyOwned,
| ^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:102:6
...
...
@@ -60,6 +66,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | &box MyOwned,
| ^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:104:6
...
...
@@ -72,6 +80,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | &box MyOwned,
| ^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:111:5
...
...
@@ -84,6 +94,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | box 3;
| ^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0507]: cannot move out of static item `x`
--> $DIR/check-static-values-constraints.rs:116:45
...
...
@@ -105,6 +117,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | let y = { static x: Box<isize> = box 3; x };
| ^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 17 previous errors
...
...
src/test/ui/const-suggest-feature.rs
0 → 100644
浏览文件 @
73867365
const
WRITE
:
()
=
unsafe
{
*
std
::
ptr
::
null_mut
()
=
0
;
//~^ ERROR dereferencing raw pointers in constants is unstable
//~| HELP add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
//~| ERROR constant contains unimplemented expression type
//~| HELP add `#![feature(const_mut_refs)]` to the crate attributes to enable
};
fn
main
()
{}
src/test/ui/const-suggest-feature.stderr
0 → 100644
浏览文件 @
73867365
error[E0658]: dereferencing raw pointers in constants is unstable
--> $DIR/const-suggest-feature.rs:2:5
|
LL | *std::ptr::null_mut() = 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information
= help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
error[E0019]: constant contains unimplemented expression type
--> $DIR/const-suggest-feature.rs:2:5
|
LL | *std::ptr::null_mut() = 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0019, E0658.
For more information about an error, try `rustc --explain E0019`.
src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr
浏览文件 @
73867365
...
...
@@ -3,6 +3,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | *FOO.0.get() = 5;
| ^^^^^^^^^^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to previous error
...
...
src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr
浏览文件 @
73867365
...
...
@@ -3,6 +3,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | *FOO.0.get() = 5;
| ^^^^^^^^^^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
--> $DIR/mod-static-with-const-fn.rs:21:5
...
...
src/test/ui/consts/const_let_assign3.stderr
浏览文件 @
73867365
...
...
@@ -3,6 +3,8 @@ error[E0019]: constant function contains unimplemented expression type
|
LL | self.state = x;
| ^^^^^^^^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0658]: references in constants may only refer to immutable values
--> $DIR/const_let_assign3.rs:16:5
...
...
@@ -27,6 +29,8 @@ error[E0019]: constant contains unimplemented expression type
|
LL | *y = 42;
| ^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 4 previous errors
...
...
src/test/ui/consts/projection_qualif.stock.stderr
浏览文件 @
73867365
...
...
@@ -21,6 +21,8 @@ error[E0019]: constant contains unimplemented expression type
|
LL | unsafe { *b = 5; }
| ^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 3 previous errors
...
...
src/test/ui/consts/static_mut_containing_mut_ref2.stock.stderr
浏览文件 @
73867365
...
...
@@ -12,6 +12,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 2 previous errors
...
...
src/test/ui/error-codes/E0010-teach.stderr
浏览文件 @
73867365
...
...
@@ -12,6 +12,7 @@ error[E0019]: constant contains unimplemented expression type
LL | const CON : Box<i32> = box 0;
| ^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
= note: A function call isn't allowed in the const's initialization expression because the expression's value must be known at compile-time.
= note: Remember: you can't use a function call inside a const's initialization expression! However, you can use it anywhere else.
...
...
src/test/ui/error-codes/E0010.stderr
浏览文件 @
73867365
...
...
@@ -9,6 +9,8 @@ error[E0019]: constant contains unimplemented expression type
|
LL | const CON : Box<i32> = box 0;
| ^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 2 previous errors
...
...
src/test/ui/error-codes/E0017.stderr
浏览文件 @
73867365
...
...
@@ -12,6 +12,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | static STATIC_REF: &'static mut i32 = &mut X;
| ^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0658]: references in statics may only refer to immutable values
--> $DIR/E0017.rs:6:39
...
...
src/test/ui/error-codes/E0388.stderr
浏览文件 @
73867365
...
...
@@ -12,6 +12,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | static STATIC_REF: &'static mut i32 = &mut X;
| ^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0658]: references in statics may only refer to immutable values
--> $DIR/E0388.rs:5:39
...
...
src/test/ui/issues/issue-7364.stderr
浏览文件 @
73867365
...
...
@@ -9,6 +9,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | static boxed: Box<RefCell<isize>> = box RefCell::new(0);
| ^^^^^^^^^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0277]: `std::cell::RefCell<isize>` cannot be shared between threads safely
--> $DIR/issue-7364.rs:6:1
...
...
src/test/ui/static/static-mut-not-constant.stderr
浏览文件 @
73867365
...
...
@@ -9,6 +9,8 @@ error[E0019]: static contains unimplemented expression type
|
LL | static mut a: Box<isize> = box 3;
| ^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 2 previous errors
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录