about summary refs log tree commit diff
path: root/src/librustc_span
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2020-01-09 05:56:38 -0500
committerNiko Matsakis <niko@alum.mit.edu>2020-03-26 06:52:55 -0400
commitfda3378e3fcf279a19409ef368ce9bd5b57bfd62 (patch)
tree7fb3ae6e92d79b4c068d1e6f0d1d2dc45de49733 /src/librustc_span
parent65071708f8fe72dd2103c6eace0eb6802a6acf03 (diff)
introduce `negative_impls` feature gate and document
They used to be covered by `optin_builtin_traits` but negative impls
are now applicable to all traits, not just auto traits.

This also adds docs in the unstable book for the current state of auto traits.
Diffstat (limited to 'src/librustc_span')
-rw-r--r--src/librustc_span/lib.rs43
-rw-r--r--src/librustc_span/symbol.rs1
2 files changed, 37 insertions, 7 deletions
diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs
index 3ebcef947bc..7a1aea15753 100644
--- a/src/librustc_span/lib.rs
+++ b/src/librustc_span/lib.rs
@@ -9,6 +9,7 @@
 #![feature(const_if_match)]
 #![feature(const_fn)]
 #![feature(const_panic)]
+#![cfg_attr(not(bootstrap), feature(negative_impls))]
 #![feature(nll)]
 #![feature(optin_builtin_traits)]
 #![feature(specialization)]
@@ -305,7 +306,11 @@ impl Span {
 
     /// Returns `self` if `self` is not the dummy span, and `other` otherwise.
     pub fn substitute_dummy(self, other: Span) -> Span {
-        if self.is_dummy() { other } else { self }
+        if self.is_dummy() {
+            other
+        } else {
+            self
+        }
     }
 
     /// Returns `true` if `self` fully encloses `other`.
@@ -336,21 +341,33 @@ impl Span {
     pub fn trim_start(self, other: Span) -> Option<Span> {
         let span = self.data();
         let other = other.data();
-        if span.hi > other.hi { Some(span.with_lo(cmp::max(span.lo, other.hi))) } else { None }
+        if span.hi > other.hi {
+            Some(span.with_lo(cmp::max(span.lo, other.hi)))
+        } else {
+            None
+        }
     }
 
     /// Returns the source span -- this is either the supplied span, or the span for
     /// the macro callsite that expanded to it.
     pub fn source_callsite(self) -> Span {
         let expn_data = self.ctxt().outer_expn_data();
-        if !expn_data.is_root() { expn_data.call_site.source_callsite() } else { self }
+        if !expn_data.is_root() {
+            expn_data.call_site.source_callsite()
+        } else {
+            self
+        }
     }
 
     /// The `Span` for the tokens in the previous macro expansion from which `self` was generated,
     /// if any.
     pub fn parent(self) -> Option<Span> {
         let expn_data = self.ctxt().outer_expn_data();
-        if !expn_data.is_root() { Some(expn_data.call_site) } else { None }
+        if !expn_data.is_root() {
+            Some(expn_data.call_site)
+        } else {
+            None
+        }
     }
 
     /// Edition of the crate from which this span came.
@@ -376,10 +393,18 @@ impl Span {
     pub fn source_callee(self) -> Option<ExpnData> {
         fn source_callee(expn_data: ExpnData) -> ExpnData {
             let next_expn_data = expn_data.call_site.ctxt().outer_expn_data();
-            if !next_expn_data.is_root() { source_callee(next_expn_data) } else { expn_data }
+            if !next_expn_data.is_root() {
+                source_callee(next_expn_data)
+            } else {
+                expn_data
+            }
         }
         let expn_data = self.ctxt().outer_expn_data();
-        if !expn_data.is_root() { Some(source_callee(expn_data)) } else { None }
+        if !expn_data.is_root() {
+            Some(source_callee(expn_data))
+        } else {
+            None
+        }
     }
 
     /// Checks if a span is "internal" to a macro in which `#[unstable]`
@@ -1199,7 +1224,11 @@ impl SourceFile {
 
         let line_index = lookup_line(&self.lines[..], pos);
         assert!(line_index < self.lines.len() as isize);
-        if line_index >= 0 { Some(line_index as usize) } else { None }
+        if line_index >= 0 {
+            Some(line_index as usize)
+        } else {
+            None
+        }
     }
 
     pub fn line_bounds(&self, line_index: usize) -> (BytePos, BytePos) {
diff --git a/src/librustc_span/symbol.rs b/src/librustc_span/symbol.rs
index dcb4e849a75..bb41629ef09 100644
--- a/src/librustc_span/symbol.rs
+++ b/src/librustc_span/symbol.rs
@@ -473,6 +473,7 @@ symbols! {
         needs_drop,
         needs_panic_runtime,
         negate_unsigned,
+        negative_impls,
         never,
         never_type,
         never_type_fallback,