Skip to content

Commit c6f7346

Browse files
committed
fix: cfg out by original flag
1 parent 1b3c961 commit c6f7346

File tree

6 files changed

+32
-28
lines changed

6 files changed

+32
-28
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ default = ["vendored"]
3333
# This could be disabled with `--no-default-features` to minimize the dependency tree
3434
# when building against an existing copy of the NGINX with the NGX_OBJS variable.
3535
vendored = ["nginx-sys/vendored"]
36-
static_ref = []
3736

3837
[badges]
3938
maintenance = { status = "experimental" }
4039

4140
[dev-dependencies]
4241
target-triple = "0.1.2"
42+
43+
[lints.rust]
44+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(static_ref_mut)'] }

examples/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ crate-type = ["cdylib"]
5151
name = "type_driven"
5252
path = "type_driven.rs"
5353
crate-type = ["cdylib"]
54-
required-features = ["static_ref"]
5554

5655
[features]
5756
default = ["export-modules", "ngx/vendored"]
@@ -62,4 +61,3 @@ default = ["export-modules", "ngx/vendored"]
6261
# See https://github.com/rust-lang/rust/issues/20267
6362
export-modules = []
6463
linux = []
65-
static_ref = ["ngx/static_ref"]

examples/type_driven.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,29 @@ use ngx::http::{HttpMainConf, HttpModuleSkel};
66
use ngx::module::{
77
CommandArgFlag, CommandArgFlagSet, CommandCallRule, CommandContextFlag, CommandContextFlagSet, CommandError,
88
};
9-
use ngx::{arg_flags, context_flags, exhibit_modules, ngx_string};
9+
use ngx::{arg_flags, context_flags, ngx_string};
1010
use ngx::{
11-
http::{DefaultInit, DefaultMerge, HttpModule, NgxHttpModule, NgxHttpModuleCommands, NgxHttpModuleCommandsRefMut},
11+
http::{DefaultInit, DefaultMerge, HttpModule, NgxHttpModule, NgxHttpModuleCommands},
1212
module::{Command, NgxModuleCommandsBuilder},
13-
util::StaticRefMut,
1413
};
1514

16-
#[cfg(feature = "export-modules")]
15+
#[cfg(static_ref_mut)]
16+
use ngx::{exhibit_modules, http::NgxHttpModuleCommandsRefMut, util::StaticRefMut};
17+
18+
#[cfg(all(static_ref_mut, feature = "export-modules"))]
1719
exhibit_modules!(HttpModuleSkel<FooBarHttpModule>);
1820

1921
struct FooBarHttpModule;
2022
impl HttpModule for FooBarHttpModule {
23+
#[cfg(static_ref_mut)]
2124
const SELF: StaticRefMut<NgxHttpModule<Self>> = {
2225
static mut FOO_BAR_HTTP_MODULE: NgxHttpModule<FooBarHttpModule> = NgxHttpModule::new();
2326
unsafe { StaticRefMut::from_mut(&mut *addr_of_mut!(FOO_BAR_HTTP_MODULE)) }
2427
};
2528

2629
const NAME: &'static CStr = c"foo_bar_module";
2730

31+
#[cfg(static_ref_mut)]
2832
const COMMANDS: NgxHttpModuleCommandsRefMut<Self> = {
2933
static mut FOO_BAR_HTTP_MODULE_COMMANDS: NgxHttpModuleCommands<FooBarHttpModule, { 1 + 1 }> =
3034
NgxModuleCommandsBuilder::new().add::<FooBarCommand>().build();

src/http/module_new.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::module::{
1515
CommandCallRule, CommandCallRuleBy, CommandOffset, CycleDelegate, Module, ModuleSignature, NgxModule,
1616
NgxModuleCommands, NgxModuleCtx, PreCycleDelegate,
1717
};
18-
#[cfg(feature = "static_ref")]
18+
#[cfg(static_ref_mut)]
1919
use crate::{module::NgxModuleCommandsRefMut, util::StaticRefMut};
2020
use ::core::marker::PhantomData;
2121
use std::ffi::{c_char, c_void, CStr};
@@ -26,14 +26,14 @@ use super::{Merge, MergeConfigError, Request};
2626
/// Wrapper of `HttpModule` implementing `Module`.
2727
pub struct HttpModuleSkel<M: HttpModule>(PhantomData<M>);
2828
impl<M: HttpModule> Module for HttpModuleSkel<M> {
29-
#[cfg(feature = "static_ref")]
29+
#[cfg(static_ref_mut)]
3030
const SELF: StaticRefMut<NgxModule<Self>> = unsafe { StaticRefMut::from_mut(&mut M::SELF.to_mut().0) };
3131
const NAME: &'static CStr = M::NAME;
3232
const TYPE: ModuleSignature = unsafe { ModuleSignature::from_ngx_uint(NGX_HTTP_MODULE as ngx_uint_t) };
3333
type Ctx = ngx_http_module_t;
34-
#[cfg(feature = "static_ref")]
34+
#[cfg(static_ref_mut)]
3535
const CTX: StaticRefMut<NgxModuleCtx<Self>> = unsafe { StaticRefMut::from_mut(&mut M::SELF.to_mut().1) };
36-
#[cfg(feature = "static_ref")]
36+
#[cfg(static_ref_mut)]
3737
const COMMANDS: NgxModuleCommandsRefMut<Self> = M::COMMANDS;
3838

3939
type MasterInitializer = M::MasterInitializer;
@@ -47,7 +47,7 @@ pub struct NgxHttpModule<M: HttpModule>(
4747
#[allow(dead_code)] NgxModule<HttpModuleSkel<M>>,
4848
NgxModuleCtx<HttpModuleSkel<M>>,
4949
);
50-
#[cfg(feature = "static_ref")]
50+
#[cfg(static_ref_mut)]
5151
impl<M: HttpModule> Default for NgxHttpModule<M> {
5252
fn default() -> Self {
5353
Self::new()
@@ -56,7 +56,7 @@ impl<M: HttpModule> Default for NgxHttpModule<M> {
5656

5757
impl<M: HttpModule> NgxHttpModule<M> {
5858
/// Construct this type.
59-
#[cfg(feature = "static_ref")]
59+
#[cfg(static_ref_mut)]
6060
pub const fn new() -> Self {
6161
Self(NgxModule::new(), unsafe {
6262
NgxModuleCtx::from_raw(ngx_http_module_t {
@@ -100,18 +100,18 @@ impl<M: HttpModule> NgxHttpModule<M> {
100100
/// Type Alias of `NgxModuleCommands` for `HttpModule`.
101101
pub type NgxHttpModuleCommands<M, const N: usize> = NgxModuleCommands<HttpModuleSkel<M>, N>;
102102
/// Type Alias of `NgxModuleCommandsRefMut` for `HttpModule`.
103-
#[cfg(feature = "static_ref")]
103+
#[cfg(static_ref_mut)]
104104
pub type NgxHttpModuleCommandsRefMut<M> = NgxModuleCommandsRefMut<HttpModuleSkel<M>>;
105105

106106
/// Type safe interface expressing unique Nginx Http module.
107107
pub trait HttpModule: Sized + 'static {
108108
/// Wrapper of static mutable `NgxModule` and `NgxModuleCtx` object expressing this module.
109-
#[cfg(feature = "static_ref")]
109+
#[cfg(static_ref_mut)]
110110
const SELF: StaticRefMut<NgxHttpModule<Self>>;
111111
/// CStr module name expression.
112112
const NAME: &'static CStr;
113113
/// Wrapper of static mutable `NgxHttpModuleCommands` object bound to this module.
114-
#[cfg(feature = "static_ref")]
114+
#[cfg(static_ref_mut)]
115115
const COMMANDS: NgxHttpModuleCommandsRefMut<Self>;
116116

117117
/// Type deligating `init_master` (not called now).

src/module.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
util::ConstArrayBuilder,
99
};
1010

11-
#[cfg(feature = "static_ref")]
11+
#[cfg(static_ref_mut)]
1212
use crate::util::StaticRefMut;
1313

1414
use ::core::{
@@ -52,7 +52,7 @@ pub const NGX_MODULE_EMPTY: ngx_module_t = ngx_module_t {
5252
/// Type safe interface expressing unique Nginx module.
5353
pub trait Module: Sized + 'static {
5454
/// Wrapper of static mutable `NgxModule` object expressing this module.
55-
#[cfg(feature = "static_ref")]
55+
#[cfg(static_ref_mut)]
5656
const SELF: StaticRefMut<NgxModule<Self>>;
5757
/// CStr module name expression.
5858
const NAME: &'static CStr;
@@ -61,10 +61,10 @@ pub trait Module: Sized + 'static {
6161
/// Module context type.
6262
type Ctx: 'static;
6363
/// Wrapper of static mutable `NgxModuleCtx` object bound to this module as context object.
64-
#[cfg(feature = "static_ref")]
64+
#[cfg(static_ref_mut)]
6565
const CTX: StaticRefMut<NgxModuleCtx<Self>>;
6666
/// Wrapper of static mutable `NgxModuleCommands` object bound to this module.
67-
#[cfg(feature = "static_ref")]
67+
#[cfg(static_ref_mut)]
6868
const COMMANDS: NgxModuleCommandsRefMut<Self>;
6969

7070
/// Type deligating `init_master` (not called now).
@@ -79,7 +79,7 @@ pub trait Module: Sized + 'static {
7979

8080
/// Type safe wrapper of `ngx_module_t` by specifying `Module`.
8181
pub struct NgxModule<M: Module>(#[allow(dead_code)] ngx_module_t, PhantomData<M>);
82-
#[cfg(feature = "static_ref")]
82+
#[cfg(static_ref_mut)]
8383
impl<M: Module> Default for NgxModule<M> {
8484
fn default() -> Self {
8585
Self::new()
@@ -88,7 +88,7 @@ impl<M: Module> Default for NgxModule<M> {
8888

8989
impl<M: Module> NgxModule<M> {
9090
/// Construct this type.
91-
#[cfg(feature = "static_ref")]
91+
#[cfg(static_ref_mut)]
9292
pub const fn new() -> Self {
9393
Self(
9494
ngx_module_t {
@@ -167,9 +167,9 @@ impl<M: Module> NgxModuleCtx<M> {
167167
}
168168

169169
/// Reference to static mutable `NgxModuleCommands` object ignoring the length.
170-
#[cfg(feature = "static_ref")]
170+
#[cfg(static_ref_mut)]
171171
pub struct NgxModuleCommandsRefMut<M: Module>(PhantomData<M>, StaticRefMut<[ngx_command_t]>);
172-
#[cfg(feature = "static_ref")]
172+
#[cfg(static_ref_mut)]
173173
impl<M: Module> NgxModuleCommandsRefMut<M> {
174174
/// Wrap a static mutable reference to `NgxModuleCommands` into this type.
175175
///
@@ -428,7 +428,7 @@ impl CycleDelegate for () {
428428
/// These are normally generated by the Nginx module system, but need to be
429429
/// defined when building modules outside of it.
430430
#[macro_export]
431-
#[cfg(feature = "static_ref")]
431+
#[cfg(static_ref_mut)]
432432
macro_rules! exhibit_modules {
433433
($( $mod:ty ),+) => {
434434
#[no_mangle]
@@ -450,7 +450,7 @@ macro_rules! exhibit_modules {
450450
}
451451

452452
#[doc(hidden)]
453-
#[cfg(feature = "static_ref")]
453+
#[cfg(static_ref_mut)]
454454
pub mod __macro {
455455
pub use core::{ffi::c_char, ptr::null};
456456

src/util/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod const_array;
2-
#[cfg(feature = "static_ref")]
2+
#[cfg(static_ref_mut)]
33
mod static_ref;
44

55
pub use const_array::*;
6-
#[cfg(feature = "static_ref")]
6+
#[cfg(static_ref_mut)]
77
pub use static_ref::*;

0 commit comments

Comments
 (0)