infer for a proc whether it is OK to pass an argument as borrowed

this only looks at calls to lowlevels right now, not calls to other functions
This commit is contained in:
Folkert 2024-03-13 20:12:51 +01:00
parent ae88295365
commit 51a4192659
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
3 changed files with 141 additions and 4 deletions

View file

@ -223,17 +223,17 @@ impl<'a, 'i> SymbolRcTypesEnv<'a, 'i> {
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Ownership {
pub(crate) enum Ownership {
Owned,
Borrowed,
}
impl Ownership {
fn is_owned(&self) -> bool {
pub(crate) fn is_owned(&self) -> bool {
matches!(self, Ownership::Owned)
}
fn is_borrowed(&self) -> bool {
pub(crate) fn is_borrowed(&self) -> bool {
matches!(self, Ownership::Borrowed)
}
}
@ -1265,7 +1265,7 @@ fn insert_dec_stmt<'a>(
/**
* Retrieve the borrow signature of a low-level operation.
*/
fn lowlevel_borrow_signature(op: LowLevel) -> &'static [Ownership] {
pub(crate) fn lowlevel_borrow_signature(op: LowLevel) -> &'static [Ownership] {
use LowLevel::*;
const IRRELEVANT: Ownership = Ownership::Owned;