-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Make Default
const and add some const Default
impls
#134628
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
base: master
Are you sure you want to change the base?
Changes from all commits
e2b12ba
0ae3f87
84a6915
f811624
ec41e44
170f887
34d461b
9ee6024
7cd06dc
4069e12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,12 +240,6 @@ error: use of `unwrap_or` to construct default value | |
LL | let _ = opt.unwrap_or({ i32::default() }); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` | ||
|
||
error: function call inside of `unwrap_or` | ||
--> tests/ui/or_fun_call.rs:409:21 | ||
| | ||
LL | let _ = opt_foo.unwrap_or(Foo { val: String::default() }); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| Foo { val: String::default() })` | ||
Comment on lines
-243
to
-247
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this clippy lint have a check that the value is const constructable in a stable way (which would revert this output change)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, otherwise users get clippy lints they cannot address |
||
|
||
error: function call inside of `map_or` | ||
--> tests/ui/or_fun_call.rs:424:19 | ||
| | ||
|
@@ -264,5 +258,5 @@ error: function call inside of `get_or_insert` | |
LL | let _ = x.get_or_insert(g()); | ||
| ^^^^^^^^^^^^^^^^^^ help: try: `get_or_insert_with(g)` | ||
|
||
error: aborting due to 41 previous errors | ||
error: aborting due to 40 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//@ run-pass | ||
#![feature(const_trait_impl, const_default)] | ||
#![allow(dead_code)] | ||
// alloc::string | ||
const STRING: String = Default::default(); | ||
// alloc::vec | ||
const VEC: Vec<()> = Default::default(); | ||
|
||
fn main() {} |
Uh oh!
There was an error while loading. Please reload this page.