Skip to content

Commit

Permalink
Added remove_page
Browse files Browse the repository at this point in the history
  • Loading branch information
bergel committed Mar 4, 2024
1 parent 541cc25 commit e0c02e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/linting/extended_checks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct ArrayWithNoType_Extension <: ExtendedRule end
struct Threads_Extension <: ExtendedRule end
struct Generated_Extension <: ExtendedRule end
struct Sync_Extension <: ExtendedRule end
struct RemovePage_Extension <: ExtendedRule end

const all_extended_rule_types = Ref{Any}(InteractiveUtils.subtypes(ExtendedRule))

Expand Down Expand Up @@ -193,3 +194,5 @@ function check(::Sync_Extension, x::EXPR)
generic_check(x, "@sync hole_variable", msg)
generic_check(x, "Threads.@sync hole_variable", msg)
end

check(::RemovePage_Extension, x::EXPR) = generic_check(x, "remove_page(hole_variable,hole_variable)")
10 changes: 9 additions & 1 deletion test/rai_rules_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ end
"Line 18, column 5: `wait` should be used with extreme caution.")
end

@testset "fetch, @inbounds, Atomic, Ptr" begin
@testset "fetch, @inbounds, Atomic, Ptr, remove_page" begin
source = """
function f()
fut = Future{Any}()
Expand All @@ -384,6 +384,12 @@ end
pointer(page) == Ptr{Nothing}(0) && return
end
function _clear_pager!(pager)
for (pid, _) in pager.owned_pages
remove_page(pager, pid)
end
end
"""

@test lint_test(source, "Line 3, column 10: `fetch` should be used with extreme caution.")
Expand All @@ -394,6 +400,8 @@ end
@test lint_test(source, "Line 17, column 20: `Atomic` should be used with extreme caution.")

@test lint_test(source, "Line 19, column 22: `Ptr` should be used with extreme caution.")

@test lint_test(source, "Line 24, column 9: `remove_page` should be used with extreme caution.")
end

@testset "Array with no specific type 01" begin
Expand Down

0 comments on commit e0c02e7

Please sign in to comment.