Skip to content

Commit 0053aa4

Browse files
authored
Rollup merge of #135049 - cramertj:rmunused, r=compiler-errors
Remove unused fields from RepeatElementCopy obligation
2 parents e0f4dc9 + 9281be9 commit 0053aa4

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

Diff for: compiler/rustc_hir_typeck/src/expr.rs

+2-15
Original file line numberDiff line numberDiff line change
@@ -1907,21 +1907,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19071907
};
19081908

19091909
let lang_item = self.tcx.require_lang_item(LangItem::Copy, None);
1910-
let code = traits::ObligationCauseCode::RepeatElementCopy {
1911-
is_constable,
1912-
elt_type: element_ty,
1913-
elt_span: element.span,
1914-
elt_stmt_span: self
1915-
.tcx
1916-
.hir()
1917-
.parent_iter(element.hir_id)
1918-
.find_map(|(_, node)| match node {
1919-
hir::Node::Item(it) => Some(it.span),
1920-
hir::Node::Stmt(stmt) => Some(stmt.span),
1921-
_ => None,
1922-
})
1923-
.expect("array repeat expressions must be inside an item or statement"),
1924-
};
1910+
let code =
1911+
traits::ObligationCauseCode::RepeatElementCopy { is_constable, elt_span: element.span };
19251912
self.require_type_meets(element_ty, element.span, code, lang_item);
19261913
}
19271914

Diff for: compiler/rustc_middle/src/traits/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ pub enum ObligationCauseCode<'tcx> {
247247
/// If element is a `const fn` or const ctor we display a help message suggesting
248248
/// to move it to a new `const` item while saying that `T` doesn't implement `Copy`.
249249
is_constable: IsConstable,
250-
elt_type: Ty<'tcx>,
250+
251+
/// Span of the repeat element.
252+
///
253+
/// This is used to suggest wrapping it in a `const { ... }` block.
251254
elt_span: Span,
252-
/// Span of the statement/item in which the repeat expression occurs. We can use this to
253-
/// place a `const` declaration before it
254-
elt_stmt_span: Span,
255255
},
256256

257257
/// Types of fields (other than the last, except for packed structs) in a struct must be sized.

Diff for: compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -2966,12 +2966,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
29662966
"required for the cast from `{source}` to `{target}`",
29672967
)));
29682968
}
2969-
ObligationCauseCode::RepeatElementCopy {
2970-
is_constable,
2971-
elt_type: _,
2972-
elt_span,
2973-
elt_stmt_span: _,
2974-
} => {
2969+
ObligationCauseCode::RepeatElementCopy { is_constable, elt_span } => {
29752970
err.note(
29762971
"the `Copy` trait is required because this value will be copied for each element of the array",
29772972
);

0 commit comments

Comments
 (0)