Rollup merge of #151278 - estebank:issue-108894, r=davidtwco
Provide more context on trait bounds being unmet due to imperfect derive
When encountering a value that has a borrow checker error where the type was previously moved, when suggesting cloning verify that it is not already being derived. If it is, explain why the `derive(Clone)` doesn't apply:
```
note: if `TypedAddress<T>` implemented `Clone`, you could clone the value
--> $DIR/derive-clone-implicit-bound.rs:6:1
|
LL | #[derive(Clone, Copy)]
| ----- derived `Clone` adds implicit bounds on type parameters
LL | pub struct TypedAddress<T>{
| ^^^^^^^^^^^^^^^^^^^^^^^^-^
| | |
| | introduces an implicit `T: Clone` bound
| consider manually implementing `Clone` for this type
...
LL | let old = self.return_value(offset);
| ------ you could clone this value
```
When encountering a bound coming from a derive macro, suggest manual impl of the trait.
Use the span for the specific param when adding bounds in builtin derive macros, so the diagnostic will point at them as well as the derive macro itself.
```
note: required for `Id<SomeNode>` to implement `PartialEq`
--> $DIR/derive-implicit-bound.rs:5:10
|
LL | #[derive(PartialEq, Eq)]
| ^^^^^^^^^
LL | pub struct Id<T>(PhantomData<T>);
| - unsatisfied trait bound introduced in this `derive` macro
= help: consider manually implementing `PartialEq` to avoid undesired bounds
```
Mention that the trait could be manually implemented in E0599.
Fix rust-lang/rust#108894. Address rust-lang/rust#143714. Address #rust-lang/rust#146515 (but ideally would also suggest constraining the fn bound correctly as well).
This commit is contained in:
commit
7b821d1752
81 changed files with 830 additions and 368 deletions
|
|
@ -1256,7 +1256,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
self.suggest_cloning_inner(err, ty, expr);
|
||||
}
|
||||
} else if let ty::Adt(def, args) = ty.kind()
|
||||
&& def.did().as_local().is_some()
|
||||
&& let Some(local_did) = def.did().as_local()
|
||||
&& def.variants().iter().all(|variant| {
|
||||
variant
|
||||
.fields
|
||||
|
|
@ -1266,12 +1266,50 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
{
|
||||
let ty_span = self.infcx.tcx.def_span(def.did());
|
||||
let mut span: MultiSpan = ty_span.into();
|
||||
span.push_span_label(ty_span, "consider implementing `Clone` for this type");
|
||||
span.push_span_label(expr.span, "you could clone this value");
|
||||
err.span_note(
|
||||
span,
|
||||
format!("if `{ty}` implemented `Clone`, you could clone the value"),
|
||||
let mut derive_clone = false;
|
||||
self.infcx.tcx.for_each_relevant_impl(
|
||||
self.infcx.tcx.lang_items().clone_trait().unwrap(),
|
||||
ty,
|
||||
|def_id| {
|
||||
if self.infcx.tcx.is_automatically_derived(def_id) {
|
||||
derive_clone = true;
|
||||
span.push_span_label(
|
||||
self.infcx.tcx.def_span(def_id),
|
||||
"derived `Clone` adds implicit bounds on type parameters",
|
||||
);
|
||||
if let Some(generics) = self.infcx.tcx.hir_get_generics(local_did) {
|
||||
for param in generics.params {
|
||||
if let hir::GenericParamKind::Type { .. } = param.kind {
|
||||
span.push_span_label(
|
||||
param.span,
|
||||
format!(
|
||||
"introduces an implicit `{}: Clone` bound",
|
||||
param.name.ident()
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
let msg = if !derive_clone {
|
||||
span.push_span_label(
|
||||
ty_span,
|
||||
format!(
|
||||
"consider {}implementing `Clone` for this type",
|
||||
if derive_clone { "manually " } else { "" }
|
||||
),
|
||||
);
|
||||
format!("if `{ty}` implemented `Clone`, you could clone the value")
|
||||
} else {
|
||||
format!("if all bounds were met, you could clone the value")
|
||||
};
|
||||
span.push_span_label(expr.span, "you could clone this value");
|
||||
err.span_note(span, msg);
|
||||
if derive_clone {
|
||||
err.help("consider manually implementing `Clone` to avoid undesired bounds");
|
||||
}
|
||||
} else if let ty::Param(param) = ty.kind()
|
||||
&& let Some(_clone_trait_def) = self.infcx.tcx.lang_items().clone_trait()
|
||||
&& let generics = self.infcx.tcx.generics_of(self.mir_def_id())
|
||||
|
|
|
|||
|
|
@ -638,27 +638,27 @@ impl<'a> TraitDef<'a> {
|
|||
GenericParamKind::Type { .. } => {
|
||||
// Extra restrictions on the generics parameters to the
|
||||
// type being derived upon.
|
||||
let span = param.ident.span.with_ctxt(ctxt);
|
||||
let bounds: Vec<_> = self
|
||||
.additional_bounds
|
||||
.iter()
|
||||
.map(|p| {
|
||||
cx.trait_bound(
|
||||
p.to_path(cx, self.span, type_ident, generics),
|
||||
self.is_const,
|
||||
)
|
||||
cx.trait_bound(p.to_path(cx, span, type_ident, generics), self.is_const)
|
||||
})
|
||||
.chain(
|
||||
// Add a bound for the current trait.
|
||||
self.skip_path_as_bound
|
||||
.not()
|
||||
.then(|| cx.trait_bound(trait_path.clone(), self.is_const)),
|
||||
self.skip_path_as_bound.not().then(|| {
|
||||
let mut trait_path = trait_path.clone();
|
||||
trait_path.span = span;
|
||||
cx.trait_bound(trait_path, self.is_const)
|
||||
}),
|
||||
)
|
||||
.chain({
|
||||
// Add a `Copy` bound if required.
|
||||
if is_packed && self.needs_copy_as_bound_if_packed {
|
||||
let p = deriving::path_std!(marker::Copy);
|
||||
Some(cx.trait_bound(
|
||||
p.to_path(cx, self.span, type_ident, generics),
|
||||
p.to_path(cx, span, type_ident, generics),
|
||||
self.is_const,
|
||||
))
|
||||
} else {
|
||||
|
|
@ -671,7 +671,7 @@ impl<'a> TraitDef<'a> {
|
|||
)
|
||||
.collect();
|
||||
|
||||
cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, bounds, None)
|
||||
cx.typaram(span, param.ident, bounds, None)
|
||||
}
|
||||
GenericParamKind::Const { ty, span, .. } => {
|
||||
let const_nodefault_kind = GenericParamKind::Const {
|
||||
|
|
@ -791,7 +791,8 @@ impl<'a> TraitDef<'a> {
|
|||
.collect();
|
||||
|
||||
// Create the type of `self`.
|
||||
let path = cx.path_all(self.span, false, vec![type_ident], self_params);
|
||||
let path =
|
||||
cx.path_all(type_ident.span.with_ctxt(ctxt), false, vec![type_ident], self_params);
|
||||
let self_type = cx.ty_path(path);
|
||||
let rustc_const_unstable =
|
||||
cx.path_ident(self.span, Ident::new(sym::rustc_const_unstable, self.span));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// ignore-tidy-filelength
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
use std::ops::Not;
|
||||
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_ast::attr::AttributeExt;
|
||||
|
|
@ -1012,10 +1013,14 @@ impl<'hir> Generics<'hir> {
|
|||
|
||||
span_for_parentheses.map_or_else(
|
||||
|| {
|
||||
// We include bounds that come from a `#[derive(_)]` but point at the user's code,
|
||||
// as we use this method to get a span appropriate for suggestions.
|
||||
// We include bounds that come from a `#[derive(_)]` but point at the user's
|
||||
// code, as we use this method to get a span appropriate for suggestions.
|
||||
let bs = bound.span();
|
||||
bs.can_be_used_for_suggestions().then(|| (bs.shrink_to_hi(), None))
|
||||
// We use `from_expansion` instead of `can_be_used_for_suggestions` because
|
||||
// the trait bound from imperfect derives do point at the type parameter,
|
||||
// but expanded to a where clause, so we want to ignore those. This is only
|
||||
// true for derive intrinsics.
|
||||
bs.from_expansion().not().then(|| (bs.shrink_to_hi(), None))
|
||||
},
|
||||
|span| Some((span.shrink_to_hi(), Some(span.shrink_to_lo()))),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ hir_analysis_copy_impl_on_non_adt =
|
|||
hir_analysis_copy_impl_on_type_with_dtor =
|
||||
the trait `Copy` cannot be implemented for this type; the type has a destructor
|
||||
.label = `Copy` not allowed on types with destructors
|
||||
.note = destructor declared here
|
||||
|
||||
hir_analysis_cross_crate_traits = cross-crate traits with a default impl, like `{$traits}`, can only be implemented for a struct/enum type, not `{$self_ty}`
|
||||
.label = can't implement cross-crate trait with a default impl for non-struct/enum type
|
||||
|
|
|
|||
|
|
@ -122,9 +122,10 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
|
|||
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
|
||||
Err(tcx.dcx().emit_err(errors::CopyImplOnNonAdt { span }))
|
||||
}
|
||||
Err(CopyImplementationError::HasDestructor) => {
|
||||
Err(CopyImplementationError::HasDestructor(did)) => {
|
||||
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
|
||||
Err(tcx.dcx().emit_err(errors::CopyImplOnTypeWithDtor { span }))
|
||||
let impl_ = tcx.def_span(did);
|
||||
Err(tcx.dcx().emit_err(errors::CopyImplOnTypeWithDtor { span, impl_ }))
|
||||
}
|
||||
Err(CopyImplementationError::HasUnsafeFields) => {
|
||||
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
|
||||
|
|
|
|||
|
|
@ -278,6 +278,8 @@ pub(crate) struct CopyImplOnTypeWithDtor {
|
|||
#[primary_span]
|
||||
#[label]
|
||||
pub span: Span,
|
||||
#[note]
|
||||
pub impl_: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
|
|
|||
|
|
@ -592,7 +592,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
if span.can_be_used_for_suggestions()
|
||||
&& poly_trait_ref.trait_ref.trait_def_id().is_some()
|
||||
&& !self.maybe_suggest_impl_trait(span, hir_id, hir_bounds, &mut diag)
|
||||
&& !self.maybe_suggest_dyn_trait(hir_id, sugg, &mut diag)
|
||||
&& !self.maybe_suggest_dyn_trait(hir_id, span, sugg, &mut diag)
|
||||
{
|
||||
self.maybe_suggest_add_generic_impl_trait(span, hir_id, &mut diag);
|
||||
}
|
||||
|
|
@ -750,10 +750,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
fn maybe_suggest_dyn_trait(
|
||||
&self,
|
||||
hir_id: hir::HirId,
|
||||
span: Span,
|
||||
sugg: Vec<(Span, String)>,
|
||||
diag: &mut Diag<'_>,
|
||||
) -> bool {
|
||||
let tcx = self.tcx();
|
||||
if span.in_derive_expansion() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Look at the direct HIR parent, since we care about the relationship between
|
||||
// the type and the thing that directly encloses it.
|
||||
|
|
|
|||
|
|
@ -1932,25 +1932,94 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
None,
|
||||
);
|
||||
} else {
|
||||
let mut suggest_derive = true;
|
||||
if let Some(errors) =
|
||||
self.type_implements_trait_shallow(clone_trait_did, expected_ty, self.param_env)
|
||||
{
|
||||
let manually_impl = "consider manually implementing `Clone` to avoid the \
|
||||
implicit type parameter bounds";
|
||||
match &errors[..] {
|
||||
[] => {}
|
||||
[error] => {
|
||||
diag.help(format!(
|
||||
"`Clone` is not implemented because the trait bound `{}` is \
|
||||
not satisfied",
|
||||
error.obligation.predicate,
|
||||
));
|
||||
let msg = "`Clone` is not implemented because a trait bound is not \
|
||||
satisfied";
|
||||
if let traits::ObligationCauseCode::ImplDerived(data) =
|
||||
error.obligation.cause.code()
|
||||
{
|
||||
let mut span: MultiSpan = data.span.into();
|
||||
if self.tcx.is_automatically_derived(data.impl_or_alias_def_id) {
|
||||
span.push_span_label(
|
||||
data.span,
|
||||
format!(
|
||||
"derive introduces an implicit `{}` bound",
|
||||
error.obligation.predicate
|
||||
),
|
||||
);
|
||||
}
|
||||
diag.span_help(span, msg);
|
||||
if self.tcx.is_automatically_derived(data.impl_or_alias_def_id)
|
||||
&& data.impl_or_alias_def_id.is_local()
|
||||
{
|
||||
diag.help(manually_impl);
|
||||
suggest_derive = false;
|
||||
}
|
||||
} else {
|
||||
diag.help(msg);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
diag.help(format!(
|
||||
"`Clone` is not implemented because the following trait bounds \
|
||||
could not be satisfied: {}",
|
||||
listify(&errors, |e| format!("`{}`", e.obligation.predicate))
|
||||
.unwrap(),
|
||||
));
|
||||
let unsatisfied_bounds: Vec<_> = errors
|
||||
.iter()
|
||||
.filter_map(|error| match error.obligation.cause.code() {
|
||||
traits::ObligationCauseCode::ImplDerived(data) => {
|
||||
let pre = if self
|
||||
.tcx
|
||||
.is_automatically_derived(data.impl_or_alias_def_id)
|
||||
{
|
||||
"derive introduces an implicit "
|
||||
} else {
|
||||
""
|
||||
};
|
||||
Some((
|
||||
data.span,
|
||||
format!(
|
||||
"{pre}unsatisfied trait bound `{}`",
|
||||
error.obligation.predicate
|
||||
),
|
||||
))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let msg = "`Clone` is not implemented because the some trait bounds \
|
||||
could not be satisfied";
|
||||
if errors.len() == unsatisfied_bounds.len() {
|
||||
let mut unsatisfied_bounds_spans: MultiSpan = unsatisfied_bounds
|
||||
.iter()
|
||||
.map(|(span, _)| *span)
|
||||
.collect::<Vec<Span>>()
|
||||
.into();
|
||||
for (span, label) in unsatisfied_bounds {
|
||||
unsatisfied_bounds_spans.push_span_label(span, label);
|
||||
}
|
||||
diag.span_help(unsatisfied_bounds_spans, msg);
|
||||
if errors.iter().all(|error| match error.obligation.cause.code() {
|
||||
traits::ObligationCauseCode::ImplDerived(data) => {
|
||||
self.tcx.is_automatically_derived(data.impl_or_alias_def_id)
|
||||
&& data.impl_or_alias_def_id.is_local()
|
||||
}
|
||||
_ => false,
|
||||
}) {
|
||||
diag.help(manually_impl);
|
||||
suggest_derive = false;
|
||||
}
|
||||
} else {
|
||||
diag.help(format!(
|
||||
"{msg}: {}",
|
||||
listify(&errors, |e| format!("`{}`", e.obligation.predicate))
|
||||
.unwrap(),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
for error in errors {
|
||||
|
|
@ -1968,7 +2037,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
self.suggest_derive(diag, &vec![(trait_ref.upcast(self.tcx), None, None)]);
|
||||
if suggest_derive {
|
||||
self.suggest_derive(diag, &vec![(trait_ref.upcast(self.tcx), None, None)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1748,19 +1748,34 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// Find all the requirements that come from a local `impl` block.
|
||||
let mut skip_list: UnordSet<_> = Default::default();
|
||||
let mut spanned_predicates = FxIndexMap::default();
|
||||
let mut manually_impl = false;
|
||||
for (p, parent_p, cause) in unsatisfied_predicates {
|
||||
// Extract the predicate span and parent def id of the cause,
|
||||
// if we have one.
|
||||
let (item_def_id, cause_span) = match cause.as_ref().map(|cause| cause.code()) {
|
||||
Some(ObligationCauseCode::ImplDerived(data)) => {
|
||||
(data.impl_or_alias_def_id, data.span)
|
||||
}
|
||||
Some(
|
||||
ObligationCauseCode::WhereClauseInExpr(def_id, span, _, _)
|
||||
| ObligationCauseCode::WhereClause(def_id, span),
|
||||
) if !span.is_dummy() => (*def_id, *span),
|
||||
_ => continue,
|
||||
};
|
||||
let (item_def_id, cause_span, cause_msg) =
|
||||
match cause.as_ref().map(|cause| cause.code()) {
|
||||
Some(ObligationCauseCode::ImplDerived(data)) => {
|
||||
let msg = if let DefKind::Impl { of_trait: true } =
|
||||
self.tcx.def_kind(data.impl_or_alias_def_id)
|
||||
{
|
||||
format!(
|
||||
"type parameter would need to implement `{}`",
|
||||
self.tcx
|
||||
.item_name(self.tcx.impl_trait_id(data.impl_or_alias_def_id))
|
||||
)
|
||||
} else {
|
||||
format!("unsatisfied bound `{p}` introduced here")
|
||||
};
|
||||
(data.impl_or_alias_def_id, data.span, msg)
|
||||
}
|
||||
Some(
|
||||
ObligationCauseCode::WhereClauseInExpr(def_id, span, _, _)
|
||||
| ObligationCauseCode::WhereClause(def_id, span),
|
||||
) if !span.is_dummy() => {
|
||||
(*def_id, *span, format!("unsatisfied bound `{p}` introduced here"))
|
||||
}
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
// Don't point out the span of `WellFormed` predicates.
|
||||
if !matches!(
|
||||
|
|
@ -1791,13 +1806,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let entry = entry.or_insert_with(|| {
|
||||
(FxIndexSet::default(), FxIndexSet::default(), Vec::new())
|
||||
});
|
||||
entry.0.insert(span);
|
||||
entry.0.insert(cause_span);
|
||||
entry.1.insert((
|
||||
span,
|
||||
"unsatisfied trait bound introduced in this `derive` macro",
|
||||
cause_span,
|
||||
cause_msg,
|
||||
));
|
||||
entry.2.push(p);
|
||||
skip_list.insert(p);
|
||||
manually_impl = true;
|
||||
}
|
||||
|
||||
// Unmet obligation coming from an `impl`.
|
||||
|
|
@ -1842,7 +1858,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
entry.2.push(p);
|
||||
if cause_span != *item_span {
|
||||
entry.0.insert(cause_span);
|
||||
entry.1.insert((cause_span, "unsatisfied trait bound introduced here"));
|
||||
entry.1.insert((cause_span, "unsatisfied trait bound introduced here".to_string()));
|
||||
} else {
|
||||
if let Some(of_trait) = of_trait {
|
||||
entry.0.insert(of_trait.trait_ref.path.span);
|
||||
|
|
@ -1850,9 +1866,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
entry.0.insert(self_ty.span);
|
||||
};
|
||||
if let Some(of_trait) = of_trait {
|
||||
entry.1.insert((of_trait.trait_ref.path.span, ""));
|
||||
entry.1.insert((of_trait.trait_ref.path.span, String::new()));
|
||||
}
|
||||
entry.1.insert((self_ty.span, ""));
|
||||
entry.1.insert((self_ty.span, String::new()));
|
||||
}
|
||||
Some(Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Trait(_, rustc_ast::ast::IsAuto::Yes, ..),
|
||||
|
|
@ -1881,8 +1897,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
(FxIndexSet::default(), FxIndexSet::default(), Vec::new())
|
||||
});
|
||||
entry.0.insert(cause_span);
|
||||
entry.1.insert((ident.span, ""));
|
||||
entry.1.insert((cause_span, "unsatisfied trait bound introduced here"));
|
||||
entry.1.insert((ident.span, String::new()));
|
||||
entry.1.insert((cause_span, "unsatisfied trait bound introduced here".to_string()));
|
||||
entry.2.push(p);
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -2083,6 +2099,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
*suggested_derive = self.suggest_derive(err, unsatisfied_predicates);
|
||||
*unsatisfied_bounds = true;
|
||||
}
|
||||
if manually_impl {
|
||||
err.help("consider manually implementing the trait to avoid undesired bounds");
|
||||
}
|
||||
}
|
||||
|
||||
/// If an appropriate error source is not found, check method chain for possible candidates
|
||||
|
|
|
|||
|
|
@ -526,12 +526,15 @@ pub fn suggest_constraining_type_params<'a>(
|
|||
//
|
||||
// fn foo<T>(t: T) { ... }
|
||||
// - help: consider restricting this type parameter with `T: Foo`
|
||||
suggestions.push((
|
||||
param.span.shrink_to_hi(),
|
||||
post,
|
||||
format!(": {constraint}"),
|
||||
SuggestChangingConstraintsMessage::RestrictType { ty: param_name },
|
||||
));
|
||||
let span = param.span.shrink_to_hi();
|
||||
if span.can_be_used_for_suggestions() {
|
||||
suggestions.push((
|
||||
span,
|
||||
post,
|
||||
format!(": {constraint}"),
|
||||
SuggestChangingConstraintsMessage::RestrictType { ty: param_name },
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: remove the suggestions that are from derive, as the span is not correct
|
||||
|
|
|
|||
|
|
@ -3583,11 +3583,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
..
|
||||
})) => {
|
||||
let mut spans = Vec::with_capacity(2);
|
||||
if let Some(of_trait) = of_trait {
|
||||
if let Some(of_trait) = of_trait
|
||||
&& !of_trait.trait_ref.path.span.in_derive_expansion()
|
||||
{
|
||||
spans.push(of_trait.trait_ref.path.span);
|
||||
}
|
||||
spans.push(self_ty.span);
|
||||
let mut spans: MultiSpan = spans.into();
|
||||
let mut derived = false;
|
||||
if matches!(
|
||||
self_ty.span.ctxt().outer_expn_data().kind,
|
||||
ExpnKind::Macro(MacroKind::Derive, _)
|
||||
|
|
@ -3595,9 +3598,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
of_trait.map(|t| t.trait_ref.path.span.ctxt().outer_expn_data().kind),
|
||||
Some(ExpnKind::Macro(MacroKind::Derive, _))
|
||||
) {
|
||||
derived = true;
|
||||
spans.push_span_label(
|
||||
data.span,
|
||||
"unsatisfied trait bound introduced in this `derive` macro",
|
||||
if data.span.in_derive_expansion() {
|
||||
format!("type parameter would need to implement `{trait_name}`")
|
||||
} else {
|
||||
format!("unsatisfied trait bound")
|
||||
},
|
||||
);
|
||||
} else if !data.span.is_dummy() && !data.span.overlaps(self_ty.span) {
|
||||
// `Sized` may be an explicit or implicit trait bound. If it is
|
||||
|
|
@ -3623,6 +3631,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
err.span_note(spans, msg);
|
||||
if derived && trait_name != "Copy" {
|
||||
err.help(format!(
|
||||
"consider manually implementing `{trait_name}` to avoid undesired \
|
||||
bounds",
|
||||
));
|
||||
}
|
||||
point_at_assoc_type_restriction(
|
||||
tcx,
|
||||
err,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use crate::traits::{self, FulfillmentError, Obligation, ObligationCause};
|
|||
pub enum CopyImplementationError<'tcx> {
|
||||
InfringingFields(Vec<(&'tcx ty::FieldDef, Ty<'tcx>, InfringingFieldsReason<'tcx>)>),
|
||||
NotAnAdt,
|
||||
HasDestructor,
|
||||
HasDestructor(hir::def_id::DefId),
|
||||
HasUnsafeFields,
|
||||
}
|
||||
|
||||
|
|
@ -76,8 +76,8 @@ pub fn type_allowed_to_implement_copy<'tcx>(
|
|||
)
|
||||
.map_err(CopyImplementationError::InfringingFields)?;
|
||||
|
||||
if adt.has_dtor(tcx) {
|
||||
return Err(CopyImplementationError::HasDestructor);
|
||||
if let Some(did) = adt.destructor(tcx).map(|dtor| dtor.did) {
|
||||
return Err(CopyImplementationError::HasDestructor(did));
|
||||
}
|
||||
|
||||
if impl_safety.is_safe() && self_type.has_unsafe_fields() {
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ pub trait Column: Expression {}
|
|||
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
pub enum ColumnInsertValue<Col, Expr> where
|
||||
//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
Col: Column,
|
||||
Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
|
||||
//~^ ERROR the trait bound `<Col as Expression>::SqlType: IntoNullable` is not satisfied
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
--> $DIR/issue-38821.rs:40:1
|
||||
--> $DIR/issue-38821.rs:37:1
|
||||
|
|
||||
LL | pub enum ColumnInsertValue<Col, Expr> where
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
||||
|
|
@ -82,10 +82,13 @@ LL | impl<T: NotNull> IntoNullable for T {
|
|||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
--> $DIR/issue-38821.rs:23:10
|
||||
--> $DIR/issue-38821.rs:37:10
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
||||
| ----- in this derive macro expansion
|
||||
...
|
||||
LL | pub enum ColumnInsertValue<Col, Expr> where
|
||||
| ^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
||||
|
|
||||
note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
|
||||
--> $DIR/issue-38821.rs:9:18
|
||||
|
|
@ -95,13 +98,17 @@ LL | impl<T: NotNull> IntoNullable for T {
|
|||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
note: required for `ColumnInsertValue<Col, Expr>` to implement `Debug`
|
||||
--> $DIR/issue-38821.rs:23:10
|
||||
--> $DIR/issue-38821.rs:37:10
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^^
|
||||
| ----- in this derive macro expansion
|
||||
...
|
||||
LL | pub enum ColumnInsertValue<Col, Expr> where
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
|
||||
| ------------------------------------------------ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ------------------------------------------------ unsatisfied trait bound
|
||||
= help: consider manually implementing `Debug` to avoid undesired bounds
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull,
|
||||
|
|
@ -126,10 +133,13 @@ LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Co
|
|||
| +++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
--> $DIR/issue-38821.rs:23:17
|
||||
--> $DIR/issue-38821.rs:37:10
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
||||
| ---- in this derive macro expansion
|
||||
...
|
||||
LL | pub enum ColumnInsertValue<Col, Expr> where
|
||||
| ^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
||||
|
|
||||
note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
|
||||
--> $DIR/issue-38821.rs:9:18
|
||||
|
|
@ -139,13 +149,16 @@ LL | impl<T: NotNull> IntoNullable for T {
|
|||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
note: required for `ColumnInsertValue<Col, Expr>` to implement `Copy`
|
||||
--> $DIR/issue-38821.rs:23:17
|
||||
--> $DIR/issue-38821.rs:37:10
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^
|
||||
| ---- in this derive macro expansion
|
||||
...
|
||||
LL | pub enum ColumnInsertValue<Col, Expr> where
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
|
||||
| ------------------------------------------------ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ------------------------------------------------ unsatisfied trait bound
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull,
|
||||
|
|
@ -199,10 +212,13 @@ LL | impl<T: NotNull> IntoNullable for T {
|
|||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
|
||||
--> $DIR/issue-38821.rs:23:23
|
||||
--> $DIR/issue-38821.rs:37:10
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
||||
| ----- in this derive macro expansion
|
||||
...
|
||||
LL | pub enum ColumnInsertValue<Col, Expr> where
|
||||
| ^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
||||
|
|
||||
note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
|
||||
--> $DIR/issue-38821.rs:9:18
|
||||
|
|
@ -212,13 +228,17 @@ LL | impl<T: NotNull> IntoNullable for T {
|
|||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
note: required for `ColumnInsertValue<Col, Expr>` to implement `Clone`
|
||||
--> $DIR/issue-38821.rs:23:23
|
||||
--> $DIR/issue-38821.rs:37:10
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^^
|
||||
| ----- in this derive macro expansion
|
||||
...
|
||||
LL | pub enum ColumnInsertValue<Col, Expr> where
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
|
||||
| ------------------------------------------------ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ------------------------------------------------ unsatisfied trait bound
|
||||
= help: consider manually implementing `Clone` to avoid undesired bounds
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull,
|
||||
|
|
|
|||
32
tests/ui/borrowck/derive-clone-implicit-bound.rs
Normal file
32
tests/ui/borrowck/derive-clone-implicit-bound.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Issue #108894
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[derive(Clone, Copy)] //~ NOTE: derived `Clone` adds implicit bounds on type parameters
|
||||
pub struct TypedAddress<T>{
|
||||
//~^ NOTE: if all bounds were met, you could clone the value
|
||||
//~| NOTE: introduces an implicit `T: Clone` bound
|
||||
inner: u64,
|
||||
phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
pub trait Memory {
|
||||
fn write_value<T>(&self, offset: TypedAddress<T>, value: &T);
|
||||
fn return_value<T>(&self, offset: TypedAddress<T>) -> T;
|
||||
//~^ NOTE: consider changing this parameter type in method `return_value` to borrow instead if owning the value isn't necessary
|
||||
//~| NOTE: in this method
|
||||
//~| NOTE: this parameter takes ownership of the value
|
||||
fn update_value<T, F>(&self, offset: TypedAddress<T>, update: F)
|
||||
//~^ NOTE: move occurs because `offset` has type `TypedAddress<T>`, which does not implement the `Copy` trait
|
||||
where F: FnOnce(T) -> T //~ HELP: consider further restricting type parameter `T`
|
||||
{
|
||||
let old = self.return_value(offset); //~ NOTE: value moved here
|
||||
//~^ NOTE: you could clone this value
|
||||
let new = update(old);
|
||||
self.write_value(offset, &new); //~ ERROR: use of moved value: `offset`
|
||||
//~^ NOTE: value used here after move
|
||||
//~| HELP: consider manually implementing `Clone` to avoid undesired bounds
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
38
tests/ui/borrowck/derive-clone-implicit-bound.stderr
Normal file
38
tests/ui/borrowck/derive-clone-implicit-bound.stderr
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
error[E0382]: use of moved value: `offset`
|
||||
--> $DIR/derive-clone-implicit-bound.rs:26:26
|
||||
|
|
||||
LL | fn update_value<T, F>(&self, offset: TypedAddress<T>, update: F)
|
||||
| ------ move occurs because `offset` has type `TypedAddress<T>`, which does not implement the `Copy` trait
|
||||
...
|
||||
LL | let old = self.return_value(offset);
|
||||
| ------ value moved here
|
||||
...
|
||||
LL | self.write_value(offset, &new);
|
||||
| ^^^^^^ value used here after move
|
||||
|
|
||||
note: consider changing this parameter type in method `return_value` to borrow instead if owning the value isn't necessary
|
||||
--> $DIR/derive-clone-implicit-bound.rs:15:39
|
||||
|
|
||||
LL | fn return_value<T>(&self, offset: TypedAddress<T>) -> T;
|
||||
| ------------ in this method ^^^^^^^^^^^^^^^ this parameter takes ownership of the value
|
||||
note: if all bounds were met, you could clone the value
|
||||
--> $DIR/derive-clone-implicit-bound.rs:6:1
|
||||
|
|
||||
LL | #[derive(Clone, Copy)]
|
||||
| ----- derived `Clone` adds implicit bounds on type parameters
|
||||
LL | pub struct TypedAddress<T>{
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^-^
|
||||
| |
|
||||
| introduces an implicit `T: Clone` bound
|
||||
...
|
||||
LL | let old = self.return_value(offset);
|
||||
| ------ you could clone this value
|
||||
= help: consider manually implementing `Clone` to avoid undesired bounds
|
||||
help: consider further restricting type parameter `T` with trait `Copy`
|
||||
|
|
||||
LL | where F: FnOnce(T) -> T, T: Copy
|
||||
| +++++++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
//! regression test for <https://github.com/rust-lang/rust/issues/24357>
|
||||
struct NoCopy; //~ NOTE if `NoCopy` implemented `Clone`, you could clone the value
|
||||
//~^ NOTE consider implementing `Clone` for this type
|
||||
struct NoCopy; //~ NOTE: if `NoCopy` implemented `Clone`, you could clone the value
|
||||
//~^ NOTE: consider implementing `Clone` for this type
|
||||
fn main() {
|
||||
let x = NoCopy;
|
||||
//~^ NOTE move occurs because `x` has type `NoCopy`
|
||||
//~^ NOTE: move occurs because `x` has type `NoCopy`
|
||||
let f = move || {
|
||||
//~^ NOTE value moved into closure here
|
||||
//~^ NOTE: value moved into closure here
|
||||
let y = x;
|
||||
//~^ NOTE variable moved due to use in closure
|
||||
//~| NOTE you could clone this value
|
||||
//~^ NOTE: variable moved due to use in closure
|
||||
//~| NOTE: you could clone this value
|
||||
};
|
||||
let z = x;
|
||||
//~^ ERROR use of moved value: `x`
|
||||
//~| NOTE value used here after move
|
||||
//~^ ERROR: use of moved value: `x`
|
||||
//~| NOTE: value used here after move
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ struct NotParam;
|
|||
struct CantParam(NotParam);
|
||||
|
||||
impl std::marker::ConstParamTy_ for CantParam {}
|
||||
//~^ error: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
|
||||
#[derive(std::marker::ConstParamTy, Eq, PartialEq)]
|
||||
//~^ error: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
struct CantParamDerive(NotParam);
|
||||
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,12 @@ LL | impl std::marker::ConstParamTy_ for CantParam {}
|
|||
| ^^^^^^^^^
|
||||
|
||||
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
--> $DIR/const_param_ty_impl_bad_field.rs:13:10
|
||||
--> $DIR/const_param_ty_impl_bad_field.rs:14:8
|
||||
|
|
||||
LL | #[derive(std::marker::ConstParamTy, Eq, PartialEq)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL |
|
||||
| ------------------------- in this derive macro expansion
|
||||
LL | struct CantParamDerive(NotParam);
|
||||
| -------- this field does not implement `ConstParamTy_`
|
||||
| ^^^^^^^^^^^^^^^ -------- this field does not implement `ConstParamTy_`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ impl std::marker::ConstParamTy_ for ImplementsConstParamTy {}
|
|||
struct CantParam(ImplementsConstParamTy);
|
||||
|
||||
impl std::marker::ConstParamTy_ for CantParam {}
|
||||
//~^ error: the type `CantParam` does not `#[derive(PartialEq)]`
|
||||
//~| ERROR the trait bound `CantParam: Eq` is not satisfied
|
||||
//~^ ERROR: the type `CantParam` does not `#[derive(PartialEq)]`
|
||||
//~| ERROR: the trait bound `CantParam: Eq` is not satisfied
|
||||
|
||||
#[derive(std::marker::ConstParamTy)]
|
||||
//~^ error: the type `CantParamDerive` does not `#[derive(PartialEq)]`
|
||||
//~| ERROR the trait bound `CantParamDerive: Eq` is not satisfied
|
||||
struct CantParamDerive(ImplementsConstParamTy);
|
||||
//~^ ERROR: the type `CantParamDerive` does not `#[derive(PartialEq)]`
|
||||
//~| ERROR: the trait bound `CantParamDerive: Eq` is not satisfied
|
||||
|
||||
fn check<T: std::marker::ConstParamTy_>() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,12 @@ note: required by a bound in `ConstParamTy_`
|
|||
--> $SRC_DIR/core/src/marker.rs:LL:COL
|
||||
|
||||
error[E0277]: the trait bound `CantParamDerive: Eq` is not satisfied
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:15:8
|
||||
|
|
||||
LL | #[derive(std::marker::ConstParamTy)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `CantParamDerive`
|
||||
| ------------------------- in this derive macro expansion
|
||||
LL | struct CantParamDerive(ImplementsConstParamTy);
|
||||
| ^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `CantParamDerive`
|
||||
|
|
||||
note: required by a bound in `ConstParamTy_`
|
||||
--> $SRC_DIR/core/src/marker.rs:LL:COL
|
||||
|
|
@ -41,13 +43,15 @@ LL | struct CantParamDerive(ImplementsConstParamTy);
|
|||
|
|
||||
|
||||
error[E0277]: the type `CantParamDerive` does not `#[derive(PartialEq)]`
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:15:8
|
||||
|
|
||||
LL | #[derive(std::marker::ConstParamTy)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
||||
| ------------------------- in this derive macro expansion
|
||||
LL | struct CantParamDerive(ImplementsConstParamTy);
|
||||
| ^^^^^^^^^^^^^^^ unsatisfied trait bound
|
||||
|
|
||||
help: the nightly-only, unstable trait `StructuralPartialEq` is not implemented for `CantParamDerive`
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:17:1
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:15:1
|
||||
|
|
||||
LL | struct CantParamDerive(ImplementsConstParamTy);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@
|
|||
use std::marker::ConstParamTy;
|
||||
|
||||
#[derive(ConstParamTy)]
|
||||
//~^ ERROR the trait `ConstParamTy_` cannot be implemented for this ty
|
||||
struct Foo([*const u8; 1]);
|
||||
//~^ ERROR the trait `ConstParamTy_` cannot be implemented for this ty
|
||||
|
||||
#[derive(ConstParamTy)]
|
||||
//~^ ERROR the trait `ConstParamTy_` cannot be implemented for this ty
|
||||
struct Foo2([*mut u8; 1]);
|
||||
//~^ ERROR the trait `ConstParamTy_` cannot be implemented for this ty
|
||||
|
||||
#[derive(ConstParamTy)]
|
||||
//~^ ERROR the trait `ConstParamTy_` cannot be implemented for this ty
|
||||
struct Foo3([fn(); 1]);
|
||||
//~^ ERROR the trait `ConstParamTy_` cannot be implemented for this ty
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,44 +1,41 @@
|
|||
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
--> $DIR/nested_bad_const_param_ty.rs:6:10
|
||||
--> $DIR/nested_bad_const_param_ty.rs:7:8
|
||||
|
|
||||
LL | #[derive(ConstParamTy)]
|
||||
| ^^^^^^^^^^^^
|
||||
LL |
|
||||
| ------------ in this derive macro expansion
|
||||
LL | struct Foo([*const u8; 1]);
|
||||
| -------------- this field does not implement `ConstParamTy_`
|
||||
| ^^^ -------------- this field does not implement `ConstParamTy_`
|
||||
|
|
||||
note: the `ConstParamTy_` impl for `[*const u8; 1]` requires that `*const u8: ConstParamTy_`
|
||||
--> $DIR/nested_bad_const_param_ty.rs:8:12
|
||||
--> $DIR/nested_bad_const_param_ty.rs:7:12
|
||||
|
|
||||
LL | struct Foo([*const u8; 1]);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
--> $DIR/nested_bad_const_param_ty.rs:10:10
|
||||
--> $DIR/nested_bad_const_param_ty.rs:11:8
|
||||
|
|
||||
LL | #[derive(ConstParamTy)]
|
||||
| ^^^^^^^^^^^^
|
||||
LL |
|
||||
| ------------ in this derive macro expansion
|
||||
LL | struct Foo2([*mut u8; 1]);
|
||||
| ------------ this field does not implement `ConstParamTy_`
|
||||
| ^^^^ ------------ this field does not implement `ConstParamTy_`
|
||||
|
|
||||
note: the `ConstParamTy_` impl for `[*mut u8; 1]` requires that `*mut u8: ConstParamTy_`
|
||||
--> $DIR/nested_bad_const_param_ty.rs:12:13
|
||||
--> $DIR/nested_bad_const_param_ty.rs:11:13
|
||||
|
|
||||
LL | struct Foo2([*mut u8; 1]);
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
--> $DIR/nested_bad_const_param_ty.rs:14:10
|
||||
--> $DIR/nested_bad_const_param_ty.rs:15:8
|
||||
|
|
||||
LL | #[derive(ConstParamTy)]
|
||||
| ^^^^^^^^^^^^
|
||||
LL |
|
||||
| ------------ in this derive macro expansion
|
||||
LL | struct Foo3([fn(); 1]);
|
||||
| --------- this field does not implement `ConstParamTy_`
|
||||
| ^^^^ --------- this field does not implement `ConstParamTy_`
|
||||
|
|
||||
note: the `ConstParamTy_` impl for `[fn(); 1]` requires that `fn(): ConstParamTy_`
|
||||
--> $DIR/nested_bad_const_param_ty.rs:16:13
|
||||
--> $DIR/nested_bad_const_param_ty.rs:15:13
|
||||
|
|
||||
LL | struct Foo3([fn(); 1]);
|
||||
| ^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -6,18 +6,18 @@ extern crate unsized_const_param;
|
|||
use std::marker::ConstParamTy;
|
||||
|
||||
#[derive(ConstParamTy, Eq, PartialEq)]
|
||||
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
struct A([u8]);
|
||||
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
|
||||
#[derive(ConstParamTy, Eq, PartialEq)]
|
||||
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
struct B(&'static [u8]);
|
||||
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
|
||||
#[derive(ConstParamTy, Eq, PartialEq)]
|
||||
struct C(unsized_const_param::Foo);
|
||||
|
||||
#[derive(std::marker::ConstParamTy, Eq, PartialEq)]
|
||||
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>);
|
||||
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,44 +1,41 @@
|
|||
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
--> $DIR/unsized_field-1.rs:8:10
|
||||
--> $DIR/unsized_field-1.rs:9:8
|
||||
|
|
||||
LL | #[derive(ConstParamTy, Eq, PartialEq)]
|
||||
| ^^^^^^^^^^^^
|
||||
LL |
|
||||
| ------------ in this derive macro expansion
|
||||
LL | struct A([u8]);
|
||||
| ---- this field does not implement `ConstParamTy_`
|
||||
| ^ ---- this field does not implement `ConstParamTy_`
|
||||
|
|
||||
note: the `ConstParamTy_` impl for `[u8]` requires that `feature(unsized_const_params) is enabled`
|
||||
--> $DIR/unsized_field-1.rs:10:10
|
||||
--> $DIR/unsized_field-1.rs:9:10
|
||||
|
|
||||
LL | struct A([u8]);
|
||||
| ^^^^
|
||||
|
||||
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
--> $DIR/unsized_field-1.rs:12:10
|
||||
--> $DIR/unsized_field-1.rs:13:8
|
||||
|
|
||||
LL | #[derive(ConstParamTy, Eq, PartialEq)]
|
||||
| ^^^^^^^^^^^^
|
||||
LL |
|
||||
| ------------ in this derive macro expansion
|
||||
LL | struct B(&'static [u8]);
|
||||
| ------------- this field does not implement `ConstParamTy_`
|
||||
| ^ ------------- this field does not implement `ConstParamTy_`
|
||||
|
|
||||
note: the `ConstParamTy_` impl for `&'static [u8]` requires that `feature(unsized_const_params) is enabled`
|
||||
--> $DIR/unsized_field-1.rs:14:10
|
||||
--> $DIR/unsized_field-1.rs:13:10
|
||||
|
|
||||
LL | struct B(&'static [u8]);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
--> $DIR/unsized_field-1.rs:19:10
|
||||
--> $DIR/unsized_field-1.rs:20:8
|
||||
|
|
||||
LL | #[derive(std::marker::ConstParamTy, Eq, PartialEq)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL |
|
||||
| ------------------------- in this derive macro expansion
|
||||
LL | struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>);
|
||||
| ---------------------------------------------------------- this field does not implement `ConstParamTy_`
|
||||
| ^ ---------------------------------------------------------- this field does not implement `ConstParamTy_`
|
||||
|
|
||||
note: the `ConstParamTy_` impl for `GenericNotUnsizedParam<&'static [u8]>` requires that `feature(unsized_const_params) is enabled`
|
||||
--> $DIR/unsized_field-1.rs:21:10
|
||||
--> $DIR/unsized_field-1.rs:20:10
|
||||
|
|
||||
LL | struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
use std::marker::ConstParamTy;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, ConstParamTy)]
|
||||
//~^ ERROR the trait `ConstParamTy_`
|
||||
struct Foo {
|
||||
//~^ ERROR the trait `ConstParamTy_`
|
||||
nested: &'static Bar<dyn std::fmt::Debug>,
|
||||
//~^ ERROR the size for values
|
||||
//~| ERROR the size for values
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ LL | struct Bar<T>(T);
|
|||
| this could be changed to `T: ?Sized`...
|
||||
|
||||
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
|
||||
--> $DIR/unsizing-wfcheck-issue-126272.rs:8:32
|
||||
--> $DIR/unsizing-wfcheck-issue-126272.rs:9:8
|
||||
|
|
||||
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
|
||||
| ^^^^^^^^^^^^
|
||||
...
|
||||
| ------------ in this derive macro expansion
|
||||
LL | struct Foo {
|
||||
| ^^^
|
||||
LL |
|
||||
LL | nested: &'static Bar<dyn std::fmt::Debug>,
|
||||
| ----------------------------------------- this field does not implement `ConstParamTy_`
|
||||
|
|
||||
|
|
@ -59,12 +61,13 @@ help: the trait `Debug` is implemented for `Bar<T>`
|
|||
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
|
||||
| ^^^^^
|
||||
note: required for `Bar<(dyn Debug + 'static)>` to implement `Debug`
|
||||
--> $DIR/unsizing-wfcheck-issue-126272.rs:19:10
|
||||
--> $DIR/unsizing-wfcheck-issue-126272.rs:20:8
|
||||
|
|
||||
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
|
||||
| ^^^^^
|
||||
| ----- in this derive macro expansion
|
||||
LL | struct Bar<T>(T);
|
||||
| - unsatisfied trait bound introduced in this `derive` macro
|
||||
| ^^^ - unsatisfied trait bound
|
||||
= help: consider manually implementing `Debug` to avoid undesired bounds
|
||||
= note: 2 redundant requirements hidden
|
||||
= note: required for `&&'static Bar<(dyn Debug + 'static)>` to implement `Debug`
|
||||
= note: required for the cast from `&&&'static Bar<(dyn Debug + 'static)>` to `&dyn Debug`
|
||||
|
|
@ -93,10 +96,13 @@ help: the trait `Eq` is implemented for `Bar<T>`
|
|||
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
|
||||
| ^^
|
||||
note: required for `Bar<dyn Debug>` to implement `Eq`
|
||||
--> $DIR/unsizing-wfcheck-issue-126272.rs:19:28
|
||||
--> $DIR/unsizing-wfcheck-issue-126272.rs:20:8
|
||||
|
|
||||
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
|
||||
| ^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
| -- in this derive macro expansion
|
||||
LL | struct Bar<T>(T);
|
||||
| ^^^ - type parameter would need to implement `Eq`
|
||||
= help: consider manually implementing `Eq` to avoid undesired bounds
|
||||
= note: 1 redundant requirement hidden
|
||||
= note: required for `&'static Bar<dyn Debug>` to implement `Eq`
|
||||
note: required by a bound in `std::cmp::AssertParamIsEq`
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ LL | [Foo(String::new()); 4];
|
|||
| ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
|
||||
|
|
||||
note: required for `Foo<String>` to implement `Copy`
|
||||
--> $DIR/trait-error.rs:1:10
|
||||
--> $DIR/trait-error.rs:2:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct Foo<T>(T);
|
||||
| ^^^ - type parameter would need to implement `Copy`
|
||||
= note: the `Copy` trait is required because this value will be copied for each element of the array
|
||||
help: create an inline `const` block
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
//! Regression test for issue #20126: Copy and Drop traits are mutually exclusive
|
||||
|
||||
#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented
|
||||
struct Foo;
|
||||
#[derive(Copy, Clone)]
|
||||
struct Foo; //~ ERROR the trait `Copy` cannot be implemented
|
||||
|
||||
impl Drop for Foo {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented
|
||||
struct Bar<T>(::std::marker::PhantomData<T>);
|
||||
#[derive(Copy, Clone)]
|
||||
struct Bar<T>(::std::marker::PhantomData<T>); //~ ERROR the trait `Copy` cannot be implemented
|
||||
|
||||
impl<T> Drop for Bar<T> {
|
||||
fn drop(&mut self) {}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,30 @@
|
|||
error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor
|
||||
--> $DIR/copy-drop-mutually-exclusive.rs:3:10
|
||||
--> $DIR/copy-drop-mutually-exclusive.rs:4:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^ `Copy` not allowed on types with destructors
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct Foo;
|
||||
| ^^^ `Copy` not allowed on types with destructors
|
||||
|
|
||||
note: destructor declared here
|
||||
--> $DIR/copy-drop-mutually-exclusive.rs:7:5
|
||||
|
|
||||
LL | fn drop(&mut self) {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor
|
||||
--> $DIR/copy-drop-mutually-exclusive.rs:10:10
|
||||
--> $DIR/copy-drop-mutually-exclusive.rs:11:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^ `Copy` not allowed on types with destructors
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct Bar<T>(::std::marker::PhantomData<T>);
|
||||
| ^^^ `Copy` not allowed on types with destructors
|
||||
|
|
||||
note: destructor declared here
|
||||
--> $DIR/copy-drop-mutually-exclusive.rs:14:5
|
||||
|
|
||||
LL | fn drop(&mut self) {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,13 @@ LL | Bar::<NotClone> { x: 1 }.clone();
|
|||
| ^^^^^ method cannot be called on `Bar<NotClone>` due to unsatisfied trait bounds
|
||||
|
|
||||
note: trait bound `NotClone: Clone` was not satisfied
|
||||
--> $DIR/derive-assoc-type-not-impl.rs:6:10
|
||||
--> $DIR/derive-assoc-type-not-impl.rs:7:12
|
||||
|
|
||||
LL | #[derive(Clone)]
|
||||
| ^^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ----- in this derive macro expansion
|
||||
LL | struct Bar<T: Foo> {
|
||||
| ^ type parameter would need to implement `Clone`
|
||||
= help: consider manually implementing the trait to avoid undesired bounds
|
||||
help: consider annotating `NotClone` with `#[derive(Clone)]`
|
||||
|
|
||||
LL + #[derive(Clone)]
|
||||
|
|
|
|||
|
|
@ -7,10 +7,12 @@ LL | is_copy(B { a: 1, b: C });
|
|||
| required by a bound introduced by this call
|
||||
|
|
||||
note: required for `B<C>` to implement `Copy`
|
||||
--> $DIR/deriving-copyclone.rs:9:10
|
||||
--> $DIR/deriving-copyclone.rs:10:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct B<T> {
|
||||
| ^ - type parameter would need to implement `Copy`
|
||||
note: required by a bound in `is_copy`
|
||||
--> $DIR/deriving-copyclone.rs:18:15
|
||||
|
|
||||
|
|
@ -30,10 +32,13 @@ LL | is_clone(B { a: 1, b: C });
|
|||
| required by a bound introduced by this call
|
||||
|
|
||||
note: required for `B<C>` to implement `Clone`
|
||||
--> $DIR/deriving-copyclone.rs:9:16
|
||||
--> $DIR/deriving-copyclone.rs:10:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ----- in this derive macro expansion
|
||||
LL | struct B<T> {
|
||||
| ^ - type parameter would need to implement `Clone`
|
||||
= help: consider manually implementing `Clone` to avoid undesired bounds
|
||||
note: required by a bound in `is_clone`
|
||||
--> $DIR/deriving-copyclone.rs:19:16
|
||||
|
|
||||
|
|
@ -53,10 +58,12 @@ LL | is_copy(B { a: 1, b: D });
|
|||
| required by a bound introduced by this call
|
||||
|
|
||||
note: required for `B<D>` to implement `Copy`
|
||||
--> $DIR/deriving-copyclone.rs:9:10
|
||||
--> $DIR/deriving-copyclone.rs:10:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct B<T> {
|
||||
| ^ - type parameter would need to implement `Copy`
|
||||
note: required by a bound in `is_copy`
|
||||
--> $DIR/deriving-copyclone.rs:18:15
|
||||
|
|
||||
|
|
|
|||
|
|
@ -21,10 +21,14 @@ LL | let x: Foo<NonCopy> = Foo(NonCopy, NonCopy, NonCopy);
|
|||
note: the following trait bounds were not satisfied:
|
||||
`NonCopy: Clone`
|
||||
`NonCopy: Copy`
|
||||
--> $DIR/deriving-with-repr-packed-2.rs:5:16
|
||||
--> $DIR/deriving-with-repr-packed-2.rs:7:16
|
||||
|
|
||||
LL | #[derive(Copy, Clone, Default, PartialEq, Eq)]
|
||||
| ^^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ----- in this derive macro expansion
|
||||
LL | #[repr(packed)]
|
||||
LL | pub struct Foo<T>(T, T, T);
|
||||
| ^ type parameter would need to implement `Clone`
|
||||
= help: consider manually implementing the trait to avoid undesired bounds
|
||||
help: consider annotating `NonCopy` with `#[derive(Clone, Copy)]`
|
||||
|
|
||||
LL + #[derive(Clone, Copy)]
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@ error[E0109]: type arguments are not allowed on type parameter `Irrelevant`
|
|||
--> $DIR/issue-97343.rs:4:23
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| -----
|
||||
| |
|
||||
| not allowed on type parameter `Irrelevant`
|
||||
| in this derive macro expansion
|
||||
| ----- in this derive macro expansion
|
||||
LL | pub struct Irrelevant<Irrelevant> {
|
||||
| ^^^^^^^^^^ type argument not allowed
|
||||
| ---------- ^^^^^^^^^^ type argument not allowed
|
||||
| |
|
||||
| not allowed on type parameter `Irrelevant`
|
||||
|
|
||||
note: type parameter `Irrelevant` defined here
|
||||
--> $DIR/issue-97343.rs:4:23
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
struct NonGeneric {}
|
||||
|
||||
#[derive(Default)]
|
||||
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied
|
||||
//~^^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied
|
||||
//~^^^ ERROR struct takes 0 generic arguments but 1 generic argument was supplied
|
||||
//~^^^^ ERROR struct takes 0 generic arguments but 1 generic argument was supplied
|
||||
//~^ ERROR: struct takes 0 lifetime arguments but 1 lifetime argument was supplied
|
||||
//~| ERROR: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||
struct NonGeneric<'a, const N: usize> {}
|
||||
//~^ ERROR lifetime parameter `'a` is never used
|
||||
//~^^ ERROR the name `NonGeneric` is defined multiple times
|
||||
//~^ ERROR: struct takes 0 lifetime arguments but 1 lifetime argument was supplied
|
||||
//~| ERROR: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||
//~| ERROR: lifetime parameter `'a` is never used
|
||||
//~| ERROR: the name `NonGeneric` is defined multiple times
|
||||
|
||||
pub fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0428]: the name `NonGeneric` is defined multiple times
|
||||
--> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:10:1
|
||||
--> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:1
|
||||
|
|
||||
LL | struct NonGeneric {}
|
||||
| ----------------- previous definition of the type `NonGeneric` here
|
||||
|
|
@ -37,7 +37,7 @@ LL | struct NonGeneric {}
|
|||
| ^^^^^^^^^^
|
||||
|
||||
error[E0392]: lifetime parameter `'a` is never used
|
||||
--> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:10:19
|
||||
--> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:19
|
||||
|
|
||||
LL | struct NonGeneric<'a, const N: usize> {}
|
||||
| ^^ unused lifetime parameter
|
||||
|
|
@ -45,29 +45,26 @@ LL | struct NonGeneric<'a, const N: usize> {}
|
|||
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
|
||||
error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied
|
||||
--> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:5:10
|
||||
--> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:8
|
||||
|
|
||||
LL | #[derive(Default)]
|
||||
| ^^^^^^^ expected 0 lifetime arguments
|
||||
...
|
||||
LL | struct NonGeneric<'a, const N: usize> {}
|
||||
| -- help: remove the lifetime argument
|
||||
| ^^^^^^^^^^ -- help: remove the lifetime argument
|
||||
| |
|
||||
| expected 0 lifetime arguments
|
||||
|
|
||||
note: struct defined here, with 0 lifetime parameters
|
||||
--> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:3:8
|
||||
|
|
||||
LL | struct NonGeneric {}
|
||||
| ^^^^^^^^^^
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||
--> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:5:10
|
||||
--> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:8
|
||||
|
|
||||
LL | #[derive(Default)]
|
||||
| ^^^^^^^ expected 0 generic arguments
|
||||
...
|
||||
LL | struct NonGeneric<'a, const N: usize> {}
|
||||
| - help: remove the unnecessary generic argument
|
||||
| ^^^^^^^^^^ - help: remove the unnecessary generic argument
|
||||
| |
|
||||
| expected 0 generic arguments
|
||||
|
|
||||
note: struct defined here, with 0 generic parameters
|
||||
--> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:3:8
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@
|
|||
struct NotSM;
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
//~^ ERROR struct takes 0 generic arguments
|
||||
//~| ERROR struct takes 0 generic arguments
|
||||
//~| ERROR struct takes 0 generic arguments
|
||||
//~| ERROR struct takes 0 generic arguments
|
||||
//~^ ERROR: struct takes 0 generic arguments
|
||||
struct NotSM<T>(T);
|
||||
//~^ ERROR the name `NotSM` is defined multiple times
|
||||
//~| ERROR no field `0`
|
||||
//~^ ERROR: struct takes 0 generic arguments
|
||||
//~| ERROR: struct takes 0 generic arguments
|
||||
//~| ERROR: struct takes 0 generic arguments
|
||||
//~| ERROR: the name `NotSM` is defined multiple times
|
||||
//~| ERROR: no field `0`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0428]: the name `NotSM` is defined multiple times
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:15:1
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:12:1
|
||||
|
|
||||
LL | struct NotSM;
|
||||
| ------------- previous definition of the type `NotSM` here
|
||||
|
|
@ -10,10 +10,10 @@ LL | struct NotSM<T>(T);
|
|||
= note: `NotSM` must be defined only once in the type namespace of this module
|
||||
|
||||
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:10:10
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:12:8
|
||||
|
|
||||
LL | #[derive(PartialEq, Eq)]
|
||||
| ^^^^^^^^^ expected 0 generic arguments
|
||||
LL | struct NotSM<T>(T);
|
||||
| ^^^^^ expected 0 generic arguments
|
||||
|
|
||||
note: struct defined here, with 0 generic parameters
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:8:8
|
||||
|
|
@ -30,27 +30,27 @@ LL | #[derive(PartialEq, Eq)]
|
|||
note: struct defined here, with 0 generic parameters
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:8:8
|
||||
|
|
||||
LL | struct NotSM;
|
||||
| ^^^^^
|
||||
|
||||
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:12:8
|
||||
|
|
||||
LL | struct NotSM<T>(T);
|
||||
| ^^^^^ expected 0 generic arguments
|
||||
|
|
||||
note: struct defined here, with 0 generic parameters
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:8:8
|
||||
|
|
||||
LL | struct NotSM;
|
||||
| ^^^^^
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:10:21
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:12:8
|
||||
|
|
||||
LL | #[derive(PartialEq, Eq)]
|
||||
| ^^ expected 0 generic arguments
|
||||
|
|
||||
note: struct defined here, with 0 generic parameters
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:8:8
|
||||
|
|
||||
LL | struct NotSM;
|
||||
| ^^^^^
|
||||
|
||||
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:10:10
|
||||
|
|
||||
LL | #[derive(PartialEq, Eq)]
|
||||
| ^^^^^^^^^ expected 0 generic arguments
|
||||
LL | struct NotSM<T>(T);
|
||||
| ^^^^^ expected 0 generic arguments
|
||||
|
|
||||
note: struct defined here, with 0 generic parameters
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:8:8
|
||||
|
|
@ -60,7 +60,7 @@ LL | struct NotSM;
|
|||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0609]: no field `0` on type `&NotSM`
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:15:17
|
||||
--> $DIR/multiple-types-with-same-name-and-derive.rs:12:17
|
||||
|
|
||||
LL | struct NotSM<T>(T);
|
||||
| ^ unknown field
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#[derive(Copy)] //~ ERROR E0184
|
||||
struct Foo;
|
||||
#[derive(Copy)]
|
||||
struct Foo; //~ ERROR E0184
|
||||
|
||||
impl Drop for Foo {
|
||||
fn drop(&mut self) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,16 @@
|
|||
error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor
|
||||
--> $DIR/E0184.rs:1:10
|
||||
--> $DIR/E0184.rs:2:8
|
||||
|
|
||||
LL | #[derive(Copy)]
|
||||
| ^^^^ `Copy` not allowed on types with destructors
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct Foo;
|
||||
| ^^^ `Copy` not allowed on types with destructors
|
||||
|
|
||||
note: destructor declared here
|
||||
--> $DIR/E0184.rs:5:5
|
||||
|
|
||||
LL | fn drop(&mut self) {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,12 @@ LL | type C = String where Self: Copy;
|
|||
| ^^^^ the trait `Copy` is not implemented for `T`
|
||||
|
|
||||
note: required for `Fooy<T>` to implement `Copy`
|
||||
--> $DIR/impl_bounds.rs:10:10
|
||||
--> $DIR/impl_bounds.rs:11:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct Fooy<T>(T);
|
||||
| ^^^^ - type parameter would need to implement `Copy`
|
||||
note: the requirement `Fooy<T>: Copy` appears on the `impl`'s associated type `C` but not on the corresponding trait's associated type
|
||||
--> $DIR/impl_bounds.rs:6:10
|
||||
|
|
||||
|
|
@ -53,10 +55,12 @@ LL | fn d() where Self: Copy {}
|
|||
| ^^^^ the trait `Copy` is not implemented for `T`
|
||||
|
|
||||
note: required for `Fooy<T>` to implement `Copy`
|
||||
--> $DIR/impl_bounds.rs:10:10
|
||||
--> $DIR/impl_bounds.rs:11:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct Fooy<T>(T);
|
||||
| ^^^^ - type parameter would need to implement `Copy`
|
||||
note: the requirement `Fooy<T>: Copy` appears on the `impl`'s associated function `d` but not on the corresponding trait's associated function
|
||||
--> $DIR/impl_bounds.rs:7:8
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
struct Foo;
|
||||
#[derive(Copy, Clone)]
|
||||
//~^ ERROR the trait `Copy` cannot be implemented for this type
|
||||
struct Bar(Foo);
|
||||
//~^ ERROR `Foo: Clone` is not satisfied
|
||||
//~^ ERROR: the trait `Copy` cannot be implemented for this type
|
||||
//~| ERROR: `Foo: Clone` is not satisfied
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/issue-27340.rs:2:10
|
||||
--> $DIR/issue-27340.rs:3:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^
|
||||
LL |
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct Bar(Foo);
|
||||
| --- this field does not implement `Copy`
|
||||
| ^^^ --- this field does not implement `Copy`
|
||||
|
||||
error[E0277]: the trait bound `Foo: Clone` is not satisfied
|
||||
--> $DIR/issue-27340.rs:4:12
|
||||
--> $DIR/issue-27340.rs:3:12
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ----- in this derive macro expansion
|
||||
LL |
|
||||
LL | struct Bar(Foo);
|
||||
| ^^^ the trait `Clone` is not implemented for `Foo`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
#[derive(Copy(Bad))]
|
||||
//~^ ERROR traits in `#[derive(...)]` don't accept arguments
|
||||
//~| ERROR the trait bound
|
||||
//~^ ERROR: traits in `#[derive(...)]` don't accept arguments
|
||||
struct Test1;
|
||||
//~^ ERROR: the trait bound
|
||||
|
||||
#[derive(Copy="bad")]
|
||||
//~^ ERROR traits in `#[derive(...)]` don't accept values
|
||||
//~| ERROR the trait bound
|
||||
//~^ ERROR: traits in `#[derive(...)]` don't accept values
|
||||
struct Test2;
|
||||
//~^ ERROR: the trait bound
|
||||
|
||||
#[derive] //~ ERROR malformed `derive` attribute input
|
||||
#[derive] //~ ERROR: malformed `derive` attribute input
|
||||
struct Test4;
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,13 @@ LL | #[derive]
|
|||
| ^^^^^^^^^ help: must be of the form: `#[derive(Trait1, Trait2, ...)]`
|
||||
|
||||
error[E0277]: the trait bound `Test1: Clone` is not satisfied
|
||||
--> $DIR/malformed-derive-entry.rs:1:10
|
||||
--> $DIR/malformed-derive-entry.rs:3:8
|
||||
|
|
||||
LL | #[derive(Copy(Bad))]
|
||||
| ^^^^ the trait `Clone` is not implemented for `Test1`
|
||||
| ---- in this derive macro expansion
|
||||
LL |
|
||||
LL | struct Test1;
|
||||
| ^^^^^ the trait `Clone` is not implemented for `Test1`
|
||||
|
|
||||
note: required by a bound in `Copy`
|
||||
--> $SRC_DIR/core/src/marker.rs:LL:COL
|
||||
|
|
@ -31,10 +34,13 @@ LL | struct Test1;
|
|||
|
|
||||
|
||||
error[E0277]: the trait bound `Test2: Clone` is not satisfied
|
||||
--> $DIR/malformed-derive-entry.rs:6:10
|
||||
--> $DIR/malformed-derive-entry.rs:8:8
|
||||
|
|
||||
LL | #[derive(Copy="bad")]
|
||||
| ^^^^ the trait `Clone` is not implemented for `Test2`
|
||||
| ---- in this derive macro expansion
|
||||
LL |
|
||||
LL | struct Test2;
|
||||
| ^^^^^ the trait `Clone` is not implemented for `Test2`
|
||||
|
|
||||
note: required by a bound in `Copy`
|
||||
--> $SRC_DIR/core/src/marker.rs:LL:COL
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ note: `HashSet<Day>` does not implement `Clone`, so `&HashSet<Day>` was cloned i
|
|||
|
|
||||
LL | let mut x: HashSet<Day> = v.clone();
|
||||
| ^
|
||||
= help: `Clone` is not implemented because the trait bound `Day: Clone` is not satisfied
|
||||
help: `Clone` is not implemented because a trait bound is not satisfied
|
||||
--> $SRC_DIR/std/src/collections/hash/set.rs:LL:COL
|
||||
help: consider annotating `Day` with `#[derive(Clone)]`
|
||||
|
|
||||
LL + #[derive(Clone)]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ note: `HashSet<Day>` does not implement `Clone`, so `&HashSet<Day>` was cloned i
|
|||
|
|
||||
LL | let mut x: HashSet<Day> = v.clone();
|
||||
| ^
|
||||
= help: `Clone` is not implemented because the trait bound `Day: Clone` is not satisfied
|
||||
help: `Clone` is not implemented because a trait bound is not satisfied
|
||||
--> $SRC_DIR/std/src/collections/hash/set.rs:LL:COL
|
||||
help: consider annotating `Day` with `#[derive(Clone)]`
|
||||
|
|
||||
LL + #[derive(Clone)]
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ fn moved_loop_2() {
|
|||
fn uninit_1() {
|
||||
loop {
|
||||
let value: NonCopy; //~ NOTE declared here
|
||||
//~^ HELP consider assigning a value
|
||||
let _used = value; //~ ERROR binding `value` isn't initialized
|
||||
//~^ NOTE `value` used here but it isn't initialized
|
||||
}
|
||||
|
|
@ -77,6 +78,7 @@ fn uninit_1() {
|
|||
|
||||
fn uninit_2() {
|
||||
let mut value: NonCopy; //~ NOTE declared here
|
||||
//~^ HELP consider assigning a value
|
||||
loop {
|
||||
let _used = value; //~ ERROR binding `value` isn't initialized
|
||||
//~^ NOTE `value` used here but it isn't initialized
|
||||
|
|
|
|||
|
|
@ -83,10 +83,11 @@ LL | let _used2 = value;
|
|||
| ----- you could clone this value
|
||||
|
||||
error[E0381]: used binding `value` isn't initialized
|
||||
--> $DIR/issue-72649-uninit-in-loop.rs:73:21
|
||||
--> $DIR/issue-72649-uninit-in-loop.rs:74:21
|
||||
|
|
||||
LL | let value: NonCopy;
|
||||
| ----- binding declared here but left uninitialized
|
||||
LL |
|
||||
LL | let _used = value;
|
||||
| ^^^^^ `value` used here but it isn't initialized
|
||||
|
|
||||
|
|
@ -96,11 +97,11 @@ LL | let value: NonCopy = /* value */;
|
|||
| +++++++++++++
|
||||
|
||||
error[E0381]: used binding `value` isn't initialized
|
||||
--> $DIR/issue-72649-uninit-in-loop.rs:81:21
|
||||
--> $DIR/issue-72649-uninit-in-loop.rs:83:21
|
||||
|
|
||||
LL | let mut value: NonCopy;
|
||||
| --------- binding declared here but left uninitialized
|
||||
LL | loop {
|
||||
...
|
||||
LL | let _used = value;
|
||||
| ^^^^^ `value` used here but it isn't initialized
|
||||
|
|
||||
|
|
|
|||
|
|
@ -12,12 +12,11 @@ struct PriorityQueueEntry<T> {
|
|||
}
|
||||
|
||||
#[derive(PartialOrd, AddImpl)]
|
||||
//~^ ERROR can't compare `PriorityQueue<T>` with `PriorityQueue<T>`
|
||||
//~| ERROR the trait bound `PriorityQueue<T>: Eq` is not satisfied
|
||||
//~| ERROR can't compare `T` with `T`
|
||||
//~| ERROR no method named `cmp` found for struct `BinaryHeap<PriorityQueueEntry<T>>`
|
||||
//~| ERROR no field `height` on type `&PriorityQueue<T>`
|
||||
|
||||
//~^ ERROR: the trait bound `PriorityQueue<T>: Eq` is not satisfied
|
||||
//~| ERROR: can't compare `T` with `T`
|
||||
//~| ERROR: no method named `cmp` found for struct `BinaryHeap<PriorityQueueEntry<T>>`
|
||||
//~| ERROR: no field `height` on type `&PriorityQueue<T>`
|
||||
struct PriorityQueue<T>(BinaryHeap<PriorityQueueEntry<T>>);
|
||||
//~^ ERROR can't compare `BinaryHeap<PriorityQueueEntry<T>>` with `_`
|
||||
//~^ ERROR: can't compare `PriorityQueue<T>` with `PriorityQueue<T>`
|
||||
//~| ERROR: can't compare `BinaryHeap<PriorityQueueEntry<T>>` with `_`
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
error[E0277]: can't compare `PriorityQueue<T>` with `PriorityQueue<T>`
|
||||
--> $DIR/issue-104884-trait-impl-sugg-err.rs:14:10
|
||||
--> $DIR/issue-104884-trait-impl-sugg-err.rs:19:8
|
||||
|
|
||||
LL | #[derive(PartialOrd, AddImpl)]
|
||||
| ^^^^^^^^^^ no implementation for `PriorityQueue<T> == PriorityQueue<T>`
|
||||
| ---------- in this derive macro expansion
|
||||
...
|
||||
LL | struct PriorityQueue<T>(BinaryHeap<PriorityQueueEntry<T>>);
|
||||
| ^^^^^^^^^^^^^ no implementation for `PriorityQueue<T> == PriorityQueue<T>`
|
||||
|
|
||||
help: the trait `PartialEq` is not implemented for `PriorityQueue<T>`
|
||||
--> $DIR/issue-104884-trait-impl-sugg-err.rs:21:1
|
||||
--> $DIR/issue-104884-trait-impl-sugg-err.rs:19:1
|
||||
|
|
||||
LL | struct PriorityQueue<T>(BinaryHeap<PriorityQueueEntry<T>>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -19,7 +22,7 @@ LL | #[derive(PartialOrd, AddImpl)]
|
|||
| ^^^^^^^ unsatisfied trait bound
|
||||
|
|
||||
help: the trait `Eq` is not implemented for `PriorityQueue<T>`
|
||||
--> $DIR/issue-104884-trait-impl-sugg-err.rs:21:1
|
||||
--> $DIR/issue-104884-trait-impl-sugg-err.rs:19:1
|
||||
|
|
||||
LL | struct PriorityQueue<T>(BinaryHeap<PriorityQueueEntry<T>>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -34,15 +37,19 @@ LL | #[derive(PartialOrd, AddImpl)]
|
|||
| ^^^^^^^ no implementation for `T < T` and `T > T`
|
||||
|
|
||||
note: required for `PriorityQueue<T>` to implement `PartialOrd`
|
||||
--> $DIR/issue-104884-trait-impl-sugg-err.rs:14:10
|
||||
--> $DIR/issue-104884-trait-impl-sugg-err.rs:19:8
|
||||
|
|
||||
LL | #[derive(PartialOrd, AddImpl)]
|
||||
| ^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ---------- in this derive macro expansion
|
||||
...
|
||||
LL | struct PriorityQueue<T>(BinaryHeap<PriorityQueueEntry<T>>);
|
||||
| ^^^^^^^^^^^^^ - type parameter would need to implement `PartialOrd`
|
||||
= help: consider manually implementing `PartialOrd` to avoid undesired bounds
|
||||
note: required by a bound in `Ord`
|
||||
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
||||
|
||||
error[E0277]: can't compare `BinaryHeap<PriorityQueueEntry<T>>` with `_`
|
||||
--> $DIR/issue-104884-trait-impl-sugg-err.rs:21:25
|
||||
--> $DIR/issue-104884-trait-impl-sugg-err.rs:19:25
|
||||
|
|
||||
LL | #[derive(PartialOrd, AddImpl)]
|
||||
| ---------- in this derive macro expansion
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::ops::*;
|
||||
|
||||
#[derive(Copy, Clone)] //~ ERROR Copy
|
||||
struct R(Range<usize>);
|
||||
#[derive(Copy, Clone)]
|
||||
struct R(Range<usize>); //~ ERROR Copy
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/range_traits-2.rs:3:10
|
||||
--> $DIR/range_traits-2.rs:4:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct R(Range<usize>);
|
||||
| ------------ this field does not implement `Copy`
|
||||
| ^ ------------ this field does not implement `Copy`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::ops::*;
|
||||
|
||||
#[derive(Copy, Clone)] //~ ERROR Copy
|
||||
struct R(RangeFrom<usize>);
|
||||
#[derive(Copy, Clone)]
|
||||
struct R(RangeFrom<usize>); //~ ERROR Copy
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/range_traits-3.rs:3:10
|
||||
--> $DIR/range_traits-3.rs:4:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct R(RangeFrom<usize>);
|
||||
| ---------------- this field does not implement `Copy`
|
||||
| ^ ---------------- this field does not implement `Copy`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::ops::*;
|
||||
|
||||
#[derive(Copy, Clone)] //~ ERROR Copy
|
||||
struct R(RangeInclusive<usize>);
|
||||
#[derive(Copy, Clone)]
|
||||
struct R(RangeInclusive<usize>); //~ ERROR Copy
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/range_traits-6.rs:3:10
|
||||
--> $DIR/range_traits-6.rs:4:8
|
||||
|
|
||||
LL | #[derive(Copy, Clone)]
|
||||
| ^^^^
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct R(RangeInclusive<usize>);
|
||||
| --------------------- this field does not implement `Copy`
|
||||
| ^ --------------------- this field does not implement `Copy`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ struct Foo {
|
|||
|
||||
impl Copy for Foo { } //~ ERROR cannot be implemented for this type
|
||||
|
||||
#[derive(Copy)] //~ ERROR cannot be implemented for this type
|
||||
struct Foo2<'a> {
|
||||
#[derive(Copy)]
|
||||
struct Foo2<'a> { //~ ERROR cannot be implemented for this type
|
||||
ty: &'a mut bool,
|
||||
}
|
||||
|
||||
|
|
@ -16,8 +16,8 @@ enum EFoo {
|
|||
|
||||
impl Copy for EFoo { } //~ ERROR cannot be implemented for this type
|
||||
|
||||
#[derive(Copy)] //~ ERROR cannot be implemented for this type
|
||||
enum EFoo2<'a> {
|
||||
#[derive(Copy)]
|
||||
enum EFoo2<'a> { //~ ERROR cannot be implemented for this type
|
||||
Bar(&'a mut bool),
|
||||
Baz,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,12 @@ LL | impl Copy for Foo { }
|
|||
| ^^^
|
||||
|
||||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/E0204.rs:7:10
|
||||
--> $DIR/E0204.rs:8:8
|
||||
|
|
||||
LL | #[derive(Copy)]
|
||||
| ^^^^
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct Foo2<'a> {
|
||||
| ^^^^
|
||||
LL | ty: &'a mut bool,
|
||||
| ---------------- this field does not implement `Copy`
|
||||
|
||||
|
|
@ -26,11 +27,12 @@ LL | impl Copy for EFoo { }
|
|||
| ^^^^
|
||||
|
||||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/E0204.rs:19:10
|
||||
--> $DIR/E0204.rs:20:6
|
||||
|
|
||||
LL | #[derive(Copy)]
|
||||
| ^^^^
|
||||
| ---- in this derive macro expansion
|
||||
LL | enum EFoo2<'a> {
|
||||
| ^^^^^
|
||||
LL | Bar(&'a mut bool),
|
||||
| ------------ this field does not implement `Copy`
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use std::rc::Rc;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct ContainsRc<T> {
|
||||
#[derive(Clone)] //~ NOTE in this expansion
|
||||
struct ContainsRc<T> { //~ NOTE derive introduces an implicit `T: Clone` bound
|
||||
value: Rc<T>,
|
||||
}
|
||||
|
||||
|
|
@ -14,7 +14,6 @@ fn clone_me<T>(x: &ContainsRc<T>) -> ContainsRc<T> {
|
|||
//~| NOTE expected `ContainsRc<T>`, found `&ContainsRc<T>`
|
||||
//~| NOTE expected struct `ContainsRc<_>`
|
||||
//~| NOTE `ContainsRc<T>` does not implement `Clone`, so `&ContainsRc<T>` was cloned instead
|
||||
//~| NOTE the trait `Clone` must be implemented
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,14 @@ note: `ContainsRc<T>` does not implement `Clone`, so `&ContainsRc<T>` was cloned
|
|||
|
|
||||
LL | x.clone()
|
||||
| ^
|
||||
= help: `Clone` is not implemented because the trait bound `T: Clone` is not satisfied
|
||||
note: the trait `Clone` must be implemented
|
||||
--> $SRC_DIR/core/src/clone.rs:LL:COL
|
||||
help: `Clone` is not implemented because a trait bound is not satisfied
|
||||
--> $DIR/derive-clone-already-present-issue-146515.rs:6:19
|
||||
|
|
||||
LL | #[derive(Clone)]
|
||||
| ----- in this derive macro expansion
|
||||
LL | struct ContainsRc<T> {
|
||||
| ^ derive introduces an implicit `T: Clone` bound
|
||||
= help: consider manually implementing `Clone` to avoid the implicit type parameter bounds
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
//@ run-rustfix
|
||||
// https://github.com/rust-lang/rust/issues/79076
|
||||
|
||||
#[derive(Clone, Eq)] //~ ERROR [E0277]
|
||||
pub struct Struct<T: std::clone::Clone>(T);
|
||||
#[derive(Clone, Eq)]
|
||||
pub struct Struct<T: std::clone::Clone>(T); //~ ERROR [E0277]
|
||||
|
||||
impl<T: Clone, U> PartialEq<U> for Struct<T>
|
||||
where
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
//@ run-rustfix
|
||||
// https://github.com/rust-lang/rust/issues/79076
|
||||
|
||||
#[derive(Clone, Eq)] //~ ERROR [E0277]
|
||||
pub struct Struct<T>(T);
|
||||
#[derive(Clone, Eq)]
|
||||
pub struct Struct<T>(T); //~ ERROR [E0277]
|
||||
|
||||
impl<T: Clone, U> PartialEq<U> for Struct<T>
|
||||
where
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error[E0277]: the trait bound `T: Clone` is not satisfied
|
||||
--> $DIR/derive-clone-for-eq.rs:4:17
|
||||
--> $DIR/derive-clone-for-eq.rs:5:12
|
||||
|
|
||||
LL | #[derive(Clone, Eq)]
|
||||
| ^^ the trait `Clone` is not implemented for `T`
|
||||
| -- in this derive macro expansion
|
||||
LL | pub struct Struct<T>(T);
|
||||
| ^^^^^^ the trait `Clone` is not implemented for `T`
|
||||
|
|
||||
note: required for `Struct<T>` to implement `PartialEq`
|
||||
--> $DIR/derive-clone-for-eq.rs:7:19
|
||||
|
|
|
|||
|
|
@ -24,12 +24,13 @@ LL | pub loc: Vector2<K>,
|
|||
| ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `K`
|
||||
|
|
||||
note: required for `Vector2<K>` to implement `Debug`
|
||||
--> $DIR/missing-bound-in-derive-copy-impl-2.rs:4:10
|
||||
--> $DIR/missing-bound-in-derive-copy-impl-2.rs:5:12
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^^
|
||||
| ----- in this derive macro expansion
|
||||
LL | pub struct Vector2<T: Debug + Copy + Clone> {
|
||||
| ---- unsatisfied trait bound introduced in this `derive` macro
|
||||
| ^^^^^^^ ---- unsatisfied trait bound
|
||||
= help: consider manually implementing `Debug` to avoid undesired bounds
|
||||
= note: required for the cast from `&Vector2<K>` to `&dyn Debug`
|
||||
help: consider further restricting type parameter `K` with trait `Copy`
|
||||
|
|
||||
|
|
@ -65,12 +66,13 @@ LL | pub size: Vector2<K>,
|
|||
| ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `K`
|
||||
|
|
||||
note: required for `Vector2<K>` to implement `Clone`
|
||||
--> $DIR/missing-bound-in-derive-copy-impl-2.rs:4:23
|
||||
--> $DIR/missing-bound-in-derive-copy-impl-2.rs:5:12
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^^
|
||||
| ----- in this derive macro expansion
|
||||
LL | pub struct Vector2<T: Debug + Copy + Clone> {
|
||||
| ---- unsatisfied trait bound introduced in this `derive` macro
|
||||
| ^^^^^^^ ---- unsatisfied trait bound
|
||||
= help: consider manually implementing `Clone` to avoid undesired bounds
|
||||
help: consider further restricting type parameter `K` with trait `Copy`
|
||||
|
|
||||
LL | pub struct AABB<K: Debug + std::marker::Copy> {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ pub struct Vector2<T: Debug + Copy + Clone>{
|
|||
pub y: T
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented for this type
|
||||
pub struct AABB<K: Copy + Debug + std::fmt::Debug>{
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct AABB<K: Copy + Debug + std::fmt::Debug> { //~ ERROR the trait `Copy` cannot be implemented for this type
|
||||
pub loc: Vector2<K>, //~ ERROR `K` doesn't implement `Debug`
|
||||
//~^ ERROR `K` doesn't implement `Debug`
|
||||
pub size: Vector2<K> //~ ERROR `K` doesn't implement `Debug`
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ pub struct Vector2<T: Debug + Copy + Clone>{
|
|||
pub y: T
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented for this type
|
||||
pub struct AABB<K: Copy>{
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct AABB<K: Copy> { //~ ERROR the trait `Copy` cannot be implemented for this type
|
||||
pub loc: Vector2<K>, //~ ERROR `K` doesn't implement `Debug`
|
||||
//~^ ERROR `K` doesn't implement `Debug`
|
||||
pub size: Vector2<K> //~ ERROR `K` doesn't implement `Debug`
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/missing-bound-in-derive-copy-impl-3.rs:10:17
|
||||
--> $DIR/missing-bound-in-derive-copy-impl-3.rs:11:12
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^
|
||||
LL | pub struct AABB<K: Copy>{
|
||||
| ---- in this derive macro expansion
|
||||
LL | pub struct AABB<K: Copy> {
|
||||
| ^^^^
|
||||
LL | pub loc: Vector2<K>,
|
||||
| ------------------- this field does not implement `Copy`
|
||||
|
|
||||
|
|
@ -14,7 +15,7 @@ LL | pub loc: Vector2<K>,
|
|||
| ^^^^^^^^^^
|
||||
help: consider further restricting type parameter `K` with trait `Debug`
|
||||
|
|
||||
LL | pub struct AABB<K: Copy + Debug>{
|
||||
LL | pub struct AABB<K: Copy + Debug> {
|
||||
| +++++++
|
||||
|
||||
error[E0277]: `K` doesn't implement `Debug`
|
||||
|
|
@ -30,7 +31,7 @@ LL | pub struct Vector2<T: Debug + Copy + Clone>{
|
|||
| ^^^^^ required by this bound in `Vector2`
|
||||
help: consider further restricting type parameter `K` with trait `Debug`
|
||||
|
|
||||
LL | pub struct AABB<K: Copy + std::fmt::Debug>{
|
||||
LL | pub struct AABB<K: Copy + std::fmt::Debug> {
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0277]: `K` doesn't implement `Debug`
|
||||
|
|
@ -38,13 +39,13 @@ error[E0277]: `K` doesn't implement `Debug`
|
|||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ----- in this derive macro expansion
|
||||
LL | pub struct AABB<K: Copy>{
|
||||
LL | pub struct AABB<K: Copy> {
|
||||
LL | pub loc: Vector2<K>,
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `K`
|
||||
|
|
||||
help: consider further restricting type parameter `K` with trait `Debug`
|
||||
|
|
||||
LL | pub struct AABB<K: Copy + std::fmt::Debug>{
|
||||
LL | pub struct AABB<K: Copy + std::fmt::Debug> {
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0277]: `K` doesn't implement `Debug`
|
||||
|
|
@ -58,7 +59,7 @@ LL | pub size: Vector2<K>
|
|||
|
|
||||
help: consider further restricting type parameter `K` with trait `Debug`
|
||||
|
|
||||
LL | pub struct AABB<K: Copy + std::fmt::Debug>{
|
||||
LL | pub struct AABB<K: Copy + std::fmt::Debug> {
|
||||
| +++++++++++++++++
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ pub struct Vector2<T: Debug + Copy + Clone> {
|
|||
pub y: T,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented for this type
|
||||
pub struct AABB<K> {
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct AABB<K> { //~ ERROR the trait `Copy` cannot be implemented for this type
|
||||
pub loc: Vector2<K>,
|
||||
//~^ ERROR doesn't implement `Debug`
|
||||
//~| ERROR `K: Copy` is not satisfied
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/missing-bound-in-derive-copy-impl.rs:9:17
|
||||
--> $DIR/missing-bound-in-derive-copy-impl.rs:10:12
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^
|
||||
| ---- in this derive macro expansion
|
||||
LL | pub struct AABB<K> {
|
||||
| ^^^^
|
||||
LL | pub loc: Vector2<K>,
|
||||
| ------------------- this field does not implement `Copy`
|
||||
|
|
||||
|
|
@ -59,12 +60,13 @@ LL | pub loc: Vector2<K>,
|
|||
| ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `K`
|
||||
|
|
||||
note: required for `Vector2<K>` to implement `Debug`
|
||||
--> $DIR/missing-bound-in-derive-copy-impl.rs:3:10
|
||||
--> $DIR/missing-bound-in-derive-copy-impl.rs:4:12
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^^
|
||||
| ----- in this derive macro expansion
|
||||
LL | pub struct Vector2<T: Debug + Copy + Clone> {
|
||||
| ---- unsatisfied trait bound introduced in this `derive` macro
|
||||
| ^^^^^^^ ---- unsatisfied trait bound
|
||||
= help: consider manually implementing `Debug` to avoid undesired bounds
|
||||
= note: required for the cast from `&Vector2<K>` to `&dyn Debug`
|
||||
help: consider restricting type parameter `K` with trait `Copy`
|
||||
|
|
||||
|
|
@ -128,12 +130,13 @@ LL | pub size: Vector2<K>,
|
|||
| ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `K`
|
||||
|
|
||||
note: required for `Vector2<K>` to implement `Clone`
|
||||
--> $DIR/missing-bound-in-derive-copy-impl.rs:3:23
|
||||
--> $DIR/missing-bound-in-derive-copy-impl.rs:4:12
|
||||
|
|
||||
LL | #[derive(Debug, Copy, Clone)]
|
||||
| ^^^^^
|
||||
| ----- in this derive macro expansion
|
||||
LL | pub struct Vector2<T: Debug + Copy + Clone> {
|
||||
| ---- unsatisfied trait bound introduced in this `derive` macro
|
||||
| ^^^^^^^ ---- unsatisfied trait bound
|
||||
= help: consider manually implementing `Clone` to avoid undesired bounds
|
||||
help: consider restricting type parameter `K` with trait `Copy`
|
||||
|
|
||||
LL | pub struct AABB<K: std::marker::Copy> {
|
||||
|
|
|
|||
24
tests/ui/traits/derive-implicit-bound-on-clone.rs
Normal file
24
tests/ui/traits/derive-implicit-bound-on-clone.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Issue #146515
|
||||
use std::rc::Rc;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct ContainsRc<T, K> { //~ HELP `Clone` is not implemented
|
||||
value: Rc<(T, K)>,
|
||||
}
|
||||
|
||||
fn clone_me<T, K>(x: &ContainsRc<T, K>) -> ContainsRc<T, K> {
|
||||
x.clone() //~ ERROR E0308
|
||||
//~^ HELP consider manually implementing `Clone`
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct ContainsRcSingle<T> { //~ HELP `Clone` is not implemented
|
||||
value: Rc<T>,
|
||||
}
|
||||
|
||||
fn clone_me_single<T>(x: &ContainsRcSingle<T>) -> ContainsRcSingle<T> {
|
||||
x.clone() //~ ERROR E0308
|
||||
//~^ HELP consider manually implementing `Clone`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
53
tests/ui/traits/derive-implicit-bound-on-clone.stderr
Normal file
53
tests/ui/traits/derive-implicit-bound-on-clone.stderr
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/derive-implicit-bound-on-clone.rs:10:5
|
||||
|
|
||||
LL | fn clone_me<T, K>(x: &ContainsRc<T, K>) -> ContainsRc<T, K> {
|
||||
| ---------------- expected `ContainsRc<T, K>` because of return type
|
||||
LL | x.clone()
|
||||
| ^^^^^^^^^ expected `ContainsRc<T, K>`, found `&ContainsRc<T, K>`
|
||||
|
|
||||
= note: expected struct `ContainsRc<_, _>`
|
||||
found reference `&ContainsRc<_, _>`
|
||||
note: `ContainsRc<T, K>` does not implement `Clone`, so `&ContainsRc<T, K>` was cloned instead
|
||||
--> $DIR/derive-implicit-bound-on-clone.rs:10:5
|
||||
|
|
||||
LL | x.clone()
|
||||
| ^
|
||||
help: `Clone` is not implemented because the some trait bounds could not be satisfied
|
||||
--> $DIR/derive-implicit-bound-on-clone.rs:5:19
|
||||
|
|
||||
LL | #[derive(Clone)]
|
||||
| ----- in this derive macro expansion
|
||||
LL | struct ContainsRc<T, K> {
|
||||
| ^ ^ derive introduces an implicit unsatisfied trait bound `K: Clone`
|
||||
| |
|
||||
| derive introduces an implicit unsatisfied trait bound `T: Clone`
|
||||
= help: consider manually implementing `Clone` to avoid the implicit type parameter bounds
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/derive-implicit-bound-on-clone.rs:20:5
|
||||
|
|
||||
LL | fn clone_me_single<T>(x: &ContainsRcSingle<T>) -> ContainsRcSingle<T> {
|
||||
| ------------------- expected `ContainsRcSingle<T>` because of return type
|
||||
LL | x.clone()
|
||||
| ^^^^^^^^^ expected `ContainsRcSingle<T>`, found `&ContainsRcSingle<T>`
|
||||
|
|
||||
= note: expected struct `ContainsRcSingle<_>`
|
||||
found reference `&ContainsRcSingle<_>`
|
||||
note: `ContainsRcSingle<T>` does not implement `Clone`, so `&ContainsRcSingle<T>` was cloned instead
|
||||
--> $DIR/derive-implicit-bound-on-clone.rs:20:5
|
||||
|
|
||||
LL | x.clone()
|
||||
| ^
|
||||
help: `Clone` is not implemented because a trait bound is not satisfied
|
||||
--> $DIR/derive-implicit-bound-on-clone.rs:15:25
|
||||
|
|
||||
LL | #[derive(Clone)]
|
||||
| ----- in this derive macro expansion
|
||||
LL | struct ContainsRcSingle<T> {
|
||||
| ^ derive introduces an implicit `T: Clone` bound
|
||||
= help: consider manually implementing `Clone` to avoid the implicit type parameter bounds
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
34
tests/ui/traits/derive-implicit-bound.rs
Normal file
34
tests/ui/traits/derive-implicit-bound.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
// Second case reported in issue #108894.
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct Id<T>(PhantomData<T>);
|
||||
|
||||
// manual implementation which would break the usage of const patterns
|
||||
// impl<T> PartialEq for Id<T> { fn eq(&self, _: &Id<T>) -> bool { true } }
|
||||
// impl<T> Eq for Id<T> {}
|
||||
|
||||
// This derive is undesired but cannot be removed without
|
||||
// breaking the usages below
|
||||
// #[derive(PartialEq, Eq)]
|
||||
struct SomeNode();
|
||||
|
||||
fn accept_eq(_: &impl PartialEq) { }
|
||||
|
||||
fn main() {
|
||||
let node = Id::<SomeNode>(PhantomData);
|
||||
|
||||
// this will only work if
|
||||
// - `Partial/Eq` is implemented manually, or
|
||||
// - `SomeNode` also needlessly(?) implements `Partial/Eq`
|
||||
accept_eq(&node); //~ ERROR can't compare `SomeNode` with `SomeNode`
|
||||
|
||||
const CONST_ID: Id::<SomeNode> = Id::<SomeNode>(PhantomData);
|
||||
// this will work only when `Partial/Eq` is being derived
|
||||
// otherwise: error: to use a constant of type `Id<SomeNode>` in a pattern,
|
||||
// `Id<SomeNode>` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
match node {
|
||||
CONST_ID => {}
|
||||
}
|
||||
}
|
||||
31
tests/ui/traits/derive-implicit-bound.stderr
Normal file
31
tests/ui/traits/derive-implicit-bound.stderr
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
error[E0277]: can't compare `SomeNode` with `SomeNode`
|
||||
--> $DIR/derive-implicit-bound.rs:25:15
|
||||
|
|
||||
LL | accept_eq(&node);
|
||||
| --------- ^^^^^ no implementation for `SomeNode == SomeNode`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= help: the trait `PartialEq` is not implemented for `SomeNode`
|
||||
note: required for `Id<SomeNode>` to implement `PartialEq`
|
||||
--> $DIR/derive-implicit-bound.rs:6:12
|
||||
|
|
||||
LL | #[derive(PartialEq, Eq)]
|
||||
| --------- in this derive macro expansion
|
||||
LL | pub struct Id<T>(PhantomData<T>);
|
||||
| ^^ - type parameter would need to implement `PartialEq`
|
||||
= help: consider manually implementing `PartialEq` to avoid undesired bounds
|
||||
note: required by a bound in `accept_eq`
|
||||
--> $DIR/derive-implicit-bound.rs:17:23
|
||||
|
|
||||
LL | fn accept_eq(_: &impl PartialEq) { }
|
||||
| ^^^^^^^^^ required by this bound in `accept_eq`
|
||||
help: consider annotating `SomeNode` with `#[derive(PartialEq)]`
|
||||
|
|
||||
LL + #[derive(PartialEq)]
|
||||
LL | struct SomeNode();
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
#[derive(Clone)]
|
||||
//~^ ERROR expected a type, found a trait
|
||||
//~| ERROR expected a type, found a trait
|
||||
struct Foo;
|
||||
trait Foo {} //~ ERROR the name `Foo` is defined multiple times
|
||||
#[derive(Clone)] //~ ERROR: expected a type, found a trait
|
||||
struct Foo; //~ ERROR: expected a type, found a trait
|
||||
trait Foo {} //~ ERROR: the name `Foo` is defined multiple times
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0428]: the name `Foo` is defined multiple times
|
||||
--> $DIR/issue-106072.rs:5:1
|
||||
--> $DIR/issue-106072.rs:3:1
|
||||
|
|
||||
LL | struct Foo;
|
||||
| ----------- previous definition of the type `Foo` here
|
||||
|
|
@ -9,18 +9,18 @@ LL | trait Foo {}
|
|||
= note: `Foo` must be defined only once in the type namespace of this module
|
||||
|
||||
error[E0782]: expected a type, found a trait
|
||||
--> $DIR/issue-106072.rs:1:10
|
||||
--> $DIR/issue-106072.rs:2:8
|
||||
|
|
||||
LL | #[derive(Clone)]
|
||||
| ^^^^^
|
||||
| ----- in this derive macro expansion
|
||||
LL | struct Foo;
|
||||
| ^^^
|
||||
|
||||
error[E0782]: expected a type, found a trait
|
||||
--> $DIR/issue-106072.rs:1:10
|
||||
|
|
||||
LL | #[derive(Clone)]
|
||||
| ^^^^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
#[derive(Clone, Copy)]
|
||||
//~^ ERROR the trait `Copy` cannot be implemented for this type
|
||||
struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
//~^ ERROR cannot find type `NotDefined` in this scope
|
||||
//~^ ERROR the trait `Copy` cannot be implemented for this type
|
||||
//~| ERROR cannot find type `NotDefined` in this scope
|
||||
//~| ERROR cannot find type `NotDefined` in this scope
|
||||
//~| ERROR cannot find type `N` in this scope
|
||||
//~| ERROR cannot find type `N` in this scope
|
||||
//~| ERROR `i32` is not an iterator
|
||||
//~| ERROR `i32` is not an iterator
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
//~^ ERROR the trait `Copy` cannot be implemented for this type
|
||||
//~| ERROR `i32` is not an iterator
|
||||
#[derive(Clone, Copy)] //~ ERROR `i32` is not an iterator
|
||||
struct Bar<T>(T, N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
//~^ ERROR cannot find type `NotDefined` in this scope
|
||||
//~^ ERROR the trait `Copy` cannot be implemented for this type
|
||||
//~| ERROR cannot find type `NotDefined` in this scope
|
||||
//~| ERROR cannot find type `N` in this scope
|
||||
//~| ERROR `i32` is not an iterator
|
||||
//~| ERROR `i32` is not an iterator
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0425]: cannot find type `N` in this scope
|
||||
--> $DIR/issue-50480.rs:3:12
|
||||
--> $DIR/issue-50480.rs:2:12
|
||||
|
|
||||
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| ^ not found in this scope
|
||||
|
|
@ -10,13 +10,13 @@ LL | struct Foo<N>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
|||
| +++
|
||||
|
||||
error[E0425]: cannot find type `NotDefined` in this scope
|
||||
--> $DIR/issue-50480.rs:3:15
|
||||
--> $DIR/issue-50480.rs:2:15
|
||||
|
|
||||
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| ^^^^^^^^^^ not found in this scope
|
||||
|
||||
error[E0425]: cannot find type `N` in this scope
|
||||
--> $DIR/issue-50480.rs:3:12
|
||||
--> $DIR/issue-50480.rs:2:12
|
||||
|
|
||||
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| ^ not found in this scope
|
||||
|
|
@ -27,7 +27,7 @@ LL | struct Foo<N>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
|||
| +++
|
||||
|
||||
error[E0425]: cannot find type `NotDefined` in this scope
|
||||
--> $DIR/issue-50480.rs:3:15
|
||||
--> $DIR/issue-50480.rs:2:15
|
||||
|
|
||||
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| ^^^^^^^^^^ not found in this scope
|
||||
|
|
@ -38,7 +38,7 @@ LL | struct Foo<NotDefined>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, St
|
|||
| ++++++++++++
|
||||
|
||||
error[E0425]: cannot find type `N` in this scope
|
||||
--> $DIR/issue-50480.rs:14:18
|
||||
--> $DIR/issue-50480.rs:12:18
|
||||
|
|
||||
LL | struct Bar<T>(T, N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| - ^
|
||||
|
|
@ -56,13 +56,13 @@ LL | struct Bar<T, N>(T, N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, Strin
|
|||
| +++
|
||||
|
||||
error[E0425]: cannot find type `NotDefined` in this scope
|
||||
--> $DIR/issue-50480.rs:14:21
|
||||
--> $DIR/issue-50480.rs:12:21
|
||||
|
|
||||
LL | struct Bar<T>(T, N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| ^^^^^^^^^^ not found in this scope
|
||||
|
||||
error[E0277]: `i32` is not an iterator
|
||||
--> $DIR/issue-50480.rs:3:27
|
||||
--> $DIR/issue-50480.rs:2:27
|
||||
|
|
||||
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator
|
||||
|
|
@ -70,29 +70,27 @@ LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
|||
= help: the trait `Iterator` is not implemented for `i32`
|
||||
|
||||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/issue-50480.rs:1:17
|
||||
--> $DIR/issue-50480.rs:2:8
|
||||
|
|
||||
LL | #[derive(Clone, Copy)]
|
||||
| ^^^^
|
||||
LL |
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| -------- ------ this field does not implement `Copy`
|
||||
| ^^^ -------- ------ this field does not implement `Copy`
|
||||
| |
|
||||
| this field does not implement `Copy`
|
||||
|
||||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/issue-50480.rs:11:17
|
||||
--> $DIR/issue-50480.rs:12:8
|
||||
|
|
||||
LL | #[derive(Clone, Copy)]
|
||||
| ^^^^
|
||||
...
|
||||
| ---- in this derive macro expansion
|
||||
LL | struct Bar<T>(T, N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| -------- ------ this field does not implement `Copy`
|
||||
| ^^^ -------- ------ this field does not implement `Copy`
|
||||
| |
|
||||
| this field does not implement `Copy`
|
||||
|
||||
error[E0277]: `i32` is not an iterator
|
||||
--> $DIR/issue-50480.rs:14:33
|
||||
--> $DIR/issue-50480.rs:12:33
|
||||
|
|
||||
LL | struct Bar<T>(T, N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator
|
||||
|
|
@ -100,7 +98,7 @@ LL | struct Bar<T>(T, N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
|||
= help: the trait `Iterator` is not implemented for `i32`
|
||||
|
||||
error[E0277]: `i32` is not an iterator
|
||||
--> $DIR/issue-50480.rs:3:28
|
||||
--> $DIR/issue-50480.rs:2:28
|
||||
|
|
||||
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| ^^^ `i32` is not an iterator
|
||||
|
|
@ -116,11 +114,10 @@ LL | #[derive(Clone, Copy)]
|
|||
= help: the trait `Iterator` is not implemented for `i32`
|
||||
|
||||
error[E0277]: `i32` is not an iterator
|
||||
--> $DIR/issue-50480.rs:14:33
|
||||
--> $DIR/issue-50480.rs:12:33
|
||||
|
|
||||
LL | #[derive(Clone, Copy)]
|
||||
| ----- in this derive macro expansion
|
||||
...
|
||||
LL | struct Bar<T>(T, N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator
|
||||
|
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
// we already face this difficulty, probably. If we need to fix this by reducing the error margin,
|
||||
// we should improve compiletest.
|
||||
|
||||
#[derive(Clone, Eq)] //~ ERROR [E0277]
|
||||
pub struct Struct<T>(T);
|
||||
#[derive(Clone, Eq)]
|
||||
pub struct Struct<T>(T); //~ ERROR [E0277]
|
||||
|
||||
impl<T: Clone, U> PartialEq<U> for Struct<T>
|
||||
where
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error[E0277]: the trait bound `T: Clone` is not satisfied
|
||||
--> $DIR/global-cache-and-parallel-frontend.rs:15:17
|
||||
--> $DIR/global-cache-and-parallel-frontend.rs:16:12
|
||||
|
|
||||
LL | #[derive(Clone, Eq)]
|
||||
| ^^ the trait `Clone` is not implemented for `T`
|
||||
| -- in this derive macro expansion
|
||||
LL | pub struct Struct<T>(T);
|
||||
| ^^^^^^ the trait `Clone` is not implemented for `T`
|
||||
|
|
||||
note: required for `Struct<T>` to implement `PartialEq`
|
||||
--> $DIR/global-cache-and-parallel-frontend.rs:18:19
|
||||
|
|
|
|||
|
|
@ -25,10 +25,13 @@ LL | let w = u.clone();
|
|||
| ^^^^^ method cannot be called on `U5<CloneNoCopy>` due to unsatisfied trait bounds
|
||||
|
|
||||
note: trait bound `CloneNoCopy: Copy` was not satisfied
|
||||
--> $DIR/union-derive-clone.rs:25:10
|
||||
--> $DIR/union-derive-clone.rs:26:10
|
||||
|
|
||||
LL | #[derive(Clone, Copy)]
|
||||
| ^^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
| ----- in this derive macro expansion
|
||||
LL | union U5<T> {
|
||||
| ^ type parameter would need to implement `Clone`
|
||||
= help: consider manually implementing the trait to avoid undesired bounds
|
||||
help: consider annotating `CloneNoCopy` with `#[derive(Clone, Copy)]`
|
||||
|
|
||||
LL + #[derive(Clone, Copy)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue