Skip to content

Commit

Permalink
Revert "Merge pull request rust-lang#3257 from o01eg/remove-sysroot"
Browse files Browse the repository at this point in the history
This reverts commit 041c49c, reversing
changes made to 278b94e.
  • Loading branch information
matthiaskrgr committed Dec 11, 2018
1 parent 82e6dbb commit 2375c31
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 24 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ rustup update
Once you have rustup and the latest stable release (at least Rust 1.29) installed, run the following command:

```terminal
rustup component add clippy
rustup component add clippy-preview
```

Now you can run Clippy by invoking `cargo clippy`.
Expand Down Expand Up @@ -95,7 +95,7 @@ rust:
- stable
- beta
before_script:
- rustup component add clippy
- rustup component add clippy-preview
script:
- cargo clippy
# if you want the build job to fail when encountering warnings, use
Expand All @@ -114,7 +114,7 @@ language: rust
rust:
- nightly
before_script:
- rustup component add clippy --toolchain=nightly || cargo install --git https://github.com/rust-lang/rust-clippy/ --force clippy
- rustup component add clippy-preview --toolchain=nightly || cargo install --git https://github.com/rust-lang/rust-clippy/ --force clippy
# etc
```

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/block_in_if_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
if let ExprKind::Closure(_, _, eid, _, _) = expr.node {
let body = self.cx.tcx.hir().body(eid);
let ex = &body.value;
if matches!(ex.node, ExprKind::Block(_, _)) && !in_macro(body.value.span) {
if matches!(ex.node, ExprKind::Block(_, _)) {
self.found_block = Some(ex);
return;
}
Expand Down
9 changes: 7 additions & 2 deletions clippy_lints/src/implicit_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ pub struct Pass;
impl Pass {
fn expr_match(cx: &LateContext<'_, '_>, expr: &rustc::hir::Expr) {
match &expr.node {
// loops could be using `break` instead of `return`
ExprKind::Block(block, ..) | ExprKind::Loop(block, ..) => {
ExprKind::Block(block, ..) => {
if let Some(expr) = &block.expr {
Self::expr_match(cx, expr);
}
Expand Down Expand Up @@ -86,6 +85,12 @@ impl Pass {
Self::expr_match(cx, &arm.body);
}
},
// loops could be using `break` instead of `return`
ExprKind::Loop(block, ..) => {
if let Some(expr) = &block.expr {
Self::expr_match(cx, expr);
}
},
// skip if it already has a return statement
ExprKind::Ret(..) => (),
// everything else is missing `return`
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/use_self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::rustc::ty;
use crate::rustc::{declare_tool_lint, lint_array};
use crate::rustc_errors::Applicability;
use crate::syntax::ast::NodeId;
use crate::syntax_pos::symbol::keywords::SelfUpper;
use crate::syntax_pos::symbol::keywords::SelfType;
use crate::utils::{in_macro, span_lint_and_sugg};
use if_chain::if_chain;

Expand Down Expand Up @@ -226,7 +226,7 @@ struct UseSelfVisitor<'a, 'tcx: 'a> {

impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
fn visit_path(&mut self, path: &'tcx Path, _id: HirId) {
if self.item_path.def == path.def && path.segments.last().expect(SEGMENTS_MSG).ident.name != SelfUpper.name() {
if self.item_path.def == path.def && path.segments.last().expect(SEGMENTS_MSG).ident.name != SelfType.name() {
span_use_self_lint(self.cx, path);
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ pub fn opt_def_id(def: Def) -> Option<DefId> {

pub fn is_self(slf: &Arg) -> bool {
if let PatKind::Binding(_, _, name, _) = slf.pat.node {
name.name == keywords::SelfLower.name()
name.name == keywords::SelfValue.name()
} else {
false
}
Expand Down
8 changes: 0 additions & 8 deletions tests/ui/block_in_if_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,3 @@ fn condition_is_unsafe_block() {

fn main() {
}

fn macro_in_closure() {
let option = Some(true);

if option.unwrap_or_else(|| unimplemented!()) {
unimplemented!()
}
}
8 changes: 1 addition & 7 deletions tests/ui/implicit_return.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ error: missing return statement
38 | true
| ^^^^ help: add `return` as shown: `return true`

error: missing return statement
--> $DIR/implicit_return.rs:46:9
|
46 | break true;
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`

error: missing return statement
--> $DIR/implicit_return.rs:52:9
|
Expand All @@ -48,5 +42,5 @@ error: missing return statement
54 | let _ = || true;
| ^^^^ help: add `return` as shown: `return true`

error: aborting due to 8 previous errors
error: aborting due to 7 previous errors

0 comments on commit 2375c31

Please sign in to comment.