8000 Rollup of 31 pull requests by Mark-Simulacrum · Pull Request #52931 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 31 pull requests #52931

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

Closed
wants to merge 87 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
acdafa0
Document From conversions for OsString and OsStr
cypher Jul 11, 2018
b81ee0b
Document From conversions for CString and CStr
cypher Jul 11, 2018
6c50ee5
dead-code lint: say "constructed" for structs
zackmdavis Jul 22, 2018
ed5edcb
Seperate summaries from rest of the comment
cypher Jul 23, 2018
7fb0a52
Update clippy to latest master
cmdln Jul 26, 2018
922bf1d
Clarify thread::park semantics
matklad Jul 27, 2018
5f87f78
Fix ws
matklad Jul 27, 2018
173c330
Don't make "fake" match variables mutable
matthewjasper Jul 28, 2018
b6d3143
pretty print for std::collections::vecdeque
fukatani Jul 29, 2018
ea25cf1
Fix From<LocalWaker>
MajorBreakfast Jul 29, 2018
9ccd7ee
Fix -Wpessimizing-move warnings in rustllvm/PassWrapper
varkor Jul 29, 2018
9845ee0
fix coding style
fukatani Jul 29, 2018
2b25ee0
update comment
toidiu Jul 30, 2018
< 8000 a href="/rust-lang/rust/pull/52931/commits/2994b27e4033c2a0b77ab90f5a896ce09a122992" class="select-menu-item " role="menuitem" data-commit="2994b27e4033c2a0b77ab90f5a896ce09a122992" data-parent-commit="b12235db096ab24a31e6e894757abfe8b018d44a">
2994b27
Add timeout to use of `curl` in bootstrap.py.
kennytm Jul 30, 2018
c57deb9
Remove references to AUTHORS.txt file
dsciarra Jul 29, 2018
4b466ee
Introduce the declare_tool_lint macro
flip1995 Jul 30, 2018
f8d1dc8
improve --stage documentation
RalfJung Jul 30, 2018
aa7d7d0
improve test stage documentation
RalfJung Jul 30, 2018
e50f4ee
Add targets for HermitCore (https://hermitcore.org) to the Rust compi…
ColinFinck Jul 30, 2018
57c7742
Check if the lint_name is from a tool and if the tool_lint exists
flip1995 Jul 30, 2018
d4ff949
Add a test for the declare_tool_lint macro
flip1995 Jul 30, 2018
7b9388b
Explain that the tool is responsible for unknown tool_lints
flip1995 Jul 30, 2018
ca762ba
rustc: Disallow machine applicability in foreign macros
alexcrichton Jul 26, 2018
d933174
releases.md: fix 2 typos
matthiaskrgr Jul 30, 2018
b6b025b
Fix wrong issue number in the test name
Jul 30, 2018
d8b3c83
Remove the unstable std_unicode crate, deprecated since 1.27
SimonSapin Jul 26, 2018
4ca77f7
Remove unstable and deprecated APIs
SimonSapin Jul 26, 2018
cbbcecb
Implement Unpin for FutureObj and LocalFutureObj
cramertj Jul 30, 2018
9169934
Use Vec::extend in SmallVec::extend when applicable
ljedrz Jul 30, 2018
d5f1f70
Fix Alias intra doc ICE
GuillaumeGomez Jul 29, 2018
1ea2765
run-pass/const-endianness: negate before to_le()
cuviper Jul 30, 2018
c883edf
Include lifetime in mutability suggestion in NLL messages
estebank Jul 30, 2018
4ad4ad0
Fix coding style.
ColinFinck Jul 31, 2018
ca52648
Benchmarks for SmallVec
ljedrz Jul 31, 2018
e8c2995
Sort NLL error diagnostics by span in an attempt to make them match s…
pnkfelix Jul 31, 2018
6787e25
Blindly update the `#[rustc_region]` tests which got touched by the N…
pnkfelix Jul 31, 2018
2677685
Update tests that use `-Z borrowck=compare` or `#[feature(nll)]` to a…
pnkfelix Jul 31, 2018
faf841a
Update the `.nll.stderr` files under new sorted-by-span scheme.
pnkfelix Jul 31, 2018
830ac8c
Fix a typo in unsize.rs
pravic Jul 31, 2018
a5a3f76
NLL: On "cannot move out of type" error, print original source before…
pnkfelix Jul 31, 2018
0af5a6b
Pull out nightly checking to edges
Mark-Simulacrum Jul 21, 2018
ad40e45
Provide warnings for invalid code blocks in markdown files
Mark-Simulacrum Jul 21, 2018
de5cebd
Provide test configuration through struct
Mark-Simulacrum Jul 21, 2018
03e34f8
Remove dependency on error handling from find_testable_code
Mark-Simulacrum Jul 21, 2018
01d9555
Further extract error code switch
Mark-Simulacrum Jul 22, 2018
2216db9
Format code for easier editing
Mark-Simulacrum Jul 22, 2018
38e311e
Use SetLenOnDrop in Vec::truncate()
lnicola Jul 31, 2018
d94bdf8
Put back original field discovery
GuillaumeGomez Jul 31, 2018
40a6046
Only run the sparc-abi test on sparc
nagisa Jul 31, 2018
779792f
address review feedback (`sort_by_key` is so much cleaner here than `…
pnkfelix Jul 31, 2018
6b138f5
Backport 1.27.2 release notes
pietroalbini Jul 31, 2018
7bea518
Remove global derive_id and reset_ids functions
Mark-Simulacrum Jul 22, 2018
8e65a46
Cleanup highlighting code
Mark-Simulacrum Jul 22, 2018
4cd0047
Add dyn to Write
Mark-Simulacrum Jul 29, 2018
0f680b3
Fixup test case
Mark-Simulacrum Jul 29, 2018
bcab7e2
Update compatibility note for 1.28.0 to be correct
Havvy Aug 1, 2018
88fae6a
Rollup merge of #52332 - zackmdavis:dead_code_lint_should_say_2_elect…
Mark-Simulacrum Aug 1, 2018
c1e2ea1
Rollup merge of #52340 - cypher:document-from-trait-in-ffi, r=stevekl…
Mark-Simulacrum Aug 1, 2018
e292913
Rollup merge of #52628 - Mark-Simulacrum:rustdoc-cleanup-1, r=QuietMi…
Mark-Simulacrum Aug 1, 2018
e65104a
Rollup merge of #52732 - SimonSapin:spring, r=Mark-Simulacrum
Mark-Simulacrum Aug 1, 2018
f4afba0
Rollup merge of #52745 - commandline:master, r=oli-obk
Mark-Simulacrum Aug 1, 2018
a624d7f
Rollup merge of #52756 - alexcrichton:cap-applicable, r=oli-obk
Mark-Simulacrum Aug 1, 2018
eca1912
Rollup merge of #52771 - matklad:patch-1, r=kennytm
Mark-Simulacrum Aug 1, 2018
ce005b5
Rollup merge of #52810 - matthewjasper:more-immutablity, r=pnkfelix
Mark-Simulacrum Aug 1, 2018
16646fd
Rollup merge of #52821 - fukatani:gdb-vecdeque-print, r=michaelwoerister
Mark-Simulacrum Aug 1, 2018
16ec9bb
Rollup merge of #52822 - MajorBreakfast:fix-from-local-waker, r=cramertj
Mark-Simulacrum Aug 1, 2018
6bc7dda
Rollup merge of #52824 - varkor:fix-llvm-ret-move-warnings, r=rkruppe
Mark-Simulacrum Aug 1, 2018
a5e993d
Rollup merge of #52831 - dsciarra:rm-ref-to-author-file, r=alexcrichton
Mark-Simulacrum Aug 1, 2018
bc721a1
Rollup merge of #52835 - GuillaumeGomez:ice-rustdoc-links, r=eddyb
Mark-Simulacrum Aug 1, 2018
3f6186f
Rollup merge of #52842 - toidiu:ak-commentUpdate, r=estebank
Mark-Simulacrum Aug 1, 2018
ae84f89
Rollup merge of #52846 - kennytm:bootstrap-curl-timeout, r=Mark-Simul…
Mark-Simulacrum Aug 1, 2018
ca4364f
Rollup merge of #52851 - flip1995:tool_lints, r=oli-obk
Mark-Simulacrum Aug 1, 2018
fe0c255
Rollup merge of #52853 - RalfJung:bootstrap-help, r=alexcrichton
Mark-Simulacrum Aug 1, 2018
df2055f
Rollup merge of #52859 - ljedrz:smallvec_true_extend, r=Mark-Simulacrum
Mark-Simulacrum Aug 1, 2018
209db81
Rollup merge of #52861 - ColinFinck:master, r=alexcrichton
Mark-Simulacrum Aug 1, 2018
258314b
Rollup merge of #52867 - matthiaskrgr:release_typos, r=Mark-Simulacrum
Mark-Simulacrum Aug 1, 2018
d382a88
Rollup merge of #52870 - cramertj:unpin-futureobj, r=aturon
Mark-Simulacrum Aug 1, 2018
4e17e43
Rollup merge of #52876 - cuviper:const-endianness-be, r=kennytm
Mark-Simulacrum Aug 1, 2018
fc596b1
Rollup merge of #52878 - mikhail-m1:master, r=kennytm
Mark-Simulacrum Aug 1, 2018
2bc38ac
Rollup merge of #52883 - estebank:nll-diag-mut, r=oli-obk
Mark-Simulacrum Aug 1, 2018
20d2c3f
Rollup merge of #52904 - pnkfelix:issue-51167-sort-by-span, r=petroch…
Mark-Simulacrum Aug 1, 2018
cf6db38
Rollup merge of #52905 - pravic:unsize-typo, r=alexcrichton
Mark-Simulacrum Aug 1, 2018
afbd9ae
Rollup merge of #52907 - pnkfelix:issue-52877-original-source-should-…
Mark-Simulacrum Aug 1, 2018
5061f1a
Rollup merge of #52908 - lnicola:vec-truncate-opt, r=alexcrichton
Mark-Simulacrum Aug 1, 2018
f6a8c78
Rollup merge of #52914 - nagisa:sparc-is-sparc’s-own-business, r=alex…
Mark-Simulacrum Aug 1, 2018
bedc3a3
Rollup merge of #52918 - pietroalbini:1.27.2-notes, r=Mark-Simulacrum
Mark-Simulacrum Aug 1, 2018
dcb71f0
Rollup merge of #52929 - Havvy:patch-1, r=alexcrichton
Mark-Simulacrum Aug 1, 2018
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
54 changes: 43 additions & 11 deletions src/librustc_mir/borrow_check/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
let local_decl = &self.mir.local_decls[*local];
let suggestion = match local_decl.is_user_variable.as_ref().unwrap() {
ClearCrossCrate::Set(mir::BindingForm::ImplicitSelf) => {
Some(suggest_ampmut_self(local_decl))
Some(suggest_ampmut_self(self.tcx, local_decl))
}

ClearCrossCrate::Set(mir::BindingForm::Var(mir::VarBindingForm {
Expand Down Expand Up @@ -418,8 +418,22 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
}
}

fn suggest_ampmut_self<'cx, 'gcx, 'tcx>(local_decl: &mir::LocalDecl<'tcx>) -> (Span, String) {
(local_decl.source_info.span, "&mut self".to_string())
fn suggest_ampmut_self<'cx, 'gcx, 'tcx>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
local_decl: &mir::LocalDecl<'tcx>,
) -> (Span, String) {
let sp = local_decl.source_info.span;
(sp, match tcx.sess.codemap().span_to_snippet(sp) {
Ok(snippet) => {
let lt_pos = snippet.find('\'');
if let Some(lt_pos) = lt_pos {
format!("&{}mut self", &snippet[lt_pos..snippet.len() - 4])
} else {
"&mut self".to_string()
}
}
_ => "&mut self".to_string()
})
}

// When we want to suggest a user change a local variable to be a `&mut`, there
Expand Down Expand Up @@ -447,9 +461,15 @@ fn suggest_ampmut<'cx, 'gcx, 'tcx>(
let locations = mir.find_assignments(local);
if locations.len() > 0 {
let assignment_rhs_span = mir.source_info(locations[0]).span;
let snippet = tcx.sess.codemap().span_to_snippet(assignment_rhs_span);
if let Ok(src) = snippet {
if src.starts_with('&') {
if let Ok(src) = tcx.sess.codemap().span_to_snippet(assignment_rhs_span) {
if let (true, Some(ws_pos)) = (
src.starts_with("&'"),
src.find(|c: char| -> bool { c.is_whitespace() }),
) {
let lt_name = &src[1..ws_pos];
let ty = &src[ws_pos..];
return (assignment_rhs_span, format!("&{} mut {}", lt_name, ty));
} else if src.starts_with('&') {
let borrowed_expr = src[1..].to_string();
return (assignment_rhs_span, format!("&mut {}", borrowed_expr));
}
Expand All @@ -466,13 +486,25 @@ fn suggest_ampmut<'cx, 'gcx, 'tcx>(
None => local_decl.source_info.span,
};

if let Ok(src) = tcx.sess.codemap().span_to_snippet(highlight_span) {
if let (true, Some(ws_pos)) = (
src.starts_with("&'"),
src.find(|c: char| -> bool { c.is_whitespace() }),
) {
let lt_name = &src[1..ws_pos];
let ty = &src[ws_pos..];
return (highlight_span, format!("&{} mut{}", lt_name, ty));
}
}

let ty_mut = local_decl.ty.builtin_deref(true).unwrap();
assert_eq!(ty_mut.mutbl, hir::MutImmutable);
if local_decl.ty.is_region_ptr() {
(highlight_span, format!("&mut {}", ty_mut.ty))
} else {
(highlight_span, format!("*mut {}", ty_mut.ty))
}
(highlight_span,
if local_decl.ty.is_region_ptr() {
format!("&mut {}", ty_mut.ty)
} else {
format!("*mut {}", ty_mut.ty)
})
}

fn is_closure_or_generator(ty: ty::Ty) -> bool {
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/did_you_mean/issue-39544.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
--> $DIR/issue-39544.rs:26:17
|
LL | fn foo<'z>(&'z self) {
| -------- help: consider changing this to be a mutable reference: `&mut self`
| -------- help: consider changing this to be a mutable reference: `&'z mut self`
LL | let _ = &mut self.x; //~ ERROR cannot borrow
| ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable

Expand All @@ -35,7 +35,7 @@ error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
--> $DIR/issue-39544.rs:35:17
|
LL | fn foo2<'a>(&'a self, other: &Z) {
| -------- help: consider changing this to be a mutable reference: `&mut self`
| -------- help: consider changing this to be a mutable reference: `&'a mut self`
LL | let _ = &mut self.x; //~ ERROR cannot borrow
| ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable

Expand All @@ -52,7 +52,7 @@ error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
--> $DIR/issue-39544.rs:40:17
|
LL | fn foo3<'a>(self: &'a Self, other: &Z) {
| -------- help: consider changing this to be a mutable reference: `&mut Z`
| -------- help: consider changing this to be a mutable reference: `&'a mut Self`
LL | let _ = &mut self.x; //~ ERROR cannot borrow
| ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:102:5
|
LL | fn assign_field2<'a>(x: &'a Own<Point>) {
| -------------- help: consider changing this to be a mutable reference: `&mut Own<Point>`
| -------------- help: consider changing this to be a mutable reference: `&'a mut Own<Point>`
LL | x.y = 3; //~ ERROR cannot borrow
| ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable

Expand Down Expand Up @@ -58,7 +58,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:143:6
|
LL | fn assign_method2<'a>(x: &'a Own<Point>) {
| -------------- help: consider changing this to be a mutable reference: `&mut Own<Point>`
| -------------- help: consider changing this to be a mutable reference: `&'a mut Own<Point>`
LL | *x.y_mut() = 3; //~ ERROR cannot borrow
| ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
--> $DIR/borrowck-borrow-overloaded-deref-mut.rs:51:11
|
LL | fn deref_extend_mut1<'a>(x: &'a Own<isize>) -> &'a mut isize {
| -------------- help: consider changing this to be a mutable reference: `&mut Own<isize>`
| -------------- help: consider changing this to be a mutable reference: `&'a mut Own<isize>`
LL | &mut **x //~ ERROR cannot borrow
| ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable

Expand All @@ -26,7 +26,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
--> $DIR/borrowck-borrow-overloaded-deref-mut.rs:63:6
|
LL | fn assign2<'a>(x: &'a Own<isize>) {
| -------------- help: consider changing this to be a mutable reference: `&mut Own<isize>`
| -------------- help: consider changing this to be a mutable reference: `&'a mut Own<isize>`
LL | **x = 3; //~ ERROR cannot borrow
| ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/span/mut-arg-hint.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference
--> $DIR/mut-arg-hint.rs:18:5
|
LL | pub fn foo<'a>(mut a: &'a String) {
| ---------- help: consider changing this to be a mutable reference: `&mut std::string::String`
| ---------- help: consider changing this to be a mutable reference: `&'a mut String`
LL | a.push_str("foo"); //~ ERROR cannot borrow immutable borrowed content
| ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference
--> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:16:5
|
LL | fn reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy {
| --------------- help: consider changing this to be a mutable reference: `&mut &mut i32`
| --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32`
LL | *t //~ ERROR
| ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference
--> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:20:6
|
LL | fn copy_reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy {
| --------------- help: consider changing this to be a mutable reference: `&mut &mut i32`
| --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32`
LL | {*t} //~ ERROR
| ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable

Expand Down
0