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 17 pull requests #73475

Closed
wants to merge 77 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
d4fe955
Implement partial error recovery for `let` with `BinOpEq`
mibac138 May 7, 2020
48ff12a
Expand partial error recovery for `let` with `BinOpEq`
mibac138 May 7, 2020
05d6531
Error recovery for `let` with `+=`
mibac138 May 7, 2020
6ad24ba
Adjust according to estebank's review comments
mibac138 May 7, 2020
98532a3
Adjust according to petrochenkov's review comments
mibac138 May 20, 2020
591584e
Add tests for 'impl Default for [T; N]'
MikailBag May 26, 2020
3313bf6
Skip leak test on targets without panic=unwind
MikailBag May 28, 2020
358dc1d
Added io forwarding methods to the stdio structs
Lucretiel May 28, 2020
f7d745f
tag/niche terminology cleanup
RalfJung May 23, 2020
7a6d03c
miri errors: rename InvalidDiscriminant -> InvalidTag
RalfJung May 30, 2020
1bc4e45
Only highlight results via mouseover if mouse has moved
carols10cents Jun 2, 2020
724dfba
Clean up some weird command strings
GuillaumeGomez Jun 13, 2020
4606168
Make new type param suggestion more targetted
estebank Jun 13, 2020
afbbd38
Note numeric literals that can never fit in an expected type
ayazhafiz Jun 13, 2020
2b936bb
fixup! Note numeric literals that can never fit in an expected type
ayazhafiz Jun 14, 2020
e32db84
Add rust features to print target features
aszenz Jun 14, 2020
f62903b
Export `#[inline] #[no_mangle]` fns in cdylibs and staticlibs
doctorn Jun 5, 2020
6b7cacb
Export all fns with extern indicator
doctorn Jun 8, 2020
d23bedd
Fix whitespace
doctorn Jun 8, 2020
ee810a7
Fix exports with `#[inline(always)]`
doctorn Jun 9, 2020
11b56fb
Fix whitespace
doctorn Jun 9, 2020
babda94
Fix sanitizer test
doctorn Jun 15, 2020
e8e0a0e
Update sanitizer test
doctorn Jun 15, 2020
9e51008
Complete the std::time documentation to warn about the inconsistencie…
poliorcetics Jun 15, 2020
81c9094
Suggest substituting `'static` lifetime in impl/dyn `Trait + 'static`…
estebank May 29, 2020
4e90f17
When `'static` is explicit, suggest constraining argument with it
estebank May 30, 2020
921f35f
Reduce verbosity of suggestion message and mention lifetime in label
estebank May 30, 2020
e755889
Move overlapping span to a note
estebank May 30, 2020
bc15790
Tweak output for overlapping required/captured spans
estebank May 30, 2020
539e978
Tweak wording and add error code
estebank May 30, 2020
31ea589
review comments: wording
estebank Jun 1, 2020
10d9bf1
Use note for requirement source span
estebank Jun 2, 2020
34d8692
Register new eror code
estebank Jun 2, 2020
e31367d
small tweaks
estebank Jun 2, 2020
f7a1f97
Change E0758 to E0759 to avoid conflict with #72912
estebank Jun 3, 2020
bfe1434
fix rebase
estebank Jun 15, 2020
10c8d2a
add FIXME to EnumTagInfo
RalfJung Jun 15, 2020
96f5584
Expand "recursive opaque type" diagnostic
estebank Apr 19, 2020
8f12485
review comments
estebank Jun 15, 2020
268decb
make all uses of ty::Error or ConstKind::Error delay a span bug
mark-i-m May 6, 2020
e855b90
track caller for delay_span_bug
mark-i-m May 26, 2020
0bcefd9
remove visit_terminator_kind from MIR visitor
RalfJung May 31, 2020
302fb50
get rid of an unused 'span' field
RalfJung May 31, 2020
046165a
rename location field of Drop terminators to place
RalfJung Jun 10, 2020
6c5345f
fmt; make visit_terminator arg names consistent with the rest
RalfJung Jun 10, 2020
827ccf7
add probably accidentally missing super_* calls
RalfJung Jun 10, 2020
f0d3689
fixup! Note numeric literals that can never fit in an expected type
ayazhafiz Jun 16, 2020
cfdbbb5
format derives
mark-i-m Jun 16, 2020
4506a35
add header for rust specific feature
aszenz Jun 16, 2020
9f50f84
break long line for formatting
aszenz Jun 16, 2020
457acbd
trim whitespace
aszenz Jun 16, 2020
af45d8a
Suggest new type param on single char ident
estebank Jun 13, 2020
d7277df
fixup! Note numeric literals that can never fit in an expected type
ayazhafiz Jun 17, 2020
caffb28
add blank line bw sections
aszenz Jun 17, 2020
7a89a33
fixup! Note numeric literals that can never fit in an expected type
ayazhafiz Jun 17, 2020
b60cefe
Removed write_fmt forwarding, to fix recursive borrow issues
Lucretiel Jun 17, 2020
8d1a380
review comments
estebank Jun 17, 2020
14d385b
Restore some write_fmts
Lucretiel Jun 17, 2020
e5c5df8
Add specialization of `ToString for char`
tesuji Jun 18, 2020
d134870
Document format correction
qy3u Jun 18, 2020
d176448
Rollup merge of #70551 - mark-i-m:ty-err-2, r=varkor
Manishearth Jun 18, 2020
2e9e434
Rollup merge of #71338 - estebank:recursive-impl-trait, r=nikomatsakis
Manishearth Jun 18, 2020
09ca6a4
Rollup merge of #71976 - mibac138:let-recovery, r=estebank
Manishearth Jun 18, 2020
0a9ad17
Rollup merge of #72497 - RalfJung:tag-term, r=oli-obk
Manishearth Jun 18, 2020
538671b
Rollup merge of #72628 - MikailBag:array-default-tests, r=shepmaster
Manishearth Jun 18, 2020
90a2403
Rollup merge of #72705 - Lucretiel:stdio-forwarding, r=Amanieu
Manishearth Jun 18, 2020
32b4084
Rollup merge of #72804 - estebank:opaque-missing-lts-in-fn-2, r=nikom…
Manishearth Jun 18, 2020
be8fe77
Rollup merge of #72814 - RalfJung:mir-visir-terminator, r=oli-obk
Manishearth Jun 18, 2020
f419606
Rollup merge of #72836 - poliorcetics:std-time-os-specificities, r=sh…
Manishearth Jun 18, 2020
4641943
Rollup merge of #72968 - integer32llc:docs-arrow-keys, r=GuillaumeGomez
Manishearth Jun 18, 2020
89825e2
Rollup merge of #73034 - doctorn:nomangle-inline-linkage, r=matthewja…
Manishearth Jun 18, 2020
d315db4
Rollup merge of #73315 - GuillaumeGomez:clean-up-config-strs, r=kinnison
Manishearth Jun 18, 2020
6717409
Rollup merge of #73320 - estebank:type-param-sugg-more, r=davidtwco
Manishearth Jun 18, 2020
a2125e5
Rollup merge of #73334 - ayazhafiz:err/num-type-cannot-fit, r=estebank
Manishearth Jun 18, 2020
8fa2f09
Rollup merge of #73346 - aszenz:patch-1, r=cuviper
Manishearth Jun 18, 2020
d8f6804
Rollup merge of #73464 - qy3u:fs-document-format-correction, r=jonas-…
Manishearth Jun 18, 2020
67d5f65
Rollup merge of #73465 - lzutao:spec-char-tostring, r=sfackler
Manishearth Jun 18, 2020
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
Next Next commit
Implement partial error recovery for let with BinOpEq
When parsing `let x: i8 += 1` the compiler interprets `i8` as a trait
which makes it more complicated to do error recovery. More advanced
error recovery is not implemented in this commit.
  • Loading branch information
mibac138 committed May 20, 2020
commit d4fe9553f65df51a18999e956fd507e26271e74e
29 changes: 27 additions & 2 deletions src/librustc_parse/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_ast::ast::{Block, BlockCheckMode, Expr, ExprKind, Local, Stmt, StmtKin
use rustc_ast::ptr::P;
use rustc_ast::token::{self, TokenKind};
use rustc_ast::util::classify;
use rustc_errors::{Applicability, PResult};
use rustc_errors::{struct_span_err, Applicability, PResult};
use rustc_span::source_map::{BytePos, Span};
use rustc_span::symbol::{kw, sym};

Expand Down Expand Up @@ -217,7 +217,32 @@ impl<'a> Parser<'a> {

/// Parses the RHS of a local variable declaration (e.g., '= 14;').
fn parse_initializer(&mut self, skip_eq: bool) -> PResult<'a, Option<P<Expr>>> {
if self.eat(&token::Eq) || skip_eq { Ok(Some(self.parse_expr()?)) } else { Ok(None) }
let parse = if !self.eat(&token::Eq) && !skip_eq {
// Error recovery for `let x += 1`
if matches!(self.token.kind, TokenKind::BinOpEq(_)) {
struct_span_err!(
self.sess.span_diagnostic,
self.token.span,
E0067,
"can't reassign to a uninitialized variable"
)
.span_suggestion_short(
self.token.span,
"replace with `=` to initialize the variable",
"=".to_string(),
Applicability::MaybeIncorrect,
)
.emit();
self.bump();
true
} else {
false
}
} else {
true
};

if parse { Ok(Some(self.parse_expr()?)) } else { Ok(None) }
}

/// Parses a block. No inner attributes are allowed.
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/parser/let-binop-plus.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![allow(bare_trait_objects)]

fn main() {
let a: i8 += 1;
//~^ ERROR expected trait, found builtin type `i8`
let _ = a;
}
9 changes: 9 additions & 0 deletions src/test/ui/parser/let-binop-plus.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0404]: expected trait, found builtin type `i8`
--> $DIR/let-binop-plus.rs:4:12
|
LL | let a: i8 += 1;
| ^^ not a trait

error: aborting due to previous error

For more information about this error, try `rustc --explain E0404`.
8 changes: 8 additions & 0 deletions src/test/ui/parser/let-binop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main() {
let a: i8 *= 1; //~ ERROR can't reassign to a uninitialized variable
let _ = a;
let b += 1; //~ ERROR can't reassign to a uninitialized variable
let _ = b;
let c *= 1; //~ ERROR can't reassign to a uninitialized variable
let _ = c;
}
21 changes: 21 additions & 0 deletions src/test/ui/parser/let-binop.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0067]: can't reassign to a uninitialized variable
--> $DIR/let-binop.rs:2:15
|
LL | let a: i8 *= 1;
| ^^ help: replace with `=` to initialize the variable

error[E0067]: can't reassign to a uninitialized variable
--> $DIR/let-binop.rs:4:11
|
LL | let b += 1;
| ^^ help: replace with `=` to initialize the variable

error[E0067]: can't reassign to a uninitialized variable
--> $DIR/let-binop.rs:6:11
|
LL | let c *= 1;
| ^^ help: replace with `=` to initialize the variable

error: aborting due to 3 previous errors

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