diff options
| author | varkor <github@varkor.com> | 2018-07-23 01:21:03 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-08-05 15:54:49 +0100 |
| commit | 70ff6fd46f1e46faca928241448095866d46194d (patch) | |
| tree | 9ffc2dbb1d868d211fdcdd98431e15c77f9496fe | |
| parent | 5242dce01db3fc42d5ec91eb166cce83194149cb (diff) | |
Add error for inconsistent stability `since` value
| -rw-r--r-- | src/librustc/middle/lib_features.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/librustc/middle/lib_features.rs b/src/librustc/middle/lib_features.rs index 27bd69f04fd..e451cf5cfa1 100644 --- a/src/librustc/middle/lib_features.rs +++ b/src/librustc/middle/lib_features.rs @@ -101,6 +101,21 @@ impl<'a, 'tcx> LibFeatureCollector<'a, 'tcx> { match (since, already_in_stable, already_in_unstable) { (Some(since), _, false) => { + if let Some(prev_since) = self.lib_features.stable.get(&feature) { + if *prev_since != since { + let msg = format!( + "feature `{}` is declared stable since {}, \ + but was previously declared stable since {}", + feature, + since, + prev_since, + ); + self.tcx.sess.struct_span_err_with_code(span, &msg, + DiagnosticId::Error("E0711".into())).emit(); + return; + } + } + self.lib_features.stable.insert(feature, since); } (None, false, _) => { |
