Skip to content

Commit

Permalink
Rollup merge of rust-lang#72045 - RalfJung:incomplete-unsound, r=petr…
Browse files Browse the repository at this point in the history
…ochenkov

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.
  • Loading branch information
RalfJung authored May 14, 2020
2 parents 30811cf + 6a8cf4a commit c038ea1
Show file tree
Hide file tree
Showing 176 changed files with 284 additions and 182 deletions.
20 changes: 14 additions & 6 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use rustc_ast::visit::{FnCtxt, FnKind};
use rustc_ast_pretty::pprust::{self, expr_to_string};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_feature::Stability;
use rustc_feature::{deprecated_attributes, AttributeGate, AttributeTemplate, AttributeType};
use rustc_feature::{GateIssue, Stability};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
Expand Down Expand Up @@ -1817,13 +1817,21 @@ impl EarlyLintPass for IncompleteFeatures {
.map(|(name, span, _)| (name, span))
.chain(features.declared_lib_features.iter().map(|(name, span)| (name, span)))
.filter(|(name, _)| rustc_feature::INCOMPLETE_FEATURES.iter().any(|f| name == &f))
.for_each(|(name, &span)| {
.for_each(|(&name, &span)| {
cx.struct_span_lint(INCOMPLETE_FEATURES, span, |lint| {
lint.build(&format!(
"the feature `{}` is incomplete and may cause the compiler to crash",
let mut builder = lint.build(&format!(
"the feature `{}` is incomplete and may not be safe to use \
and/or cause compiler crashes",
name,
))
.emit()
));
if let Some(n) = rustc_feature::find_feature_issue(name, GateIssue::Language) {
builder.note(&format!(
"see issue #{} <https://github.com/rust-lang/rust/issues/{}> \
for more information",
n, n,
));
}
builder.emit();
})
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/incremental/const-generics/issue-62536.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// revisions:cfail1
#![feature(const_generics)]
//[cfail1]~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
//[cfail1]~^ WARN the feature `const_generics` is incomplete

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

Expand Down
2 changes: 1 addition & 1 deletion src/test/incremental/const-generics/issue-64087.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// revisions:cfail1
#![feature(const_generics)]
//[cfail1]~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
//[cfail1]~^ WARN the feature `const_generics` is incomplete

fn combinator<T, const S: usize>() -> [T; S] {}
//[cfail1]~^ ERROR mismatched types
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/array-slice-vec/match_arr_unknown_len.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
//~^ WARN the feature `const_generics` is incomplete

fn is_123<const N: usize>(x: [u32; N]) -> bool {
match x {
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/array-slice-vec/match_arr_unknown_len.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/match_arr_unknown_len.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

error[E0308]: mismatched types
--> $DIR/match_arr_unknown_len.rs:6:9
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/associated-type-bounds/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![feature(associated_type_bounds)]
#![feature(type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)] //~ WARN the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash [incomplete_features]
#![feature(impl_trait_in_bindings)] //~ WARN the feature `impl_trait_in_bindings` is incomplete
#![feature(untagged_unions)]

use std::iter;
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/associated-type-bounds/duplicate.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/duplicate.rs:5:12
|
LL | #![feature(impl_trait_in_bindings)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information

error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified
--> $DIR/duplicate.rs:10:36
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/associated-type-bounds/dyn-lcsit.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/dyn-lcsit.rs:4:12
|
LL | #![feature(impl_trait_in_bindings)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information

warning: 1 warning emitted

3 changes: 2 additions & 1 deletion src/test/ui/associated-type-bounds/lcsit.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/lcsit.rs:4:12
|
LL | #![feature(impl_trait_in_bindings)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information

warning: 1 warning emitted

3 changes: 2 additions & 1 deletion src/test/ui/binding/const-param.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/const-param.rs:3:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

error[E0158]: const parameters cannot be referenced in patterns
--> $DIR/const-param.rs:7:9
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/apit-with-const-param.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// check-pass

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

trait Trait {}

Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/const-generics/apit-with-const-param.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/apit-with-const-param.rs:3:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/argument_order.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
//~^ WARN the feature `const_generics` is incomplete

struct Bad<const N: usize, T> { //~ ERROR type parameters must be declared prior
arr: [u8; { N }],
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/const-generics/argument_order.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ error: type parameters must be declared prior to const parameters
LL | struct Bad<const N: usize, T> {
| -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>`

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

error: aborting due to previous error; 1 warning emitted

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

#[allow(dead_code)]
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/array-size-in-generic-struct-param.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

error: constant expression depends on a generic parameter
--> $DIR/array-size-in-generic-struct-param.rs:5:38
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/array-wrapper-struct-ctor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// run-pass

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

#![allow(dead_code)]

Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/const-generics/array-wrapper-struct-ctor.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/array-wrapper-struct-ctor.rs:3:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/broken-mir-1.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// run-pass

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

pub trait Foo {
fn foo(&self);
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/const-generics/broken-mir-1.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/broken-mir-1.rs:3:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/broken-mir-2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
//~^ WARN the feature `const_generics` is incomplete

use std::fmt::Debug;

Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/const-generics/broken-mir-2.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/broken-mir-2.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

error[E0277]: arrays only have std trait implementations for lengths 0..=32
--> $DIR/broken-mir-2.rs:7:36
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/cannot-infer-const-args.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
//~^ WARN the feature `const_generics` is incomplete

fn foo<const X: usize>() -> usize {
0
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/const-generics/cannot-infer-const-args.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/cannot-infer-const-args.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

error[E0282]: type annotations needed
--> $DIR/cannot-infer-const-args.rs:9:5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// check-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
//~^ WARN the feature `const_generics` is incomplete

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

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/concrete-const-as-fn-arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// run-pass

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

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

Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/const-generics/concrete-const-as-fn-arg.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/concrete-const-as-fn-arg.rs:4:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/concrete-const-impl-method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// run-pass

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

pub struct A<const N: u32>;

Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/const-generics/concrete-const-impl-method.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/concrete-const-impl-method.rs:5:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/condition-in-trait-const-arg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// run-pass

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

trait IsZeroTrait<const IS_ZERO: bool>{}

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

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/const-arg-in-fn.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// run-pass

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

fn const_u32_identity<const X: u32>() -> u32 {
X
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/const-generics/const-arg-in-fn.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/const-arg-in-fn.rs:3:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

warning: 1 warning emitted

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

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

Expand Down
Loading

0 comments on commit c038ea1

Please sign in to comment.