MCPcopy Create free account
hub / github.com/davidblewett/rure-python / no_stack_overflow_on_drop

Function no_stack_overflow_on_drop

regex/regex-syntax/src/hir/mod.rs:2155–2191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2153 #[test]
2154 #[cfg(any(unix, windows))]
2155 fn no_stack_overflow_on_drop() {
2156 use std::thread;
2157
2158 let run = || {
2159 let mut expr = Hir::empty();
2160 for _ in 0..100 {
2161 expr = Hir::group(Group {
2162 kind: GroupKind::NonCapturing,
2163 hir: Box::new(expr),
2164 });
2165 expr = Hir::repetition(Repetition {
2166 kind: RepetitionKind::ZeroOrOne,
2167 greedy: true,
2168 hir: Box::new(expr),
2169 });
2170
2171 expr = Hir {
2172 kind: HirKind::Concat(vec![expr]),
2173 info: HirInfo::new(),
2174 };
2175 expr = Hir {
2176 kind: HirKind::Alternation(vec![expr]),
2177 info: HirInfo::new(),
2178 };
2179 }
2180 assert!(!expr.kind.is_empty());
2181 };
2182
2183 // We run our test on a thread with a small stack size so we can
2184 // force the issue more easily.
2185 thread::Builder::new()
2186 .stack_size(1<<10)
2187 .spawn(run)
2188 .unwrap()
2189 .join()
2190 .unwrap();
2191 }
2192}

Callers

nothing calls this directly

Calls 6

repetitionFunction · 0.85
ConcatClass · 0.85
AlternationClass · 0.85
unwrapMethod · 0.80
emptyFunction · 0.70
groupFunction · 0.70

Tested by

no test coverage detected