diff --git a/rust/ruby-prism-sys/build/vendored.rs b/rust/ruby-prism-sys/build/vendored.rs index 122fd3e265c..670df42d50a 100644 --- a/rust/ruby-prism-sys/build/vendored.rs +++ b/rust/ruby-prism-sys/build/vendored.rs @@ -74,6 +74,11 @@ fn version() -> &'static str { env!("CARGO_PKG_VERSION") } +/// Generated by running the following command: +/// +/// ```sh +/// bundle exec rake cargo:build +/// ``` fn vendor_dir() -> PathBuf { let prism_dir = format!("prism-{}", version()); Path::new(env!("CARGO_MANIFEST_DIR")).join("vendor").join(prism_dir) diff --git a/rust/ruby-prism/build.rs b/rust/ruby-prism/build.rs index f1f1cb696dc..c8618815c51 100644 --- a/rust/ruby-prism/build.rs +++ b/rust/ruby-prism/build.rs @@ -304,8 +304,12 @@ fn write_node(file: &mut File, flags: &[Flags], node: &Node) -> Result<(), Box { - writeln!(file, " pub const fn {}(&self) -> &str {{", field.name)?; - writeln!(file, " \"\"")?; + writeln!(file, " pub fn {}(&self) -> &[u8] {{", field.name)?; + writeln!(file, " unsafe {{")?; + writeln!(file, " let source = (*self.pointer).{}.source;", field.name)?; + writeln!(file, " let length = (*self.pointer).{}.length;", field.name)?; + writeln!(file, " std::slice::from_raw_parts(source, length)")?; + writeln!(file, " }}")?; writeln!(file, " }}")?; }, NodeFieldType::Constant => {