diff options
| author | kennytm <kennytm@gmail.com> | 2018-08-17 00:13:23 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-17 00:13:23 +0800 |
| commit | 4968eea6395f69df57274deeed473bbed853467b (patch) | |
| tree | 612bf34377f15cd942afb95a201febde0150ac55 /src/libsyntax | |
| parent | 1cda84bfdbed2c14ae787cb41ebff1c166ac5fd9 (diff) | |
| parent | bc8cead070a44a9ebc7cd559479e0266c45c7c72 (diff) | |
| download | rust-4968eea6395f69df57274deeed473bbed853467b.tar.gz rust-4968eea6395f69df57274deeed473bbed853467b.zip | |
Rollup merge of #53364 - varkor:gat-warn-broken, r=pnkfelix
Warn if the user tries to use GATs GATs are currently broken, but still accessible behind a feature gate. This leads to people attempting to use them and then immediately encountering ICEs (or other broken behaviour). Here, we emit a warning if the user tries to use any feature associated with GATs, hopefully making it obvious that ICEs and the like are expected. For the meantime, this seems better than continually getting reported errors (for example: [here](https://github.com/rust-lang/rust/issues?q=is%3Aissue+gat+is%3Aclosed) and [here](https://github.com/rust-lang/rust/issues?utf8=%E2%9C%93&q=is%3Aissue+generic_associated_types+is%3Aclosed)).
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index f837bead6a0..395e5c98652 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1922,6 +1922,11 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], err.emit(); } + // Some features are known to be incomplete and using them is likely to have + // unanticipated results, such as compiler crashes. We warn the user about these + // to alert them. + let incomplete_features = ["generic_associated_types"]; + let mut features = Features::new(); let mut edition_enabled_features = FxHashMap(); @@ -1957,6 +1962,16 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], continue }; + if incomplete_features.iter().any(|f| *f == name.as_str()) { + span_handler.struct_span_warn( + mi.span, + &format!( + "the feature `{}` is incomplete and may cause the compiler to crash", + name + ) + ).emit(); + } + if let Some(edition) = ALL_EDITIONS.iter().find(|e| name == e.feature_name()) { if *edition <= crate_edition { continue |
