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 22 pull requests #40644

Closed
wants to merge 70 commits into from
Closed
Changes from 4 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
c7db40f
Rename expected_types_for_fn_args to expected_inputs_for_expected_out…
eddyb Mar 9, 2017
50aee36
Propagate expected type hints through struct literals.
eddyb Mar 9, 2017
6ba494b
Point to let when modifying field of immutable variable
estebank Mar 11, 2017
38b5b29
Change label to "consider changing this to `mut f`"
estebank Mar 12, 2017
197e529
Initial attempt at implementing optimization fuel and re-enabling str…
ahicks92 Mar 8, 2017
8f36057
Make a comment better.
ahicks92 Mar 9, 2017
c2d14fc
Tests for -Z fuel=foo=n
ahicks92 Mar 10, 2017
3fb94b7
UI test for -Z print-fuel=foo
ahicks92 Mar 10, 2017
9ac628d
Add label to primary span for mutable access of immutable struct error
estebank Mar 13, 2017
460bf55
Cleanup.
jseyfried Mar 6, 2017
68c1cc6
Refactor `Attribute` to use `Path` and `TokenStream` instead of `Meta…
jseyfried Mar 3, 2017
839c286
Liberalize attributes.
jseyfried Mar 8, 2017
85e02bd
Add tests.
jseyfried Mar 8, 2017
b43c744
Add feature toggle for rvalue-static-promotion RFC
tbg Mar 11, 2017
20c0f32
Use `&&` instead of `&`
tbg Mar 12, 2017
f06b049
Improve the documentation for `rvalue_static_promotion`
tbg Mar 12, 2017
9741c9d
add test for nested macro def (#31946)
durka Mar 14, 2017
cc23d17
make shift builtins panic-free with new unchecked_sh* intrinsics
TimNN Mar 14, 2017
ff63866
Change how the `0` flag works in format!
Sawyer47 Mar 3, 2017
8065486
Change how the 0 flag works in format! for floats
Sawyer47 Mar 4, 2017
c11ab21
save-analysis: only index path references once
nrc Mar 8, 2017
310f5bd
save-analysis: index extern blocks
nrc Mar 8, 2017
4cf22cb
rebased
nrc Mar 15, 2017
ce616a7
Improve the `TokenStream` quoter.
jseyfried Mar 14, 2017
9b89274
Fix const not displayed in rustdoc
GuillaumeGomez Mar 16, 2017
8c16c45
Check for conflicts between macros 1.0 exports (`#[macro_export]`, `#…
jseyfried Mar 14, 2017
910532e
Add a test for issue 34571
topecongiro Mar 16, 2017
449219a
isolate llvm 4.0 code path
TimNN Mar 16, 2017
222ca3c
clang-format
TimNN Mar 16, 2017
95bd7f2
add missing global metadata
TimNN Mar 16, 2017
50cede0
documented order of conversion between u32 an ipv4addr
Mar 17, 2017
963d4df
minor wording tweak to slice::{as_ptr, as_mut_ptr}
QuietMisdreavus Mar 17, 2017
ec8ecf4
Fix typo in mutex.rs docs
ScottAbbey Mar 17, 2017
33a5665
Stabilize move_cell feature, closes #39264
aturon Mar 15, 2017
65b7c4e
Stabilize expect_err feature, closes #39041
aturon Mar 15, 2017
d38ea8b
Stabilize ptr_unaligned feature, closes #37955
aturon Mar 15, 2017
9511fe6
Stabilize process_abort feature, closes #37838
aturon Mar 15, 2017
10510ae
Stabilize ptr_eq feature, closes #36497
aturon Mar 15, 2017
37b38a2
Stabilize btree_range, closes #27787
aturon Mar 15, 2017
48890d4
Stabilize ordering_chaining, closes #37053
aturon Mar 15, 2017
a8f4a1b
Stabilize rc_raw feature, closes #37197
aturon Mar 15, 2017
1241a88
Minor fixups to fix tidy errors
alexcrichton Mar 15, 2017
27fcdb8
Specialize Vec::from_elem<u8> to use calloc or memset
mbrubeck Mar 10, 2017
ae630ca
Specialize Vec::from_elem for other integer types
mbrubeck Mar 10, 2017
cb96ade
Fix regression when `include!()`ing a `macro_rules!` containing a `$c…
jseyfried Mar 16, 2017
2976ddb
Fix a spelling error in HashMap documentation, and slightly reword it…
jswalden Mar 18, 2017
8eaac08
Parse 0e+10 as a valid floating-point literal
topecongiro Mar 17, 2017
e16d286
add inline attributes to stage 0 methods
TimNN Mar 18, 2017
a6cb1ef
Rollup merge of #40241 - Sawyer47:fix-39997, r=alexcrichton
Mar 18, 2017
67cc915
Rollup merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrc
Mar 18, 2017
8e6afbf
Rollup merge of #40348 - nrc:save-extern-fn, r=@eddyb
Mar 18, 2017
74028ba
Rollup merge of #40377 - camlorn:optimization_fuel, r=arielb1
Mar 18, 2017
834e2e8
Rollup merge of #40398 - eddyb:struct-hint, r=nikomatsakis
Mar 18, 2017
f340b0b
Rollup merge of #40409 - mbrubeck:calloc, r=sfackler
Mar 18, 2017
d050aee
Rollup merge of #40441 - tschottdorf:promotable-rfc, r=eddyb
Mar 18, 2017
6a6d6de
Rollup merge of #40445 - estebank:issue-18150, r=jonathandturner
Mar 18, 2017
bed891d
Rollup merge of #40509 - jseyfried:duplicate_check_macro_exports, r=nrc
Mar 18, 2017
7474930
Rollup merge of #40521 - TimNN:panic-free-shift, r=alexcrichton
Mar 18, 2017
ca26c79
Rollup merge of #40523 - durka:patch-38, r=petrochenkov
Mar 18, 2017
663409b
Rollup merge of #40532 - jseyfried:improve_tokenstream_quoter, r=nrc
Mar 18, 2017
c2e6d72
Rollup merge of #40538 - aturon:stab-1.17, r=alexcrichton
Mar 18, 2017
196011c
Rollup merge of #40564 - GuillaumeGomez:rustdoc-const, r=frewsxcv
Mar 18, 2017
3c912fb
Rollup merge of #40581 - TimNN:di-global-40, r=alexcrichton
Mar 18, 2017
76c9d17
Rollup merge of #40583 - jseyfried:fix_include_macro_regression, r=nrc
Mar 18, 2017
664d9a5
Rollup merge of #40588 - topecongiro:add-missing-tests, r=alexcrichton
Mar 18, 2017
d3d2866
Rollup merge of #40589 - topecongiro:floating-point-literal, r=nagisa
Mar 18, 2017
a8b619c
Rollup merge of #40590 - z1mvader:master, r=steveklabnik
Mar 18, 2017
42ead56
Rollup merge of #40603 - QuietMisdreavus:slice-ptr-docs, r=GuillaumeG…
Mar 18, 2017
144c9e6
Rollup merge of #40611 - ScottAbbey:patch-1, r=GuillaumeGomez
Mar 18, 2017
337cbc1
Rollup merge of #40621 - jswalden:dependant-spelling-fix, r=sfackler
Mar 18, 2017
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
15 changes: 15 additions & 0 deletions src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
@@ -195,6 +195,21 @@ pub struct cmt_<'tcx> {
pub type cmt<'tcx> = Rc<cmt_<'tcx>>;

impl<'tcx> cmt_<'tcx> {
pub fn get_def(&self) -> Option<ast::NodeId> {
match self.cat {
Categorization::Deref(ref cmt, ..) |
Categorization::Interior(ref cmt, _) |
Categorization::Downcast(ref cmt, _) => {
if let Categorization::Local(nid) = cmt.cat {
Some(nid)
} else {
None
}
}
_ => None
}
}

pub fn get_field(&self, name: ast::Name) -> Option<DefId> {
match self.cat {
Categorization::Deref(ref cmt, ..) |
19 changes: 19 additions & 0 deletions src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
@@ -662,6 +662,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
pub fn bckerr_to_diag(&self, err: &BckError<'tcx>) -> DiagnosticBuilder<'a> {
let span = err.span.clone();
let mut immutable_field = None;
let mut local_def = None;

let msg = &match err.code {
err_mutbl => {
@@ -711,6 +712,14 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}
None
});
local_def = err.cmt.get_def()
.and_then(|nid| {
if !self.tcx.hir.is_argument(nid) {
Some(self.tcx.hir.span(nid))
} else {
None
}
});

format!("cannot borrow {} as mutable", descr)
}
@@ -741,6 +750,11 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
if let Some((span, msg)) = immutable_field {
db.span_label(span, &msg);
}
if let Some(let_span) = local_def {
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(let_span) {
db.span_label(let_span, &format!("consider changing this to `mut {}`", snippet));
}
}
db
}

@@ -1109,6 +1123,11 @@ before rustc 1.16, this temporary lived longer - see issue #39283 \
} else {
db.span_label(*error_span, &format!("cannot borrow mutably"));
}
} else if let Categorization::Interior(ref cmt, _) = err.cmt.cat {
if let mc::MutabilityCategory::McImmutable = cmt.mutbl {
db.span_label(*error_span,
&"cannot mutably borrow immutable field");
}
}
}
}
4 changes: 3 additions & 1 deletion src/test/ui/did_you_mean/issue-39544.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error: cannot borrow immutable field `z.x` as mutable
--> $DIR/issue-39544.rs:21:18
|
20 | let z = Z { x: X::Y };
| - consider changing this to `mut z`
21 | let _ = &mut z.x;
| ^^^
| ^^^ cannot mutably borrow immutable field

error: aborting due to previous error