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

Skip to content

Rollup of 11 pull requests #51930

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 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
30d825c
Fix doc links
MajorBreakfast Jun 27, 2018
64f8e3b
Update liblibc
est31 Jun 28, 2018
fb58db4
Require type is sized in wfcheck.check_item_type for externed DSTs, c…
krk Jun 28, 2018
cd8ca26
Point at lifetimes instead of def span for E0195
estebank Jun 27, 2018
5436a5c
Point to lifetime in fn definition on lifetime error note
estebank Jun 27, 2018
3005162
Extend support to `get_generics` for all `NodeItem`s
estebank Jun 27, 2018
03bcebb
Also point to free named region on lifetime errors
estebank Jun 28, 2018
9a9b747
review comments: unify duplicated code
estebank Jun 28, 2018
8449c5a
Fix rebase
estebank Jun 28, 2018
23d59d0
Suggest correct comparison against negative literal
estebank Jun 28, 2018
d6cf182
Fix inconsequential typo in GlobalAlloc doc example
Ixrec Jun 29, 2018
52b7eb9
Do not allow LLVM to increase a TLS's alignment on macOS.
kennytm Jun 27, 2018
0250302
Implement PartialEq between &str and OsString
GabrielMajeri May 29, 2018
fdcee4d
Fix stability attributes
GabrielMajeri May 30, 2018
fbd3c92
Add run-pass test
GabrielMajeri Jun 5, 2018
28c4813
use literal span for concrete type suggestion
euclio Jun 29, 2018
faaf250
improve the error message when `#[panic_implementation]` is missing
japaric Jun 29, 2018
ee52862
update another cfail test
japaric Jun 29, 2018
1328bde
resolve: Cleanup `resolve_crate_root`
petrochenkov Jun 24, 2018
09856c8
expansion: Give names to some fields of `SyntaxExtension`
petrochenkov Jun 24, 2018
99ecdb3
hygiene: Implement transparent marks
petrochenkov Jun 24, 2018
297109e
proc-macro: Use transparent marks for call-site hygiene
petrochenkov Jun 24, 2018
9f92fce
Fortify dummy span checking
petrochenkov Jun 24, 2018
b69d511
Restore the old behavior of `$crate` in nested `macro_rules`
petrochenkov Jun 29, 2018
84f1bc8
Address comments
petrochenkov Jun 29, 2018
12247fd
Rollup merge of #51178 - GabrielMajeri:os-str-compare, r=SimonSapin
Mark-Simulacrum Jun 30, 2018
d562bff
Rollup merge of #51762 - petrochenkov:oh-hi-mark, r=oli-obk
Mark-Simulacrum Jun 30, 2018
8c30769
Rollup merge of #51828 - kennytm:no-simd-swap-for-mac, r=alexcrichton
Mark-Simulacrum Jun 30, 2018
4b6d98d
Rollup merge of #51853 - MajorBreakfast:fix-doc-links, r=cramertj
Mark-Simulacrum Jun 30, 2018
b3f8989
Rollup merge of #51862 - estebank:lifetime-spans, r=nikomatsakis
Mark-Simulacrum Jun 30, 2018
bea664b
Rollup merge of #51864 - est31:libc_update, r=alexcrichton
Mark-Simulacrum Jun 30, 2018
de85644
Rollup merge of #51867 - krk:issue-36122, r=petrochenkov
Mark-Simulacrum Jun 30, 2018
2223cc8
Rollup merge of #51883 - estebank:placement-suggestion, r=varkor
Mark-Simulacrum Jun 30, 2018
cf957c8
Rollup merge of #51890 - Ixrec:patch-3, r=alexcrichton
Mark-Simulacrum Jun 30, 2018
b50a6ba
Rollup merge of #51920 - euclio:concrete-type-suggestion, r=estebank
Mark-Simulacrum Jun 30, 2018
b7bd4aa
Rollup merge of #51921 - japaric:panic-impl-error, r=nagisa
Mark-Simulacrum Jun 30, 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
Prev Previous commit
Next Next commit
Suggest correct comparison against negative literal
When parsing as emplacement syntax (`x<-1`), suggest the correct syntax
for comparison against a negative value (`x< -1`).
  • Loading branch information
estebank committed Jun 28, 2018
commit 23d59d00be7c12a4b8fef68ef663a6d97290c415
27 changes: 21 additions & 6 deletions src/librustc_passes/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,27 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
ExprKind::InlineAsm(..) if !self.session.target.target.options.allow_asm => {
span_err!(self.session, expr.span, E0472, "asm! is unsupported on this target");
}
ExprKind::ObsoleteInPlace(..) => {
self.err_handler()
.struct_span_err(expr.span, "emplacement syntax is obsolete (for now, anyway)")
.note("for more information, see \
<https://github.com/rust-lang/rust/issues/27779#issuecomment-378416911>")
.emit();
ExprKind::ObsoleteInPlace(ref place, ref val) => {
let mut err = self.err_handler().struct_span_err(
expr.span,
"emplacement syntax is obsolete (for now, anyway)",
);
err.note(
"for more information, see \
<https://github.com/rust-lang/rust/issues/27779#issuecomment-378416911>"
);
match val.node {
ExprKind::Lit(ref v) if v.node.is_numeric() => {
err.span_suggestion(
place.span.between(val.span),
"if you meant to write a comparison against a negative value, add a \
space in between `<` and `-`",
"< -".to_string(),
);
}
_ => {}
}
err.emit();
}
_ => {}
}
Expand Down
10 changes: 10 additions & 0 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,16 @@ impl LitKind {
}
}

/// Returns true if this is a numeric literal.
pub fn is_numeric(&self) -> bool {
match *self {
LitKind::Int(..) |
LitKind::Float(..) |
LitKind::FloatUnsuffixed(..) => true,
_ => false,
}
}

/// Returns true if this literal has no suffix. Note: this will return true
/// for literals with prefixes such as raw strings and byte strings.
pub fn is_unsuffixed(&self) -> bool {
Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/suggestions/placement-syntax.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn main() {
let x = -5;
if x<-1 {
//~^ ERROR emplacement syntax is obsolete
println!("ok");
}
}
14 changes: 14 additions & 0 deletions src/test/ui/suggestions/placement-syntax.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: emplacement syntax is obsolete (for now, anyway)
--> $DIR/placement-syntax.rs:13:8
|
LL | if x<-1 {
| ^^^^
|
= note: for more information, see <https://github.com/rust-lang/rust/issues/27779#issuecomment-378416911>
help: if you meant to write a comparison against a negative value, add a space in between `<` and `-`
|
LL | if x< -1 {
| ^^^

error: aborting due to previous error

0