MCPcopy Index your code
hub / github.com/RustPython/RustPython / compile_future_features

Method compile_future_features

crates/codegen/src/compile.rs:9336–9355  ·  view source on GitHub ↗
(&mut self, features: &[ast::Alias])

Source from the content-addressed store, hash-verified

9334 }
9335
9336 fn compile_future_features(&mut self, features: &[ast::Alias]) -> Result<(), CodegenError> {
9337 if let DoneWithFuture::Yes = self.done_with_future_stmts {
9338 return Err(self.error(CodegenErrorType::InvalidFuturePlacement));
9339 }
9340 self.done_with_future_stmts = DoneWithFuture::DoneWithDoc;
9341 for feature in features {
9342 match feature.name.as_str() {
9343 // Python 3 features; we've already implemented them by default
9344 "nested_scopes" | "generators" | "division" | "absolute_import"
9345 | "with_statement" | "print_function" | "unicode_literals" | "generator_stop" => {}
9346 "annotations" => self.future_annotations = true,
9347 other => {
9348 return Err(
9349 self.error(CodegenErrorType::InvalidFutureFeature(other.to_owned()))
9350 );
9351 }
9352 }
9353 }
9354 Ok(())
9355 }
9356
9357 // Low level helper functions:
9358 fn _emit<I: Into<AnyInstruction>>(&mut self, instr: I, arg: OpArg, target: BlockIdx) {

Callers 1

compile_statementMethod · 0.80

Calls 4

ErrClass · 0.50
errorMethod · 0.45
as_strMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected