Skip to content

Commit d7cada1

Browse files
committed
obligation cause: RepeatVec -> RepeatValueCopy
1 parent e730969 commit d7cada1

File tree

4 files changed

+11
-8
lines changed
  • compiler
    • rustc_borrowck/src/type_check
    • rustc_middle/src/traits
    • rustc_mir_build/src/thir/pattern
    • rustc_trait_selection/src/traits/error_reporting

4 files changed

+11
-8
lines changed

Diff for: compiler/rustc_borrowck/src/type_check/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18991899
ObligationCause::new(
19001900
span,
19011901
self.tcx().hir().local_def_id_to_hir_id(def_id),
1902-
traits::ObligationCauseCode::RepeatVec(is_const_fn),
1902+
traits::ObligationCauseCode::RepeatElementCopy {
1903+
is_const_fn,
1904+
},
19031905
),
19041906
self.param_env,
19051907
ty::Binder::dummy(ty::TraitRef::new(

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,12 @@ pub enum ObligationCauseCode<'tcx> {
236236
SizedBoxType,
237237
/// Inline asm operand type must be `Sized`.
238238
InlineAsmSized,
239-
/// `[T, ..n]` implies that `T` must be `Copy`.
240-
/// If the function in the array repeat expression is a `const fn`,
241-
/// display a help message suggesting to move the function call to a
242-
/// new `const` item while saying that `T` doesn't implement `Copy`.
243-
RepeatVec(bool),
239+
/// `[expr; N]` requires `type_of(expr): Copy`.
240+
RepeatElementCopy {
241+
/// If element is a `const fn` we display a help message suggesting to move the
242+
/// function call to a new `const` item while saying that `T` doesn't implement `Copy`.
243+
is_const_fn: bool,
244+
},
244245

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

Diff for: compiler/rustc_mir_build/src/thir/pattern/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
198198
let kind = match pat.kind {
199199
hir::PatKind::Wild => PatKind::Wild,
200200

201-
hir::PatKind::Lit(ref value) => self.lower_lit(value),
201+
hir::PatKind::Lit(value) => self.lower_lit(value),
202202

203203
hir::PatKind::Range(ref lo_expr, ref hi_expr, end) => {
204204
let (lo_expr, hi_expr) = (lo_expr.as_deref(), hi_expr.as_deref());

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
19881988
ObligationCauseCode::Coercion { source: _, target } => {
19891989
err.note(&format!("required by cast to type `{}`", self.ty_to_string(target)));
19901990
}
1991-
ObligationCauseCode::RepeatVec(is_const_fn) => {
1991+
ObligationCauseCode::RepeatElementCopy { is_const_fn } => {
19921992
err.note(
19931993
"the `Copy` trait is required because the repeated element will be copied",
19941994
);

0 commit comments

Comments
 (0)