Wording tweak
This commit is contained in:
parent
5f91614d12
commit
d09851cfba
11 changed files with 45 additions and 26 deletions
|
@ -98,8 +98,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let err =
|
let err = self.report_use_of_uninitialized(
|
||||||
self.report_use_of_uninitialized(mpi, used_place, desired_action, span, use_spans);
|
mpi,
|
||||||
|
used_place,
|
||||||
|
moved_place,
|
||||||
|
desired_action,
|
||||||
|
span,
|
||||||
|
use_spans,
|
||||||
|
);
|
||||||
self.buffer_error(err);
|
self.buffer_error(err);
|
||||||
} else {
|
} else {
|
||||||
if let Some((reported_place, _)) = self.has_move_error(&move_out_indices) {
|
if let Some((reported_place, _)) = self.has_move_error(&move_out_indices) {
|
||||||
|
@ -316,6 +322,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
&self,
|
&self,
|
||||||
mpi: MovePathIndex,
|
mpi: MovePathIndex,
|
||||||
used_place: PlaceRef<'tcx>,
|
used_place: PlaceRef<'tcx>,
|
||||||
|
moved_place: PlaceRef<'tcx>,
|
||||||
desired_action: InitializationRequiringAction,
|
desired_action: InitializationRequiringAction,
|
||||||
span: Span,
|
span: Span,
|
||||||
use_spans: UseSpans<'tcx>,
|
use_spans: UseSpans<'tcx>,
|
||||||
|
@ -334,11 +341,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (binding, name, desc) =
|
let (name, desc) =
|
||||||
match self.describe_place_with_options(used_place, IncludingDowncast(true)) {
|
match self.describe_place_with_options(moved_place, IncludingDowncast(true)) {
|
||||||
Some(name) => (format!("`{name}`"), format!("`{name}`"), format!("`{name}` ")),
|
Some(name) => (format!("`{name}`"), format!("`{name}` ")),
|
||||||
None => ("value".to_string(), "the variable".to_string(), String::new()),
|
None => ("the variable".to_string(), String::new()),
|
||||||
};
|
};
|
||||||
|
let path = match self.describe_place_with_options(used_place, IncludingDowncast(true)) {
|
||||||
|
Some(name) => format!("`{name}`"),
|
||||||
|
None => "value".to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
// We use the statements were the binding was initialized, and inspect the HIR to look
|
// We use the statements were the binding was initialized, and inspect the HIR to look
|
||||||
// for the branching codepaths that aren't covered, to point at them.
|
// for the branching codepaths that aren't covered, to point at them.
|
||||||
|
@ -390,13 +401,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
|
format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let InitializationRequiringAction::PartialAssignment = desired_action {
|
if let InitializationRequiringAction::PartialAssignment
|
||||||
|
| InitializationRequiringAction::Assignment = desired_action
|
||||||
|
{
|
||||||
err.help(
|
err.help(
|
||||||
"partial initialization isn't supported, fully initialize the binding with a \
|
"partial initialization isn't supported, fully initialize the binding with a \
|
||||||
default value and mutate it, or use `std::mem::MaybeUninit`",
|
default value and mutate it, or use `std::mem::MaybeUninit`",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
err.span_label(span, format!("{binding} {used} here but it {isnt_initialized}"));
|
err.span_label(span, format!("{path} {used} here but it {isnt_initialized}"));
|
||||||
|
|
||||||
let mut shown = false;
|
let mut shown = false;
|
||||||
for (sp, label) in visitor.errors {
|
for (sp, label) in visitor.errors {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0381]: used binding `origin.y` isn't initialized
|
error[E0381]: used binding `origin` isn't initialized
|
||||||
--> $DIR/borrowck-init-in-fru.rs:9:14
|
--> $DIR/borrowck-init-in-fru.rs:9:14
|
||||||
|
|
|
|
||||||
LL | let mut origin: Point;
|
LL | let mut origin: Point;
|
||||||
|
|
|
@ -5,6 +5,8 @@ LL | let mut x : (Test2, Test2);
|
||||||
| ----- binding declared here but left uninitialized
|
| ----- binding declared here but left uninitialized
|
||||||
LL | (x.0).0 = Some(Test);
|
LL | (x.0).0 = Some(Test);
|
||||||
| ^^^^^^^ `x.0` assigned here but it isn't fully initialized
|
| ^^^^^^^ `x.0` assigned here but it isn't fully initialized
|
||||||
|
|
|
||||||
|
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0381]: used binding `a.x` isn't initialized
|
error[E0381]: used binding `a` isn't initialized
|
||||||
--> $DIR/borrowck-uninit-field-access.rs:21:13
|
--> $DIR/borrowck-uninit-field-access.rs:21:13
|
||||||
|
|
|
|
||||||
LL | let mut a: Point;
|
LL | let mut a: Point;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0381]: used binding `**x` isn't initialized
|
error[E0381]: used binding `x` isn't initialized
|
||||||
--> $DIR/borrowck-uninit-ref-chain.rs:8:14
|
--> $DIR/borrowck-uninit-ref-chain.rs:8:14
|
||||||
|
|
|
|
||||||
LL | let x: &&Box<i32>;
|
LL | let x: &&Box<i32>;
|
||||||
|
@ -6,7 +6,7 @@ LL | let x: &&Box<i32>;
|
||||||
LL | let _y = &**x;
|
LL | let _y = &**x;
|
||||||
| ^^^^ `**x` used here but it isn't initialized
|
| ^^^^ `**x` used here but it isn't initialized
|
||||||
|
|
||||||
error[E0381]: used binding `**x` isn't initialized
|
error[E0381]: used binding `x` isn't initialized
|
||||||
--> $DIR/borrowck-uninit-ref-chain.rs:11:14
|
--> $DIR/borrowck-uninit-ref-chain.rs:11:14
|
||||||
|
|
|
|
||||||
LL | let x: &&S<i32, i32>;
|
LL | let x: &&S<i32, i32>;
|
||||||
|
@ -14,7 +14,7 @@ LL | let x: &&S<i32, i32>;
|
||||||
LL | let _y = &**x;
|
LL | let _y = &**x;
|
||||||
| ^^^^ `**x` used here but it isn't initialized
|
| ^^^^ `**x` used here but it isn't initialized
|
||||||
|
|
||||||
error[E0381]: used binding `**x` isn't initialized
|
error[E0381]: used binding `x` isn't initialized
|
||||||
--> $DIR/borrowck-uninit-ref-chain.rs:14:14
|
--> $DIR/borrowck-uninit-ref-chain.rs:14:14
|
||||||
|
|
|
|
||||||
LL | let x: &&i32;
|
LL | let x: &&i32;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0381]: used binding `*w` isn't initialized
|
error[E0381]: used binding `w` isn't initialized
|
||||||
--> $DIR/borrowck-use-in-index-lvalue.rs:3:5
|
--> $DIR/borrowck-use-in-index-lvalue.rs:3:5
|
||||||
|
|
|
|
||||||
LL | let w: &mut [isize];
|
LL | let w: &mut [isize];
|
||||||
|
@ -6,7 +6,7 @@ LL | let w: &mut [isize];
|
||||||
LL | w[5] = 0;
|
LL | w[5] = 0;
|
||||||
| ^^^^ `*w` used here but it isn't initialized
|
| ^^^^ `*w` used here but it isn't initialized
|
||||||
|
|
||||||
error[E0381]: used binding `*w` isn't initialized
|
error[E0381]: used binding `w` isn't initialized
|
||||||
--> $DIR/borrowck-use-in-index-lvalue.rs:6:5
|
--> $DIR/borrowck-use-in-index-lvalue.rs:6:5
|
||||||
|
|
|
|
||||||
LL | let mut w: &mut [isize];
|
LL | let mut w: &mut [isize];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0381]: used binding `*x` isn't initialized
|
error[E0381]: used binding `x` isn't initialized
|
||||||
--> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:9:13
|
--> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:9:13
|
||||||
|
|
|
|
||||||
LL | let x: &i32;
|
LL | let x: &i32;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0381]: used binding `*x` isn't initialized
|
error[E0381]: used binding `x` isn't initialized
|
||||||
--> $DIR/borrowck-use-uninitialized-in-cast.rs:7:13
|
--> $DIR/borrowck-use-uninitialized-in-cast.rs:7:13
|
||||||
|
|
|
|
||||||
LL | let x: &i32;
|
LL | let x: &i32;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0381]: used binding `*s` isn't initialized
|
error[E0381]: used binding `s` isn't initialized
|
||||||
--> $DIR/const-generic-default-wont-borrowck.rs:2:26
|
--> $DIR/const-generic-default-wont-borrowck.rs:2:26
|
||||||
|
|
|
|
||||||
LL | let s: &'static str; s.len()
|
LL | let s: &'static str; s.len()
|
||||||
|
|
|
@ -5,6 +5,8 @@ LL | let d: D;
|
||||||
| - binding declared here but left uninitialized
|
| - binding declared here but left uninitialized
|
||||||
LL | d.x = 10;
|
LL | d.x = 10;
|
||||||
| ^^^^^^^^ `d` assigned here but it isn't fully initialized
|
| ^^^^^^^^ `d` assigned here but it isn't fully initialized
|
||||||
|
|
|
||||||
|
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
||||||
|
|
||||||
error[E0381]: assigned binding `d` isn't fully initialized
|
error[E0381]: assigned binding `d` isn't fully initialized
|
||||||
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:33:5
|
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:33:5
|
||||||
|
@ -13,6 +15,8 @@ LL | let mut d: D;
|
||||||
| ----- binding declared here but left uninitialized
|
| ----- binding declared here but left uninitialized
|
||||||
LL | d.x = 10;
|
LL | d.x = 10;
|
||||||
| ^^^^^^^^ `d` assigned here but it isn't fully initialized
|
| ^^^^^^^^ `d` assigned here but it isn't fully initialized
|
||||||
|
|
|
||||||
|
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
||||||
|
|
||||||
error[E0382]: assign of moved value: `d`
|
error[E0382]: assign of moved value: `d`
|
||||||
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:39:5
|
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:39:5
|
||||||
|
@ -24,7 +28,7 @@ LL | drop(d);
|
||||||
LL | d.x = 10;
|
LL | d.x = 10;
|
||||||
| ^^^^^^^^ value assigned here after move
|
| ^^^^^^^^ value assigned here after move
|
||||||
|
|
||||||
error[E0381]: partially assigned binding `d.s` isn't fully initialized
|
error[E0381]: partially assigned binding `d` isn't fully initialized
|
||||||
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:45:5
|
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:45:5
|
||||||
|
|
|
|
||||||
LL | let d: D;
|
LL | let d: D;
|
||||||
|
@ -34,7 +38,7 @@ LL | d.s.y = 20;
|
||||||
|
|
|
|
||||||
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
||||||
|
|
||||||
error[E0381]: partially assigned binding `d.s` isn't fully initialized
|
error[E0381]: partially assigned binding `d` isn't fully initialized
|
||||||
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:50:5
|
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:50:5
|
||||||
|
|
|
|
||||||
LL | let mut d: D;
|
LL | let mut d: D;
|
||||||
|
|
|
@ -98,7 +98,7 @@ LL | t.0 = 10;
|
||||||
|
|
|
|
||||||
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
||||||
|
|
||||||
error[E0381]: partially assigned binding `q.r.f` isn't fully initialized
|
error[E0381]: partially assigned binding `q` isn't fully initialized
|
||||||
--> $DIR/issue-21232-partial-init-and-use.rs:170:5
|
--> $DIR/issue-21232-partial-init-and-use.rs:170:5
|
||||||
|
|
|
|
||||||
LL | let q: Q<S<B>>;
|
LL | let q: Q<S<B>>;
|
||||||
|
@ -108,7 +108,7 @@ LL | q.r.f.x = 10; q.r.f.y = Box::new(20);
|
||||||
|
|
|
|
||||||
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
||||||
|
|
||||||
error[E0381]: partially assigned binding `q.r.f` isn't fully initialized
|
error[E0381]: partially assigned binding `q` isn't fully initialized
|
||||||
--> $DIR/issue-21232-partial-init-and-use.rs:176:5
|
--> $DIR/issue-21232-partial-init-and-use.rs:176:5
|
||||||
|
|
|
|
||||||
LL | let q: Q<T>;
|
LL | let q: Q<T>;
|
||||||
|
@ -138,7 +138,7 @@ LL | q.r.f.0 = 10; q.r.f.1 = Box::new(20);
|
||||||
|
|
|
|
||||||
= note: move occurs because `q.r` has type `R<(u32, Box<u32>)>`, which does not implement the `Copy` trait
|
= note: move occurs because `q.r` has type `R<(u32, Box<u32>)>`, which does not implement the `Copy` trait
|
||||||
|
|
||||||
error[E0381]: partially assigned binding `q.r.f` isn't fully initialized
|
error[E0381]: partially assigned binding `q` isn't fully initialized
|
||||||
--> $DIR/issue-21232-partial-init-and-use.rs:196:5
|
--> $DIR/issue-21232-partial-init-and-use.rs:196:5
|
||||||
|
|
|
|
||||||
LL | let q: Q<S<B>>;
|
LL | let q: Q<S<B>>;
|
||||||
|
@ -148,7 +148,7 @@ LL | q.r.f.x = 10;
|
||||||
|
|
|
|
||||||
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
||||||
|
|
||||||
error[E0381]: partially assigned binding `q.r.f` isn't fully initialized
|
error[E0381]: partially assigned binding `q` isn't fully initialized
|
||||||
--> $DIR/issue-21232-partial-init-and-use.rs:202:5
|
--> $DIR/issue-21232-partial-init-and-use.rs:202:5
|
||||||
|
|
|
|
||||||
LL | let q: Q<T>;
|
LL | let q: Q<T>;
|
||||||
|
@ -178,7 +178,7 @@ LL | q.r.f.0 = 10;
|
||||||
|
|
|
|
||||||
= note: move occurs because `q.r` has type `R<(u32, Box<u32>)>`, which does not implement the `Copy` trait
|
= note: move occurs because `q.r` has type `R<(u32, Box<u32>)>`, which does not implement the `Copy` trait
|
||||||
|
|
||||||
error[E0381]: partially assigned binding `q.r.f` isn't fully initialized
|
error[E0381]: partially assigned binding `q` isn't fully initialized
|
||||||
--> $DIR/issue-21232-partial-init-and-use.rs:222:5
|
--> $DIR/issue-21232-partial-init-and-use.rs:222:5
|
||||||
|
|
|
|
||||||
LL | let mut q: Q<S<Void>>;
|
LL | let mut q: Q<S<Void>>;
|
||||||
|
@ -188,7 +188,7 @@ LL | q.r.f.x = 10;
|
||||||
|
|
|
|
||||||
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
= help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
|
||||||
|
|
||||||
error[E0381]: partially assigned binding `q.r.f` isn't fully initialized
|
error[E0381]: partially assigned binding `q` isn't fully initialized
|
||||||
--> $DIR/issue-21232-partial-init-and-use.rs:228:5
|
--> $DIR/issue-21232-partial-init-and-use.rs:228:5
|
||||||
|
|
|
|
||||||
LL | let mut q: Q<Tvoid>;
|
LL | let mut q: Q<Tvoid>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue