mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-10-31 12:05:57 +00:00 
			
		
		
		
	 7abc41727b
			
		
	
	
		7abc41727b
		
			
		
	
	
	
	
		
			
			## Summary Removes the `module_ptr` field from `AstNodeRef` in release mode, and change `NodeIndex` to a `NonZeroU32` to reduce the size of `Option<AstNodeRef<_>>` fields. I believe CI runs in debug mode, so this won't show up in the memory report, but this reduces memory by ~2% in release mode.
		
			
				
	
	
		
			78 lines
		
	
	
	
		
			2.8 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
	
		
			2.8 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| ---
 | |
| source: crates/ruff_python_parser/tests/fixtures.rs
 | |
| input_file: crates/ruff_python_parser/resources/inline/ok/nonlocal_stmt.py
 | |
| ---
 | |
| ## AST
 | |
| 
 | |
| ```
 | |
| Module(
 | |
|     ModModule {
 | |
|         node_index: NodeIndex(None),
 | |
|         range: 0..45,
 | |
|         body: [
 | |
|             FunctionDef(
 | |
|                 StmtFunctionDef {
 | |
|                     node_index: NodeIndex(None),
 | |
|                     range: 0..44,
 | |
|                     is_async: false,
 | |
|                     decorator_list: [],
 | |
|                     name: Identifier {
 | |
|                         id: Name("_"),
 | |
|                         range: 4..5,
 | |
|                         node_index: NodeIndex(None),
 | |
|                     },
 | |
|                     type_params: None,
 | |
|                     parameters: Parameters {
 | |
|                         range: 5..7,
 | |
|                         node_index: NodeIndex(None),
 | |
|                         posonlyargs: [],
 | |
|                         args: [],
 | |
|                         vararg: None,
 | |
|                         kwonlyargs: [],
 | |
|                         kwarg: None,
 | |
|                     },
 | |
|                     returns: None,
 | |
|                     body: [
 | |
|                         Nonlocal(
 | |
|                             StmtNonlocal {
 | |
|                                 node_index: NodeIndex(None),
 | |
|                                 range: 13..23,
 | |
|                                 names: [
 | |
|                                     Identifier {
 | |
|                                         id: Name("x"),
 | |
|                                         range: 22..23,
 | |
|                                         node_index: NodeIndex(None),
 | |
|                                     },
 | |
|                                 ],
 | |
|                             },
 | |
|                         ),
 | |
|                         Nonlocal(
 | |
|                             StmtNonlocal {
 | |
|                                 node_index: NodeIndex(None),
 | |
|                                 range: 28..44,
 | |
|                                 names: [
 | |
|                                     Identifier {
 | |
|                                         id: Name("x"),
 | |
|                                         range: 37..38,
 | |
|                                         node_index: NodeIndex(None),
 | |
|                                     },
 | |
|                                     Identifier {
 | |
|                                         id: Name("y"),
 | |
|                                         range: 40..41,
 | |
|                                         node_index: NodeIndex(None),
 | |
|                                     },
 | |
|                                     Identifier {
 | |
|                                         id: Name("z"),
 | |
|                                         range: 43..44,
 | |
|                                         node_index: NodeIndex(None),
 | |
|                                     },
 | |
|                                 ],
 | |
|                             },
 | |
|                         ),
 | |
|                     ],
 | |
|                 },
 | |
|             ),
 | |
|         ],
 | |
|     },
 | |
| )
 | |
| ```
 |