Skip to content

Commit aecab5e

Browse files
authored
Rollup merge of rust-lang#72045 - RalfJung:incomplete-unsound, r=petrochenkov
Incomplete features can also be unsound Some incomplete features do not just ICE, they are also currently unsound (e.g. rust-lang#72029, and also `specialization` -- which is not yet marked incomplete but [should be](rust-lang#71420)). This makes the message reflect that. While at it I also added a link to the tracking issue, which hopefully should explain what is incomplete/unsound about the feature.
2 parents 6163394 + 6a8cf4a commit aecab5e

File tree

176 files changed

+284
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+284
-182
lines changed

src/librustc_lint/builtin.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ use rustc_ast::visit::{FnCtxt, FnKind};
2828
use rustc_ast_pretty::pprust::{self, expr_to_string};
2929
use rustc_data_structures::fx::FxHashSet;
3030
use rustc_errors::{Applicability, DiagnosticBuilder};
31-
use rustc_feature::Stability;
3231
use rustc_feature::{deprecated_attributes, AttributeGate, AttributeTemplate, AttributeType};
32+
use rustc_feature::{GateIssue, Stability};
3333
use rustc_hir as hir;
3434
use rustc_hir::def::{DefKind, Res};
3535
use rustc_hir::def_id::DefId;
@@ -1817,13 +1817,21 @@ impl EarlyLintPass for IncompleteFeatures {
18171817
.map(|(name, span, _)| (name, span))
18181818
.chain(features.declared_lib_features.iter().map(|(name, span)| (name, span)))
18191819
.filter(|(name, _)| rustc_feature::INCOMPLETE_FEATURES.iter().any(|f| name == &f))
1820-
.for_each(|(name, &span)| {
1820+
.for_each(|(&name, &span)| {
18211821
cx.struct_span_lint(INCOMPLETE_FEATURES, span, |lint| {
1822-
lint.build(&format!(
1823-
"the feature `{}` is incomplete and may cause the compiler to crash",
1822+
let mut builder = lint.build(&format!(
1823+
"the feature `{}` is incomplete and may not be safe to use \
1824+
and/or cause compiler crashes",
18241825
name,
1825-
))
1826-
.emit()
1826+
));
1827+
if let Some(n) = rustc_feature::find_feature_issue(name, GateIssue::Language) {
1828+
builder.note(&format!(
1829+
"see issue #{} <https://github.com/rust-lang/rust/issues/{}> \
1830+
for more information",
1831+
n, n,
1832+
));
1833+
}
1834+
builder.emit();
18271835
})
18281836
});
18291837
}

src/test/incremental/const-generics/issue-62536.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// revisions:cfail1
22
#![feature(const_generics)]
3-
//[cfail1]~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
3+
//[cfail1]~^ WARN the feature `const_generics` is incomplete
44

55
struct S<T, const N: usize>([T; N]);
66

src/test/incremental/const-generics/issue-64087.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// revisions:cfail1
22
#![feature(const_generics)]
3-
//[cfail1]~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
3+
//[cfail1]~^ WARN the feature `const_generics` is incomplete
44

55
fn combinator<T, const S: usize>() -> [T; S] {}
66
//[cfail1]~^ ERROR mismatched types

src/test/ui/array-slice-vec/match_arr_unknown_len.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
2+
//~^ WARN the feature `const_generics` is incomplete
33

44
fn is_123<const N: usize>(x: [u32; N]) -> bool {
55
match x {

src/test/ui/array-slice-vec/match_arr_unknown_len.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/match_arr_unknown_len.rs:1:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
error[E0308]: mismatched types
1011
--> $DIR/match_arr_unknown_len.rs:6:9

src/test/ui/associated-type-bounds/duplicate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#![feature(associated_type_bounds)]
44
#![feature(type_alias_impl_trait)]
5-
#![feature(impl_trait_in_bindings)] //~ WARN the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash [incomplete_features]
5+
#![feature(impl_trait_in_bindings)] //~ WARN the feature `impl_trait_in_bindings` is incomplete
66
#![feature(untagged_unions)]
77

88
use std::iter;

src/test/ui/associated-type-bounds/duplicate.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
1+
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/duplicate.rs:5:12
33
|
44
LL | #![feature(impl_trait_in_bindings)]
55
| ^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
89

910
error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified
1011
--> $DIR/duplicate.rs:10:36
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
1+
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/dyn-lcsit.rs:4:12
33
|
44
LL | #![feature(impl_trait_in_bindings)]
55
| ^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
89

910
warning: 1 warning emitted
1011

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
1+
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/lcsit.rs:4:12
33
|
44
LL | #![feature(impl_trait_in_bindings)]
55
| ^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
89

910
warning: 1 warning emitted
1011

src/test/ui/binding/const-param.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/const-param.rs:3:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
error[E0158]: const parameters cannot be referenced in patterns
1011
--> $DIR/const-param.rs:7:9

src/test/ui/const-generics/apit-with-const-param.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// check-pass
22

33
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
4+
//~^ WARN the feature `const_generics` is incomplete
55

66
trait Trait {}
77

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/apit-with-const-param.rs:3:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
warning: 1 warning emitted
1011

src/test/ui/const-generics/argument_order.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
2+
//~^ WARN the feature `const_generics` is incomplete
33

44
struct Bad<const N: usize, T> { //~ ERROR type parameters must be declared prior
55
arr: [u8; { N }],

src/test/ui/const-generics/argument_order.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ error: type parameters must be declared prior to const parameters
44
LL | struct Bad<const N: usize, T> {
55
| -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>`
66

7-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
7+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
88
--> $DIR/argument_order.rs:1:12
99
|
1010
LL | #![feature(const_generics)]
1111
| ^^^^^^^^^^^^^^
1212
|
1313
= note: `#[warn(incomplete_features)]` on by default
14+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
1415

1516
error: aborting due to previous error; 1 warning emitted
1617

src/test/ui/const-generics/array-size-in-generic-struct-param.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
2+
//~^ WARN the feature `const_generics` is incomplete
33

44
#[allow(dead_code)]
55
struct ArithArrayLen<const N: usize>([u32; 0 + N]);

src/test/ui/const-generics/array-size-in-generic-struct-param.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/array-size-in-generic-struct-param.rs:1:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
error: constant expression depends on a generic parameter
1011
--> $DIR/array-size-in-generic-struct-param.rs:5:38

src/test/ui/const-generics/array-wrapper-struct-ctor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-pass
22

33
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
4+
//~^ WARN the feature `const_generics` is incomplete
55

66
#![allow(dead_code)]
77

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/array-wrapper-struct-ctor.rs:3:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
warning: 1 warning emitted
1011

src/test/ui/const-generics/broken-mir-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-pass
22

33
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
4+
//~^ WARN the feature `const_generics` is incomplete
55

66
pub trait Foo {
77
fn foo(&self);
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/broken-mir-1.rs:3:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
warning: 1 warning emitted
1011

src/test/ui/const-generics/broken-mir-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
2+
//~^ WARN the feature `const_generics` is incomplete
33

44
use std::fmt::Debug;
55

src/test/ui/const-generics/broken-mir-2.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/broken-mir-2.rs:1:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
error[E0277]: arrays only have std trait implementations for lengths 0..=32
1011
--> $DIR/broken-mir-2.rs:7:36

src/test/ui/const-generics/cannot-infer-const-args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
2+
//~^ WARN the feature `const_generics` is incomplete
33

44
fn foo<const X: usize>() -> usize {
55
0

src/test/ui/const-generics/cannot-infer-const-args.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/cannot-infer-const-args.rs:1:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
error[E0282]: type annotations needed
1011
--> $DIR/cannot-infer-const-args.rs:9:5

src/test/ui/const-generics/cannot-infer-type-for-const-param.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// check-pass
22
#![feature(const_generics)]
3-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
3+
//~^ WARN the feature `const_generics` is incomplete
44

55
// This test confirms that the types can be inferred correctly for this example with const
66
// generics. Previously this would ICE, and more recently error.
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/cannot-infer-type-for-const-param.rs:2:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
warning: 1 warning emitted
1011

src/test/ui/const-generics/concrete-const-as-fn-arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// run-pass
33

44
#![feature(const_generics)]
5-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5+
//~^ WARN the feature `const_generics` is incomplete
66

77
struct A<const N: usize>; // ok
88

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/concrete-const-as-fn-arg.rs:4:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
warning: 1 warning emitted
1011

src/test/ui/const-generics/concrete-const-impl-method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// run-pass
44

55
#![feature(const_generics)]
6-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
6+
//~^ WARN the feature `const_generics` is incomplete
77

88
pub struct A<const N: u32>;
99

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/concrete-const-impl-method.rs:5:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
warning: 1 warning emitted
1011

src/test/ui/const-generics/condition-in-trait-const-arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-pass
22

33
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
4+
//~^ WARN the feature `const_generics` is incomplete
55

66
trait IsZeroTrait<const IS_ZERO: bool>{}
77

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/condition-in-trait-const-arg.rs:3:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
warning: 1 warning emitted
1011

src/test/ui/const-generics/const-arg-in-fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-pass
22

33
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
4+
//~^ WARN the feature `const_generics` is incomplete
55

66
fn const_u32_identity<const X: u32>() -> u32 {
77
X
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
22
--> $DIR/const-arg-in-fn.rs:3:12
33
|
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
89

910
warning: 1 warning emitted
1011

src/test/ui/const-generics/const-arg-type-arg-misordered.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
2+
//~^ WARN the feature `const_generics` is incomplete
33

44
type Array<T, const N: usize> = [T; N];
55

0 commit comments

Comments
 (0)