Rollup merge of #91928 - fee1-dead:constification1, r=oli-obk

Constify (most) `Option` methods

r? ``@oli-obk``
This commit is contained in:
Matthias Krüger 2021-12-18 08:16:29 +01:00 committed by GitHub
commit fcc59794a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 311 additions and 77 deletions

View file

@ -11,8 +11,8 @@ LL | let y = x.or_else(4);
note: required by a bound in `Option::<T>::or_else`
--> $SRC_DIR/core/src/option.rs:LL:COL
|
LL | pub fn or_else<F: FnOnce() -> Option<T>>(self, f: F) -> Option<T> {
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Option::<T>::or_else`
LL | F: ~const FnOnce() -> Option<T>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Option::<T>::or_else`
error: aborting due to previous error

View file

@ -10,8 +10,8 @@ LL | let x: Option<&[u8]> = Some("foo").map(std::mem::transmute);
note: required by a bound in `Option::<T>::map`
--> $SRC_DIR/core/src/option.rs:LL:COL
|
LL | pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {
| ^^^^^^^^^^^^^^ required by this bound in `Option::<T>::map`
LL | F: ~const FnOnce(T) -> U,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Option::<T>::map`
error: aborting due to previous error

View file

@ -23,8 +23,8 @@ LL | | });
note: required by a bound in `Option::<T>::and_then`
--> $SRC_DIR/core/src/option.rs:LL:COL
|
LL | pub fn and_then<U, F: FnOnce(T) -> Option<U>>(self, f: F) -> Option<U> {
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Option::<T>::and_then`
LL | F: ~const FnOnce(T) -> Option<U>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Option::<T>::and_then`
error: aborting due to 2 previous errors

View file

@ -11,8 +11,8 @@ LL | None::<()>.map(Self::f);
note: required by a bound in `Option::<T>::map`
--> $SRC_DIR/core/src/option.rs:LL:COL
|
LL | pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {
| ^^^^^^^^^^^^^^ required by this bound in `Option::<T>::map`
LL | F: ~const FnOnce(T) -> U,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Option::<T>::map`
error: aborting due to previous error

View file

@ -12,8 +12,8 @@ LL | self.foo.map(Foo::new)
note: required by a bound in `Option::<T>::map`
--> $SRC_DIR/core/src/option.rs:LL:COL
|
LL | pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {
| ^^^^^^^^^^^^^^ required by this bound in `Option::<T>::map`
LL | F: ~const FnOnce(T) -> U,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Option::<T>::map`
error[E0593]: function is expected to take 0 arguments, but it takes 1 argument
--> $DIR/issue-47706.rs:27:9

View file

@ -11,8 +11,8 @@ LL | let _y = foo;
note: this function takes ownership of the receiver `self`, which moves `foo`
--> $SRC_DIR/core/src/option.rs:LL:COL
|
LL | pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {
| ^^^^
LL | pub const fn map<U, F>(self, f: F) -> Option<U>
| ^^^^
help: consider calling `.as_ref()` to borrow the type's contents
|
LL | let _x: Option<Struct> = foo.as_ref().map(|s| bar(&s));