-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #58784 - oli-obk:accidental_promotion, r=eddyb
Don't promote function calls to nonpromotable things fixes #58767 and fixes #58634 r? @eddyb should we additionally check the function call return type? It might be a promotable function (or any `const fn` inside a `const fn`), but its return type might contain interior mutability.
- Loading branch information
Showing
2 changed files
with
22 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// compile-pass | ||
// note this was only reproducible with lib crates | ||
// compile-flags: --crate-type=lib | ||
|
||
pub struct Hz; | ||
|
||
impl Hz { | ||
pub const fn num(&self) -> u32 { | ||
42 | ||
} | ||
pub const fn normalized(&self) -> Hz { | ||
Hz | ||
} | ||
|
||
pub const fn as_u32(&self) -> u32 { | ||
self.normalized().num() // this used to promote the `self.normalized()` | ||
} | ||
} |