Skip to content

let_unit_value triggers on generic return value #8998

@madsmtm

Description

@madsmtm

Summary

When using objc, a library commonly used when dealing with Objective-C, you often have to use let _: () = ... to tell the compiler what the return type, since the return type is generic.

This triggers the lint. Trying to apply the lint's suggestion results in a compilation error. The lint doesn't trigger on Rust 1.61.0.

Lint Name

let_unit_value

Reproducer

I tried the following code (see this playground link for a simplified testcase):

// objc v0.2.7
use objc::{class, msg_send};
use objc::runtime::Object;

let cls = class!(NSObject);
let obj: *mut Object = unsafe { msg_send![cls, new] };
let _: () = unsafe { msg_send![obj, release] };

I expected the lint to not trigger, instead it triggers on the last statement.

Version

rustc 1.63.0-nightly (ec55c6130 2022-06-10)
binary: rustc
commit-hash: ec55c61305eaf385fc1b93ac9a78284b4d887fe5
commit-date: 2022-06-10
host: x86_64-apple-darwin
release: 1.63.0-nightly
LLVM version: 14.0.5

Additional Labels

@rustbot label +regression-from-stable-to-nightly
@rustbot label +I-suggestion-causes-error

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions