]> git.lizzy.rs Git - rust.git/commitdiff
Increase verbosity when suggesting subtle code changes
authorEsteban Küber <esteban@kuber.com.ar>
Thu, 12 Mar 2020 03:38:21 +0000 (20:38 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Sun, 22 Mar 2020 17:36:45 +0000 (10:36 -0700)
32 files changed:
src/librustc_infer/infer/error_reporting/need_type_info.rs
src/librustc_trait_selection/traits/error_reporting/mod.rs
src/librustc_trait_selection/traits/error_reporting/suggestions.rs
src/librustc_typeck/check/method/mod.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/pat.rs
src/test/ui/error-codes/E0615.stderr
src/test/ui/extern/extern-types-unsized.stderr
src/test/ui/implicit-method-bind.stderr
src/test/ui/issues/issue-13853-2.stderr
src/test/ui/issues/issue-26472.stderr
src/test/ui/issues/issue-35241.stderr
src/test/ui/methods/method-missing-call.stderr
src/test/ui/question-mark-type-infer.stderr
src/test/ui/reify-intrinsic.stderr
src/test/ui/resolve/privacy-enum-ctor.stderr
src/test/ui/span/type-annotations-needed-expr.stderr
src/test/ui/str/str-mut-idx.stderr
src/test/ui/substs-ppaux.normal.stderr
src/test/ui/substs-ppaux.verbose.stderr
src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
src/test/ui/suggestions/const-in-struct-pat.stderr
src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr
src/test/ui/suggestions/imm-ref-trait-object-literal.stderr
src/test/ui/suggestions/method-missing-parentheses.stderr
src/test/ui/type-inference/or_else-multiple-type-params.stderr
src/test/ui/type-inference/sort_by_key.stderr
src/test/ui/type/type-annotation-needed.stderr
src/test/ui/union/union-suggest-field.rs
src/test/ui/union/union-suggest-field.stderr
src/test/ui/unsized3.stderr

index 0eda4555e25656f671c9d6f8c88dbf739c85dd4a..ea8b4f41888dc2ec267084a777ee47172223bf19 100644 (file)
@@ -3,7 +3,7 @@
 use rustc::hir::map::Map;
 use rustc::ty::print::Print;
 use rustc::ty::{self, DefIdTree, Infer, Ty, TyVar};
-use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
+use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder};
 use rustc_hir as hir;
 use rustc_hir::def::{DefKind, Namespace};
 use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
@@ -462,24 +462,19 @@ fn annotate_method_call(
         e: &Expr<'_>,
         err: &mut DiagnosticBuilder<'_>,
     ) {
-        if let (Ok(snippet), Some(tables), None) = (
-            self.tcx.sess.source_map().span_to_snippet(segment.ident.span),
-            self.in_progress_tables,
-            &segment.args,
-        ) {
+        if let (Some(tables), None) = (self.in_progress_tables, &segment.args) {
             let borrow = tables.borrow();
             if let Some((DefKind::AssocFn, did)) = borrow.type_dependent_def(e.hir_id) {
                 let generics = self.tcx.generics_of(did);
                 if !generics.params.is_empty() {
-                    err.span_suggestion(
-                        segment.ident.span,
+                    err.span_suggestion_verbose(
+                        segment.ident.span.shrink_to_hi(),
                         &format!(
                             "consider specifying the type argument{} in the method call",
-                            if generics.params.len() > 1 { "s" } else { "" },
+                            pluralize!(generics.params.len()),
                         ),
                         format!(
-                            "{}::<{}>",
-                            snippet,
+                            "::<{}>",
                             generics
                                 .params
                                 .iter()
index ef62958a3f7d0a99a0b13a55730bd5a9bbea4c34..d001ced3e7ea136043dab921d2867bd83f26ed52 100644 (file)
@@ -815,11 +815,11 @@ fn report_arg_count_mismatch(
             // For example, if `expected_args_length` is 2, suggest `|_, _|`.
             if found_args.is_empty() && is_closure {
                 let underscores = vec!["_"; expected_args.len()].join(", ");
-                err.span_suggestion(
+                err.span_suggestion_verbose(
                     pipe_span,
                     &format!(
                         "consider changing the closure to take and ignore the expected argument{}",
-                        if expected_args.len() < 2 { "" } else { "s" }
+                        pluralize!(expected_args.len())
                     ),
                     format!("|{}|", underscores),
                     Applicability::MachineApplicable,
@@ -833,7 +833,7 @@ fn report_arg_count_mismatch(
                         .map(|(name, _)| name.to_owned())
                         .collect::<Vec<String>>()
                         .join(", ");
-                    err.span_suggestion(
+                    err.span_suggestion_verbose(
                         found_span,
                         "change the closure to take multiple arguments instead of a single tuple",
                         format!("|{}|", sugg),
@@ -870,7 +870,7 @@ fn report_arg_count_mismatch(
                             String::new()
                         },
                     );
-                    err.span_suggestion(
+                    err.span_suggestion_verbose(
                         found_span,
                         "change the closure to accept a tuple instead of individual arguments",
                         sugg,
@@ -1420,15 +1420,14 @@ fn maybe_report_ambiguity(
                         //    |
                         //    = note: cannot resolve `_: Tt`
 
-                        err.span_suggestion(
-                            span,
+                        err.span_suggestion_verbose(
+                            span.shrink_to_hi(),
                             &format!(
                                 "consider specifying the type argument{} in the function call",
-                                if generics.params.len() > 1 { "s" } else { "" },
+                                pluralize!(generics.params.len()),
                             ),
                             format!(
-                                "{}::<{}>",
-                                snippet,
+                                "::<{}>",
                                 generics
                                     .params
                                     .iter()
@@ -1590,7 +1589,7 @@ fn suggest_unsized_bound_if_applicable(
                             [] => (span.shrink_to_hi(), ":"),
                             [.., bound] => (bound.span().shrink_to_hi(), " + "),
                         };
-                        err.span_suggestion(
+                        err.span_suggestion_verbose(
                             span,
                             "consider relaxing the implicit `Sized` restriction",
                             format!("{} ?Sized", separator),
index 40eb893e6daa85e3d0ef353a27da5d333e1881d7..fdb5def193031a9f18115a153af637b561c4f557 100644 (file)
@@ -390,7 +390,7 @@ fn suggest_fn_call(
         }
         let hir = self.tcx.hir();
         // Get the name of the callable and the arguments to be used in the suggestion.
-        let snippet = match hir.get_if_local(def_id) {
+        let (snippet, sugg) = match hir.get_if_local(def_id) {
             Some(hir::Node::Expr(hir::Expr {
                 kind: hir::ExprKind::Closure(_, decl, _, span, ..),
                 ..
@@ -401,7 +401,8 @@ fn suggest_fn_call(
                     None => return,
                 };
                 let args = decl.inputs.iter().map(|_| "_").collect::<Vec<_>>().join(", ");
-                format!("{}({})", name, args)
+                let sugg = format!("({})", args);
+                (format!("{}{}", name, sugg), sugg)
             }
             Some(hir::Node::Item(hir::Item {
                 ident,
@@ -422,7 +423,8 @@ fn suggest_fn_call(
                     })
                     .collect::<Vec<_>>()
                     .join(", ");
-                format!("{}({})", ident, args)
+                let sugg = format!("({})", args);
+                (format!("{}{}", ident, sugg), sugg)
             }
             _ => return,
         };
@@ -431,10 +433,10 @@ fn suggest_fn_call(
             // an argument, the `obligation.cause.span` points at the expression
             // of the argument, so we can provide a suggestion. This is signaled
             // by `points_at_arg`. Otherwise, we give a more general note.
-            err.span_suggestion(
-                obligation.cause.span,
+            err.span_suggestion_verbose(
+                obligation.cause.span.shrink_to_hi(),
                 &msg,
-                snippet,
+                sugg,
                 Applicability::HasPlaceholders,
             );
         } else {
@@ -619,7 +621,7 @@ fn suggest_change_mut(
                         .source_map()
                         .span_take_while(span, |c| c.is_whitespace() || *c == '&');
                     if points_at_arg && mutability == hir::Mutability::Not && refs_number > 0 {
-                        err.span_suggestion(
+                        err.span_suggestion_verbose(
                             sp,
                             "consider changing this borrow's mutability",
                             "&mut ".to_string(),
index 3cf7b65e30f2f377688d4a08ac238cb51e07ea9d..abe284b42c6b9d7aa0d33432c2298a76b888ed23 100644 (file)
@@ -137,7 +137,7 @@ pub fn method_exists(
         self_ty: Ty<'tcx>,
         call_expr: &hir::Expr<'_>,
     ) {
-        let has_params = self
+        let params = self
             .probe_for_name(
                 method_name.span,
                 probe::Mode::MethodCall,
@@ -147,26 +147,20 @@ pub fn method_exists(
                 call_expr.hir_id,
                 ProbeScope::TraitsInScope,
             )
-            .and_then(|pick| {
+            .map(|pick| {
                 let sig = self.tcx.fn_sig(pick.item.def_id);
-                Ok(sig.inputs().skip_binder().len() > 1)
-            });
+                sig.inputs().skip_binder().len().saturating_sub(1)
+            })
+            .unwrap_or(0);
 
         // Account for `foo.bar<T>`;
-        let sugg_span = method_name.span.with_hi(call_expr.span.hi());
-        let snippet = self
-            .tcx
-            .sess
-            .source_map()
-            .span_to_snippet(sugg_span)
-            .unwrap_or_else(|_| method_name.to_string());
-        let (suggestion, applicability) = if has_params.unwrap_or_default() {
-            (format!("{}(...)", snippet), Applicability::HasPlaceholders)
-        } else {
-            (format!("{}()", snippet), Applicability::MaybeIncorrect)
-        };
+        let sugg_span = call_expr.span.shrink_to_hi();
+        let (suggestion, applicability) = (
+            format!("({})", (0..params).map(|_| "_").collect::<Vec<_>>().join(", ")),
+            if params > 0 { Applicability::HasPlaceholders } else { Applicability::MaybeIncorrect },
+        );
 
-        err.span_suggestion(sugg_span, msg, suggestion, applicability);
+        err.span_suggestion_verbose(sugg_span, msg, suggestion, applicability);
     }
 
     /// Performs method lookup. If lookup is successful, it will return the callee
index e4bd42f61c32129bd5c385fe5676979f02afbe0f..a73f2d9f0c766cc75d109731f7721c4b2f458f08 100644 (file)
@@ -4941,15 +4941,13 @@ fn suggest_fn_call(
                 }
                 _ => {}
             }
-            if let Ok(code) = self.sess().source_map().span_to_snippet(expr.span) {
-                err.span_suggestion(
-                    expr.span,
-                    &format!("use parentheses to {}", msg),
-                    format!("{}({})", code, sugg_call),
-                    applicability,
-                );
-                return true;
-            }
+            err.span_suggestion_verbose(
+                expr.span.shrink_to_hi(),
+                &format!("use parentheses to {}", msg),
+                format!("({})", sugg_call),
+                applicability,
+            );
+            return true;
         }
         false
     }
index 0f3884de84e1282048189a45a90147d4487439bd..0d38fa98bd7f8e32c6ddb0de5692b54fbbb566ae 100644 (file)
@@ -753,17 +753,21 @@ fn emit_bad_pat_path(
                         res.descr(),
                     ),
                 );
-                let (msg, sugg) = match parent_pat {
-                    Some(Pat { kind: hir::PatKind::Struct(..), .. }) => (
-                        "bind the struct field to a different name instead",
-                        format!("{}: other_{}", ident, ident.as_str().to_lowercase()),
-                    ),
-                    _ => (
-                        "introduce a new binding instead",
-                        format!("other_{}", ident.as_str().to_lowercase()),
-                    ),
+                match parent_pat {
+                    Some(Pat { kind: hir::PatKind::Struct(..), .. }) => {
+                        e.span_suggestion_verbose(
+                            ident.span.shrink_to_hi(),
+                            "bind the struct field to a different name instead",
+                            format!(": other_{}", ident.as_str().to_lowercase()),
+                            Applicability::HasPlaceholders,
+                        );
+                    }
+                    _ => {
+                        let msg = "introduce a new binding instead";
+                        let sugg = format!("other_{}", ident.as_str().to_lowercase());
+                        e.span_suggestion(ident.span, msg, sugg, Applicability::HasPlaceholders);
+                    }
                 };
-                e.span_suggestion(ident.span, msg, sugg, Applicability::HasPlaceholders);
             }
         }
         e.emit();
index 772058719ae04919a38eb9285d62167e74f4efc5..039d736673c08385c88df2894b65f8a217641fd7 100644 (file)
@@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `method` on type `Foo`
   --> $DIR/E0615.rs:11:7
    |
 LL |     f.method;
-   |       ^^^^^^ help: use parentheses to call the method: `method()`
+   |       ^^^^^^
+   |
+help: use parentheses to call the method
+   |
+LL |     f.method();
+   |             ^^
 
 error: aborting due to previous error
 
index 0c9165fd9585d4d84d497d8d589eaac8b02b313c..871757ec7b0c698e22aea5bc002179dc3c2cdaa2 100644 (file)
@@ -2,15 +2,17 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim
   --> $DIR/extern-types-unsized.rs:22:20
    |
 LL | fn assert_sized<T>() { }
-   |    ------------ -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized`
-   |                 |
-   |                 required by this bound in `assert_sized`
+   |    ------------ - required by this bound in `assert_sized`
 ...
 LL |     assert_sized::<A>();
    |                    ^ doesn't have a size known at compile-time
    |
    = help: the trait `std::marker::Sized` is not implemented for `A`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+help: consider relaxing the implicit `Sized` restriction
+   |
+LL | fn assert_sized<T: ?Sized>() { }
+   |                  ^^^^^^^^
 
 error[E0277]: the size for values of type `A` cannot be known at compilation time
   --> $DIR/extern-types-unsized.rs:25:5
index 968272d4d2c193b93956882dfd3d97ed1156c0e1..e9616f8317f916ca25c98f1bb70d2560ae772d23 100644 (file)
@@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `abs` on type `i32`
   --> $DIR/implicit-method-bind.rs:2:20
    |
 LL |     let _f = 10i32.abs;
-   |                    ^^^ help: use parentheses to call the method: `abs()`
+   |                    ^^^
+   |
+help: use parentheses to call the method
+   |
+LL |     let _f = 10i32.abs();
+   |                       ^^
 
 error: aborting due to previous error
 
index ea3b38940cf01523e707a5f7823c0323667122e8..264faa0da333b71121cff022105f60d316e1693e 100644 (file)
@@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `get` on type `std::boxed::Box<(
   --> $DIR/issue-13853-2.rs:5:43
    |
 LL | fn foo(res : Box<dyn ResponseHook>) { res.get }
-   |                                           ^^^ help: use parentheses to call the method: `get()`
+   |                                           ^^^
+   |
+help: use parentheses to call the method
+   |
+LL | fn foo(res : Box<dyn ResponseHook>) { res.get() }
+   |                                              ^^
 
 error: aborting due to previous error
 
index 245ebeaf972ed56390abd31172d16ead57f2bfef..9073bfed8948ee50cccd2c310e95a13c9052fc9a 100644 (file)
@@ -2,9 +2,12 @@ error[E0616]: field `len` of struct `sub::S` is private
   --> $DIR/issue-26472.rs:11:13
    |
 LL |     let v = s.len;
-   |             ^^---
-   |               |
-   |               help: a method `len` also exists, call it with parentheses: `len()`
+   |             ^^^^^
+   |
+help: a method `len` also exists, call it with parentheses
+   |
+LL |     let v = s.len();
+   |                  ^^
 
 error[E0616]: field `len` of struct `sub::S` is private
   --> $DIR/issue-26472.rs:12:5
index 4a52a292ef30a9f232a121845cd5737c16f5679e..b6045c993a9585f14d5ecb30cbf47e6ca88df249 100644 (file)
@@ -5,14 +5,16 @@ LL | struct Foo(u32);
    | ---------------- fn(u32) -> Foo {Foo} defined here
 LL | 
 LL | fn test() -> Foo { Foo }
-   |              ---   ^^^
-   |              |     |
-   |              |     expected struct `Foo`, found fn item
-   |              |     help: use parentheses to instantiate this tuple struct: `Foo(_)`
+   |              ---   ^^^ expected struct `Foo`, found fn item
+   |              |
    |              expected `Foo` because of return type
    |
    = note: expected struct `Foo`
              found fn item `fn(u32) -> Foo {Foo}`
+help: use parentheses to instantiate this tuple struct
+   |
+LL | fn test() -> Foo { Foo(_) }
+   |                       ^^^
 
 error: aborting due to previous error
 
index 3ab5f66a0c3f62d89ab0a0bcc46fa73bb099b059..23f8970e9e79080714c9c1b000796f068b9c5a6e 100644 (file)
@@ -2,13 +2,23 @@ error[E0615]: attempted to take value of method `get_x` on type `Point`
   --> $DIR/method-missing-call.rs:22:26
    |
 LL |                         .get_x;
-   |                          ^^^^^ help: use parentheses to call the method: `get_x()`
+   |                          ^^^^^
+   |
+help: use parentheses to call the method
+   |
+LL |                         .get_x();
+   |                               ^^
 
 error[E0615]: attempted to take value of method `filter_map` on type `std::iter::Filter<std::iter::Map<std::slice::Iter<'_, {integer}>, [closure@$DIR/method-missing-call.rs:27:20: 27:25]>, [closure@$DIR/method-missing-call.rs:28:23: 28:35]>`
   --> $DIR/method-missing-call.rs:29:16
    |
 LL |               .filter_map;
-   |                ^^^^^^^^^^ help: use parentheses to call the method: `filter_map(...)`
+   |                ^^^^^^^^^^
+   |
+help: use parentheses to call the method
+   |
+LL |               .filter_map(_);
+   |                          ^^^
 
 error: aborting due to 2 previous errors
 
index 7911701946cd3db3723e6372177ca6732a3181c4..262344fba59999be0d93aada8a8dbb72b127d16b 100644 (file)
@@ -2,12 +2,13 @@ error[E0284]: type annotations needed
   --> $DIR/question-mark-type-infer.rs:12:21
    |
 LL |     l.iter().map(f).collect()?
-   |                     ^^^^^^^
-   |                     |
-   |                     cannot infer type
-   |                     help: consider specifying the type argument in the method call: `collect::<B>`
+   |                     ^^^^^^^ cannot infer type
    |
    = note: cannot resolve `<_ as std::ops::Try>::Ok == _`
+help: consider specifying the type argument in the method call
+   |
+LL |     l.iter().map(f).collect::<B>()?
+   |                            ^^^^^
 
 error: aborting due to previous error
 
index 4defe12b1b37b58ba9d760603e601b25755d6925..c4eee0f46611935c5a1793d44e4aa517a2e814fb 100644 (file)
@@ -2,14 +2,16 @@ error[E0308]: cannot coerce intrinsics to function pointers
   --> $DIR/reify-intrinsic.rs:6:64
    |
 LL |     let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::transmute;
-   |            -------------------------------------------------   ^^^^^^^^^^^^^^^^^^^
-   |            |                                                   |
-   |            |                                                   cannot coerce intrinsics to function pointers
-   |            |                                                   help: use parentheses to call this function: `std::mem::transmute(...)`
+   |            -------------------------------------------------   ^^^^^^^^^^^^^^^^^^^ cannot coerce intrinsics to function pointers
+   |            |
    |            expected due to this
    |
    = note: expected fn pointer `unsafe extern "rust-intrinsic" fn(isize) -> usize`
                  found fn item `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}`
+help: use parentheses to call this function
+   |
+LL |     let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::transmute(...);
+   |                                                                                   ^^^^^
 
 error[E0606]: casting `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}` as `unsafe extern "rust-intrinsic" fn(isize) -> usize` is invalid
   --> $DIR/reify-intrinsic.rs:11:13
index 08a1d790197a6384740304397043239d0d97aa95..bf24cfc4d73776016fcab5cbf27dd54b223715b5 100644 (file)
@@ -304,14 +304,16 @@ LL |             Fn(u8),
    |             ------ fn(u8) -> m::n::Z {m::n::Z::Fn} defined here
 ...
 LL |         let _: Z = Z::Fn;
-   |                -   ^^^^^
-   |                |   |
-   |                |   expected enum `m::n::Z`, found fn item
-   |                |   help: use parentheses to instantiate this tuple variant: `Z::Fn(_)`
+   |                -   ^^^^^ expected enum `m::n::Z`, found fn item
+   |                |
    |                expected due to this
    |
    = note: expected enum `m::n::Z`
            found fn item `fn(u8) -> m::n::Z {m::n::Z::Fn}`
+help: use parentheses to instantiate this tuple variant
+   |
+LL |         let _: Z = Z::Fn(_);
+   |                         ^^^
 
 error[E0618]: expected function, found enum variant `Z::Unit`
   --> $DIR/privacy-enum-ctor.rs:31:17
@@ -336,14 +338,16 @@ LL |         Fn(u8),
    |         ------ fn(u8) -> m::E {m::E::Fn} defined here
 ...
 LL |     let _: E = m::E::Fn;
-   |            -   ^^^^^^^^
-   |            |   |
-   |            |   expected enum `m::E`, found fn item
-   |            |   help: use parentheses to instantiate this tuple variant: `m::E::Fn(_)`
+   |            -   ^^^^^^^^ expected enum `m::E`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected enum `m::E`
            found fn item `fn(u8) -> m::E {m::E::Fn}`
+help: use parentheses to instantiate this tuple variant
+   |
+LL |     let _: E = m::E::Fn(_);
+   |                        ^^^
 
 error[E0618]: expected function, found enum variant `m::E::Unit`
   --> $DIR/privacy-enum-ctor.rs:47:16
@@ -368,14 +372,16 @@ LL |         Fn(u8),
    |         ------ fn(u8) -> m::E {m::E::Fn} defined here
 ...
 LL |     let _: E = E::Fn;
-   |            -   ^^^^^
-   |            |   |
-   |            |   expected enum `m::E`, found fn item
-   |            |   help: use parentheses to instantiate this tuple variant: `E::Fn(_)`
+   |            -   ^^^^^ expected enum `m::E`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected enum `m::E`
            found fn item `fn(u8) -> m::E {m::E::Fn}`
+help: use parentheses to instantiate this tuple variant
+   |
+LL |     let _: E = E::Fn(_);
+   |                     ^^^
 
 error[E0618]: expected function, found enum variant `E::Unit`
   --> $DIR/privacy-enum-ctor.rs:55:16
index 35d994e194f3f9ec4c3f119767ca98f866cbb318..3e6d350b36c330f0ef4e3741b012c7d9e8adf70e 100644 (file)
@@ -2,12 +2,13 @@ error[E0282]: type annotations needed
   --> $DIR/type-annotations-needed-expr.rs:2:39
    |
 LL |     let _ = (vec![1,2,3]).into_iter().sum() as f64;
-   |                                       ^^^
-   |                                       |
-   |                                       cannot infer type for type parameter `S` declared on the associated function `sum`
-   |                                       help: consider specifying the type argument in the method call: `sum::<S>`
+   |                                       ^^^ cannot infer type for type parameter `S` declared on the associated function `sum`
    |
    = note: type must be known at this point
+help: consider specifying the type argument in the method call
+   |
+LL |     let _ = (vec![1,2,3]).into_iter().sum::<S>() as f64;
+   |                                          ^^^^^
 
 error: aborting due to previous error
 
index a9ec6b9c02fe8e4987a839c1e0549a441fdc467d..d0afb2ae7af74fecc4f293bea9f58fffe7c831bc 100644 (file)
@@ -2,15 +2,17 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t
   --> $DIR/str-mut-idx.rs:4:15
    |
 LL | fn bot<T>() -> T { loop {} }
-   |    --- -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized`
-   |        |
-   |        required by this bound in `bot`
+   |    --- - required by this bound in `bot`
 ...
 LL |     s[1..2] = bot();
    |               ^^^ doesn't have a size known at compile-time
    |
    = help: the trait `std::marker::Sized` is not implemented for `str`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+help: consider relaxing the implicit `Sized` restriction
+   |
+LL | fn bot<T: ?Sized>() -> T { loop {} }
+   |         ^^^^^^^^
 
 error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> $DIR/str-mut-idx.rs:4:5
index 4423f3c130e2a31ddf562d1cd65b362e264c6efe..3ad2a1414f96986eb56ba990e3d29c34a60bf628 100644 (file)
@@ -5,14 +5,16 @@ LL |     fn bar<'a, T>() where T: 'a {}
    |     --------------------------- fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>} defined here
 ...
 LL |     let x: () = <i8 as Foo<'static, 'static,  u8>>::bar::<'static, char>;
-   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |            |    |
-   |            |    expected `()`, found fn item
-   |            |    help: use parentheses to call this function: `<i8 as Foo<'static, 'static,  u8>>::bar::<'static, char>()`
+   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected unit type `()`
                 found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
+help: use parentheses to call this function
+   |
+LL |     let x: () = <i8 as Foo<'static, 'static,  u8>>::bar::<'static, char>();
+   |                                                                         ^^
 
 error[E0308]: mismatched types
   --> $DIR/substs-ppaux.rs:25:17
@@ -21,14 +23,16 @@ LL |     fn bar<'a, T>() where T: 'a {}
    |     --------------------------- fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>} defined here
 ...
 LL |     let x: () = <i8 as Foo<'static, 'static,  u32>>::bar::<'static, char>;
-   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |            |    |
-   |            |    expected `()`, found fn item
-   |            |    help: use parentheses to call this function: `<i8 as Foo<'static, 'static,  u32>>::bar::<'static, char>()`
+   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected unit type `()`
                 found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
+help: use parentheses to call this function
+   |
+LL |     let x: () = <i8 as Foo<'static, 'static,  u32>>::bar::<'static, char>();
+   |                                                                          ^^
 
 error[E0308]: mismatched types
   --> $DIR/substs-ppaux.rs:33:17
@@ -37,14 +41,16 @@ LL |     fn baz() {}
    |     -------- fn() {<i8 as Foo<'static, 'static, u8>>::baz} defined here
 ...
 LL |     let x: () = <i8 as Foo<'static, 'static,  u8>>::baz;
-   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |            |    |
-   |            |    expected `()`, found fn item
-   |            |    help: use parentheses to call this function: `<i8 as Foo<'static, 'static,  u8>>::baz()`
+   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected unit type `()`
                 found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
+help: use parentheses to call this function
+   |
+LL |     let x: () = <i8 as Foo<'static, 'static,  u8>>::baz();
+   |                                                        ^^
 
 error[E0308]: mismatched types
   --> $DIR/substs-ppaux.rs:41:17
@@ -53,14 +59,16 @@ LL | fn foo<'z>() where &'z (): Sized {
    | -------------------------------- fn() {foo::<'static>} defined here
 ...
 LL |     let x: () = foo::<'static>;
-   |            --   ^^^^^^^^^^^^^^
-   |            |    |
-   |            |    expected `()`, found fn item
-   |            |    help: use parentheses to call this function: `foo::<'static>()`
+   |            --   ^^^^^^^^^^^^^^ expected `()`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected unit type `()`
                 found fn item `fn() {foo::<'static>}`
+help: use parentheses to call this function
+   |
+LL |     let x: () = foo::<'static>();
+   |                               ^^
 
 error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> $DIR/substs-ppaux.rs:49:5
index 2aebdebee72c1e1ccf5fb663a1f965a0fa72145e..e23f06a3ef590036aeaafa5e63caa5a628eabdcc 100644 (file)
@@ -5,14 +5,16 @@ LL |     fn bar<'a, T>() where T: 'a {}
    |     --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>} defined here
 ...
 LL |     let x: () = <i8 as Foo<'static, 'static,  u8>>::bar::<'static, char>;
-   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |            |    |
-   |            |    expected `()`, found fn item
-   |            |    help: use parentheses to call this function: `<i8 as Foo<'static, 'static,  u8>>::bar::<'static, char>()`
+   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected unit type `()`
                 found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>}`
+help: use parentheses to call this function
+   |
+LL |     let x: () = <i8 as Foo<'static, 'static,  u8>>::bar::<'static, char>();
+   |                                                                         ^^
 
 error[E0308]: mismatched types
   --> $DIR/substs-ppaux.rs:25:17
@@ -21,14 +23,16 @@ LL |     fn bar<'a, T>() where T: 'a {}
    |     --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>} defined here
 ...
 LL |     let x: () = <i8 as Foo<'static, 'static,  u32>>::bar::<'static, char>;
-   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |            |    |
-   |            |    expected `()`, found fn item
-   |            |    help: use parentheses to call this function: `<i8 as Foo<'static, 'static,  u32>>::bar::<'static, char>()`
+   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected unit type `()`
                 found fn item `fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>}`
+help: use parentheses to call this function
+   |
+LL |     let x: () = <i8 as Foo<'static, 'static,  u32>>::bar::<'static, char>();
+   |                                                                          ^^
 
 error[E0308]: mismatched types
   --> $DIR/substs-ppaux.rs:33:17
@@ -37,14 +41,16 @@ LL |     fn baz() {}
    |     -------- fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz} defined here
 ...
 LL |     let x: () = <i8 as Foo<'static, 'static,  u8>>::baz;
-   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |            |    |
-   |            |    expected `()`, found fn item
-   |            |    help: use parentheses to call this function: `<i8 as Foo<'static, 'static,  u8>>::baz()`
+   |            --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected unit type `()`
                 found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz}`
+help: use parentheses to call this function
+   |
+LL |     let x: () = <i8 as Foo<'static, 'static,  u8>>::baz();
+   |                                                        ^^
 
 error[E0308]: mismatched types
   --> $DIR/substs-ppaux.rs:41:17
@@ -53,14 +59,16 @@ LL | fn foo<'z>() where &'z (): Sized {
    | -------------------------------- fn() {foo::<ReStatic>} defined here
 ...
 LL |     let x: () = foo::<'static>;
-   |            --   ^^^^^^^^^^^^^^
-   |            |    |
-   |            |    expected `()`, found fn item
-   |            |    help: use parentheses to call this function: `foo::<'static>()`
+   |            --   ^^^^^^^^^^^^^^ expected `()`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected unit type `()`
                 found fn item `fn() {foo::<ReStatic>}`
+help: use parentheses to call this function
+   |
+LL |     let x: () = foo::<'static>();
+   |                               ^^
 
 error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> $DIR/substs-ppaux.rs:49:5
index 05583876a066c3aca42f206fce868e9c75ebd380..638d504d7feab73a82344ababf67a9fcf7316f5c 100644 (file)
@@ -8,10 +8,12 @@ LL | fn bar(f: impl Future<Output=()>) {}
    |    ---         ----------------- required by this bound in `bar`
 ...
 LL |     bar(foo);
-   |         ^^^
-   |         |
-   |         the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}`
-   |         help: use parentheses to call the function: `foo()`
+   |         ^^^ the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}`
+   |
+help: use parentheses to call the function
+   |
+LL |     bar(foo());
+   |            ^^
 
 error[E0277]: the trait bound `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]: std::future::Future` is not satisfied
   --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9
@@ -22,10 +24,12 @@ LL | fn bar(f: impl Future<Output=()>) {}
 LL |     let async_closure = async || ();
    |                         -------- consider calling this closure
 LL |     bar(async_closure);
-   |         ^^^^^^^^^^^^^
-   |         |
-   |         the trait `std::future::Future` is not implemented for `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]`
-   |         help: use parentheses to call the closure: `async_closure()`
+   |         ^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]`
+   |
+help: use parentheses to call the closure
+   |
+LL |     bar(async_closure());
+   |                      ^^
 
 error: aborting due to 2 previous errors
 
index 0a010dcab4c26ba5f193adbe7d495f5a827fa6fc..ab336b14d29480915dbf8dc644e5404b2fd83f0a 100644 (file)
@@ -9,7 +9,11 @@ LL |     let Thing { foo } = t;
    |                 |
    |                 expected struct `std::string::String`, found struct `foo`
    |                 `foo` is interpreted as a unit struct, not a new binding
-   |                 help: bind the struct field to a different name instead: `foo: other_foo`
+   |
+help: bind the struct field to a different name instead
+   |
+LL |     let Thing { foo: other_foo } = t;
+   |                    ^^^^^^^^^^^
 
 error: aborting due to previous error
 
index 91f60e8f426c4fa552a8c5bb68c304a2cccca99f..ed4a0b8487dff01ef0fb8e56fa0b2967d5d83b12 100644 (file)
@@ -8,10 +8,12 @@ LL | fn bar(f: impl T<O=()>) {}
    |    ---         ------- required by this bound in `bar`
 ...
 LL |     bar(foo);
-   |         ^^^
-   |         |
-   |         the trait `T` is not implemented for `fn() -> impl T {foo}`
-   |         help: use parentheses to call the function: `foo()`
+   |         ^^^ the trait `T` is not implemented for `fn() -> impl T {foo}`
+   |
+help: use parentheses to call the function
+   |
+LL |     bar(foo());
+   |            ^^
 
 error[E0277]: the trait bound `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]: T` is not satisfied
   --> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:19:9
@@ -22,10 +24,12 @@ LL | fn bar(f: impl T<O=()>) {}
 LL |     let closure = || S;
    |                   -- consider calling this closure
 LL |     bar(closure);
-   |         ^^^^^^^
-   |         |
-   |         the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]`
-   |         help: use parentheses to call the closure: `closure()`
+   |         ^^^^^^^ the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]`
+   |
+help: use parentheses to call the closure
+   |
+LL |     bar(closure());
+   |                ^^
 
 error: aborting due to 2 previous errors
 
index 232e54b5d37b24e2b2bb90e73dfd46ca6e14c4bf..69aef0853cec3ceb305ea07edcabd9f0ccc5520c 100644 (file)
@@ -19,14 +19,16 @@ LL | fn foo(a: usize, b: usize) -> usize { a }
    | ----------------------------------- fn(usize, usize) -> usize {foo} defined here
 ...
 LL |     let _: usize = foo;
-   |            -----   ^^^
-   |            |       |
-   |            |       expected `usize`, found fn item
-   |            |       help: use parentheses to call this function: `foo(a, b)`
+   |            -----   ^^^ expected `usize`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected type `usize`
            found fn item `fn(usize, usize) -> usize {foo}`
+help: use parentheses to call this function
+   |
+LL |     let _: usize = foo(a, b);
+   |                       ^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:30:16
@@ -35,14 +37,16 @@ LL | struct S(usize, usize);
    | ----------------------- fn(usize, usize) -> S {S} defined here
 ...
 LL |     let _: S = S;
-   |            -   ^
-   |            |   |
-   |            |   expected struct `S`, found fn item
-   |            |   help: use parentheses to instantiate this tuple struct: `S(_, _)`
+   |            -   ^ expected struct `S`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected struct `S`
              found fn item `fn(usize, usize) -> S {S}`
+help: use parentheses to instantiate this tuple struct
+   |
+LL |     let _: S = S(_, _);
+   |                 ^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:31:20
@@ -51,14 +55,16 @@ LL | fn bar() -> usize { 42 }
    | ----------------- fn() -> usize {bar} defined here
 ...
 LL |     let _: usize = bar;
-   |            -----   ^^^
-   |            |       |
-   |            |       expected `usize`, found fn item
-   |            |       help: use parentheses to call this function: `bar()`
+   |            -----   ^^^ expected `usize`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected type `usize`
            found fn item `fn() -> usize {bar}`
+help: use parentheses to call this function
+   |
+LL |     let _: usize = bar();
+   |                       ^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:32:16
@@ -67,14 +73,16 @@ LL | struct V();
    | ----------- fn() -> V {V} defined here
 ...
 LL |     let _: V = V;
-   |            -   ^
-   |            |   |
-   |            |   expected struct `V`, found fn item
-   |            |   help: use parentheses to instantiate this tuple struct: `V()`
+   |            -   ^ expected struct `V`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected struct `V`
              found fn item `fn() -> V {V}`
+help: use parentheses to instantiate this tuple struct
+   |
+LL |     let _: V = V();
+   |                 ^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:33:20
@@ -83,14 +91,16 @@ LL |     fn baz(x: usize, y: usize) -> usize { x }
    |     ----------------------------------- fn(usize, usize) -> usize {<_ as T>::baz} defined here
 ...
 LL |     let _: usize = T::baz;
-   |            -----   ^^^^^^
-   |            |       |
-   |            |       expected `usize`, found fn item
-   |            |       help: use parentheses to call this function: `T::baz(x, y)`
+   |            -----   ^^^^^^ expected `usize`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected type `usize`
            found fn item `fn(usize, usize) -> usize {<_ as T>::baz}`
+help: use parentheses to call this function
+   |
+LL |     let _: usize = T::baz(x, y);
+   |                          ^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:34:20
@@ -99,14 +109,16 @@ LL |     fn bat(x: usize) -> usize { 42 }
    |     ------------------------- fn(usize) -> usize {<_ as T>::bat} defined here
 ...
 LL |     let _: usize = T::bat;
-   |            -----   ^^^^^^
-   |            |       |
-   |            |       expected `usize`, found fn item
-   |            |       help: use parentheses to call this function: `T::bat(x)`
+   |            -----   ^^^^^^ expected `usize`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected type `usize`
            found fn item `fn(usize) -> usize {<_ as T>::bat}`
+help: use parentheses to call this function
+   |
+LL |     let _: usize = T::bat(x);
+   |                          ^^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:35:16
@@ -115,14 +127,16 @@ LL |     A(usize),
    |     -------- fn(usize) -> E {E::A} defined here
 ...
 LL |     let _: E = E::A;
-   |            -   ^^^^
-   |            |   |
-   |            |   expected enum `E`, found fn item
-   |            |   help: use parentheses to instantiate this tuple variant: `E::A(_)`
+   |            -   ^^^^ expected enum `E`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected enum `E`
            found fn item `fn(usize) -> E {E::A}`
+help: use parentheses to instantiate this tuple variant
+   |
+LL |     let _: E = E::A(_);
+   |                    ^^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:37:20
@@ -131,14 +145,16 @@ LL |     fn baz(x: usize, y: usize) -> usize { x }
    |     ----------------------------------- fn(usize, usize) -> usize {<X as T>::baz} defined here
 ...
 LL |     let _: usize = X::baz;
-   |            -----   ^^^^^^
-   |            |       |
-   |            |       expected `usize`, found fn item
-   |            |       help: use parentheses to call this function: `X::baz(x, y)`
+   |            -----   ^^^^^^ expected `usize`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected type `usize`
            found fn item `fn(usize, usize) -> usize {<X as T>::baz}`
+help: use parentheses to call this function
+   |
+LL |     let _: usize = X::baz(x, y);
+   |                          ^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:38:20
@@ -147,14 +163,16 @@ LL |     fn bat(x: usize) -> usize { 42 }
    |     ------------------------- fn(usize) -> usize {<X as T>::bat} defined here
 ...
 LL |     let _: usize = X::bat;
-   |            -----   ^^^^^^
-   |            |       |
-   |            |       expected `usize`, found fn item
-   |            |       help: use parentheses to call this function: `X::bat(x)`
+   |            -----   ^^^^^^ expected `usize`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected type `usize`
            found fn item `fn(usize) -> usize {<X as T>::bat}`
+help: use parentheses to call this function
+   |
+LL |     let _: usize = X::bat(x);
+   |                          ^^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:39:20
@@ -163,14 +181,16 @@ LL |     fn bax(x: usize) -> usize { 42 }
    |     ------------------------- fn(usize) -> usize {<X as T>::bax} defined here
 ...
 LL |     let _: usize = X::bax;
-   |            -----   ^^^^^^
-   |            |       |
-   |            |       expected `usize`, found fn item
-   |            |       help: use parentheses to call this function: `X::bax(x)`
+   |            -----   ^^^^^^ expected `usize`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected type `usize`
            found fn item `fn(usize) -> usize {<X as T>::bax}`
+help: use parentheses to call this function
+   |
+LL |     let _: usize = X::bax(x);
+   |                          ^^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:40:20
@@ -179,14 +199,16 @@ LL |     fn bach(x: usize) -> usize;
    |     --------------------------- fn(usize) -> usize {<X as T>::bach} defined here
 ...
 LL |     let _: usize = X::bach;
-   |            -----   ^^^^^^^
-   |            |       |
-   |            |       expected `usize`, found fn item
-   |            |       help: use parentheses to call this function: `X::bach(x)`
+   |            -----   ^^^^^^^ expected `usize`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected type `usize`
            found fn item `fn(usize) -> usize {<X as T>::bach}`
+help: use parentheses to call this function
+   |
+LL |     let _: usize = X::bach(x);
+   |                           ^^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:41:20
@@ -195,14 +217,16 @@ LL |     fn ban(&self) -> usize { 42 }
    |     ---------------------- for<'r> fn(&'r X) -> usize {<X as T>::ban} defined here
 ...
 LL |     let _: usize = X::ban;
-   |            -----   ^^^^^^
-   |            |       |
-   |            |       expected `usize`, found fn item
-   |            |       help: use parentheses to call this function: `X::ban(_)`
+   |            -----   ^^^^^^ expected `usize`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected type `usize`
            found fn item `for<'r> fn(&'r X) -> usize {<X as T>::ban}`
+help: use parentheses to call this function
+   |
+LL |     let _: usize = X::ban(_);
+   |                          ^^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:42:20
@@ -211,26 +235,38 @@ LL |     fn bal(&self) -> usize;
    |     ----------------------- for<'r> fn(&'r X) -> usize {<X as T>::bal} defined here
 ...
 LL |     let _: usize = X::bal;
-   |            -----   ^^^^^^
-   |            |       |
-   |            |       expected `usize`, found fn item
-   |            |       help: use parentheses to call this function: `X::bal(_)`
+   |            -----   ^^^^^^ expected `usize`, found fn item
+   |            |
    |            expected due to this
    |
    = note: expected type `usize`
            found fn item `for<'r> fn(&'r X) -> usize {<X as T>::bal}`
+help: use parentheses to call this function
+   |
+LL |     let _: usize = X::bal(_);
+   |                          ^^^
 
 error[E0615]: attempted to take value of method `ban` on type `X`
   --> $DIR/fn-or-tuple-struct-without-args.rs:43:22
    |
 LL |     let _: usize = X.ban;
-   |                      ^^^ help: use parentheses to call the method: `ban()`
+   |                      ^^^
+   |
+help: use parentheses to call the method
+   |
+LL |     let _: usize = X.ban();
+   |                         ^^
 
 error[E0615]: attempted to take value of method `bal` on type `X`
   --> $DIR/fn-or-tuple-struct-without-args.rs:44:22
    |
 LL |     let _: usize = X.bal;
-   |                      ^^^ help: use parentheses to call the method: `bal()`
+   |                      ^^^
+   |
+help: use parentheses to call the method
+   |
+LL |     let _: usize = X.bal();
+   |                         ^^
 
 error[E0308]: mismatched types
   --> $DIR/fn-or-tuple-struct-without-args.rs:46:20
@@ -238,14 +274,16 @@ error[E0308]: mismatched types
 LL |     let closure = || 42;
    |                   ----- the found closure
 LL |     let _: usize = closure;
-   |            -----   ^^^^^^^
-   |            |       |
-   |            |       expected `usize`, found closure
-   |            |       help: use parentheses to call this closure: `closure()`
+   |            -----   ^^^^^^^ expected `usize`, found closure
+   |            |
    |            expected due to this
    |
    = note: expected type `usize`
            found closure `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:24]`
+help: use parentheses to call this closure
+   |
+LL |     let _: usize = closure();
+   |                           ^^
 
 error: aborting due to 17 previous errors
 
index ccaceefacd739649761db3181773aac6c8c199c3..84ba935191b48615dd1bbd38ce97d3800f6b2be1 100644 (file)
@@ -5,13 +5,14 @@ LL | fn foo<X: Trait>(_: X) {}
    |    ---    ----- required by this bound in `foo`
 ...
 LL |   foo(&s);
-   |       -^
-   |       |
-   |       the trait `Trait` is not implemented for `&S`
-   |       help: consider changing this borrow's mutability: `&mut`
+   |       ^^ the trait `Trait` is not implemented for `&S`
    |
    = help: the following implementations were found:
              <&'a mut S as Trait>
+help: consider changing this borrow's mutability
+   |
+LL |   foo(&mut s);
+   |       ^^^^
 
 error[E0277]: the trait bound `S: Trait` is not satisfied
   --> $DIR/imm-ref-trait-object-literal.rs:13:7
index 6e4f7a84724bf7aaeee8302504d89659297d3b2f..75a6091d56e93139aecde640daa3b0285b996f81 100644 (file)
@@ -8,9 +8,12 @@ error[E0615]: attempted to take value of method `collect` on type `std::vec::Int
   --> $DIR/method-missing-parentheses.rs:2:32
    |
 LL |     let _ = vec![].into_iter().collect::<usize>;
-   |                                ^^^^^^^---------
-   |                                |
-   |                                help: use parentheses to call the method: `collect::<usize>()`
+   |                                ^^^^^^^
+   |
+help: use parentheses to call the method
+   |
+LL |     let _ = vec![].into_iter().collect::<usize>();
+   |                                                ^^
 
 error: aborting due to 2 previous errors
 
index 24122e658679a39df43f7d7b81b45b7e37d4d9ac..047728dc1ea4e3d39ea5ab0eda91b075b4de0678 100644 (file)
@@ -2,10 +2,12 @@ error[E0282]: type annotations needed
   --> $DIR/or_else-multiple-type-params.rs:7:10
    |
 LL |         .or_else(|err| {
-   |          ^^^^^^^
-   |          |
-   |          cannot infer type for type parameter `F` declared on the associated function `or_else`
-   |          help: consider specifying the type arguments in the method call: `or_else::<F, O>`
+   |          ^^^^^^^ cannot infer type for type parameter `F` declared on the associated function `or_else`
+   |
+help: consider specifying the type arguments in the method call
+   |
+LL |         .or_else::<F, O>(|err| {
+   |                 ^^^^^^^^
 
 error: aborting due to previous error
 
index bb108adcd64af53d4568c5d31888ab4e024a3914..0b6630ec8942384bdf7ea924e4288079d487535c 100644 (file)
@@ -2,9 +2,12 @@ error[E0282]: type annotations needed
   --> $DIR/sort_by_key.rs:3:9
    |
 LL |     lst.sort_by_key(|&(v, _)| v.iter().sum());
-   |         ^^^^^^^^^^^                    --- help: consider specifying the type argument in the method call: `sum::<S>`
-   |         |
-   |         cannot infer type for type parameter `K` declared on the associated function `sort_by_key`
+   |         ^^^^^^^^^^^ cannot infer type for type parameter `K` declared on the associated function `sort_by_key`
+   |
+help: consider specifying the type argument in the method call
+   |
+LL |     lst.sort_by_key(|&(v, _)| v.iter().sum::<S>());
+   |                                           ^^^^^
 
 error: aborting due to previous error
 
index c6a811e836342b6552ba8920112ba1b50fb3a959..df7d73d7a7c1d221b47c7e614e96e3be6c348bd1 100644 (file)
@@ -5,12 +5,13 @@ LL | fn foo<T: Into<String>>(x: i32) {}
    |    ---    ------------ required by this bound in `foo`
 ...
 LL |     foo(42);
-   |     ^^^
-   |     |
-   |     cannot infer type for type parameter `T` declared on the function `foo`
-   |     help: consider specifying the type argument in the function call: `foo::<T>`
+   |     ^^^ cannot infer type for type parameter `T` declared on the function `foo`
    |
    = note: cannot resolve `_: std::convert::Into<std::string::String>`
+help: consider specifying the type argument in the function call
+   |
+LL |     foo::<T>(42);
+   |        ^^^^^
 
 error: aborting due to previous error
 
index d84a22cee5ab2833884d9f6519090ded39e0b099..71b93e873c22026ceca22d8e30c146afa2b3745c 100644 (file)
@@ -17,5 +17,5 @@ fn main() {
 
     let y = u.calculate; //~ ERROR attempted to take value of method `calculate` on type `U`
                          //~| HELP use parentheses to call the method
-                         //~| SUGGESTION calculate()
+                         //~| SUGGESTION ()
 }
index 5050e4a9864998ba2537f1a51f2a494991263c07..6ab84c4836af1e685d079dcb432c945f66403489 100644 (file)
@@ -14,7 +14,12 @@ error[E0615]: attempted to take value of method `calculate` on type `U`
   --> $DIR/union-suggest-field.rs:18:15
    |
 LL |     let y = u.calculate;
-   |               ^^^^^^^^^ help: use parentheses to call the method: `calculate()`
+   |               ^^^^^^^^^
+   |
+help: use parentheses to call the method
+   |
+LL |     let y = u.calculate();
+   |                        ^^
 
 error: aborting due to 3 previous errors
 
index e97d00fc4741d998554bca7df9cdb65c4c6d12d1..083c74ba1e05d7ab575a5151c752d949ab673705 100644 (file)
@@ -7,12 +7,14 @@ LL |     f2::<X>(x);
    |             ^ doesn't have a size known at compile-time
 ...
 LL | fn f2<X>(x: &X) {
-   |    -- -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized`
-   |       |
-   |       required by this bound in `f2`
+   |    -- - required by this bound in `f2`
    |
    = help: the trait `std::marker::Sized` is not implemented for `X`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+help: consider relaxing the implicit `Sized` restriction
+   |
+LL | fn f2<X: ?Sized>(x: &X) {
+   |        ^^^^^^^^
 
 error[E0277]: the size for values of type `X` cannot be known at compilation time
   --> $DIR/unsized3.rs:18:13
@@ -23,12 +25,14 @@ LL |     f4::<X>(x);
    |             ^ doesn't have a size known at compile-time
 ...
 LL | fn f4<X: T>(x: &X) {
-   |    -- -   - help: consider relaxing the implicit `Sized` restriction: `+  ?Sized`
-   |       |
-   |       required by this bound in `f4`
+   |    -- - required by this bound in `f4`
    |
    = help: the trait `std::marker::Sized` is not implemented for `X`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+help: consider relaxing the implicit `Sized` restriction
+   |
+LL | fn f4<X: T +  ?Sized>(x: &X) {
+   |            ^^^^^^^^^
 
 error[E0277]: the size for values of type `X` cannot be known at compilation time
   --> $DIR/unsized3.rs:33:8