aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.lock10
-rw-r--r--gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml10
-rw-r--r--gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml2
-rw-r--r--gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs138
-rw-r--r--libgrust/libformat_parser/.cargo/config5
-rw-r--r--libgrust/libformat_parser/.cargo/config.toml (renamed from gcc/rust/checks/errors/borrowck/ffi-polonius/.cargo/config.toml)0
-rw-r--r--libgrust/libformat_parser/Makefile.am11
-rw-r--r--libgrust/libformat_parser/Makefile.in10
-rw-r--r--libgrust/libformat_parser/generic_format_parser/src/lib.rs14
-rw-r--r--libgrust/libformat_parser/src/lib.rs11
10 files changed, 41 insertions, 170 deletions
diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.lock b/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.lock
index f7cbd41..1b223b6 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.lock
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.lock
@@ -1,12 +1,8 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
-version = 3
-
[[package]]
name = "datafrog"
version = "2.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"
[[package]]
name = "ffi-polonius"
@@ -18,14 +14,10 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.22"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "polonius-engine"
version = "0.13.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4e8e505342045d397d0b6674dcb82d6faf5cf40484d30eeb88fc82ef14e903f"
dependencies = [
"datafrog",
"log",
@@ -35,5 +27,3 @@ dependencies = [
[[package]]
name = "rustc-hash"
version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml b/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml
index 71315c3..3bc8e3f 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml
@@ -1,11 +1,17 @@
[package]
name = "ffi-polonius"
version = "0.1.0"
-edition = "2021"
+edition = "2018"
license = "GPL-3"
[lib]
crate-type = ["staticlib"]
[dependencies]
-polonius-engine = "0.13.0" \ No newline at end of file
+polonius-engine = "0.13.0"
+
+[patch.crates-io]
+log = { path = "vendor/log" }
+datafrog = { path = "vendor/datafrog" }
+polonius-engine = { path = "vendor/polonius-engine" }
+rustc-hash = { path = "vendor/rustc-hash" }
diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml b/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml
index 313a005..a199e31 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml
@@ -10,7 +10,7 @@
# See Cargo.toml.orig for the original contents.
[package]
-edition = "2021"
+edition = "2018"
rust-version = "1.60.0"
name = "log"
version = "0.4.22"
diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs b/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs
index 6b43a9a..603bbac 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs
@@ -397,20 +397,13 @@ mod serde;
#[cfg(feature = "kv")]
pub mod kv;
-#[cfg(target_has_atomic = "ptr")]
-use std::sync::atomic::{AtomicUsize, Ordering};
-
-#[cfg(not(target_has_atomic = "ptr"))]
use std::cell::Cell;
-#[cfg(not(target_has_atomic = "ptr"))]
use std::sync::atomic::Ordering;
-#[cfg(not(target_has_atomic = "ptr"))]
struct AtomicUsize {
v: Cell<usize>,
}
-#[cfg(not(target_has_atomic = "ptr"))]
impl AtomicUsize {
const fn new(v: usize) -> AtomicUsize {
AtomicUsize { v: Cell::new(v) }
@@ -423,26 +416,10 @@ impl AtomicUsize {
fn store(&self, val: usize, _order: Ordering) {
self.v.set(val)
}
-
- #[cfg(target_has_atomic = "ptr")]
- fn compare_exchange(
- &self,
- current: usize,
- new: usize,
- _success: Ordering,
- _failure: Ordering,
- ) -> Result<usize, usize> {
- let prev = self.v.get();
- if current == prev {
- self.v.set(new);
- }
- Ok(prev)
- }
}
// Any platform without atomics is unlikely to have multiple cores, so
// writing via Cell will not be a race condition.
-#[cfg(not(target_has_atomic = "ptr"))]
unsafe impl Sync for AtomicUsize {}
// The LOGGER static holds a pointer to the global logger. It is protected by
@@ -1258,17 +1235,6 @@ where
}
}
-/// Sets the global maximum log level.
-///
-/// Generally, this should only be called by the active logging implementation.
-///
-/// Note that `Trace` is the maximum level, because it provides the maximum amount of detail in the emitted logs.
-#[inline]
-#[cfg(target_has_atomic = "ptr")]
-pub fn set_max_level(level: LevelFilter) {
- MAX_LOG_LEVEL_FILTER.store(level as usize, Ordering::Relaxed);
-}
-
/// A thread-unsafe version of [`set_max_level`].
///
/// This function is available on all platforms, even those that do not have
@@ -1320,110 +1286,6 @@ pub fn max_level() -> LevelFilter {
unsafe { mem::transmute(MAX_LOG_LEVEL_FILTER.load(Ordering::Relaxed)) }
}
-/// Sets the global logger to a `Box<Log>`.
-///
-/// This is a simple convenience wrapper over `set_logger`, which takes a
-/// `Box<Log>` rather than a `&'static Log`. See the documentation for
-/// [`set_logger`] for more details.
-///
-/// Requires the `std` feature.
-///
-/// # Errors
-///
-/// An error is returned if a logger has already been set.
-///
-/// [`set_logger`]: fn.set_logger.html
-#[cfg(all(feature = "std", target_has_atomic = "ptr"))]
-pub fn set_boxed_logger(logger: Box<dyn Log>) -> Result<(), SetLoggerError> {
- set_logger_inner(|| Box::leak(logger))
-}
-
-/// Sets the global logger to a `&'static Log`.
-///
-/// This function may only be called once in the lifetime of a program. Any log
-/// events that occur before the call to `set_logger` completes will be ignored.
-///
-/// This function does not typically need to be called manually. Logger
-/// implementations should provide an initialization method that installs the
-/// logger internally.
-///
-/// # Availability
-///
-/// This method is available even when the `std` feature is disabled. However,
-/// it is currently unavailable on `thumbv6` targets, which lack support for
-/// some atomic operations which are used by this function. Even on those
-/// targets, [`set_logger_racy`] will be available.
-///
-/// # Errors
-///
-/// An error is returned if a logger has already been set.
-///
-/// # Examples
-///
-/// ```
-/// use log::{error, info, warn, Record, Level, Metadata, LevelFilter};
-///
-/// static MY_LOGGER: MyLogger = MyLogger;
-///
-/// struct MyLogger;
-///
-/// impl log::Log for MyLogger {
-/// fn enabled(&self, metadata: &Metadata) -> bool {
-/// metadata.level() <= Level::Info
-/// }
-///
-/// fn log(&self, record: &Record) {
-/// if self.enabled(record.metadata()) {
-/// println!("{} - {}", record.level(), record.args());
-/// }
-/// }
-/// fn flush(&self) {}
-/// }
-///
-/// # fn main(){
-/// log::set_logger(&MY_LOGGER).unwrap();
-/// log::set_max_level(LevelFilter::Info);
-///
-/// info!("hello log");
-/// warn!("warning");
-/// error!("oops");
-/// # }
-/// ```
-///
-/// [`set_logger_racy`]: fn.set_logger_racy.html
-#[cfg(target_has_atomic = "ptr")]
-pub fn set_logger(logger: &'static dyn Log) -> Result<(), SetLoggerError> {
- set_logger_inner(|| logger)
-}
-
-#[cfg(target_has_atomic = "ptr")]
-fn set_logger_inner<F>(make_logger: F) -> Result<(), SetLoggerError>
-where
- F: FnOnce() -> &'static dyn Log,
-{
- match STATE.compare_exchange(
- UNINITIALIZED,
- INITIALIZING,
- Ordering::Acquire,
- Ordering::Relaxed,
- ) {
- Ok(UNINITIALIZED) => {
- unsafe {
- LOGGER = make_logger();
- }
- STATE.store(INITIALIZED, Ordering::Release);
- Ok(())
- }
- Err(INITIALIZING) => {
- while STATE.load(Ordering::Relaxed) == INITIALIZING {
- std::hint::spin_loop();
- }
- Err(SetLoggerError(()))
- }
- _ => Err(SetLoggerError(())),
- }
-}
-
/// A thread-unsafe version of [`set_logger`].
///
/// This function is available on all platforms, even those that do not have
diff --git a/libgrust/libformat_parser/.cargo/config b/libgrust/libformat_parser/.cargo/config
deleted file mode 100644
index 0236928..0000000
--- a/libgrust/libformat_parser/.cargo/config
+++ /dev/null
@@ -1,5 +0,0 @@
-[source.crates-io]
-replace-with = "vendored-sources"
-
-[source.vendored-sources]
-directory = "vendor"
diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/.cargo/config.toml b/libgrust/libformat_parser/.cargo/config.toml
index 0236928..0236928 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/.cargo/config.toml
+++ b/libgrust/libformat_parser/.cargo/config.toml
diff --git a/libgrust/libformat_parser/Makefile.am b/libgrust/libformat_parser/Makefile.am
index e0e1f45..59189c0 100644
--- a/libgrust/libformat_parser/Makefile.am
+++ b/libgrust/libformat_parser/Makefile.am
@@ -2,12 +2,9 @@ LIBFORMAT_PARSER = debug/liblibformat_parser.a
all-local: $(LIBFORMAT_PARSER)
+RUST_BUILD_DIR=$(PWD)
+
# TODO: Improve `cargo` invocation with host specific flags, possibly creating a $(CARGO) variable?
$(LIBFORMAT_PARSER): $(srcdir)/Cargo.toml $(srcdir)/src/*.rs
- cargo \
- --config $(srcdir)/.cargo/config \
- build \
- --offline \
- --target-dir . \
- --manifest-path $(srcdir)/Cargo.toml \
- # FIXME: Not always '--release', right?
+ cd $(srcdir) && \
+ cargo build --offline --target-dir $(RUST_BUILD_DIR)
diff --git a/libgrust/libformat_parser/Makefile.in b/libgrust/libformat_parser/Makefile.in
index 526b53d..f6c400d 100644
--- a/libgrust/libformat_parser/Makefile.in
+++ b/libgrust/libformat_parser/Makefile.in
@@ -263,6 +263,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
LIBFORMAT_PARSER = debug/liblibformat_parser.a
+RUST_BUILD_DIR = $(PWD)
all: all-am
.SUFFIXES:
@@ -428,13 +429,8 @@ all-local: $(LIBFORMAT_PARSER)
# TODO: Improve `cargo` invocation with host specific flags, possibly creating a $(CARGO) variable?
$(LIBFORMAT_PARSER): $(srcdir)/Cargo.toml $(srcdir)/src/*.rs
- cargo \
- --config $(srcdir)/.cargo/config \
- build \
- --offline \
- --target-dir . \
- --manifest-path $(srcdir)/Cargo.toml \
- # FIXME: Not always '--release', right?
+ cd $(srcdir) && \
+ cargo build --offline --target-dir $(RUST_BUILD_DIR)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/libgrust/libformat_parser/generic_format_parser/src/lib.rs b/libgrust/libformat_parser/generic_format_parser/src/lib.rs
index 25f6b0e..97967a9 100644
--- a/libgrust/libformat_parser/generic_format_parser/src/lib.rs
+++ b/libgrust/libformat_parser/generic_format_parser/src/lib.rs
@@ -32,6 +32,20 @@ use std::iter;
use std::str;
use std::string;
+// Extension trait for `Option<T>::is_some_and()` which was not a feature in Rust 1.49
+pub trait OptionIsSomeAndExt<T> {
+ fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool;
+}
+
+impl<T> OptionIsSomeAndExt<T> for Option<T> {
+ fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool {
+ match self {
+ None => false,
+ Some(x) => f(x),
+ }
+ }
+}
+
// Note: copied from rustc_span
/// Range inside of a `Span` used for diagnostics when we only have access to relative positions.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
diff --git a/libgrust/libformat_parser/src/lib.rs b/libgrust/libformat_parser/src/lib.rs
index d920cfa..72e5971 100644
--- a/libgrust/libformat_parser/src/lib.rs
+++ b/libgrust/libformat_parser/src/lib.rs
@@ -21,6 +21,17 @@ where
}
}
+// Extension trait to provide `String::leak` which did not exist in Rust 1.49
+pub trait StringLeakExt {
+ fn leak<'a>(self) -> &'a mut str;
+}
+
+impl StringLeakExt for String {
+ fn leak<'a>(self) -> &'a mut str {
+ Box::leak(self.into_boxed_str())
+ }
+}
+
// FIXME: Make an ffi module in a separate file
// FIXME: Remember to leak the boxed type somehow
// FIXME: How to encode the Option type? As a pointer? Option<T> -> Option<&T> -> *const T could work maybe?