Skip to content

no optimization of Some(v).unwrap() to v for certain types of v #111268

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

Closed
antonilol opened this issue May 5, 2023 · 3 comments
Closed

no optimization of Some(v).unwrap() to v for certain types of v #111268

antonilol opened this issue May 5, 2023 · 3 comments
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. I-heavy Issue: Problems and improvements with respect to binary size of generated code. I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@antonilol
Copy link
Contributor

I tried this code:

pub fn example(vec: Vec<u32>) -> Vec<u32> {
    Some(vec).unwrap() 
}

I expected to see this happen: a simple move

Instead, this happened: extra logic was added to check for None

see https://godbolt.org/z/sozWosj88

this does not happen with u32 and &Vec<u32>: https://godbolt.org/z/crhePq97z

Meta

godbolt's rustc version:

rustc 1.71.0-nightly (dbba59457 2023-05-01)
@antonilol antonilol added the C-bug Category: This is a bug. label May 5, 2023
@Jules-Bertholet
Copy link
Contributor

@rustbot label A-codegen I-heavy I-slow

@rustbot rustbot added A-codegen Area: Code generation I-heavy Issue: Problems and improvements with respect to binary size of generated code. I-slow Issue: Problems and improvements with respect to performance of generated code. labels May 5, 2023
@saethlin
Copy link
Member

saethlin commented May 6, 2023

FWIW I previously reported this: #93011

@workingjubilee
Copy link
Member

Thank you for reporting! Closing as duplicate.

@workingjubilee workingjubilee closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. I-heavy Issue: Problems and improvements with respect to binary size of generated code. I-slow Issue: Problems and improvements with respect to performance of generated code.
Projects
None yet
Development

No branches or pull requests

5 participants