mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
Fix question_mark lint+test
This commit is contained in:
parent
3cff06a0eb
commit
6f01ecfefd
2 changed files with 71 additions and 1 deletions
|
@ -27,7 +27,7 @@ use rustc::hir::def::Def;
|
|||
use rustc::hir::def_id::CrateNum;
|
||||
use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc::hir::intravisit::{NestedVisitorMap, Visitor};
|
||||
use rustc::hir::map::DisambiguatedDefPathData;
|
||||
use rustc::hir::map::{DefPathData, DisambiguatedDefPathData};
|
||||
use rustc::hir::Node;
|
||||
use rustc::hir::*;
|
||||
use rustc::lint::{LateContext, Level, Lint, LintContext};
|
||||
|
@ -178,6 +178,13 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
|
|||
disambiguated_data: &DisambiguatedDefPathData,
|
||||
) -> Result<Self::Path, Self::Error> {
|
||||
let mut path = print_prefix(self)?;
|
||||
|
||||
// Skip `::{{constructor}}` on tuple/unit structs.
|
||||
match disambiguated_data.data {
|
||||
DefPathData::Ctor => return Ok(path),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
path.push(disambiguated_data.data.as_interned_str().as_str());
|
||||
Ok(path)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:2:5
|
||||
|
|
||||
LL | / if a.is_none() {
|
||||
LL | | return None;
|
||||
LL | | }
|
||||
| |_____^ help: replace_it_with: `a?;`
|
||||
|
|
||||
= note: `-D clippy::question-mark` implied by `-D warnings`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:47:9
|
||||
|
|
||||
LL | / if (self.opt).is_none() {
|
||||
LL | | return None;
|
||||
LL | | }
|
||||
| |_________^ help: replace_it_with: `(self.opt)?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:51:9
|
||||
|
|
||||
LL | / if self.opt.is_none() {
|
||||
LL | | return None
|
||||
LL | | }
|
||||
| |_________^ help: replace_it_with: `self.opt?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:55:17
|
||||
|
|
||||
LL | let _ = if self.opt.is_none() {
|
||||
| _________________^
|
||||
LL | | return None;
|
||||
LL | | } else {
|
||||
LL | | self.opt
|
||||
LL | | };
|
||||
| |_________^ help: replace_it_with: `Some(self.opt?)`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:72:9
|
||||
|
|
||||
LL | / if self.opt.is_none() {
|
||||
LL | | return None;
|
||||
LL | | }
|
||||
| |_________^ help: replace_it_with: `self.opt.as_ref()?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:80:9
|
||||
|
|
||||
LL | / if self.opt.is_none() {
|
||||
LL | | return None;
|
||||
LL | | }
|
||||
| |_________^ help: replace_it_with: `self.opt.as_ref()?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:88:9
|
||||
|
|
||||
LL | / if self.opt.is_none() {
|
||||
LL | | return None;
|
||||
LL | | }
|
||||
| |_________^ help: replace_it_with: `self.opt.as_ref()?;`
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
Loading…
Add table
Reference in a new issue