Skip to content

Commit 4265143

Browse files
committed
Merge branch 'master' into fix-check_infinite_loop
2 parents 4028625 + b4f1769 commit 4265143

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

clippy_lints/src/consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
474474
pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
475475
use rustc::mir::interpret::{ConstValue, Scalar};
476476
match result.val {
477-
ConstValue::Scalar(Scalar::Raw { data: d, .. }) => match result.ty.kind {
477+
ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data: d, .. })) => match result.ty.kind {
478478
ty::Bool => Some(Constant::Bool(d == 1)),
479479
ty::Uint(_) | ty::Int(_) => Some(Constant::Int(d)),
480480
ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(
@@ -492,7 +492,7 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
492492
// FIXME: implement other conversions.
493493
_ => None,
494494
},
495-
ConstValue::Slice { data, start, end } => match result.ty.kind {
495+
ty::ConstKind::Value(ConstValue::Slice { data, start, end }) => match result.ty.kind {
496496
ty::Ref(_, tam, _) => match tam.kind {
497497
ty::Str => String::from_utf8(
498498
data.inspect_with_undef_and_ptr_outside_interpreter(start..end)

clippy_lints/src/functions.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::{
22
attrs::is_proc_macro, iter_input_pats, match_def_path, qpath_res, return_ty, snippet, snippet_opt,
3-
span_help_and_lint, span_lint, span_lint_and_then, type_is_unsafe_function,
3+
span_help_and_lint, span_lint, span_lint_and_then, trait_ref_of_method, type_is_unsafe_function,
44
};
55
use matches::matches;
66
use rustc::hir::{self, def::Res, def_id::DefId, intravisit};
@@ -254,7 +254,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
254254
if let Some(attr) = attr {
255255
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
256256
check_needless_must_use(cx, &sig.decl, item.hir_id, item.span, fn_header_span, attr);
257-
} else if cx.access_levels.is_exported(item.hir_id) && !is_proc_macro(&item.attrs) {
257+
} else if cx.access_levels.is_exported(item.hir_id)
258+
&& !is_proc_macro(&item.attrs)
259+
&& trait_ref_of_method(cx, item.hir_id).is_none()
260+
{
258261
check_must_use_candidate(
259262
cx,
260263
&sig.decl,

src/driver.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,14 @@ pub fn main() {
268268

269269
// Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument.
270270
// We're invoking the compiler programmatically, so we ignore this/
271-
let wrapper_mode = Path::new(&orig_args[1]).file_stem() == Some("rustc".as_ref());
271+
let wrapper_mode = orig_args.get(1).map(Path::new).and_then(Path::file_stem) == Some("rustc".as_ref());
272272

273273
if wrapper_mode {
274274
// we still want to be able to invoke it normally though
275275
orig_args.remove(1);
276276
}
277277

278-
if !wrapper_mode && std::env::args().any(|a| a == "--help" || a == "-h") {
278+
if !wrapper_mode && (orig_args.iter().any(|a| a == "--help" || a == "-h") || orig_args.len() == 1) {
279279
display_help();
280280
exit(0);
281281
}

tests/ui/must_use_candidates.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub trait MyPureTrait {
2828
}
2929

3030
impl MyPureTrait for MyPure {
31-
#[must_use] fn trait_impl_pure(&self, i: u32) -> u32 {
31+
fn trait_impl_pure(&self, i: u32) -> u32 {
3232
i
3333
}
3434
}

tests/ui/must_use_candidates.stderr

+1-7
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ error: this method could have a `#[must_use]` attribute
1212
LL | pub fn inherent_pure(&self) -> u8 {
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn inherent_pure(&self) -> u8`
1414

15-
error: this method could have a `#[must_use]` attribute
16-
--> $DIR/must_use_candidates.rs:31:5
17-
|
18-
LL | fn trait_impl_pure(&self, i: u32) -> u32 {
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] fn trait_impl_pure(&self, i: u32) -> u32`
20-
2115
error: this function could have a `#[must_use]` attribute
2216
--> $DIR/must_use_candidates.rs:48:1
2317
|
@@ -36,5 +30,5 @@ error: this function could have a `#[must_use]` attribute
3630
LL | pub fn arcd(_x: Arc<u32>) -> bool {
3731
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn arcd(_x: Arc<u32>) -> bool`
3832

39-
error: aborting due to 6 previous errors
33+
error: aborting due to 5 previous errors
4034

0 commit comments

Comments
 (0)