diff --git a/src/librustc/traits/error_reporting/mod.rs b/src/librustc/traits/error_reporting/mod.rs index 6d3719b32d07e..0c1495db267c9 100644 --- a/src/librustc/traits/error_reporting/mod.rs +++ b/src/librustc/traits/error_reporting/mod.rs @@ -27,6 +27,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; +use rustc_hir::{QPath, TyKind, WhereBoundPredicate, WherePredicate}; +use rustc_span::source_map::SourceMap; use rustc_span::{ExpnKind, Span, DUMMY_SP}; use std::fmt; use syntax::ast; @@ -1426,3 +1428,229 @@ impl ArgKind { } } } + +/// Suggest restricting a type param with a new bound. +pub fn suggest_constraining_type_param( + tcx: TyCtxt<'_>, + generics: &hir::Generics<'_>, + err: &mut DiagnosticBuilder<'_>, + param_name: &str, + constraint: &str, + source_map: &SourceMap, + span: Span, + def_id: Option, +) -> bool { + const MSG_RESTRICT_BOUND_FURTHER: &str = "consider further restricting this bound with"; + const MSG_RESTRICT_TYPE: &str = "consider restricting this type parameter with"; + const MSG_RESTRICT_TYPE_FURTHER: &str = "consider further restricting this type parameter with"; + + let param = generics.params.iter().filter(|p| p.name.ident().as_str() == param_name).next(); + + let param = if let Some(param) = param { + param + } else { + return false; + }; + + if def_id == tcx.lang_items().sized_trait() { + // Type parameters are already `Sized` by default. + err.span_label(param.span, &format!("this type parameter needs to be `{}`", constraint)); + return true; + } + + if param_name.starts_with("impl ") { + // If there's an `impl Trait` used in argument position, suggest + // restricting it: + // + // fn foo(t: impl Foo) { ... } + // -------- + // | + // help: consider further restricting this bound with `+ Bar` + // + // Suggestion for tools in this case is: + // + // fn foo(t: impl Foo) { ... } + // -------- + // | + // replace with: `impl Foo + Bar` + + err.span_help(param.span, &format!("{} `+ {}`", MSG_RESTRICT_BOUND_FURTHER, constraint)); + + err.tool_only_span_suggestion( + param.span, + MSG_RESTRICT_BOUND_FURTHER, + format!("{} + {}", param_name, constraint), + Applicability::MachineApplicable, + ); + + return true; + } + + if generics.where_clause.predicates.is_empty() { + if let Some(bounds_span) = param.bounds_span() { + // If user has provided some bounds, suggest restricting them: + // + // fn foo(t: T) { ... } + // --- + // | + // help: consider further restricting this bound with `+ Bar` + // + // Suggestion for tools in this case is: + // + // fn foo(t: T) { ... } + // -- + // | + // replace with: `T: Bar +` + + err.span_help( + bounds_span, + &format!("{} `+ {}`", MSG_RESTRICT_BOUND_FURTHER, constraint), + ); + + let span_hi = param.span.with_hi(span.hi()); + let span_with_colon = source_map.span_through_char(span_hi, ':'); + + if span_hi != param.span && span_with_colon != span_hi { + err.tool_only_span_suggestion( + span_with_colon, + MSG_RESTRICT_BOUND_FURTHER, + format!("{}: {} + ", param_name, constraint), + Applicability::MachineApplicable, + ); + } + } else { + // If user hasn't provided any bounds, suggest adding a new one: + // + // fn foo(t: T) { ... } + // - help: consider restricting this type parameter with `T: Foo` + + err.span_help( + param.span, + &format!("{} `{}: {}`", MSG_RESTRICT_TYPE, param_name, constraint), + ); + + err.tool_only_span_suggestion( + param.span, + MSG_RESTRICT_TYPE, + format!("{}: {}", param_name, constraint), + Applicability::MachineApplicable, + ); + } + + true + } else { + // This part is a bit tricky, because using the `where` clause user can + // provide zero, one or many bounds for the same type parameter, so we + // have following cases to consider: + // + // 1) When the type parameter has been provided zero bounds + // + // Message: + // fn foo(x: X, y: Y) where Y: Foo { ... } + // - help: consider restricting this type parameter with `where X: Bar` + // + // Suggestion: + // fn foo(x: X, y: Y) where Y: Foo { ... } + // - insert: `, X: Bar` + // + // + // 2) When the type parameter has been provided one bound + // + // Message: + // fn foo(t: T) where T: Foo { ... } + // ^^^^^^ + // | + // help: consider further restricting this bound with `+ Bar` + // + // Suggestion: + // fn foo(t: T) where T: Foo { ... } + // ^^ + // | + // replace with: `T: Bar +` + // + // + // 3) When the type parameter has been provided many bounds + // + // Message: + // fn foo(t: T) where T: Foo, T: Bar {... } + // - help: consider further restricting this type parameter with `where T: Zar` + // + // Suggestion: + // fn foo(t: T) where T: Foo, T: Bar {... } + // - insert: `, T: Zar` + + let mut param_spans = Vec::new(); + + for predicate in generics.where_clause.predicates { + if let WherePredicate::BoundPredicate(WhereBoundPredicate { + span, bounded_ty, .. + }) = predicate + { + if let TyKind::Path(QPath::Resolved(_, path)) = &bounded_ty.kind { + if let Some(segment) = path.segments.first() { + if segment.ident.to_string() == param_name { + param_spans.push(span); + } + } + } + } + } + + let where_clause_span = + generics.where_clause.span_for_predicates_or_empty_place().shrink_to_hi(); + + match ¶m_spans[..] { + &[] => { + err.span_help( + param.span, + &format!("{} `where {}: {}`", MSG_RESTRICT_TYPE, param_name, constraint), + ); + + err.tool_only_span_suggestion( + where_clause_span, + MSG_RESTRICT_TYPE, + format!(", {}: {}", param_name, constraint), + Applicability::MachineApplicable, + ); + } + + &[¶m_span] => { + err.span_help( + param_span, + &format!("{} `+ {}`", MSG_RESTRICT_BOUND_FURTHER, constraint), + ); + + let span_hi = param_span.with_hi(span.hi()); + let span_with_colon = source_map.span_through_char(span_hi, ':'); + + if span_hi != param_span && span_with_colon != span_hi { + err.tool_only_span_suggestion( + span_with_colon, + MSG_RESTRICT_BOUND_FURTHER, + format!("{}: {} +", param_name, constraint), + Applicability::MachineApplicable, + ); + } + } + + _ => { + err.span_help( + param.span, + &format!( + "{} `where {}: {}`", + MSG_RESTRICT_TYPE_FURTHER, param_name, constraint, + ), + ); + + err.tool_only_span_suggestion( + where_clause_span, + MSG_RESTRICT_BOUND_FURTHER, + format!(", {}: {}", param_name, constraint), + Applicability::MachineApplicable, + ); + } + } + + true + } +} diff --git a/src/librustc/traits/error_reporting/suggestions.rs b/src/librustc/traits/error_reporting/suggestions.rs index b2973c642a21e..bb576ae86cc1d 100644 --- a/src/librustc/traits/error_reporting/suggestions.rs +++ b/src/librustc/traits/error_reporting/suggestions.rs @@ -4,10 +4,10 @@ use super::{ }; use crate::infer::InferCtxt; +use crate::traits::error_reporting::suggest_constraining_type_param; use crate::traits::object_safety::object_safety_violations; use crate::ty::TypeckTables; use crate::ty::{self, AdtKind, DefIdTree, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness}; - use rustc_errors::{ error_code, pluralize, struct_span_err, Applicability, DiagnosticBuilder, Style, }; @@ -16,7 +16,6 @@ use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::Visitor; use rustc_hir::Node; -use rustc_span::source_map::SourceMap; use rustc_span::symbol::{kw, sym}; use rustc_span::{MultiSpan, Span, DUMMY_SP}; use std::fmt; @@ -430,12 +429,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { .span_take_while(span, |c| c.is_whitespace() || *c == '&'); let remove_refs = refs_remaining + 1; - let format_str = - format!("consider removing {} leading `&`-references", remove_refs); + + let msg = if remove_refs == 1 { + "consider removing the leading `&`-reference".to_string() + } else { + format!("consider removing {} leading `&`-references", remove_refs) + }; err.span_suggestion_short( sp, - &format_str, + &msg, String::new(), Applicability::MachineApplicable, ); @@ -1652,85 +1655,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } } -/// Suggest restricting a type param with a new bound. -pub fn suggest_constraining_type_param( - tcx: TyCtxt<'_>, - generics: &hir::Generics<'_>, - err: &mut DiagnosticBuilder<'_>, - param_name: &str, - constraint: &str, - source_map: &SourceMap, - span: Span, - def_id: Option, -) -> bool { - let restrict_msg = "consider further restricting this bound"; - if let Some(param) = - generics.params.iter().filter(|p| p.name.ident().as_str() == param_name).next() - { - if def_id == tcx.lang_items().sized_trait() { - // Type parameters are already `Sized` by default. - err.span_label( - param.span, - &format!("this type parameter needs to be `{}`", constraint), - ); - } else if param_name.starts_with("impl ") { - // `impl Trait` in argument: - // `fn foo(x: impl Trait) {}` → `fn foo(t: impl Trait + Trait2) {}` - err.span_suggestion( - param.span, - restrict_msg, - // `impl CurrentTrait + MissingTrait` - format!("{} + {}", param_name, constraint), - Applicability::MachineApplicable, - ); - } else if generics.where_clause.predicates.is_empty() && param.bounds.is_empty() { - // If there are no bounds whatsoever, suggest adding a constraint - // to the type parameter: - // `fn foo(t: T) {}` → `fn foo(t: T) {}` - err.span_suggestion( - param.span, - "consider restricting this bound", - format!("{}: {}", param_name, constraint), - Applicability::MachineApplicable, - ); - } else if !generics.where_clause.predicates.is_empty() { - // There is a `where` clause, so suggest expanding it: - // `fn foo(t: T) where T: Debug {}` → - // `fn foo(t: T) where T: Debug, T: Trait {}` - err.span_suggestion( - generics.where_clause.span().unwrap().shrink_to_hi(), - &format!("consider further restricting type parameter `{}`", param_name), - format!(", {}: {}", param_name, constraint), - Applicability::MachineApplicable, - ); - } else { - // If there is no `where` clause lean towards constraining to the - // type parameter: - // `fn foo(t: T, x: X) {}` → `fn foo(t: T) {}` - // `fn foo(t: T) {}` → `fn foo(t: T) {}` - let sp = param.span.with_hi(span.hi()); - let span = source_map.span_through_char(sp, ':'); - if sp != param.span && sp != span { - // Only suggest if we have high certainty that the span - // covers the colon in `foo`. - err.span_suggestion( - span, - restrict_msg, - format!("{}: {} + ", param_name, constraint), - Applicability::MachineApplicable, - ); - } else { - err.span_label( - param.span, - &format!("consider adding a `where {}: {}` bound", param_name, constraint), - ); - } - } - return true; - } - false -} - /// Collect all the returned expressions within the input expression. /// Used to point at the return spans when we want to suggest some change to them. #[derive(Default)] diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs index 0c93a192667e5..27bca1625c1c1 100644 --- a/src/librustc_hir/hir.rs +++ b/src/librustc_hir/hir.rs @@ -441,6 +441,16 @@ pub struct GenericParam<'hir> { pub kind: GenericParamKind<'hir>, } +impl GenericParam<'hir> { + pub fn bounds_span(&self) -> Option { + self.bounds.iter().fold(None, |span, bound| { + let span = span.map(|s| s.to(bound.span())).unwrap_or_else(|| bound.span()); + + Some(span) + }) + } +} + #[derive(Default)] pub struct GenericParamCount { pub lifetimes: usize, @@ -513,7 +523,7 @@ pub enum SyntheticTyParamKind { #[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub struct WhereClause<'hir> { pub predicates: &'hir [WherePredicate<'hir>], - // Only valid if predicates isn't empty. + // Only valid if predicates aren't empty. pub span: Span, } diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index b49e7b7f0d9f8..c7c7db9ad8095 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -3,7 +3,7 @@ use rustc::mir::{ FakeReadCause, Local, LocalDecl, LocalInfo, LocalKind, Location, Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, TerminatorKind, VarBindingForm, }; -use rustc::traits::error_reporting::suggestions::suggest_constraining_type_param; +use rustc::traits::error_reporting::suggest_constraining_type_param; use rustc::ty::{self, Ty}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{Applicability, DiagnosticBuilder}; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 7e5d27d93b3cb..558d4a8326aea 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1354,7 +1354,7 @@ fn check_fn<'a, 'tcx>( // for simple cases like `fn foo(x: Trait)`, // where we would error once on the parameter as a whole, and once on the binding `x`. if param.pat.simple_ident().is_none() && !tcx.features().unsized_locals { - fcx.require_type_is_sized(param_ty, decl.output.span(), traits::SizedArgumentType); + fcx.require_type_is_sized(param_ty, param.pat.span, traits::SizedArgumentType); } fcx.write_ty(param.hir_id, param_ty); diff --git a/src/test/ui/associated-const/associated-const-type-parameter-arrays-2.stderr b/src/test/ui/associated-const/associated-const-type-parameter-arrays-2.stderr index c258892057bf2..ec60db47f4429 100644 --- a/src/test/ui/associated-const/associated-const-type-parameter-arrays-2.stderr +++ b/src/test/ui/associated-const/associated-const-type-parameter-arrays-2.stderr @@ -4,10 +4,14 @@ error[E0277]: the trait bound `A: Foo` is not satisfied LL | const Y: usize; | --------------- required by `Foo::Y` ... -LL | pub fn test() { - | -- help: consider further restricting this bound: `A: Foo +` LL | let _array = [4; ::Y]; | ^^^^^^^^^^^^^ the trait `Foo` is not implemented for `A` + | +help: consider further restricting this bound with `+ Foo` + --> $DIR/associated-const-type-parameter-arrays-2.rs:15:16 + | +LL | pub fn test() { + | ^^^ error: aborting due to previous error diff --git a/src/test/ui/associated-const/associated-const-type-parameter-arrays.stderr b/src/test/ui/associated-const/associated-const-type-parameter-arrays.stderr index f6c8e99e27a81..3d38deb5a8763 100644 --- a/src/test/ui/associated-const/associated-const-type-parameter-arrays.stderr +++ b/src/test/ui/associated-const/associated-const-type-parameter-arrays.stderr @@ -4,10 +4,14 @@ error[E0277]: the trait bound `A: Foo` is not satisfied LL | const Y: usize; | --------------- required by `Foo::Y` ... -LL | pub fn test() { - | -- help: consider further restricting this bound: `A: Foo +` LL | let _array: [u32; ::Y]; | ^^^^^^^^^^^^^ the trait `Foo` is not implemented for `A` + | +help: consider further restricting this bound with `+ Foo` + --> $DIR/associated-const-type-parameter-arrays.rs:15:16 + | +LL | pub fn test() { + | ^^^ error: aborting due to previous error diff --git a/src/test/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr b/src/test/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr index 0b8b7fab1359f..bac663dfea2b3 100644 --- a/src/test/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr +++ b/src/test/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr @@ -1,10 +1,14 @@ error[E0277]: the trait bound `T: Foo` is not satisfied --> $DIR/associated-types-invalid-trait-ref-issue-18865.rs:10:12 | -LL | fn f>(t: &T) { - | -- help: consider further restricting this bound: `T: Foo +` LL | let u: >::Bar = t.get_bar(); | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `T` + | +help: consider further restricting this bound with `+ Foo` + --> $DIR/associated-types-invalid-trait-ref-issue-18865.rs:9:8 + | +LL | fn f>(t: &T) { + | ^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/associated-types/associated-types-no-suitable-bound.stderr b/src/test/ui/associated-types/associated-types-no-suitable-bound.stderr index 78198322913c7..770845167cf9c 100644 --- a/src/test/ui/associated-types/associated-types-no-suitable-bound.stderr +++ b/src/test/ui/associated-types/associated-types-no-suitable-bound.stderr @@ -2,10 +2,13 @@ error[E0277]: the trait bound `T: Get` is not satisfied --> $DIR/associated-types-no-suitable-bound.rs:11:5 | LL | fn uhoh(foo: ::Value) {} - | ^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | help: consider restricting this bound: `T: Get` - | the trait `Get` is not implemented for `T` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `T` + | +help: consider restricting this type parameter with `T: Get` + --> $DIR/associated-types-no-suitable-bound.rs:11:13 + | +LL | fn uhoh(foo: ::Value) {} + | ^ error: aborting due to previous error diff --git a/src/test/ui/bad/bad-method-typaram-kind.stderr b/src/test/ui/bad/bad-method-typaram-kind.stderr index 740667f146680..9732363221286 100644 --- a/src/test/ui/bad/bad-method-typaram-kind.stderr +++ b/src/test/ui/bad/bad-method-typaram-kind.stderr @@ -1,12 +1,15 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/bad-method-typaram-kind.rs:2:7 | -LL | fn foo() { - | -- help: consider further restricting this bound: `T: std::marker::Send +` LL | 1.bar::(); | ^^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` +help: consider further restricting this bound with `+ std::marker::Send` + --> $DIR/bad-method-typaram-kind.rs:1:10 + | +LL | fn foo() { + | ^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/binop/binop-consume-args.stderr b/src/test/ui/binop/binop-consume-args.stderr index 876e984ecb0bf..3fe7c9cbff420 100644 --- a/src/test/ui/binop/binop-consume-args.stderr +++ b/src/test/ui/binop/binop-consume-args.stderr @@ -2,251 +2,331 @@ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:7:10 | LL | fn add, B>(lhs: A, rhs: B) { - | -- --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `A: Copy +` + | --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait LL | lhs + rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-consume-args.rs:5:11 + | +LL | fn add, B>(lhs: A, rhs: B) { + | ^^^^^^^^^^^^^^^^^ error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:8:10 | LL | fn add, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | help: consider restricting this bound: `B: Copy` + | --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait LL | lhs + rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move + | +help: consider restricting this type parameter with `B: Copy` + --> $DIR/binop-consume-args.rs:5:30 + | +LL | fn add, B>(lhs: A, rhs: B) { + | ^ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:13:10 | LL | fn sub, B>(lhs: A, rhs: B) { - | -- --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `A: Copy +` + | --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait LL | lhs - rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-consume-args.rs:11:11 + | +LL | fn sub, B>(lhs: A, rhs: B) { + | ^^^^^^^^^^^^^^^^^ error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:14:10 | LL | fn sub, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | help: consider restricting this bound: `B: Copy` + | --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait LL | lhs - rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move + | +help: consider restricting this type parameter with `B: Copy` + --> $DIR/binop-consume-args.rs:11:30 + | +LL | fn sub, B>(lhs: A, rhs: B) { + | ^ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:19:10 | LL | fn mul, B>(lhs: A, rhs: B) { - | -- --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `A: Copy +` + | --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait LL | lhs * rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-consume-args.rs:17:11 + | +LL | fn mul, B>(lhs: A, rhs: B) { + | ^^^^^^^^^^^^^^^^^ error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:20:10 | LL | fn mul, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | help: consider restricting this bound: `B: Copy` + | --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait LL | lhs * rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move + | +help: consider restricting this type parameter with `B: Copy` + --> $DIR/binop-consume-args.rs:17:30 + | +LL | fn mul, B>(lhs: A, rhs: B) { + | ^ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:25:10 | LL | fn div, B>(lhs: A, rhs: B) { - | -- --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `A: Copy +` + | --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait LL | lhs / rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-consume-args.rs:23:11 + | +LL | fn div, B>(lhs: A, rhs: B) { + | ^^^^^^^^^^^^^^^^^ error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:26:10 | LL | fn div, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | help: consider restricting this bound: `B: Copy` + | --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait LL | lhs / rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move + | +help: consider restricting this type parameter with `B: Copy` + --> $DIR/binop-consume-args.rs:23:30 + | +LL | fn div, B>(lhs: A, rhs: B) { + | ^ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:31:10 | LL | fn rem, B>(lhs: A, rhs: B) { - | -- --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `A: Copy +` + | --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait LL | lhs % rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-consume-args.rs:29:11 + | +LL | fn rem, B>(lhs: A, rhs: B) { + | ^^^^^^^^^^^^^^^^^ error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:32:10 | LL | fn rem, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | help: consider restricting this bound: `B: Copy` + | --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait LL | lhs % rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move + | +help: consider restricting this type parameter with `B: Copy` + --> $DIR/binop-consume-args.rs:29:30 + | +LL | fn rem, B>(lhs: A, rhs: B) { + | ^ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:37:10 | LL | fn bitand, B>(lhs: A, rhs: B) { - | -- --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `A: Copy +` + | --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait LL | lhs & rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-consume-args.rs:35:14 + | +LL | fn bitand, B>(lhs: A, rhs: B) { + | ^^^^^^^^^^^^^^^^^^^^ error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:38:10 | LL | fn bitand, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | help: consider restricting this bound: `B: Copy` + | --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait LL | lhs & rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move + | +help: consider restricting this type parameter with `B: Copy` + --> $DIR/binop-consume-args.rs:35:36 + | +LL | fn bitand, B>(lhs: A, rhs: B) { + | ^ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:43:10 | LL | fn bitor, B>(lhs: A, rhs: B) { - | -- --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `A: Copy +` + | --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait LL | lhs | rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-consume-args.rs:41:13 + | +LL | fn bitor, B>(lhs: A, rhs: B) { + | ^^^^^^^^^^^^^^^^^^^ error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:44:10 | LL | fn bitor, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | help: consider restricting this bound: `B: Copy` + | --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait LL | lhs | rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move + | +help: consider restricting this type parameter with `B: Copy` + --> $DIR/binop-consume-args.rs:41:34 + | +LL | fn bitor, B>(lhs: A, rhs: B) { + | ^ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:49:10 | LL | fn bitxor, B>(lhs: A, rhs: B) { - | -- --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `A: Copy +` + | --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait LL | lhs ^ rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-consume-args.rs:47:14 + | +LL | fn bitxor, B>(lhs: A, rhs: B) { + | ^^^^^^^^^^^^^^^^^^^^ error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:50:10 | LL | fn bitxor, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | help: consider restricting this bound: `B: Copy` + | --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait LL | lhs ^ rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move + | +help: consider restricting this type parameter with `B: Copy` + --> $DIR/binop-consume-args.rs:47:36 + | +LL | fn bitxor, B>(lhs: A, rhs: B) { + | ^ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:55:10 | LL | fn shl, B>(lhs: A, rhs: B) { - | -- --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `A: Copy +` + | --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait LL | lhs << rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-consume-args.rs:53:11 + | +LL | fn shl, B>(lhs: A, rhs: B) { + | ^^^^^^^^^^^^^^^^^ error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:56:10 | LL | fn shl, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | help: consider restricting this bound: `B: Copy` + | --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait LL | lhs << rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move + | +help: consider restricting this type parameter with `B: Copy` + --> $DIR/binop-consume-args.rs:53:30 + | +LL | fn shl, B>(lhs: A, rhs: B) { + | ^ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:61:10 | LL | fn shr, B>(lhs: A, rhs: B) { - | -- --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `A: Copy +` + | --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait LL | lhs >> rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-consume-args.rs:59:11 + | +LL | fn shr, B>(lhs: A, rhs: B) { + | ^^^^^^^^^^^^^^^^^ error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:62:10 | LL | fn shr, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | help: consider restricting this bound: `B: Copy` + | --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait LL | lhs >> rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move + | +help: consider restricting this type parameter with `B: Copy` + --> $DIR/binop-consume-args.rs:59:30 + | +LL | fn shr, B>(lhs: A, rhs: B) { + | ^ error: aborting due to 20 previous errors diff --git a/src/test/ui/binop/binop-move-semantics.stderr b/src/test/ui/binop/binop-move-semantics.stderr index 7552dc669749c..31b594eeab4bf 100644 --- a/src/test/ui/binop/binop-move-semantics.stderr +++ b/src/test/ui/binop/binop-move-semantics.stderr @@ -2,27 +2,35 @@ error[E0382]: use of moved value: `x` --> $DIR/binop-move-semantics.rs:8:5 | LL | fn double_move>(x: T) { - | -- - move occurs because `x` has type `T`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `T: Copy +` + | - move occurs because `x` has type `T`, which does not implement the `Copy` trait LL | x | - value moved here LL | + LL | x; | ^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-move-semantics.rs:5:19 + | +LL | fn double_move>(x: T) { + | ^^^^^^^^^^^^^^ error[E0382]: borrow of moved value: `x` --> $DIR/binop-move-semantics.rs:14:5 | LL | fn move_then_borrow + Clone>(x: T) { - | -- - move occurs because `x` has type `T`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `T: Copy +` + | - move occurs because `x` has type `T`, which does not implement the `Copy` trait LL | x | - value moved here LL | + LL | x.clone(); | ^ value borrowed here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/binop-move-semantics.rs:11:24 + | +LL | fn move_then_borrow + Clone>(x: T) { + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/binop-move-semantics.rs:21:5 diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr index 5cd0471cd0d6e..33a0b0286dfe9 100644 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr +++ b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr @@ -20,13 +20,17 @@ error[E0382]: use of moved value: `f` --> $DIR/borrowck-unboxed-closures.rs:12:5 | LL | fn c isize>(f: F) { - | -- - move occurs because `f` has type `F`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `F: Copy +` + | - move occurs because `f` has type `F`, which does not implement the `Copy` trait LL | f(1, 2); | - value moved here LL | f(1, 2); | ^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/borrowck-unboxed-closures.rs:10:8 + | +LL | fn c isize>(f: F) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/bound-suggestions.fixed b/src/test/ui/bound-suggestions.fixed new file mode 100644 index 0000000000000..c77421c97e7c0 --- /dev/null +++ b/src/test/ui/bound-suggestions.fixed @@ -0,0 +1,39 @@ +// run-rustfix + +#[allow(dead_code)] +fn test_impl(t: impl Sized + std::fmt::Debug) { + println!("{:?}", t); + //~^ ERROR doesn't implement +} + +#[allow(dead_code)] +fn test_no_bounds(t: T) { + println!("{:?}", t); + //~^ ERROR doesn't implement +} + +#[allow(dead_code)] +fn test_one_bound(t: T) { + println!("{:?}", t); + //~^ ERROR doesn't implement +} + +#[allow(dead_code)] +fn test_no_bounds_where(x: X, y: Y) where X: std::fmt::Debug, Y: std::fmt::Debug { + println!("{:?} {:?}", x, y); + //~^ ERROR doesn't implement +} + +#[allow(dead_code)] +fn test_one_bound_where(x: X) where X: std::fmt::Debug + Sized { + println!("{:?}", x); + //~^ ERROR doesn't implement +} + +#[allow(dead_code)] +fn test_many_bounds_where(x: X) where X: Sized, X: Sized, X: std::fmt::Debug { + println!("{:?}", x); + //~^ ERROR doesn't implement +} + +pub fn main() { } diff --git a/src/test/ui/bound-suggestions.rs b/src/test/ui/bound-suggestions.rs new file mode 100644 index 0000000000000..605a6df838658 --- /dev/null +++ b/src/test/ui/bound-suggestions.rs @@ -0,0 +1,39 @@ +// run-rustfix + +#[allow(dead_code)] +fn test_impl(t: impl Sized) { + println!("{:?}", t); + //~^ ERROR doesn't implement +} + +#[allow(dead_code)] +fn test_no_bounds(t: T) { + println!("{:?}", t); + //~^ ERROR doesn't implement +} + +#[allow(dead_code)] +fn test_one_bound(t: T) { + println!("{:?}", t); + //~^ ERROR doesn't implement +} + +#[allow(dead_code)] +fn test_no_bounds_where(x: X, y: Y) where X: std::fmt::Debug { + println!("{:?} {:?}", x, y); + //~^ ERROR doesn't implement +} + +#[allow(dead_code)] +fn test_one_bound_where(x: X) where X: Sized { + println!("{:?}", x); + //~^ ERROR doesn't implement +} + +#[allow(dead_code)] +fn test_many_bounds_where(x: X) where X: Sized, X: Sized { + println!("{:?}", x); + //~^ ERROR doesn't implement +} + +pub fn main() { } diff --git a/src/test/ui/bound-suggestions.stderr b/src/test/ui/bound-suggestions.stderr new file mode 100644 index 0000000000000..1e85c2bf36e46 --- /dev/null +++ b/src/test/ui/bound-suggestions.stderr @@ -0,0 +1,93 @@ +error[E0277]: `impl Sized` doesn't implement `std::fmt::Debug` + --> $DIR/bound-suggestions.rs:5:22 + | +LL | println!("{:?}", t); + | ^ `impl Sized` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `impl Sized` +help: consider further restricting this bound with `+ std::fmt::Debug` + --> $DIR/bound-suggestions.rs:4:17 + | +LL | fn test_impl(t: impl Sized) { + | ^^^^^^^^^^ + = note: required by `std::fmt::Debug::fmt` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `T` doesn't implement `std::fmt::Debug` + --> $DIR/bound-suggestions.rs:11:22 + | +LL | println!("{:?}", t); + | ^ `T` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `T` +help: consider restricting this type parameter with `T: std::fmt::Debug` + --> $DIR/bound-suggestions.rs:10:19 + | +LL | fn test_no_bounds(t: T) { + | ^ + = note: required by `std::fmt::Debug::fmt` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `T` doesn't implement `std::fmt::Debug` + --> $DIR/bound-suggestions.rs:17:22 + | +LL | println!("{:?}", t); + | ^ `T` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `T` +help: consider further restricting this bound with `+ std::fmt::Debug` + --> $DIR/bound-suggestions.rs:16:22 + | +LL | fn test_one_bound(t: T) { + | ^^^^^ + = note: required by `std::fmt::Debug::fmt` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `Y` doesn't implement `std::fmt::Debug` + --> $DIR/bound-suggestions.rs:23:30 + | +LL | println!("{:?} {:?}", x, y); + | ^ `Y` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `Y` +help: consider restricting this type parameter with `where Y: std::fmt::Debug` + --> $DIR/bound-suggestions.rs:22:28 + | +LL | fn test_no_bounds_where(x: X, y: Y) where X: std::fmt::Debug { + | ^ + = note: required by `std::fmt::Debug::fmt` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `X` doesn't implement `std::fmt::Debug` + --> $DIR/bound-suggestions.rs:29:22 + | +LL | println!("{:?}", x); + | ^ `X` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `X` +help: consider further restricting this bound with `+ std::fmt::Debug` + --> $DIR/bound-suggestions.rs:28:40 + | +LL | fn test_one_bound_where(x: X) where X: Sized { + | ^^^^^^^^ + = note: required by `std::fmt::Debug::fmt` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `X` doesn't implement `std::fmt::Debug` + --> $DIR/bound-suggestions.rs:35:22 + | +LL | println!("{:?}", x); + | ^ `X` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `X` +help: consider further restricting this type parameter with `where X: std::fmt::Debug` + --> $DIR/bound-suggestions.rs:34:27 + | +LL | fn test_many_bounds_where(x: X) where X: Sized, X: Sized { + | ^ + = note: required by `std::fmt::Debug::fmt` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr index 5be6ab05d6607..a38705c834a37 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr @@ -2,22 +2,28 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/builtin-superkinds-double-superkind.rs:6:24 | LL | impl Foo for (T,) { } - | -- ^^^ `T` cannot be sent between threads safely - | | - | help: consider further restricting this bound: `T: std::marker::Send +` + | ^^^ `T` cannot be sent between threads safely | = help: within `(T,)`, the trait `std::marker::Send` is not implemented for `T` +help: consider further restricting this bound with `+ std::marker::Send` + --> $DIR/builtin-superkinds-double-superkind.rs:6:10 + | +LL | impl Foo for (T,) { } + | ^^^^^^^^^^^^ = note: required because it appears within the type `(T,)` error[E0277]: `T` cannot be shared between threads safely --> $DIR/builtin-superkinds-double-superkind.rs:9:16 | LL | impl Foo for (T,T) { } - | -- ^^^ `T` cannot be shared between threads safely - | | - | help: consider further restricting this bound: `T: std::marker::Sync +` + | ^^^ `T` cannot be shared between threads safely | = help: within `(T, T)`, the trait `std::marker::Sync` is not implemented for `T` +help: consider further restricting this bound with `+ std::marker::Sync` + --> $DIR/builtin-superkinds-double-superkind.rs:9:10 + | +LL | impl Foo for (T,T) { } + | ^^^^ = note: required because it appears within the type `(T, T)` error: aborting due to 2 previous errors diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr index 8cce9bfdf52a8..f379d97bd76c8 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr @@ -2,11 +2,14 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/builtin-superkinds-in-metadata.rs:13:23 | LL | impl RequiresRequiresShareAndSend for X { } - | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be sent between threads safely - | | - | help: consider further restricting this bound: `T: std::marker::Send +` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be sent between threads safely | = help: within `X`, the trait `std::marker::Send` is not implemented for `T` +help: consider further restricting this bound with `+ std::marker::Send` + --> $DIR/builtin-superkinds-in-metadata.rs:13:9 + | +LL | impl RequiresRequiresShareAndSend for X { } + | ^^^^^^^^^^^^ = note: required because it appears within the type `X` error: aborting due to previous error diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr index 4381a5b868262..996f39bfb665c 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr @@ -2,11 +2,14 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/builtin-superkinds-typaram-not-send.rs:5:24 | LL | impl Foo for T { } - | -- ^^^ `T` cannot be sent between threads safely - | | - | help: consider further restricting this bound: `T: std::marker::Send +` + | ^^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` +help: consider further restricting this bound with `+ std::marker::Send` + --> $DIR/builtin-superkinds-typaram-not-send.rs:5:10 + | +LL | impl Foo for T { } + | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr b/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr index 0834014b31c35..b4135af7d7755 100644 --- a/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr +++ b/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr @@ -5,11 +5,14 @@ LL | struct X where F: FnOnce() + 'static + Send { | ---------------------------------------------- required by `X` ... LL | fn foo(blk: F) -> X where F: FnOnce() + 'static { - | ^^^^ - help: consider further restricting type parameter `F`: `, F: std::marker::Send` - | | - | `F` cannot be sent between threads safely + | ^^^^ `F` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `F` +help: consider further restricting this bound with `+ std::marker::Send` + --> $DIR/closure-bounds-cant-promote-superkind-in-struct.rs:5:33 + | +LL | fn foo(blk: F) -> X where F: FnOnce() + 'static { + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/closures/closure-bounds-subtype.stderr b/src/test/ui/closures/closure-bounds-subtype.stderr index 05d5bb1e8d5a8..47504de814dbe 100644 --- a/src/test/ui/closures/closure-bounds-subtype.stderr +++ b/src/test/ui/closures/closure-bounds-subtype.stderr @@ -4,13 +4,15 @@ error[E0277]: `F` cannot be shared between threads safely LL | fn take_const_owned(_: F) where F: FnOnce() + Sync + Send { | ---------------- ---- required by this bound in `take_const_owned` ... -LL | fn give_owned(f: F) where F: FnOnce() + Send { - | - help: consider further restricting type parameter `F`: `, F: std::marker::Sync` -LL | take_any(f); LL | take_const_owned(f); | ^ `F` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `F` +help: consider further restricting this bound with `+ std::marker::Sync` + --> $DIR/closure-bounds-subtype.rs:11:30 + | +LL | fn give_owned(f: F) where F: FnOnce() + Send { + | ^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/closures/issue-67123.stderr b/src/test/ui/closures/issue-67123.stderr index b2e875b8010ef..f14478d7278cd 100644 --- a/src/test/ui/closures/issue-67123.stderr +++ b/src/test/ui/closures/issue-67123.stderr @@ -1,13 +1,16 @@ error[E0382]: use of moved value: `t` --> $DIR/issue-67123.rs:2:13 | -LL | fn foo(t: T) { - | - help: consider restricting this bound: `T: Copy` LL | || { t; t; }; | - ^ value used here after move | | | value moved here | +help: consider restricting this type parameter with `T: Copy` + --> $DIR/issue-67123.rs:1:8 + | +LL | fn foo(t: T) { + | ^ = note: move occurs because `t` has type `T`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/impl_bounds.stderr b/src/test/ui/generic-associated-types/impl_bounds.stderr index ca2350ff7577f..486b538045e49 100644 --- a/src/test/ui/generic-associated-types/impl_bounds.stderr +++ b/src/test/ui/generic-associated-types/impl_bounds.stderr @@ -31,12 +31,14 @@ LL | type B<'a, 'b> where 'b: 'a = (&'a(), &'b ()); error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/impl_bounds.rs:19:5 | -LL | impl Foo for Fooy { - | - help: consider restricting this bound: `T: std::marker::Copy` -... LL | type C where Self: Copy = String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/impl_bounds.rs:14:6 + | +LL | impl Foo for Fooy { + | ^ = note: required because of the requirements on the impl of `std::marker::Copy` for `Fooy` = note: the requirement `Fooy: std::marker::Copy` appears on the associated impl type but not on the corresponding associated trait type diff --git a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr index 5c38f47b363e9..6307a9b380ebf 100644 --- a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr +++ b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr @@ -6,11 +6,14 @@ LL | fn want_bar_for_any_ccx(b: &B) LL | where B : for<'ccx> Bar<'ccx> | ------------------- required by this bound in `want_bar_for_any_ccx` ... -LL | where B : Qux - | - help: consider further restricting type parameter `B`: `, B: for<'ccx> Bar<'ccx>` -... LL | want_bar_for_any_ccx(b); | ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` + | +help: consider further restricting this bound with `+ for<'ccx> Bar<'ccx>` + --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:44:11 + | +LL | where B : Qux + | ^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr index 768bc6c71847f..762c7c05f7ae8 100644 --- a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr +++ b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr @@ -1,9 +1,6 @@ error[E0277]: the trait bound `for<'tcx> F: Foo<'tcx>` is not satisfied --> $DIR/hrtb-higher-ranker-supertraits.rs:18:26 | -LL | where F : Foo<'x> - | - help: consider further restricting type parameter `F`: `, F: for<'tcx> Foo<'tcx>` -... LL | want_foo_for_any_tcx(f); | ^ the trait `for<'tcx> Foo<'tcx>` is not implemented for `F` ... @@ -11,13 +8,16 @@ LL | fn want_foo_for_any_tcx(f: &F) | -------------------- LL | where F : for<'tcx> Foo<'tcx> | ------------------- required by this bound in `want_foo_for_any_tcx` + | +help: consider further restricting this bound with `+ for<'tcx> Foo<'tcx>` + --> $DIR/hrtb-higher-ranker-supertraits.rs:15:11 + | +LL | where F : Foo<'x> + | ^^^^^^^^^^^ error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied --> $DIR/hrtb-higher-ranker-supertraits.rs:35:26 | -LL | where B : Bar<'x> - | - help: consider further restricting type parameter `B`: `, B: for<'ccx> Bar<'ccx>` -... LL | want_bar_for_any_ccx(b); | ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` ... @@ -25,6 +25,12 @@ LL | fn want_bar_for_any_ccx(b: &B) | -------------------- LL | where B : for<'ccx> Bar<'ccx> | ------------------- required by this bound in `want_bar_for_any_ccx` + | +help: consider further restricting this bound with `+ for<'ccx> Bar<'ccx>` + --> $DIR/hrtb-higher-ranker-supertraits.rs:29:11 + | +LL | where B : Bar<'x> + | ^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/impl-trait/issue-55872-1.stderr b/src/test/ui/impl-trait/issue-55872-1.stderr index 0d8ee61b5ba13..d62b8b1c253ea 100644 --- a/src/test/ui/impl-trait/issue-55872-1.stderr +++ b/src/test/ui/impl-trait/issue-55872-1.stderr @@ -1,11 +1,14 @@ error[E0277]: the trait bound `S: std::marker::Copy` is not satisfied in `(S, T)` --> $DIR/issue-55872-1.rs:12:5 | -LL | impl Bar for S { - | -- help: consider further restricting this bound: `S: std::marker::Copy +` LL | type E = impl Copy; | ^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `S` | +help: consider further restricting this bound with `+ std::marker::Copy` + --> $DIR/issue-55872-1.rs:11:9 + | +LL | impl Bar for S { + | ^^^^^^^ = note: required because it appears within the type `(S, T)` = note: the return type of a function must have a statically known size @@ -14,10 +17,12 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied in `(S, T) | LL | type E = impl Copy; | ^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `T` -... -LL | fn foo() -> Self::E { - | -- help: consider further restricting this bound: `T: std::marker::Copy +` | +help: consider further restricting this bound with `+ std::marker::Copy` + --> $DIR/issue-55872-1.rs:16:15 + | +LL | fn foo() -> Self::E { + | ^^^^^^^ = note: required because it appears within the type `(S, T)` = note: the return type of a function must have a statically known size diff --git a/src/test/ui/issues/issue-21837.stderr b/src/test/ui/issues/issue-21837.stderr index 50fdf2d6185be..cfc294b5fa2d7 100644 --- a/src/test/ui/issues/issue-21837.stderr +++ b/src/test/ui/issues/issue-21837.stderr @@ -5,9 +5,13 @@ LL | pub struct Foo(T); | ---------------------------- required by `Foo` ... LL | impl Trait2 for Foo {} - | - ^^^^^^ the trait `Bound` is not implemented for `T` - | | - | help: consider restricting this bound: `T: Bound` + | ^^^^^^ the trait `Bound` is not implemented for `T` + | +help: consider restricting this type parameter with `T: Bound` + --> $DIR/issue-21837.rs:8:6 + | +LL | impl Trait2 for Foo {} + | ^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-34721.stderr b/src/test/ui/issues/issue-34721.stderr index 3002b07e8c909..5c51d0444461a 100644 --- a/src/test/ui/issues/issue-34721.stderr +++ b/src/test/ui/issues/issue-34721.stderr @@ -2,9 +2,7 @@ error[E0382]: use of moved value: `x` --> $DIR/issue-34721.rs:27:9 | LL | pub fn baz(x: T) -> T { - | -- - move occurs because `x` has type `T`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `T: Copy +` + | - move occurs because `x` has type `T`, which does not implement the `Copy` trait LL | if 0 == 1 { LL | bar::bar(x.zero()) | - value moved here @@ -14,6 +12,12 @@ LL | x.zero() LL | }; LL | x.zero() | ^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/issue-34721.rs:21:19 + | +LL | pub fn baz(x: T) -> T { + | ^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-38954.stderr b/src/test/ui/issues/issue-38954.stderr index a74d6353c31f4..d3168ef9e4aaf 100644 --- a/src/test/ui/issues/issue-38954.stderr +++ b/src/test/ui/issues/issue-38954.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/issue-38954.rs:1:23 + --> $DIR/issue-38954.rs:1:10 | LL | fn _test(ref _p: str) {} - | ^ doesn't have a size known at compile-time + | ^^^^^^ 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 diff --git a/src/test/ui/issues/issue-41229-ref-str.stderr b/src/test/ui/issues/issue-41229-ref-str.stderr index bcca911c5a5c8..9d854e4be9ead 100644 --- a/src/test/ui/issues/issue-41229-ref-str.stderr +++ b/src/test/ui/issues/issue-41229-ref-str.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/issue-41229-ref-str.rs:1:28 + --> $DIR/issue-41229-ref-str.rs:1:16 | LL | pub fn example(ref s: str) {} - | ^ doesn't have a size known at compile-time + | ^^^^^ 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 diff --git a/src/test/ui/issues/issue-42312.stderr b/src/test/ui/issues/issue-42312.stderr index 6688203147eaf..915bfffd6d592 100644 --- a/src/test/ui/issues/issue-42312.stderr +++ b/src/test/ui/issues/issue-42312.stderr @@ -1,10 +1,10 @@ error[E0277]: the size for values of type `::Target` cannot be known at compilation time - --> $DIR/issue-42312.rs:4:29 + --> $DIR/issue-42312.rs:4:12 | LL | fn baz(_: Self::Target) where Self: Deref {} - | ^ - help: consider further restricting the associated type: `, ::Target: std::marker::Sized` - | | - | doesn't have a size known at compile-time + | ^ - help: consider further restricting the associated type: `, ::Target: std::marker::Sized` + | | + | doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `::Target` = note: to learn more, visit @@ -12,10 +12,10 @@ LL | fn baz(_: Self::Target) where Self: Deref {} = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `(dyn std::string::ToString + 'static)` cannot be known at compilation time - --> $DIR/issue-42312.rs:8:27 + --> $DIR/issue-42312.rs:8:10 | LL | pub fn f(_: dyn ToString) {} - | ^ doesn't have a size known at compile-time + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::string::ToString + 'static)` = note: to learn more, visit diff --git a/src/test/ui/issues/issue-43784-associated-type.stderr b/src/test/ui/issues/issue-43784-associated-type.stderr index 393b012f5f8a7..2f50a53f26c77 100644 --- a/src/test/ui/issues/issue-43784-associated-type.stderr +++ b/src/test/ui/issues/issue-43784-associated-type.stderr @@ -5,12 +5,15 @@ LL | type Assoc: Partial; | ----- associated type defined here ... LL | impl Complete for T { - | ---------------------- - | | | - | | help: consider restricting this bound: `T: std::marker::Copy` - | in this `impl` item + | ---------------------- in this `impl` item LL | type Assoc = T; | ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/issue-43784-associated-type.rs:13:6 + | +LL | impl Complete for T { + | ^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-43784-supertrait.stderr b/src/test/ui/issues/issue-43784-supertrait.stderr index 5ac32041bce48..1795db32a57bd 100644 --- a/src/test/ui/issues/issue-43784-supertrait.stderr +++ b/src/test/ui/issues/issue-43784-supertrait.stderr @@ -2,9 +2,13 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/issue-43784-supertrait.rs:8:9 | LL | impl Complete for T {} - | - ^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` - | | - | help: consider restricting this bound: `T: std::marker::Copy` + | ^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/issue-43784-supertrait.rs:8:6 + | +LL | impl Complete for T {} + | ^ error: aborting due to previous error diff --git a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr index 82efa83990553..593f55a5172d8 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr @@ -1,50 +1,58 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | fn f(val: T) { - | - help: consider restricting this bound: `T: std::marker::Send` -LL | let t: S = S(marker::PhantomData); LL | let a = &t as &dyn Gettable; | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` +help: consider restricting this type parameter with `T: std::marker::Send` + --> $DIR/kindck-impl-type-params.rs:16:6 + | +LL | fn f(val: T) { + | ^ = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | fn f(val: T) { - | - help: consider restricting this bound: `T: std::marker::Copy` -LL | let t: S = S(marker::PhantomData); LL | let a = &t as &dyn Gettable; | ^^ the trait `std::marker::Copy` is not implemented for `T` | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/kindck-impl-type-params.rs:16:6 + | +LL | fn f(val: T) { + | ^ = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` error[E0277]: `T` cannot be sent between threads safely --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | fn g(val: T) { - | - help: consider restricting this bound: `T: std::marker::Send` -LL | let t: S = S(marker::PhantomData); LL | let a: &dyn Gettable = &t; | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` +help: consider restricting this type parameter with `T: std::marker::Send` + --> $DIR/kindck-impl-type-params.rs:23:6 + | +LL | fn g(val: T) { + | ^ = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | fn g(val: T) { - | - help: consider restricting this bound: `T: std::marker::Copy` -LL | let t: S = S(marker::PhantomData); LL | let a: &dyn Gettable = &t; | ^^ the trait `std::marker::Copy` is not implemented for `T` | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/kindck-impl-type-params.rs:23:6 + | +LL | fn g(val: T) { + | ^ = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` diff --git a/src/test/ui/kindck/kindck-impl-type-params.stderr b/src/test/ui/kindck/kindck-impl-type-params.stderr index 2075fdd311e61..42318623b4d24 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.stderr @@ -1,50 +1,58 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | fn f(val: T) { - | - help: consider restricting this bound: `T: std::marker::Send` -LL | let t: S = S(marker::PhantomData); LL | let a = &t as &dyn Gettable; | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` +help: consider restricting this type parameter with `T: std::marker::Send` + --> $DIR/kindck-impl-type-params.rs:16:6 + | +LL | fn f(val: T) { + | ^ = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | fn f(val: T) { - | - help: consider restricting this bound: `T: std::marker::Copy` -LL | let t: S = S(marker::PhantomData); LL | let a = &t as &dyn Gettable; | ^^ the trait `std::marker::Copy` is not implemented for `T` | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/kindck-impl-type-params.rs:16:6 + | +LL | fn f(val: T) { + | ^ = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` error[E0277]: `T` cannot be sent between threads safely --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | fn g(val: T) { - | - help: consider restricting this bound: `T: std::marker::Send` -LL | let t: S = S(marker::PhantomData); LL | let a: &dyn Gettable = &t; | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` +help: consider restricting this type parameter with `T: std::marker::Send` + --> $DIR/kindck-impl-type-params.rs:23:6 + | +LL | fn g(val: T) { + | ^ = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | fn g(val: T) { - | - help: consider restricting this bound: `T: std::marker::Copy` -LL | let t: S = S(marker::PhantomData); LL | let a: &dyn Gettable = &t; | ^^ the trait `std::marker::Copy` is not implemented for `T` | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/kindck-impl-type-params.rs:23:6 + | +LL | fn g(val: T) { + | ^ = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` diff --git a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr index ead2cceebf857..552273b8ba927 100644 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr +++ b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr @@ -11,13 +11,17 @@ error[E0382]: borrow of moved value: `f` --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:32:5 | LL | fn conspirator(mut f: F) where F: FnMut(&mut R, bool) { - | ----- - help: consider further restricting type parameter `F`: `, F: Copy` - | | - | move occurs because `f` has type `F`, which does not implement the `Copy` trait + | ----- move occurs because `f` has type `F`, which does not implement the `Copy` trait LL | let mut r = R {c: Box::new(f)}; | - value moved here LL | f(&mut r, false) | ^ value borrowed here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:30:35 + | +LL | fn conspirator(mut f: F) where F: FnMut(&mut R, bool) { + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/once-cant-call-twice-on-heap.stderr b/src/test/ui/once-cant-call-twice-on-heap.stderr index fd99806021856..d4884469ce4d2 100644 --- a/src/test/ui/once-cant-call-twice-on-heap.stderr +++ b/src/test/ui/once-cant-call-twice-on-heap.stderr @@ -2,13 +2,17 @@ error[E0382]: use of moved value: `blk` --> $DIR/once-cant-call-twice-on-heap.rs:9:5 | LL | fn foo(blk: F) { - | -- --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `F: Copy +` + | --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait LL | blk(); | --- value moved here LL | blk(); | ^^^ value used here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/once-cant-call-twice-on-heap.rs:7:10 + | +LL | fn foo(blk: F) { + | ^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/phantom-oibit.stderr b/src/test/ui/phantom-oibit.stderr index 4d9d06b8986d5..7b6b105eb032b 100644 --- a/src/test/ui/phantom-oibit.stderr +++ b/src/test/ui/phantom-oibit.stderr @@ -3,13 +3,16 @@ error[E0277]: `T` cannot be shared between threads safely | LL | fn is_zen(_: T) {} | ------ --- required by this bound in `is_zen` -LL | -LL | fn not_sync(x: Guard) { - | - help: consider restricting this bound: `T: std::marker::Sync` +... LL | is_zen(x) | ^ `T` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `T` +help: consider restricting this type parameter with `T: std::marker::Sync` + --> $DIR/phantom-oibit.rs:20:13 + | +LL | fn not_sync(x: Guard) { + | ^ = note: required because of the requirements on the impl of `Zen` for `&T` = note: required because it appears within the type `std::marker::PhantomData<&T>` = note: required because it appears within the type `Guard<'_, T>` @@ -20,12 +23,15 @@ error[E0277]: `T` cannot be shared between threads safely LL | fn is_zen(_: T) {} | ------ --- required by this bound in `is_zen` ... -LL | fn nested_not_sync(x: Nested>) { - | - help: consider restricting this bound: `T: std::marker::Sync` LL | is_zen(x) | ^ `T` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `T` +help: consider restricting this type parameter with `T: std::marker::Sync` + --> $DIR/phantom-oibit.rs:25:20 + | +LL | fn nested_not_sync(x: Nested>) { + | ^ = note: required because of the requirements on the impl of `Zen` for `&T` = note: required because it appears within the type `std::marker::PhantomData<&T>` = note: required because it appears within the type `Guard<'_, T>` diff --git a/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr b/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr index 5275b7b1ddfa5..ee7c002b16db1 100644 --- a/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr +++ b/src/test/ui/specialization/defaultimpl/specialization-wfcheck.stderr @@ -2,9 +2,13 @@ error[E0277]: the trait bound `U: std::cmp::Eq` is not satisfied --> $DIR/specialization-wfcheck.rs:7:17 | LL | default impl Foo<'static, U> for () {} - | - ^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `U` - | | - | help: consider restricting this bound: `U: std::cmp::Eq` + | ^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `U` + | +help: consider restricting this type parameter with `U: std::cmp::Eq` + --> $DIR/specialization-wfcheck.rs:7:14 + | +LL | default impl Foo<'static, U> for () {} + | ^ error: aborting due to previous error diff --git a/src/test/ui/suggestions/restrict-type-argument.stderr b/src/test/ui/suggestions/restrict-type-argument.stderr index d6840ca4d7265..4d5cb8907e887 100644 --- a/src/test/ui/suggestions/restrict-type-argument.stderr +++ b/src/test/ui/suggestions/restrict-type-argument.stderr @@ -3,13 +3,16 @@ error[E0277]: `impl Sync` cannot be sent between threads safely | LL | fn is_send(val: T) {} | ------- ---- required by this bound in `is_send` -LL | -LL | fn use_impl_sync(val: impl Sync) { - | --------- help: consider further restricting this bound: `impl Sync + std::marker::Send` +... LL | is_send(val); | ^^^ `impl Sync` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `impl Sync` +help: consider further restricting this bound with `+ std::marker::Send` + --> $DIR/restrict-type-argument.rs:3:23 + | +LL | fn use_impl_sync(val: impl Sync) { + | ^^^^^^^^^ error[E0277]: `S` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:8:13 @@ -17,12 +20,15 @@ error[E0277]: `S` cannot be sent between threads safely LL | fn is_send(val: T) {} | ------- ---- required by this bound in `is_send` ... -LL | fn use_where(val: S) where S: Sync { - | - help: consider further restricting type parameter `S`: `, S: std::marker::Send` LL | is_send(val); | ^^^ `S` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `S` +help: consider further restricting this bound with `+ std::marker::Send` + --> $DIR/restrict-type-argument.rs:7:31 + | +LL | fn use_where(val: S) where S: Sync { + | ^^^^^^^ error[E0277]: `S` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:12:13 @@ -30,27 +36,31 @@ error[E0277]: `S` cannot be sent between threads safely LL | fn is_send(val: T) {} | ------- ---- required by this bound in `is_send` ... -LL | fn use_bound(val: S) { - | -- help: consider further restricting this bound: `S: std::marker::Send +` LL | is_send(val); | ^^^ `S` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `S` +help: consider further restricting this bound with `+ std::marker::Send` + --> $DIR/restrict-type-argument.rs:11:17 + | +LL | fn use_bound(val: S) { + | ^^^^ error[E0277]: `S` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:20:13 | -LL | fn is_send(val: T) {} - | ------- ---- required by this bound in `is_send` -... -LL | / S // Make sure we can synthezise a correct suggestion span for this case -LL | | : - | |_____- help: consider further restricting this bound: `S: std::marker::Send +` +LL | fn is_send(val: T) {} + | ------- ---- required by this bound in `is_send` ... -LL | is_send(val); - | ^^^ `S` cannot be sent between threads safely +LL | is_send(val); + | ^^^ `S` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `S` +help: consider further restricting this bound with `+ std::marker::Send` + --> $DIR/restrict-type-argument.rs:18:5 + | +LL | Sync + | ^^^^ error[E0277]: `S` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:24:13 @@ -58,12 +68,15 @@ error[E0277]: `S` cannot be sent between threads safely LL | fn is_send(val: T) {} | ------- ---- required by this bound in `is_send` ... -LL | fn use_bound_and_where(val: S) where S: std::fmt::Debug { - | - help: consider further restricting type parameter `S`: `, S: std::marker::Send` LL | is_send(val); | ^^^ `S` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `S` +help: consider further restricting this bound with `+ std::marker::Send` + --> $DIR/restrict-type-argument.rs:23:47 + | +LL | fn use_bound_and_where(val: S) where S: std::fmt::Debug { + | ^^^^^^^^^^^^^^^^^^ error[E0277]: `S` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:28:13 @@ -71,12 +84,15 @@ error[E0277]: `S` cannot be sent between threads safely LL | fn is_send(val: T) {} | ------- ---- required by this bound in `is_send` ... -LL | fn use_unbound(val: S) { - | - help: consider restricting this bound: `S: std::marker::Send` LL | is_send(val); | ^^^ `S` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `S` +help: consider restricting this type parameter with `S: std::marker::Send` + --> $DIR/restrict-type-argument.rs:27:16 + | +LL | fn use_unbound(val: S) { + | ^ error: aborting due to 6 previous errors diff --git a/src/test/ui/suggestions/suggest-remove-refs-1.stderr b/src/test/ui/suggestions/suggest-remove-refs-1.stderr index bfc313cabdc44..fcaddd40d263b 100644 --- a/src/test/ui/suggestions/suggest-remove-refs-1.stderr +++ b/src/test/ui/suggestions/suggest-remove-refs-1.stderr @@ -5,7 +5,7 @@ LL | for (i, n) in &v.iter().enumerate() { | -^^^^^^^^^^^^^^^^^^^^ | | | `&std::iter::Enumerate>` is not an iterator - | help: consider removing 1 leading `&`-references + | help: consider removing the leading `&`-reference | = help: the trait `std::iter::Iterator` is not implemented for `&std::iter::Enumerate>` = note: required by `std::iter::IntoIterator::into_iter` diff --git a/src/test/ui/traits/trait-alias/trait-alias-wf.stderr b/src/test/ui/traits/trait-alias/trait-alias-wf.stderr index b71c0d719ff3f..e7ed16a02a3f0 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-wf.stderr +++ b/src/test/ui/traits/trait-alias/trait-alias-wf.stderr @@ -4,9 +4,13 @@ error[E0277]: the trait bound `T: Foo` is not satisfied LL | trait A {} | --------------- required by `A` LL | trait B = A; - | - ^^^^ the trait `Foo` is not implemented for `T` - | | - | help: consider restricting this bound: `T: Foo` + | ^^^^ the trait `Foo` is not implemented for `T` + | +help: consider restricting this type parameter with `T: Foo` + --> $DIR/trait-alias-wf.rs:5:9 + | +LL | trait B = A; + | ^ error: aborting due to previous error diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr index 96bbd1f3e4f17..56a9e3ff54ec2 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr @@ -5,9 +5,13 @@ LL | struct Foo { | ------------------- required by `Foo` ... LL | impl Foo { - | - ^^^^^^ the trait `Trait` is not implemented for `T` - | | - | help: consider restricting this bound: `T: Trait` + | ^^^^^^ the trait `Trait` is not implemented for `T` + | +help: consider restricting this type parameter with `T: Trait` + --> $DIR/trait-bounds-on-structs-and-enums.rs:13:6 + | +LL | impl Foo { + | ^ error[E0277]: the trait bound `isize: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:19:5 @@ -33,10 +37,14 @@ error[E0277]: the trait bound `U: Trait` is not satisfied LL | struct Foo { | ------------------- required by `Foo` ... -LL | struct Badness { - | - help: consider restricting this bound: `U: Trait` LL | b: Foo, | ^^^^^^^^^ the trait `Trait` is not implemented for `U` + | +help: consider restricting this type parameter with `U: Trait` + --> $DIR/trait-bounds-on-structs-and-enums.rs:26:16 + | +LL | struct Badness { + | ^ error[E0277]: the trait bound `V: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:31:21 @@ -44,10 +52,14 @@ error[E0277]: the trait bound `V: Trait` is not satisfied LL | enum Bar { | ----------------- required by `Bar` ... -LL | enum MoreBadness { - | - help: consider restricting this bound: `V: Trait` LL | EvenMoreBadness(Bar), | ^^^^^^ the trait `Trait` is not implemented for `V` + | +help: consider restricting this type parameter with `V: Trait` + --> $DIR/trait-bounds-on-structs-and-enums.rs:30:18 + | +LL | enum MoreBadness { + | ^ error[E0277]: the trait bound `i32: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:35:5 diff --git a/src/test/ui/traits/traits-repeated-supertrait-ambig.stderr b/src/test/ui/traits/traits-repeated-supertrait-ambig.stderr index 85c7a55c31379..5b7f32ba1e0f0 100644 --- a/src/test/ui/traits/traits-repeated-supertrait-ambig.stderr +++ b/src/test/ui/traits/traits-repeated-supertrait-ambig.stderr @@ -7,10 +7,14 @@ LL | c.same_as(22) error[E0277]: the trait bound `C: CompareTo` is not satisfied --> $DIR/traits-repeated-supertrait-ambig.rs:30:7 | -LL | fn with_trait(c: &C) -> bool { - | -- help: consider further restricting this bound: `C: CompareTo +` LL | c.same_as(22) | ^^^^^^^ the trait `CompareTo` is not implemented for `C` + | +help: consider further restricting this bound with `+ CompareTo` + --> $DIR/traits-repeated-supertrait-ambig.rs:29:17 + | +LL | fn with_trait(c: &C) -> bool { + | ^^^^^^^^^^^^^ error[E0277]: the trait bound `dyn CompareToInts: CompareTo` is not satisfied --> $DIR/traits-repeated-supertrait-ambig.rs:34:5 @@ -27,10 +31,14 @@ error[E0277]: the trait bound `C: CompareTo` is not satisfied LL | fn same_as(&self, t: T) -> bool; | -------------------------------- required by `CompareTo::same_as` ... -LL | fn with_ufcs2(c: &C) -> bool { - | -- help: consider further restricting this bound: `C: CompareTo +` LL | CompareTo::same_as(c, 22) | ^^^^^^^^^^^^^^^^^^ the trait `CompareTo` is not implemented for `C` + | +help: consider further restricting this bound with `+ CompareTo` + --> $DIR/traits-repeated-supertrait-ambig.rs:37:17 + | +LL | fn with_ufcs2(c: &C) -> bool { + | ^^^^^^^^^^^^^ error[E0277]: the trait bound `i64: CompareTo` is not satisfied --> $DIR/traits-repeated-supertrait-ambig.rs:42:23 diff --git a/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr b/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr index 1eb4cf2a80255..74b858105b92f 100644 --- a/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr +++ b/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr @@ -3,9 +3,12 @@ error[E0277]: the trait bound `T: TraitWithAssoc` is not satisfied | LL | type Foo = impl Trait; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TraitWithAssoc` is not implemented for `T` -... + | +help: consider further restricting this bound with `+ TraitWithAssoc` + --> $DIR/bound_reduction2.rs:18:21 + | LL | fn foo_desugared(_: T) -> Foo { - | -- help: consider further restricting this bound: `T: TraitWithAssoc +` + | ^^^^^^^^^^^^^^ error: defining opaque type use does not fully define opaque type: generic parameter `V` is specified as concrete type `::Assoc` --> $DIR/bound_reduction2.rs:18:1 diff --git a/src/test/ui/type-alias-impl-trait/generic_underconstrained.stderr b/src/test/ui/type-alias-impl-trait/generic_underconstrained.stderr index 5f04391d7537f..299c7eae8d3a8 100644 --- a/src/test/ui/type-alias-impl-trait/generic_underconstrained.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_underconstrained.stderr @@ -9,10 +9,12 @@ error[E0277]: the trait bound `T: Trait` is not satisfied | LL | type Underconstrained = impl 'static; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` -... -LL | fn underconstrain(_: T) -> Underconstrained { - | - help: consider restricting this bound: `T: Trait` | +help: consider restricting this type parameter with `T: Trait` + --> $DIR/generic_underconstrained.rs:10:19 + | +LL | fn underconstrain(_: T) -> Underconstrained { + | ^ = note: the return type of a function must have a statically known size error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/generic_underconstrained2.stderr b/src/test/ui/type-alias-impl-trait/generic_underconstrained2.stderr index 9e8414f9c15fe..56966a32b43b2 100644 --- a/src/test/ui/type-alias-impl-trait/generic_underconstrained2.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_underconstrained2.stderr @@ -16,12 +16,15 @@ error[E0277]: `U` doesn't implement `std::fmt::Debug` LL | type Underconstrained = impl 'static; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` ... -LL | fn underconstrained(_: U) -> Underconstrained { - | - help: consider restricting this bound: `U: std::fmt::Debug` LL | 5u32 | ---- this returned value is of type `u32` | = help: the trait `std::fmt::Debug` is not implemented for `U` +help: consider restricting this type parameter with `U: std::fmt::Debug` + --> $DIR/generic_underconstrained2.rs:10:21 + | +LL | fn underconstrained(_: U) -> Underconstrained { + | ^ = note: the return type of a function must have a statically known size error[E0277]: `V` doesn't implement `std::fmt::Debug` @@ -30,12 +33,15 @@ error[E0277]: `V` doesn't implement `std::fmt::Debug` LL | type Underconstrained2 = impl 'static; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` ... -LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { - | - help: consider restricting this bound: `V: std::fmt::Debug` LL | 5u32 | ---- this returned value is of type `u32` | = help: the trait `std::fmt::Debug` is not implemented for `V` +help: consider restricting this type parameter with `V: std::fmt::Debug` + --> $DIR/generic_underconstrained2.rs:19:25 + | +LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { + | ^ = note: the return type of a function must have a statically known size error: aborting due to 4 previous errors diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index e5d2ebda31858..31ee15e0745db 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -52,9 +52,13 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied LL | trait Super { } | -------------------- required by `Super` LL | trait Base: Super { } - | - ^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` - | | - | help: consider restricting this bound: `T: std::marker::Copy` + | ^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/type-check-defaults.rs:21:12 + | +LL | trait Base: Super { } + | ^ error[E0277]: cannot add `u8` to `i32` --> $DIR/type-check-defaults.rs:24:66 diff --git a/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr b/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr index a84aef5fdbdb6..45c9d8be85ee9 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr @@ -1,8 +1,6 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/typeck-default-trait-impl-send-param.rs:5:15 | -LL | fn foo() { - | - help: consider restricting this bound: `T: std::marker::Send` LL | is_send::() | ^ `T` cannot be sent between threads safely ... @@ -10,6 +8,11 @@ LL | fn is_send() { | ------- ---- required by this bound in `is_send` | = help: the trait `std::marker::Send` is not implemented for `T` +help: consider restricting this type parameter with `T: std::marker::Send` + --> $DIR/typeck-default-trait-impl-send-param.rs:4:8 + | +LL | fn foo() { + | ^ error: aborting due to previous error diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.stderr b/src/test/ui/typeck/typeck_type_placeholder_item.stderr index f740a9f7f34b1..95e8f94c6f3e7 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item.stderr +++ b/src/test/ui/typeck/typeck_type_placeholder_item.stderr @@ -300,10 +300,10 @@ LL | b: (T, T), | error[E0282]: type annotations needed - --> $DIR/typeck_type_placeholder_item.rs:127:27 + --> $DIR/typeck_type_placeholder_item.rs:127:18 | LL | fn fn_test11(_: _) -> (_, _) { panic!() } - | ^^^^^^ cannot infer type + | ^ cannot infer type error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:127:28 diff --git a/src/test/ui/unop-move-semantics.stderr b/src/test/ui/unop-move-semantics.stderr index 092c419d7cba8..ab641c40dfe44 100644 --- a/src/test/ui/unop-move-semantics.stderr +++ b/src/test/ui/unop-move-semantics.stderr @@ -2,14 +2,18 @@ error[E0382]: borrow of moved value: `x` --> $DIR/unop-move-semantics.rs:8:5 | LL | fn move_then_borrow + Clone>(x: T) { - | -- - move occurs because `x` has type `T`, which does not implement the `Copy` trait - | | - | help: consider further restricting this bound: `T: Copy +` + | - move occurs because `x` has type `T`, which does not implement the `Copy` trait LL | !x; | - value moved here LL | LL | x.clone(); | ^ value borrowed here after move + | +help: consider further restricting this bound with `+ Copy` + --> $DIR/unop-move-semantics.rs:5:24 + | +LL | fn move_then_borrow + Clone>(x: T) { + | ^^^^^^^^^^^^^^^^^^^^^ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/unop-move-semantics.rs:15:6 diff --git a/src/test/ui/wf/wf-enum-bound.stderr b/src/test/ui/wf/wf-enum-bound.stderr index 0d22d18bf6fd9..be64ddb975994 100644 --- a/src/test/ui/wf/wf-enum-bound.stderr +++ b/src/test/ui/wf/wf-enum-bound.stderr @@ -5,9 +5,13 @@ LL | trait ExtraCopy { } | ----------------------- required by `ExtraCopy` ... LL | where T: ExtraCopy - | ^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy` - | | - | the trait `std::marker::Copy` is not implemented for `U` + | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` + | +help: consider restricting this type parameter with `where U: std::marker::Copy` + --> $DIR/wf-enum-bound.rs:9:17 + | +LL | enum SomeEnum + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-enum-fields-struct-variant.stderr b/src/test/ui/wf/wf-enum-fields-struct-variant.stderr index 52882c460d228..40454b33b7b76 100644 --- a/src/test/ui/wf/wf-enum-fields-struct-variant.stderr +++ b/src/test/ui/wf/wf-enum-fields-struct-variant.stderr @@ -4,11 +4,14 @@ error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied LL | struct IsCopy { | --------------------- required by `IsCopy` ... -LL | enum AnotherEnum { - | - help: consider restricting this bound: `A: std::marker::Copy` -LL | AnotherVariant { LL | f: IsCopy | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` + | +help: consider restricting this type parameter with `A: std::marker::Copy` + --> $DIR/wf-enum-fields-struct-variant.rs:11:18 + | +LL | enum AnotherEnum { + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-enum-fields.stderr b/src/test/ui/wf/wf-enum-fields.stderr index 0fea35d68ea6f..e2612add776d4 100644 --- a/src/test/ui/wf/wf-enum-fields.stderr +++ b/src/test/ui/wf/wf-enum-fields.stderr @@ -4,10 +4,14 @@ error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied LL | struct IsCopy { | --------------------- required by `IsCopy` ... -LL | enum SomeEnum { - | - help: consider restricting this bound: `A: std::marker::Copy` LL | SomeVariant(IsCopy) | ^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` + | +help: consider restricting this type parameter with `A: std::marker::Copy` + --> $DIR/wf-enum-fields.rs:11:15 + | +LL | enum SomeEnum { + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-fn-where-clause.stderr b/src/test/ui/wf/wf-fn-where-clause.stderr index 1c530ece29580..2a4f2df5a8986 100644 --- a/src/test/ui/wf/wf-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-fn-where-clause.stderr @@ -5,9 +5,13 @@ LL | trait ExtraCopy { } | ----------------------- required by `ExtraCopy` LL | LL | fn foo() where T: ExtraCopy - | ^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy` - | | - | the trait `std::marker::Copy` is not implemented for `U` + | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` + | +help: consider restricting this type parameter with `where U: std::marker::Copy` + --> $DIR/wf-fn-where-clause.rs:8:10 + | +LL | fn foo() where T: ExtraCopy + | ^ error[E0277]: the size for values of type `(dyn std::marker::Copy + 'static)` cannot be known at compilation time --> $DIR/wf-fn-where-clause.rs:12:16 diff --git a/src/test/ui/wf/wf-impl-associated-type-trait.stderr b/src/test/ui/wf/wf-impl-associated-type-trait.stderr index 6d71670e6a84c..7774299b39357 100644 --- a/src/test/ui/wf/wf-impl-associated-type-trait.stderr +++ b/src/test/ui/wf/wf-impl-associated-type-trait.stderr @@ -4,10 +4,14 @@ error[E0277]: the trait bound `T: MyHash` is not satisfied LL | pub struct MySet { | -------------------------- required by `MySet` ... -LL | impl Foo for T { - | - help: consider restricting this bound: `T: MyHash` LL | type Bar = MySet; | ^^^^^^^^^^^^^^^^^^^^ the trait `MyHash` is not implemented for `T` + | +help: consider restricting this type parameter with `T: MyHash` + --> $DIR/wf-impl-associated-type-trait.rs:16:6 + | +LL | impl Foo for T { + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-in-fn-arg.stderr b/src/test/ui/wf/wf-in-fn-arg.stderr index b8e88de54c2f1..c1a6657e63be7 100644 --- a/src/test/ui/wf/wf-in-fn-arg.stderr +++ b/src/test/ui/wf/wf-in-fn-arg.stderr @@ -5,9 +5,13 @@ LL | struct MustBeCopy { | ------------------------- required by `MustBeCopy` ... LL | fn bar(_: &MustBeCopy) - | - ^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` - | | - | help: consider restricting this bound: `T: std::marker::Copy` + | ^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/wf-in-fn-arg.rs:10:8 + | +LL | fn bar(_: &MustBeCopy) + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-in-fn-ret.stderr b/src/test/ui/wf/wf-in-fn-ret.stderr index 6ca1626d3aef5..754d64df0194b 100644 --- a/src/test/ui/wf/wf-in-fn-ret.stderr +++ b/src/test/ui/wf/wf-in-fn-ret.stderr @@ -5,9 +5,13 @@ LL | struct MustBeCopy { | ------------------------- required by `MustBeCopy` ... LL | fn bar() -> MustBeCopy - | - ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` - | | - | help: consider restricting this bound: `T: std::marker::Copy` + | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/wf-in-fn-ret.rs:10:8 + | +LL | fn bar() -> MustBeCopy + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-in-fn-type-arg.stderr b/src/test/ui/wf/wf-in-fn-type-arg.stderr index db4fb9f97f52d..97a5c0fd913a4 100644 --- a/src/test/ui/wf/wf-in-fn-type-arg.stderr +++ b/src/test/ui/wf/wf-in-fn-type-arg.stderr @@ -4,11 +4,14 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied LL | struct MustBeCopy { | ------------------------- required by `MustBeCopy` ... -LL | struct Bar { - | - help: consider restricting this bound: `T: std::marker::Copy` -LL | // needs T: Copy LL | x: fn(MustBeCopy) | ^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/wf-in-fn-type-arg.rs:7:12 + | +LL | struct Bar { + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-in-fn-type-ret.stderr b/src/test/ui/wf/wf-in-fn-type-ret.stderr index 09f8aa2a20182..527b000edf883 100644 --- a/src/test/ui/wf/wf-in-fn-type-ret.stderr +++ b/src/test/ui/wf/wf-in-fn-type-ret.stderr @@ -4,11 +4,14 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied LL | struct MustBeCopy { | ------------------------- required by `MustBeCopy` ... -LL | struct Foo { - | - help: consider restricting this bound: `T: std::marker::Copy` -LL | // needs T: 'static LL | x: fn() -> MustBeCopy | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/wf-in-fn-type-ret.rs:7:12 + | +LL | struct Foo { + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-in-fn-where-clause.stderr b/src/test/ui/wf/wf-in-fn-where-clause.stderr index 495041b7dadf8..62c672a21e86e 100644 --- a/src/test/ui/wf/wf-in-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-in-fn-where-clause.stderr @@ -5,9 +5,13 @@ LL | trait MustBeCopy { | ------------------------ required by `MustBeCopy` ... LL | where T: MustBeCopy - | ^^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy` - | | - | the trait `std::marker::Copy` is not implemented for `U` + | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` + | +help: consider restricting this type parameter with `where U: std::marker::Copy` + --> $DIR/wf-in-fn-where-clause.rs:9:10 + | +LL | fn bar() + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-in-obj-type-trait.stderr b/src/test/ui/wf/wf-in-obj-type-trait.stderr index 2711820d82c65..1b6438cdc2477 100644 --- a/src/test/ui/wf/wf-in-obj-type-trait.stderr +++ b/src/test/ui/wf/wf-in-obj-type-trait.stderr @@ -4,11 +4,14 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied LL | struct MustBeCopy { | ------------------------- required by `MustBeCopy` ... -LL | struct Bar { - | - help: consider restricting this bound: `T: std::marker::Copy` -LL | // needs T: Copy LL | x: dyn Object> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/wf-in-obj-type-trait.rs:9:12 + | +LL | struct Bar { + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr b/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr index e9c1c8ddaf640..70337ee40eacf 100644 --- a/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr +++ b/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr @@ -4,10 +4,14 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied LL | trait ExtraCopy { } | ----------------------- required by `ExtraCopy` ... -LL | impl Foo { - | - help: consider restricting this bound: `U: std::marker::Copy` LL | fn foo(self) where T: ExtraCopy | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` + | +help: consider restricting this type parameter with `U: std::marker::Copy` + --> $DIR/wf-inherent-impl-method-where-clause.rs:11:8 + | +LL | impl Foo { + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-inherent-impl-where-clause.stderr b/src/test/ui/wf/wf-inherent-impl-where-clause.stderr index a4e6dce39cdcd..c26d0ef787195 100644 --- a/src/test/ui/wf/wf-inherent-impl-where-clause.stderr +++ b/src/test/ui/wf/wf-inherent-impl-where-clause.stderr @@ -5,9 +5,13 @@ LL | trait ExtraCopy { } | ----------------------- required by `ExtraCopy` ... LL | impl Foo where T: ExtraCopy - | ^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy` - | | - | the trait `std::marker::Copy` is not implemented for `U` + | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` + | +help: consider restricting this type parameter with `where U: std::marker::Copy` + --> $DIR/wf-inherent-impl-where-clause.rs:11:8 + | +LL | impl Foo where T: ExtraCopy + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-struct-bound.stderr b/src/test/ui/wf/wf-struct-bound.stderr index 3f4047d9b5609..545e4f870954c 100644 --- a/src/test/ui/wf/wf-struct-bound.stderr +++ b/src/test/ui/wf/wf-struct-bound.stderr @@ -5,9 +5,13 @@ LL | trait ExtraCopy { } | ----------------------- required by `ExtraCopy` ... LL | where T: ExtraCopy - | ^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy` - | | - | the trait `std::marker::Copy` is not implemented for `U` + | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` + | +help: consider restricting this type parameter with `where U: std::marker::Copy` + --> $DIR/wf-struct-bound.rs:9:21 + | +LL | struct SomeStruct + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-struct-field.stderr b/src/test/ui/wf/wf-struct-field.stderr index 6ac4f1e2da8d2..f0ebdfba2ffc6 100644 --- a/src/test/ui/wf/wf-struct-field.stderr +++ b/src/test/ui/wf/wf-struct-field.stderr @@ -4,10 +4,14 @@ error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied LL | struct IsCopy { | --------------------- required by `IsCopy` ... -LL | struct SomeStruct { - | - help: consider restricting this bound: `A: std::marker::Copy` LL | data: IsCopy | ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` + | +help: consider restricting this type parameter with `A: std::marker::Copy` + --> $DIR/wf-struct-field.rs:11:19 + | +LL | struct SomeStruct { + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-trait-associated-type-bound.stderr b/src/test/ui/wf/wf-trait-associated-type-bound.stderr index 3370cfc86939d..dfccd4865686e 100644 --- a/src/test/ui/wf/wf-trait-associated-type-bound.stderr +++ b/src/test/ui/wf/wf-trait-associated-type-bound.stderr @@ -3,11 +3,15 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied | LL | trait ExtraCopy { } | ----------------------- required by `ExtraCopy` -LL | -LL | trait SomeTrait { - | - help: consider restricting this bound: `T: std::marker::Copy` +... LL | type Type1: ExtraCopy; | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/wf-trait-associated-type-bound.rs:9:17 + | +LL | trait SomeTrait { + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-trait-bound.stderr b/src/test/ui/wf/wf-trait-bound.stderr index 87c33714ff879..31faa14426a1f 100644 --- a/src/test/ui/wf/wf-trait-bound.stderr +++ b/src/test/ui/wf/wf-trait-bound.stderr @@ -5,9 +5,13 @@ LL | trait ExtraCopy { } | ----------------------- required by `ExtraCopy` ... LL | where T: ExtraCopy - | ^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy` - | | - | the trait `std::marker::Copy` is not implemented for `U` + | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` + | +help: consider restricting this type parameter with `where U: std::marker::Copy` + --> $DIR/wf-trait-bound.rs:9:19 + | +LL | trait SomeTrait + | ^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-trait-superbound.stderr b/src/test/ui/wf/wf-trait-superbound.stderr index 9ea9d046b2602..372a5f8ba5db7 100644 --- a/src/test/ui/wf/wf-trait-superbound.stderr +++ b/src/test/ui/wf/wf-trait-superbound.stderr @@ -5,9 +5,13 @@ LL | trait ExtraCopy { } | ----------------------- required by `ExtraCopy` LL | LL | trait SomeTrait: ExtraCopy { - | - ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` - | | - | help: consider restricting this bound: `T: std::marker::Copy` + | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/wf-trait-superbound.rs:9:17 + | +LL | trait SomeTrait: ExtraCopy { + | ^ error: aborting due to previous error diff --git a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr index 995b544600389..c6f12e7753c82 100644 --- a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr +++ b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr @@ -4,11 +4,14 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied LL | fn require_copy(x: T) {} | ------------ ---- required by this bound in `require_copy` ... -LL | impl Foo { - | - help: consider restricting this bound: `T: std::marker::Copy` -... LL | require_copy(self.x); | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/where-clause-constraints-are-local-for-inherent-impl.rs:6:6 + | +LL | impl Foo { + | ^ error: aborting due to previous error diff --git a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr index fe575f3a28a9e..95688d6f2e485 100644 --- a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr +++ b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr @@ -4,11 +4,14 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied LL | fn require_copy(x: T) {} | ------------ ---- required by this bound in `require_copy` ... -LL | impl Foo for Bar { - | - help: consider restricting this bound: `T: std::marker::Copy` -... LL | require_copy(self.x); | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | +help: consider restricting this type parameter with `T: std::marker::Copy` + --> $DIR/where-clause-constraints-are-local-for-trait-impl.rs:11:6 + | +LL | impl Foo for Bar { + | ^ error: aborting due to previous error