]> git.lizzy.rs Git - rust.git/commitdiff
Tweak unsupported negative trait bounds message
authorEsteban Küber <esteban@kuber.com.ar>
Mon, 11 Mar 2019 02:46:44 +0000 (19:46 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Sat, 23 Mar 2019 20:05:30 +0000 (13:05 -0700)
src/librustc_errors/diagnostic.rs
src/libsyntax/parse/parser.rs
src/test/ui/issues/issue-58857.stderr
src/test/ui/parser/issue-33418.fixed
src/test/ui/parser/issue-33418.rs
src/test/ui/parser/issue-33418.stderr

index 851b19e8177b53917f37cf4a9bcab637fb5f2abe..fc1fd960c4acea3397b140fcab6b9d340366cf58 100644 (file)
@@ -366,7 +366,7 @@ pub fn span_suggestion_hidden(
                 }],
             }],
             msg: msg.to_owned(),
-            style: SuggestionStyle::HideCodeInline,
+            style: SuggestionStyle::HideCodeAlways,
             applicability,
         });
         self
index 6ff06aa4b31d39c00530764e3a5586fd6b5ef3f7..99260314054168a668e2cae42039b24c5d0df539 100644 (file)
@@ -5598,8 +5598,14 @@ fn parse_generic_bounds_common(&mut self,
 
         if !negative_bounds.is_empty() || was_negative {
             let plural = negative_bounds.len() > 1;
-            let mut err = self.struct_span_err(negative_bounds,
-                                               "negative trait bounds are not supported");
+            let last_span = negative_bounds.last().map(|sp| *sp);
+            let mut err = self.struct_span_err(
+                negative_bounds,
+                "negative trait bounds are not supported",
+            );
+            if let Some(sp) = last_span {
+                err.span_label(sp, "negative trait bounds are not supported");
+            }
             if let Some(bound_list) = colon_span {
                 let bound_list = bound_list.to(self.prev_span);
                 let mut new_bound_list = String::new();
@@ -5612,11 +5618,12 @@ fn parse_generic_bounds_common(&mut self,
                     }
                     new_bound_list = new_bound_list.replacen(" +", ":", 1);
                 }
-                err.span_suggestion_short(bound_list,
-                                        &format!("remove the trait bound{}",
-                                                if plural { "s" } else { "" }),
-                                        new_bound_list,
-                                        Applicability::MachineApplicable);
+                err.span_suggestion_hidden(
+                    bound_list,
+                    &format!("remove the trait bound{}", if plural { "s" } else { "" }),
+                    new_bound_list,
+                    Applicability::MachineApplicable,
+                );
             }
             err.emit();
         }
index 040e9eb8a65676a5d7d41b3e4c23984be22c49d8..56e87215a800cb4d3b0db1d579ecf0a35693c683 100644 (file)
@@ -2,7 +2,8 @@ error: negative trait bounds are not supported
   --> $DIR/issue-58857.rs:4:7
    |
 LL | impl<A: !Valid> Conj<A>{}
-   |       ^^^^^^^^ help: remove the trait bound
+   |       ^^^^^^^^ negative trait bounds are not supported
+   = help: remove the trait bound
 
 error: aborting due to previous error
 
index df11f2d855ce0115bf16a7be7cadb88869837de1..2aaa3b5b1ea502a521a12036a25315e68e8c8486 100644 (file)
@@ -1,10 +1,15 @@
 // run-rustfix
 
-trait Tr {} //~ ERROR negative trait bounds are not supported
-trait Tr2: SuperA {} //~ ERROR negative trait bounds are not supported
-trait Tr3: SuperB {} //~ ERROR negative trait bounds are not supported
+trait Tr {}
+//~^ ERROR negative trait bounds are not supported
+trait Tr2: SuperA {}
+//~^ ERROR negative trait bounds are not supported
+trait Tr3: SuperB {}
+//~^ ERROR negative trait bounds are not supported
 trait Tr4: SuperB + SuperD {}
+//~^ ERROR negative trait bounds are not supported
 trait Tr5 {}
+//~^ ERROR negative trait bounds are not supported
 
 trait SuperA {}
 trait SuperB {}
index 5bb5f2afca377188105ed00011294633bda41c81..5533152092719f9a417a0e8ad2b547c496ed8372 100644 (file)
@@ -1,12 +1,17 @@
 // run-rustfix
 
-trait Tr: !SuperA {} //~ ERROR negative trait bounds are not supported
-trait Tr2: SuperA + !SuperB {} //~ ERROR negative trait bounds are not supported
-trait Tr3: !SuperA + SuperB {} //~ ERROR negative trait bounds are not supported
-trait Tr4: !SuperA + SuperB //~ ERROR negative trait bounds are not supported
+trait Tr: !SuperA {}
+//~^ ERROR negative trait bounds are not supported
+trait Tr2: SuperA + !SuperB {}
+//~^ ERROR negative trait bounds are not supported
+trait Tr3: !SuperA + SuperB {}
+//~^ ERROR negative trait bounds are not supported
+trait Tr4: !SuperA + SuperB
     + !SuperC + SuperD {}
-trait Tr5: !SuperA //~ ERROR negative trait bounds are not supported
+//~^ ERROR negative trait bounds are not supported
+trait Tr5: !SuperA
     + !SuperB {}
+//~^ ERROR negative trait bounds are not supported
 
 trait SuperA {}
 trait SuperB {}
index acbe597ef31a327f7fa229d0dc14375236d20733..660d9fd30c82efbe94639059614ab1a7a7357c09 100644 (file)
@@ -2,41 +2,40 @@ error: negative trait bounds are not supported
   --> $DIR/issue-33418.rs:3:9
    |
 LL | trait Tr: !SuperA {}
-   |         ^^^^^^^^^ help: remove the trait bound
+   |         ^^^^^^^^^ negative trait bounds are not supported
+   = help: remove the trait bound
 
 error: negative trait bounds are not supported
-  --> $DIR/issue-33418.rs:4:19
+  --> $DIR/issue-33418.rs:5:19
    |
 LL | trait Tr2: SuperA + !SuperB {}
-   |          ---------^^^^^^^^^
-   |          |
-   |          help: remove the trait bound
+   |                   ^^^^^^^^^ negative trait bounds are not supported
+   = help: remove the trait bound
 
 error: negative trait bounds are not supported
-  --> $DIR/issue-33418.rs:5:10
+  --> $DIR/issue-33418.rs:7:10
    |
 LL | trait Tr3: !SuperA + SuperB {}
-   |          ^^^^^^^^^---------
-   |          |
-   |          help: remove the trait bound
+   |          ^^^^^^^^^ negative trait bounds are not supported
+   = help: remove the trait bound
 
 error: negative trait bounds are not supported
-  --> $DIR/issue-33418.rs:6:10
+  --> $DIR/issue-33418.rs:9:10
    |
-LL |   trait Tr4: !SuperA + SuperB
-   |  __________-^^^^^^^^
-LL | |     + !SuperC + SuperD {}
-   | |_____^^^^^^^^^________- help: remove the trait bounds
+LL | trait Tr4: !SuperA + SuperB
+   |          ^^^^^^^^^
+LL |     + !SuperC + SuperD {}
+   |     ^^^^^^^^^ negative trait bounds are not supported
+   = help: remove the trait bounds
 
 error: negative trait bounds are not supported
-  --> $DIR/issue-33418.rs:8:10
+  --> $DIR/issue-33418.rs:12:10
    |
-LL |   trait Tr5: !SuperA
-   |  __________-^^^^^^^^
-LL | |     + !SuperB {}
-   | |     ^^^^^^^^-
-   | |_____________|
-   |               help: remove the trait bounds
+LL | trait Tr5: !SuperA
+   |          ^^^^^^^^^
+LL |     + !SuperB {}
+   |     ^^^^^^^^^ negative trait bounds are not supported
+   = help: remove the trait bounds
 
 error: aborting due to 5 previous errors