Skip to content

Commit d305f68

Browse files
committed
Warn when generic_associated_types feature gate is enabled
1 parent a573305 commit d305f68

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/libsyntax/feature_gate.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,11 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
19201920
err.emit();
19211921
}
19221922

1923+
// Some features are known to be incomplete and using them is likely to have
1924+
// unanticipated results, such as compiler crashes. We warn the user about these
1925+
// to alert them.
1926+
let incomplete_features = ["generic_associated_types"];
1927+
19231928
let mut features = Features::new();
19241929
let mut edition_enabled_features = FxHashMap();
19251930

@@ -1955,6 +1960,16 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
19551960
continue
19561961
};
19571962

1963+
if incomplete_features.iter().any(|f| *f == name.as_str()) {
1964+
span_handler.struct_span_warn(
1965+
mi.span,
1966+
&format!(
1967+
"the feature `{}` is incomplete and may cause the compiler to crash",
1968+
name
1969+
)
1970+
).emit();
1971+
}
1972+
19581973
if let Some(edition) = ALL_EDITIONS.iter().find(|e| name == e.feature_name()) {
19591974
if *edition <= crate_edition {
19601975
continue
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-pass
12+
13+
#![feature(generic_associated_types)]
14+
//~^ WARNING the feature `generic_associated_types` is incomplete
15+
16+
fn main() {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: the feature `generic_associated_types` is incomplete and may cause the compiler to crash
2+
--> $DIR/gat-incomplete-warning.rs:13:12
3+
|
4+
LL | #![feature(generic_associated_types)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+

0 commit comments

Comments
 (0)