Rollup merge of #135049 - cramertj:rmunused, r=compiler-errors
Remove unused fields from RepeatElementCopy obligation
This commit is contained in:
commit
0053aa4e9d
3 changed files with 7 additions and 25 deletions
|
@ -1907,21 +1907,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
};
|
||||
|
||||
let lang_item = self.tcx.require_lang_item(LangItem::Copy, None);
|
||||
let code = traits::ObligationCauseCode::RepeatElementCopy {
|
||||
is_constable,
|
||||
elt_type: element_ty,
|
||||
elt_span: element.span,
|
||||
elt_stmt_span: self
|
||||
.tcx
|
||||
.hir()
|
||||
.parent_iter(element.hir_id)
|
||||
.find_map(|(_, node)| match node {
|
||||
hir::Node::Item(it) => Some(it.span),
|
||||
hir::Node::Stmt(stmt) => Some(stmt.span),
|
||||
_ => None,
|
||||
})
|
||||
.expect("array repeat expressions must be inside an item or statement"),
|
||||
};
|
||||
let code =
|
||||
traits::ObligationCauseCode::RepeatElementCopy { is_constable, elt_span: element.span };
|
||||
self.require_type_meets(element_ty, element.span, code, lang_item);
|
||||
}
|
||||
|
||||
|
|
|
@ -247,11 +247,11 @@ pub enum ObligationCauseCode<'tcx> {
|
|||
/// If element is a `const fn` or const ctor we display a help message suggesting
|
||||
/// to move it to a new `const` item while saying that `T` doesn't implement `Copy`.
|
||||
is_constable: IsConstable,
|
||||
elt_type: Ty<'tcx>,
|
||||
|
||||
/// Span of the repeat element.
|
||||
///
|
||||
/// This is used to suggest wrapping it in a `const { ... }` block.
|
||||
elt_span: Span,
|
||||
/// Span of the statement/item in which the repeat expression occurs. We can use this to
|
||||
/// place a `const` declaration before it
|
||||
elt_stmt_span: Span,
|
||||
},
|
||||
|
||||
/// Types of fields (other than the last, except for packed structs) in a struct must be sized.
|
||||
|
|
|
@ -2966,12 +2966,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
"required for the cast from `{source}` to `{target}`",
|
||||
)));
|
||||
}
|
||||
ObligationCauseCode::RepeatElementCopy {
|
||||
is_constable,
|
||||
elt_type: _,
|
||||
elt_span,
|
||||
elt_stmt_span: _,
|
||||
} => {
|
||||
ObligationCauseCode::RepeatElementCopy { is_constable, elt_span } => {
|
||||
err.note(
|
||||
"the `Copy` trait is required because this value will be copied for each element of the array",
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue