Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 14 pull requests #81102

Closed
wants to merge 108 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
c06793b
Add Roadmap for 2021
flip1995 Dec 15, 2020
469281c
Check if never type feature is enabled by TyCtxt before suggesting em…
nahuakang Dec 28, 2020
83a458a
Enable never type in empty enum ui test; run cargo dev bless
nahuakang Dec 28, 2020
275988c
Add additional lint doc to known problems section
nahuakang Dec 28, 2020
af480a6
Ensure `Copy` exception in trait definition for `wrong_self_conventio…
ThibsG Dec 30, 2020
0afe2db
Update CHANGELOG for Rust 1.50
phansch Dec 30, 2020
b81111b
Address review comments
phansch Dec 30, 2020
6b37932
Fix blessing of test output in subdirectories
phansch Dec 31, 2020
6909055
s/test_dir/test_suite_dir
phansch Dec 31, 2020
5d48b91
field_reassign_with_default: don't expand macros in suggestion
matthiaskrgr Jan 1, 2021
ba4bf4f
Merge commit '1fcc74cc9e03bc91eaa80ecf92976b0b14b3aeb6' into clippyup
flip1995 Jan 2, 2021
1853f8b
Add lint
Jarcho Jan 2, 2021
78f6009
Auto merge of #6520 - phansch:update-changelog, r=flip1995
bors Jan 2, 2021
053afe4
Use bootstrap rustc for versioncheck in Clippy
flip1995 Jan 2, 2021
9427e03
Fix clone_on_copy test
Jarcho Jan 2, 2021
d37ee6f
Fix lint errors
Jarcho Jan 2, 2021
b498870
use hir::Place instead of Symbol in closure_kind_origin
roxelo Dec 3, 2020
592f7eb
Auto merge of #6531 - matthiaskrgr:6522, r=ebroto
bors Jan 2, 2021
a02806e
Auto merge of #6518 - ThibsG:CopyException, r=ebroto
bors Jan 2, 2021
7b5f549
Fix docs: use type inference
Jarcho Jan 3, 2021
8951916
Auto merge of #6525 - phansch:fix-bless-in-subdirs, r=flip1995
bors Jan 4, 2021
d141cdc
Add prioritization chapter and remove unresolved questions
flip1995 Jan 4, 2021
6dcec6a
collapsible_if: split collapsible_else_if into its own lint so we can…
matthiaskrgr Jan 4, 2021
dd1929e
Auto merge of #6544 - matthiaskrgr:else_if, r=flip1995
bors Jan 4, 2021
ba87acb
Implemented needless question mark lint
bengsparks Dec 26, 2020
ae9ae97
Auto merge of #6507 - bengsparks:lint/issue6410, r=flip1995
bors Jan 4, 2021
7acfa44
Add ui-internal to cargo dev bless
camsteffen Dec 31, 2020
cbbb188
Bless only updated since clippy build
camsteffen Dec 31, 2020
445eb99
Auto merge of #6548 - camsteffen:bless-internal, r=flip1995
bors Jan 4, 2021
bc97f5d
Address flip1995's review comments
nahuakang Jan 4, 2021
a8d47b4
Run cargo dev fmt
nahuakang Jan 4, 2021
976850b
Auto merge of #6538 - Jarcho:vec_init_then_push, r=llogiq
bors Jan 4, 2021
4b478a5
Add a new lint `ptr_as_ptr`,
rail-rain Jan 3, 2021
dfa5d7e
Fix the MSRV and add the tests for MSRV
rail-rain Jan 4, 2021
dd52066
Auto merge of #6547 - camsteffen:curse-outdated, r=phansch
bors Jan 5, 2021
311186b
Auto merge of #6513 - nahuakang:fix/empty_enum_lint_never_type, r=fli…
bors Jan 5, 2021
a6b72d3
Auto merge of #6542 - rail-rain:ptr_as_ptr, r=flip1995
bors Jan 5, 2021
ea885d9
Tiny Symbol cleanup
phansch Jan 5, 2021
42b9e92
Auto merge of #6551 - phansch:tiny-symbol-cleanup, r=flip1995
bors Jan 5, 2021
a8825e9
Use existing 'is_automatically_derived' helper
phansch Jan 5, 2021
03c0e58
Revert "Auto merge of #79637 - spastorino:revert-trait-inheritance-se…
spastorino Dec 3, 2020
92f2bbb
Fix macro issues with field_reassign_with_default
phansch Jan 5, 2021
455a0e1
Use Symbol instead of Ident as an assoc_name to prevent ICEs
spastorino Jan 5, 2021
efccfe8
Auto merge of #6553 - phansch:field-reassign-with-default-macros, r=f…
bors Jan 6, 2021
8a45ffa
Fix typo: `which which can be` -> `which can be`
sozysozbot Jan 6, 2021
8e5c5a6
Auto merge of #6554 - sozysozbot:master, r=flip1995
bors Jan 6, 2021
f50ded0
Catch `pointer::cast` too in `cast_ptr_alignment`
rail-rain Jan 7, 2021
547ce0d
Change env var used for testing Clippy
flip1995 Jan 7, 2021
2b3c0ad
Fix typo: `irrevelent` -> `irrelevant`
stanislav-tkach Jan 7, 2021
e15bef9
Auto merge of #6558 - stanislav-tkach:patch-2, r=flip1995
bors Jan 7, 2021
7d42172
Reintroduce hir::ExprKind::If
c410-f3r Jan 1, 2021
aa9adbf
Small fixes of doc in `needless_question_mark`
giraffate Jan 7, 2021
0e14a75
Reduce the span in `from_over_into` to impl header
giraffate Jan 7, 2021
ee9b47d
Move `is_hir_ty_cfg_dependant` to `util`,
rail-rain Jan 8, 2021
2950c8e
Auto merge of #6566 - giraffate:reduce_the_span_in_from_over_into, r=…
bors Jan 8, 2021
24c700b
Use DefId in interning defined symbol lint
camsteffen Dec 30, 2020
121c65f
Add keywords to interning defined symbol lint
camsteffen Dec 29, 2020
76ccfb4
Fix unnecessary keyword intern dogfood
camsteffen Dec 29, 2020
cc26919
Add unnecessary symbol string lint
camsteffen Dec 30, 2020
7871eba
Fix symbol string comparison dogfood
camsteffen Dec 29, 2020
68bcd20
Auto merge of #6569 - camsteffen:symbol-comparison, r=Manishearth
bors Jan 8, 2021
8a6fea4
Fix FP for `boxed_local` lint in default trait fn impl
ThibsG Jan 9, 2021
ee0598e
Auto merge of #6571 - ThibsG:BoxedLocalTrait, r=phansch
bors Jan 9, 2021
583715f
Auto merge of #6565 - giraffate:small_fixes_of_doc_in_needless_questi…
bors Jan 9, 2021
9e45a23
ast: Remove some indirection layers from values in key-value attributes
petrochenkov Dec 19, 2020
2c6dc88
Rework diagnostics for wrong number of generic args
Patryk27 Jan 2, 2021
1eed27f
Auto merge of #6575 - flip1995:stop_linting_deps, r=Manishearth
bors Jan 11, 2021
b7071b2
resolve: Simplify collection of traits in scope
petrochenkov Jan 6, 2021
53f8731
Simplify `cast_ptr_alignment` `pointer::casr` case
rail-rain Jan 11, 2021
7f4599a
Auto merge of #6557 - rail-rain:extending_cast_ptr_alignment, r=phansch
bors Jan 11, 2021
13ca5c8
Auto merge of #6462 - flip1995:roadmap, r=flip1995,llogiq,killercup,M…
bors Jan 12, 2021
ea02849
Make a reference a link in doc
giraffate Jan 13, 2021
dfb41f4
Separate out a `hir::Impl` struct
jyn514 Nov 22, 2020
00586df
Auto merge of #6584 - giraffate:make_references_to_issues_links, r=ll…
bors Jan 13, 2021
61a6468
Update rust-analyzer
lnicola Jan 13, 2021
dcd8c8e
Auto merge of #77524 - Patryk27:fixes/66228, r=estebank
bors Jan 13, 2021
7b3af41
Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasper
bors Jan 14, 2021
9bd037d
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jan 15, 2021
0c5ba9a
Bump nightly version to 2021-01-15
flip1995 Jan 15, 2021
f18cf82
Don't trigger needless_return lint in macros
flip1995 Jan 15, 2021
953f024
Auto merge of #6586 - flip1995:rustup, r=flip1995
bors Jan 15, 2021
3e236b3
Merge commit '953f024793dab92745fee9cd2c4dee6a60451771' into clippyup
flip1995 Jan 15, 2021
6766070
Allow downloading LLVM on Windows
jyn514 Jan 12, 2021
5c4adbe
Add all tier 1 platforms to supported platforms for "if-available"
jyn514 Jan 13, 2021
8b702e0
Support non-stage0 check
Mark-Simulacrum Jan 16, 2021
c17ed34
Print which stage is being checked (now that it may not be stage0)
jyn514 Jan 16, 2021
53989e4
Allow configuring the default stage for `x.py check`
jyn514 Jan 16, 2021
50ee0b2
BTreeMap: clean up a few more comments
ssomers Nov 18, 2020
65b5e43
Use PlaceRef more consistently in rustc_mir
oliviacrain Jan 10, 2021
28501c0
rustc_parse_format: Fix character indices in find_skips
osa1 Jan 16, 2021
15f0921
correctly deal with late-bound lifetimes in anon consts
lcnr Nov 22, 2020
76003f3
Use Option::map instead of open-coding it
LingMan Dec 30, 2020
5a706cf
Use Option::unwrap_or instead of open-coding it
LingMan Jan 16, 2021
7f9a2cf
resolve: Reject ambiguity built-in attr vs different built-in attr
petrochenkov Dec 13, 2020
f6f754a
Rollup merge of #79298 - lcnr:new-elysium, r=matthewjasper
m-ou-se Jan 16, 2021
c06ff92
Rollup merge of #80031 - petrochenkov:builtina, r=estebank
m-ou-se Jan 16, 2021
803d616
Rollup merge of #80635 - sexxi-goose:use-place-instead-of-symbol, r=n…
m-ou-se Jan 16, 2021
d2009f0
Rollup merge of #80732 - spastorino:trait-inheritance-self2, r=nikoma…
m-ou-se Jan 16, 2021
589864d
Rollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasper
m-ou-se Jan 16, 2021
42801b4
Rollup merge of #80865 - oliviacrain:proj_based, r=RalfJung
m-ou-se Jan 16, 2021
b2d8614
Rollup merge of #80932 - jyn514:download-windows-llvm, r=Mark-Simulacrum
m-ou-se Jan 16, 2021
ab62218
Rollup merge of #80984 - lnicola:bump-rust-analyzer, r=jonas-schievink
m-ou-se Jan 16, 2021
f25652d
Rollup merge of #81038 - flip1995:clippyup, r=Manishearth
m-ou-se Jan 16, 2021
85c6462
Rollup merge of #81064 - Mark-Simulacrum:support-stage1-check, r=jyn514
m-ou-se Jan 16, 2021
a5a259f
Rollup merge of #81071 - osa1:fix_81006, r=estebank
m-ou-se Jan 16, 2021
5bc3f8c
Rollup merge of #81082 - ssomers:btree_cleanup_comments, r=Mark-Simul…
m-ou-se Jan 16, 2021
6b66591
Rollup merge of #81084 - LingMan:map, r=oli-obk
m-ou-se Jan 16, 2021
576c3d5
Rollup merge of #81095 - LingMan:unwrap, r=oli-obk
m-ou-se Jan 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
use crate::arena::Arena;
use crate::dep_graph::DepGraph;
use crate::hir::exports::ExportMap;
use crate::hir::place::Place as HirPlace;
use crate::ich::{NodeIdHashingMode, StableHashingContext};
use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintLevelSource};
@@ -379,7 +380,7 @@ pub struct TypeckResults<'tcx> {

/// Records the reasons that we picked the kind of each closure;
/// not all closures are present in the map.
closure_kind_origins: ItemLocalMap<(Span, Symbol)>,
closure_kind_origins: ItemLocalMap<(Span, HirPlace<'tcx>)>,

/// For each fn, records the "liberated" types of its arguments
/// and return type. Liberated means that all bound regions
@@ -642,11 +643,13 @@ impl<'tcx> TypeckResults<'tcx> {
self.upvar_capture_map[&upvar_id]
}

pub fn closure_kind_origins(&self) -> LocalTableInContext<'_, (Span, Symbol)> {
pub fn closure_kind_origins(&self) -> LocalTableInContext<'_, (Span, HirPlace<'tcx>)> {
LocalTableInContext { hir_owner: self.hir_owner, data: &self.closure_kind_origins }
}

pub fn closure_kind_origins_mut(&mut self) -> LocalTableInContextMut<'_, (Span, Symbol)> {
pub fn closure_kind_origins_mut(
&mut self,
) -> LocalTableInContextMut<'_, (Span, HirPlace<'tcx>)> {
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.closure_kind_origins }
}

41 changes: 40 additions & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
@@ -17,7 +17,9 @@ pub use self::IntVarValue::*;
pub use self::Variance::*;

use crate::hir::exports::ExportMap;
use crate::hir::place::Place as HirPlace;
use crate::hir::place::{
Place as HirPlace, PlaceBase as HirPlaceBase, ProjectionKind as HirProjectionKind,
};
use crate::ich::StableHashingContext;
use crate::middle::cstore::CrateStoreDyn;
use crate::middle::resolve_lifetime::ObjectLifetimeDefault;
@@ -734,6 +736,43 @@ pub struct CapturedPlace<'tcx> {
pub info: CaptureInfo<'tcx>,
}

pub fn place_to_string_for_capture(tcx: TyCtxt<'tcx>, place: &HirPlace<'tcx>) -> String {
let name = match place.base {
HirPlaceBase::Upvar(upvar_id) => tcx.hir().name(upvar_id.var_path.hir_id).to_string(),
_ => bug!("Capture_information should only contain upvars"),
};
let mut curr_string = name;

for (i, proj) in place.projections.iter().enumerate() {
match proj.kind {
HirProjectionKind::Deref => {
curr_string = format!("*{}", curr_string);
}
HirProjectionKind::Field(idx, variant) => match place.ty_before_projection(i).kind() {
ty::Adt(def, ..) => {
curr_string = format!(
"{}.{}",
curr_string,
def.variants[variant].fields[idx as usize].ident.name.as_str()
);
}
ty::Tuple(_) => {
curr_string = format!("{}.{}", curr_string, idx);
}
_ => {
bug!(
"Field projection applied to a type other than Adt or Tuple: {:?}.",
place.ty_before_projection(i).kind()
)
}
},
proj => bug!("{:?} unexpected because it isn't captured", proj),
}
}

curr_string.to_string()
}

/// Part of `MinCaptureInformationMap`; describes the capture kind (&, &mut, move)
/// for a particular capture as well as identifying the part of the source code
/// that triggered this capture to occur.
8 changes: 4 additions & 4 deletions compiler/rustc_mir/src/borrow_check/diagnostics/mod.rs
Original file line number Diff line number Diff line change
@@ -103,15 +103,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let did = did.expect_local();
let hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(did);

if let Some((span, name)) =
if let Some((span, hir_place)) =
self.infcx.tcx.typeck(did).closure_kind_origins().get(hir_id)
{
diag.span_note(
*span,
&format!(
"closure cannot be invoked more than once because it moves the \
variable `{}` out of its environment",
name,
ty::place_to_string_for_capture(self.infcx.tcx, hir_place)
),
);
return;
@@ -127,15 +127,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let did = did.expect_local();
let hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(did);

if let Some((span, name)) =
if let Some((span, hir_place)) =
self.infcx.tcx.typeck(did).closure_kind_origins().get(hir_id)
{
diag.span_note(
*span,
&format!(
"closure cannot be moved more than once as it is not `Copy` due to \
moving the variable `{}` out of its environment",
name
ty::place_to_string_for_capture(self.infcx.tcx, hir_place)
),
);
}
Original file line number Diff line number Diff line change
@@ -589,23 +589,23 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
if let Some(typeck_results) = self.in_progress_typeck_results {
let typeck_results = typeck_results.borrow();
match (found_kind, typeck_results.closure_kind_origins().get(hir_id)) {
(ty::ClosureKind::FnOnce, Some((span, name))) => {
(ty::ClosureKind::FnOnce, Some((span, place))) => {
err.span_label(
*span,
format!(
"closure is `FnOnce` because it moves the \
variable `{}` out of its environment",
name
ty::place_to_string_for_capture(tcx, place)
),
);
}
(ty::ClosureKind::FnMut, Some((span, name))) => {
(ty::ClosureKind::FnMut, Some((span, place))) => {
err.span_label(
*span,
format!(
"closure is `FnMut` because it mutates the \
variable `{}` here",
name
ty::place_to_string_for_capture(tcx, place)
),
);
}
26 changes: 18 additions & 8 deletions compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
@@ -176,7 +176,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.demand_eqtype(span, inferred_kind.to_ty(self.tcx), closure_kind_ty);

// If we have an origin, store it.
if let Some(origin) = delegate.current_origin {
if let Some(origin) = delegate.current_origin.clone() {
let origin = if self.tcx.features().capture_disjoint_fields {
origin
} else {
// FIXME(project-rfc-2229#26): Once rust-lang#80092 is merged, we should restrict the
// precision of origin as well. Otherwise, this will cause issues when project-rfc-2229#26
// is fixed as we might see Index projections in the origin, which we can't print because
// we don't store enough information.
(origin.0, Place { projections: vec![], ..origin.1 })
};

self.typeck_results
.borrow_mut()
.closure_kind_origins_mut()
@@ -563,7 +573,7 @@ struct InferBorrowKind<'a, 'tcx> {

// If we modified `current_closure_kind`, this field contains a `Some()` with the
// variable access that caused us to do so.
current_origin: Option<(Span, Symbol)>,
current_origin: Option<(Span, Place<'tcx>)>,

/// For each Place that is captured by the closure, we track the minimal kind of
/// access we need (ref, ref mut, move, etc) and the expression that resulted in such access.
@@ -628,7 +638,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
upvar_id.closure_expr_id,
ty::ClosureKind::FnOnce,
usage_span,
var_name(tcx, upvar_id.var_path.hir_id),
place_with_id.place.clone(),
);

let capture_info = ty::CaptureInfo {
@@ -720,7 +730,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
upvar_id.closure_expr_id,
ty::ClosureKind::FnMut,
tcx.hir().span(diag_expr_id),
var_name(tcx, upvar_id.var_path.hir_id),
place_with_id.place.clone(),
);
}
}
@@ -765,11 +775,11 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
closure_id: LocalDefId,
new_kind: ty::ClosureKind,
upvar_span: Span,
var_name: Symbol,
place: Place<'tcx>,
) {
debug!(
"adjust_closure_kind(closure_id={:?}, new_kind={:?}, upvar_span={:?}, var_name={})",
closure_id, new_kind, upvar_span, var_name
"adjust_closure_kind(closure_id={:?}, new_kind={:?}, upvar_span={:?}, place={:?})",
closure_id, new_kind, upvar_span, place
);

// Is this the closure whose kind is currently being inferred?
@@ -797,7 +807,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
| (ty::ClosureKind::FnMut, ty::ClosureKind::FnOnce) => {
// new kind is stronger than the old kind
self.current_closure_kind = new_kind;
self.current_origin = Some((upvar_span, var_name));
self.current_origin = Some((upvar_span, place));
}
}
}
8 changes: 5 additions & 3 deletions compiler/rustc_typeck/src/check/writeback.rs
Original file line number Diff line number Diff line change
@@ -384,9 +384,11 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
let common_hir_owner = fcx_typeck_results.hir_owner;

for (&id, &origin) in fcx_typeck_results.closure_kind_origins().iter() {
let hir_id = hir::HirId { owner: common_hir_owner, local_id: id };
self.typeck_results.closure_kind_origins_mut().insert(hir_id, origin);
for (id, origin) in fcx_typeck_results.closure_kind_origins().iter() {
let hir_id = hir::HirId { owner: common_hir_owner, local_id: *id };
let place_span = origin.0;
let place = self.resolve(origin.1.clone(), &place_span);
self.typeck_results.closure_kind_origins_mut().insert(hir_id, (place_span, place));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#![feature(capture_disjoint_fields)]
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
//~| `#[warn(incomplete_features)]` on by default
//~| see issue #53488 <https://github.com/rust-lang/rust/issues/53488>

// Check that precise paths are being reported back in the error message.


enum MultiVariant {
Point(i32, i32),
Meta(i32)
}

fn main() {
let mut point = MultiVariant::Point(10, -10,);

let mut meta = MultiVariant::Meta(1);

let c = || {
if let MultiVariant::Point(ref mut x, _) = point {
*x += 1;
}

if let MultiVariant::Meta(ref mut v) = meta {
*v += 1;
}
};

let a = c;
let b = c; //~ ERROR use of moved value: `c` [E0382]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/closure-origin-multi-variant-diagnostics.rs:1:12
|
LL | #![feature(capture_disjoint_fields)]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information

error[E0382]: use of moved value: `c`
--> $DIR/closure-origin-multi-variant-diagnostics.rs:30:13
|
LL | let a = c;
| - value moved here
LL | let b = c;
| ^ value used here after move
|
note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `point.0` out of its environment
--> $DIR/closure-origin-multi-variant-diagnostics.rs:20:52
|
LL | if let MultiVariant::Point(ref mut x, _) = point {
| ^^^^^

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0382`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#![feature(capture_disjoint_fields)]
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
//~| `#[warn(incomplete_features)]` on by default
//~| see issue #53488 <https://github.com/rust-lang/rust/issues/53488>

// Check that precise paths are being reported back in the error message.

enum SingleVariant {
Point(i32, i32),
}

fn main() {
let mut point = SingleVariant::Point(10, -10);

let c = || {
// FIXME(project-rfc-2229#24): Change this to be a destructure pattern
// once this is fixed, to remove the warning.
if let SingleVariant::Point(ref mut x, _) = point {
//~^ WARNING: irrefutable if-let pattern
*x += 1;
}
};

let b = c;
let a = c; //~ ERROR use of moved value: `c` [E0382]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/closure-origin-single-variant-diagnostics.rs:1:12
|
LL | #![feature(capture_disjoint_fields)]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information

warning: irrefutable if-let pattern
--> $DIR/closure-origin-single-variant-diagnostics.rs:18:9
|
LL | / if let SingleVariant::Point(ref mut x, _) = point {
LL | |
LL | | *x += 1;
LL | | }
| |_________^
|
= note: `#[warn(irrefutable_let_patterns)]` on by default

error[E0382]: use of moved value: `c`
--> $DIR/closure-origin-single-variant-diagnostics.rs:25:13
|
LL | let b = c;
| - value moved here
LL | let a = c;
| ^ value used here after move
|
note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `point.0` out of its environment
--> $DIR/closure-origin-single-variant-diagnostics.rs:18:53
|
LL | if let SingleVariant::Point(ref mut x, _) = point {
| ^^^^^

error: aborting due to previous error; 2 warnings emitted

For more information about this error, try `rustc --explain E0382`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#![feature(capture_disjoint_fields)]
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
//~| `#[warn(incomplete_features)]` on by default
//~| see issue #53488 <https://github.com/rust-lang/rust/issues/53488>

// Check that precise paths are being reported back in the error message.

struct Y {
y: X
}

struct X {
a: u32,
b: u32,
}

fn main() {
let mut x = Y { y: X { a: 5, b: 0 } };
let hello = || {
x.y.a += 1;
};

let b = hello;
let c = hello; //~ ERROR use of moved value: `hello` [E0382]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/closure-origin-struct-diagnostics.rs:1:12
|
LL | #![feature(capture_disjoint_fields)]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information

error[E0382]: use of moved value: `hello`
--> $DIR/closure-origin-struct-diagnostics.rs:24:13
|
LL | let b = hello;
| ----- value moved here
LL | let c = hello;
| ^^^^^ value used here after move
|
note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `x.y.a` out of its environment
--> $DIR/closure-origin-struct-diagnostics.rs:20:9
|
LL | x.y.a += 1;
| ^^^^^

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0382`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![feature(capture_disjoint_fields)]
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
//~| `#[warn(incomplete_features)]` on by default
//~| see issue #53488 <https://github.com/rust-lang/rust/issues/53488>

// Check that precise paths are being reported back in the error message.

fn main() {
let mut x = (5, 0);
let hello = || {
x.0 += 1;
};

let b = hello;
let c = hello; //~ ERROR use of moved value: `hello` [E0382]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/closure-origin-tuple-diagnostics-1.rs:1:12
|
LL | #![feature(capture_disjoint_fields)]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information

error[E0382]: use of moved value: `hello`
--> $DIR/closure-origin-tuple-diagnostics-1.rs:15:13
|
LL | let b = hello;
| ----- value moved here
LL | let c = hello;
| ^^^^^ value used here after move
|
note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `x.0` out of its environment
--> $DIR/closure-origin-tuple-diagnostics-1.rs:11:9
|
LL | x.0 += 1;
| ^^^

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0382`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![feature(capture_disjoint_fields)]
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
//~| `#[warn(incomplete_features)]` on by default
//~| see issue #53488 <https://github.com/rust-lang/rust/issues/53488>
struct S(String, String);

fn expect_fn<F: Fn()>(_f: F) {}

fn main() {
let s = S(format!("s"), format!("s"));
let c = || { //~ ERROR expected a closure that implements the `Fn`
let s = s.1;
};
expect_fn(c);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/closure-origin-tuple-diagnostics.rs:1:12
|
LL | #![feature(capture_disjoint_fields)]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information

error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce`
--> $DIR/closure-origin-tuple-diagnostics.rs:11:13
|
LL | let c = || {
| ^^ this closure implements `FnOnce`, not `Fn`
LL | let s = s.1;
| --- closure is `FnOnce` because it moves the variable `s.1` out of its environment
LL | };
LL | expect_fn(c);
| --------- the requirement to implement `Fn` derives from here

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0525`.