Skip to content

Don't emit new_without_default_derive if an impl of Default exists regardless of generics #3350

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

Merged
merged 1 commit into from
Oct 24, 2018

Conversation

pengowen123
Copy link
Contributor

Fixes #2226

if let Some(self_def) = cx.tcx.type_of(self_did).ty_adt_def() {
if self_def.did.is_local() {
let self_id = cx.tcx.hir.local_def_id_to_node_id(self_def.did.to_local());
if self.impling_types.as_ref().unwrap().contains(&self_id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh... why isn't dogfood complaining about the unwrap?

@pengowen123 pengowen123 force-pushed the fix_new_without_default_derive branch from 9ed9820 to 50b9e7a Compare October 24, 2018 03:44
@pengowen123
Copy link
Contributor Author

@oli-obk I think the unwrap is fine there, but I have replaced it with an if let anyways. Dogfood may not have caught it because the code is in a macro call.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 24, 2018

Dogfood may not have caught it because the code is in a macro call.

Ah yes

I think the unwrap is fine there, but I have replaced it with an if let anyways.

It is, that's not the issue. We just have a lint that suggests expect

@oli-obk
Copy link
Contributor

oli-obk commented Oct 24, 2018

bors r+

bors bot added a commit that referenced this pull request Oct 24, 2018
3350: Don't emit `new_without_default_derive` if an impl of Default exists regardless of generics r=oli-obk a=pengowen123

Fixes #2226

Co-authored-by: Owen Sanchez <pengowen816@gmail.com>
@bors
Copy link
Contributor

bors bot commented Oct 24, 2018

@bors bors bot merged commit 50b9e7a into rust-lang:master Oct 24, 2018
@pengowen123 pengowen123 deleted the fix_new_without_default_derive branch October 24, 2018 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants