compiler: Inspect local reference sources through checked borrows
deaafa1d9f40490153a0d240f50f6fb320108540b51194a87068a719779f3c07
1 parent
6168daf0
lib/std/lang/resolver.rad
+3 -3
| 10221 | 10221 | set env.regionalLoans |= (1 as u64) << (index as u64); |
|
| 10222 | 10222 | } |
|
| 10223 | 10223 | ||
| 10224 | 10224 | /// Return whether an initializer copies a shared reference with a named region. |
|
| 10225 | 10225 | /// Address expressions and casts retain a loan on their source storage. |
|
| 10226 | - | unsafe fn copiesRegionalReference(ty: Type, value: *ast::Node) -> bool { |
|
| 10227 | - | if referenceRegion(ty) == nil or not isCopy(ty) { |
|
| 10226 | + | fn copiesRegionalReference(ty: Type, value: *ast::Node) -> bool { |
|
| 10227 | + | if referenceRegion(ty) == nil or isMutablePointerLike(ty) { |
|
| 10228 | 10228 | return false; |
|
| 10229 | 10229 | } |
|
| 10230 | 10230 | match value.value { |
|
| 10231 | 10231 | case ast::NodeValue::AddressOf(_), ast::NodeValue::As(_) => return false, |
|
| 10232 | 10232 | else => return true, |
|
| 10233 | 10233 | } |
|
| 10234 | 10234 | } |
|
| 10235 | 10235 | ||
| 10236 | 10236 | /// Return the initializer that supplies a local reference's storage. |
|
| 10237 | - | unsafe fn localReferenceSource(sym: *unsafe mut Symbol) -> ?*ast::Node { |
|
| 10237 | + | fn localReferenceSource(sym: &Symbol) -> ?*ast::Node { |
|
| 10238 | 10238 | let case SymbolData::Value { type: ty, .. } = sym.data else return nil; |
|
| 10239 | 10239 | if let case Type::Session(_) = ty { |
|
| 10240 | 10240 | if let case ast::NodeValue::RegionBinding(binding) = sym.node.value { |
|
| 10241 | 10241 | return binding.value; |
|
| 10242 | 10242 | } |