Skip to content

Commit 4e6a7dd

Browse files
jhprattjebrosen
authored andcommitted
Remove use of the 'crate_visibility_modifier' feature.
Most items with 'crate' visibility become 'pub(crate)'. Items are made 'pub' instead when they would remain private.
1 parent 335d8f7 commit 4e6a7dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+151
-157
lines changed

contrib/lib/src/helmet/policy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub trait Policy: Default + Send + Sync + 'static {
6363
fn header(&self) -> Header<'static>;
6464
}
6565

66-
crate trait SubPolicy: Send + Sync {
66+
pub(crate) trait SubPolicy: Send + Sync {
6767
fn name(&self) -> &'static UncasedStr;
6868
fn header(&self) -> Header<'static>;
6969
}

contrib/lib/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(crate_visibility_modifier)]
2-
31
#![doc(html_root_url = "https://api.rocket.rs/v0.5")]
42
#![doc(html_favicon_url = "https://rocket.rs/v0.5/images/favicon.ico")]
53
#![doc(html_logo_url = "https://rocket.rs/v0.5/images/logo-boxed.png")]

contrib/lib/src/templates/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use crate::templates::{Engines, TemplateInfo};
55

66
use rocket::http::ContentType;
77

8-
crate struct Context {
8+
pub(crate) struct Context {
99
/// The root of the template directory.
10-
crate root: PathBuf,
10+
pub root: PathBuf,
1111
/// Mapping from template name to its information.
12-
crate templates: HashMap<String, TemplateInfo>,
12+
pub templates: HashMap<String, TemplateInfo>,
1313
/// Loaded template engines
14-
crate engines: Engines,
14+
pub engines: Engines,
1515
}
1616

1717
impl Context {

contrib/lib/src/templates/engine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::templates::TemplateInfo;
77
#[cfg(feature = "tera_templates")] use crate::templates::tera::Tera;
88
#[cfg(feature = "handlebars_templates")] use crate::templates::handlebars::Handlebars;
99

10-
crate trait Engine: Send + Sync + 'static {
10+
pub(crate) trait Engine: Send + Sync + 'static {
1111
const EXT: &'static str;
1212

1313
fn init(templates: &[(&str, &TemplateInfo)]) -> Option<Self> where Self: Sized;
@@ -60,12 +60,12 @@ pub struct Engines {
6060
}
6161

6262
impl Engines {
63-
crate const ENABLED_EXTENSIONS: &'static [&'static str] = &[
63+
pub(crate) const ENABLED_EXTENSIONS: &'static [&'static str] = &[
6464
#[cfg(feature = "tera_templates")] Tera::EXT,
6565
#[cfg(feature = "handlebars_templates")] Handlebars::EXT,
6666
];
6767

68-
crate fn init(templates: &HashMap<String, TemplateInfo>) -> Option<Engines> {
68+
pub(crate) fn init(templates: &HashMap<String, TemplateInfo>) -> Option<Engines> {
6969
fn inner<E: Engine>(templates: &HashMap<String, TemplateInfo>) -> Option<E> {
7070
let named_templates = templates.iter()
7171
.filter(|&(_, i)| i.extension == E::EXT)
@@ -89,7 +89,7 @@ impl Engines {
8989
})
9090
}
9191

92-
crate fn render<C: Serialize>(
92+
pub(crate) fn render<C: Serialize>(
9393
&self,
9494
name: &str,
9595
info: &TemplateInfo,

contrib/lib/src/templates/fairing.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rocket::Rocket;
44
use rocket::config::ConfigError;
55
use rocket::fairing::{Fairing, Info, Kind};
66

7-
crate use self::context::ContextManager;
7+
pub(crate) use self::context::ContextManager;
88

99
#[cfg(not(debug_assertions))]
1010
mod context {
@@ -13,18 +13,18 @@ mod context {
1313

1414
/// Wraps a Context. With `cfg(debug_assertions)` active, this structure
1515
/// additionally provides a method to reload the context at runtime.
16-
crate struct ContextManager(Context);
16+
pub(crate) struct ContextManager(Context);
1717

1818
impl ContextManager {
19-
crate fn new(ctxt: Context) -> ContextManager {
19+
pub fn new(ctxt: Context) -> ContextManager {
2020
ContextManager(ctxt)
2121
}
2222

23-
crate fn context<'a>(&'a self) -> impl Deref<Target=Context> + 'a {
23+
pub fn context<'a>(&'a self) -> impl Deref<Target=Context> + 'a {
2424
&self.0
2525
}
2626

27-
crate fn is_reloading(&self) -> bool {
27+
pub fn is_reloading(&self) -> bool {
2828
false
2929
}
3030
}
@@ -42,15 +42,15 @@ mod context {
4242

4343
/// Wraps a Context. With `cfg(debug_assertions)` active, this structure
4444
/// additionally provides a method to reload the context at runtime.
45-
crate struct ContextManager {
45+
pub(crate) struct ContextManager {
4646
/// The current template context, inside an RwLock so it can be updated.
4747
context: RwLock<Context>,
4848
/// A filesystem watcher and the receive queue for its events.
4949
watcher: Option<Mutex<(RecommendedWatcher, Receiver<RawEvent>)>>,
5050
}
5151

5252
impl ContextManager {
53-
crate fn new(ctxt: Context) -> ContextManager {
53+
pub fn new(ctxt: Context) -> ContextManager {
5454
let (tx, rx) = channel();
5555
let watcher = raw_watcher(tx).and_then(|mut watcher| {
5656
watcher.watch(ctxt.root.canonicalize()?, RecursiveMode::Recursive)?;
@@ -73,11 +73,11 @@ mod context {
7373
}
7474
}
7575

76-
crate fn context(&self) -> impl Deref<Target=Context> + '_ {
76+
pub fn context(&self) -> impl Deref<Target=Context> + '_ {
7777
self.context.read().unwrap()
7878
}
7979

80-
crate fn is_reloading(&self) -> bool {
80+
pub fn is_reloading(&self) -> bool {
8181
self.watcher.is_some()
8282
}
8383

@@ -89,7 +89,7 @@ mod context {
8989
/// have been changes since the last reload, all templates are
9090
/// reinitialized from disk and the user's customization callback is run
9191
/// again.
92-
crate fn reload_if_needed<F: Fn(&mut Engines)>(&self, custom_callback: F) {
92+
pub fn reload_if_needed<F: Fn(&mut Engines)>(&self, custom_callback: F) {
9393
self.watcher.as_ref().map(|w| {
9494
let rx_lock = w.lock().expect("receive queue lock");
9595
let mut changed = false;
@@ -121,7 +121,7 @@ pub struct TemplateFairing {
121121
/// The user-provided customization callback, allowing the use of
122122
/// functionality specific to individual template engines. In debug mode,
123123
/// this callback might be run multiple times as templates are reloaded.
124-
crate custom_callback: Box<dyn Fn(&mut Engines) + Send + Sync + 'static>,
124+
pub custom_callback: Box<dyn Fn(&mut Engines) + Send + Sync + 'static>,
125125
}
126126

127127
impl Fairing for TemplateFairing {

contrib/lib/src/templates/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ mod metadata;
129129

130130
pub use self::engine::Engines;
131131
pub use self::metadata::Metadata;
132-
crate use self::context::Context;
133-
crate use self::fairing::ContextManager;
132+
pub(crate) use self::context::Context;
133+
pub(crate) use self::fairing::ContextManager;
134134

135135
use self::engine::Engine;
136136
use self::fairing::TemplateFairing;
@@ -209,7 +209,7 @@ pub struct Template {
209209
}
210210

211211
#[derive(Debug)]
212-
crate struct TemplateInfo {
212+
pub(crate) struct TemplateInfo {
213213
/// The complete path, including `template_dir`, to this template.
214214
path: PathBuf,
215215
/// The extension for the engine of this template.

core/codegen/src/attribute/segments.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ use crate::http::uri::{UriPart, Path};
77
use crate::http::route::RouteSegment;
88
use crate::proc_macro_ext::{Diagnostics, StringLit, PResult, DResult};
99

10-
crate use crate::http::route::{Error, Kind, Source};
10+
pub use crate::http::route::{Error, Kind, Source};
1111

1212
#[derive(Debug, Clone)]
13-
crate struct Segment {
14-
crate span: Span,
15-
crate kind: Kind,
16-
crate source: Source,
17-
crate name: String,
18-
crate index: Option<usize>,
13+
pub struct Segment {
14+
pub span: Span,
15+
pub kind: Kind,
16+
pub source: Source,
17+
pub name: String,
18+
pub index: Option<usize>,
1919
}
2020

2121
impl Segment {
@@ -115,7 +115,7 @@ fn into_diagnostic(
115115
}
116116
}
117117

118-
crate fn parse_data_segment(segment: &str, span: Span) -> PResult<Segment> {
118+
pub fn parse_data_segment(segment: &str, span: Span) -> PResult<Segment> {
119119
<RouteSegment<'_, Path>>::parse_one(segment)
120120
.map(|segment| {
121121
let mut seg = Segment::from(segment, span);
@@ -126,7 +126,7 @@ crate fn parse_data_segment(segment: &str, span: Span) -> PResult<Segment> {
126126
.map_err(|e| into_diagnostic(segment, segment, span, &e))
127127
}
128128

129-
crate fn parse_segments<P: UriPart>(
129+
pub fn parse_segments<P: UriPart>(
130130
string: &str,
131131
span: Span
132132
) -> DResult<Vec<Segment>> {

core/codegen/src/bang/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{ROUTE_STRUCT_PREFIX, CATCH_STRUCT_PREFIX};
99
mod uri;
1010
mod uri_parsing;
1111

12-
crate fn prefix_last_segment(path: &mut Path, prefix: &str) {
12+
pub fn prefix_last_segment(path: &mut Path, prefix: &str) {
1313
let mut last_seg = path.segments.last_mut().expect("syn::Path has segments");
1414
last_seg.ident = last_seg.ident.prepend(prefix);
1515
}

core/codegen/src/bang/uri.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ macro_rules! p {
2323
($n:expr, "parameter") => (p!(@go $n, "1 parameter", format!("{} parameters", $n)));
2424
}
2525

26-
crate fn _uri_macro(input: TokenStream) -> Result<TokenStream> {
26+
pub fn _uri_macro(input: TokenStream) -> Result<TokenStream> {
2727
let input2: TokenStream2 = input.clone().into();
2828
let mut params = syn::parse::<UriParams>(input).map_err(syn_to_diag)?;
2929
prefix_last_segment(&mut params.route_path, URI_MACRO_PREFIX);
@@ -212,7 +212,7 @@ fn build_origin(internal: &InternalUriParams) -> Origin<'static> {
212212
Origin::new(path, query).to_normalized().into_owned()
213213
}
214214

215-
crate fn _uri_internal_macro(input: TokenStream) -> Result<TokenStream> {
215+
pub fn _uri_internal_macro(input: TokenStream) -> Result<TokenStream> {
216216
// Parse the internal invocation and the user's URI param expressions.
217217
let internal = syn::parse::<InternalUriParams>(input).map_err(syn_to_diag)?;
218218
let (path_params, query_params) = extract_exprs(&internal)?;

core/codegen/src/derive/from_form.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ use proc_macro::{Span, TokenStream};
22
use devise::{*, ext::{TypeExt, Split3}};
33

44
#[derive(FromMeta)]
5-
crate struct Form {
6-
crate field: FormField,
5+
pub struct Form {
6+
pub field: FormField,
77
}
88

9-
crate struct FormField {
10-
crate span: Span,
11-
crate name: String
9+
pub struct FormField {
10+
pub span: Span,
11+
pub name: String
1212
}
1313

1414
fn is_valid_field_name(s: &str) -> bool {

0 commit comments

Comments
 (0)