From 6d85da4cfc53c87ad3c1d15af6be77234ee3ada0 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 11 Feb 2023 12:31:47 +0200 Subject: [PATCH] howto run the examples --- examples/README | 11 +++++++++++ examples/rustc-driver-example.rs | 13 ++++--------- examples/rustc-driver-getting-diagnostics.rs | 7 +------ examples/rustc-driver-interacting-with-the-ast.rs | 7 +------ 4 files changed, 17 insertions(+), 21 deletions(-) create mode 100644 examples/README diff --git a/examples/README b/examples/README new file mode 100644 index 000000000..ca49dd74d --- /dev/null +++ b/examples/README @@ -0,0 +1,11 @@ +For each example to compile, you will need to first run the following: + + rustup component add rustc-dev llvm-tools + +To create an executable: + + rustc rustc-driver-example.rs + +To run an executable: + + rustup run nightly ./rustc-driver-example diff --git a/examples/rustc-driver-example.rs b/examples/rustc-driver-example.rs index 13a3ebcc9..9708ab01d 100644 --- a/examples/rustc-driver-example.rs +++ b/examples/rustc-driver-example.rs @@ -1,10 +1,6 @@ #![feature(rustc_private)] -// NOTE: For the example to compile, you will need to first run the following: -// rustup component add rustc-dev llvm-tools-preview - -// version: rustc 1.68.0-nightly (935dc0721 2022-12-19) - +extern crate rustc_driver; extern crate rustc_error_codes; extern crate rustc_errors; extern crate rustc_hash; @@ -12,7 +8,6 @@ extern crate rustc_hir; extern crate rustc_interface; extern crate rustc_session; extern crate rustc_span; -extern crate rustc_driver; use std::{path, process, str}; @@ -47,9 +42,9 @@ fn main() { "# .into(), }, - output_dir: None, // Option - output_file: None, // Option - file_loader: None, // Option> + output_dir: None, // Option + output_file: None, // Option + file_loader: None, // Option> lint_caps: FxHashMap::default(), // FxHashMap // This is a callback from the driver that is called when [`ParseSess`] is created. parse_sess_created: None, //Option> diff --git a/examples/rustc-driver-getting-diagnostics.rs b/examples/rustc-driver-getting-diagnostics.rs index 6907252f2..5bc2312a2 100644 --- a/examples/rustc-driver-getting-diagnostics.rs +++ b/examples/rustc-driver-getting-diagnostics.rs @@ -1,10 +1,6 @@ #![feature(rustc_private)] -// NOTE: For the example to compile, you will need to first run the following: -// rustup component add rustc-dev llvm-tools-preview - -// version: rustc 1.68.0-nightly (935dc0721 2022-12-19) - +extern crate rustc_driver; extern crate rustc_error_codes; extern crate rustc_errors; extern crate rustc_hash; @@ -12,7 +8,6 @@ extern crate rustc_hir; extern crate rustc_interface; extern crate rustc_session; extern crate rustc_span; -extern crate rustc_driver; use rustc_errors::registry; use rustc_session::config::{self, CheckCfg}; diff --git a/examples/rustc-driver-interacting-with-the-ast.rs b/examples/rustc-driver-interacting-with-the-ast.rs index 7f9b99e49..53f8df81a 100644 --- a/examples/rustc-driver-interacting-with-the-ast.rs +++ b/examples/rustc-driver-interacting-with-the-ast.rs @@ -1,11 +1,7 @@ #![feature(rustc_private)] -// NOTE: For the example to compile, you will need to first run the following: -// rustup component add rustc-dev llvm-tools-preview - -// version: rustc 1.68.0-nightly (935dc0721 2022-12-19) - extern crate rustc_ast_pretty; +extern crate rustc_driver; extern crate rustc_error_codes; extern crate rustc_errors; extern crate rustc_hash; @@ -13,7 +9,6 @@ extern crate rustc_hir; extern crate rustc_interface; extern crate rustc_session; extern crate rustc_span; -extern crate rustc_driver; use std::{path, process, str};