Skip to content

Commit c038ea1

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 30811cf + 6a8cf4a commit c038ea1

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

Lines changed: 14 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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
Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

0 commit comments

Comments
 (0)