Skip to content

Commit

Permalink
Remove removed rustc features.
Browse files Browse the repository at this point in the history
* 'crate_visibility_modifier'
* 'external_doc'

Closes #2205.
  • Loading branch information
SergioBenitez committed May 26, 2022
1 parent 08e5b6d commit 5824f56
Show file tree
Hide file tree
Showing 53 changed files with 160 additions and 167 deletions.
2 changes: 1 addition & 1 deletion contrib/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ database_attribute = []
proc-macro = true

[dependencies]
devise = "0.2"
devise = "0.2.1"
quote = "0.6"

[build-dependencies]
Expand Down
3 changes: 1 addition & 2 deletions contrib/codegen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(proc_macro_span, proc_macro_diagnostic)]
#![feature(crate_visibility_modifier)]
#![recursion_limit="256"]

//! # Rocket Contrib - Code Generation
Expand Down Expand Up @@ -31,7 +30,7 @@ extern crate proc_macro;
#[macro_use] extern crate quote;

#[allow(unused_imports)]
crate use devise::{syn, proc_macro2};
pub(crate) use devise::{syn, proc_macro2};

#[cfg(feature = "database_attribute")]
mod database;
Expand Down
2 changes: 1 addition & 1 deletion contrib/lib/src/helmet/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub trait Policy: Default + Send + Sync + 'static {
fn header(&self) -> Header<'static>;
}

crate trait SubPolicy: Send + Sync {
pub(crate) trait SubPolicy: Send + Sync {
fn name(&self) -> &'static UncasedStr;
fn header(&self) -> Header<'static>;
}
Expand Down
1 change: 0 additions & 1 deletion contrib/lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(crate_visibility_modifier)]
#![feature(never_type)]
#![feature(doc_cfg)]

Expand Down
8 changes: 4 additions & 4 deletions contrib/lib/src/templates/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use templates::{glob, Engines, TemplateInfo};

use rocket::http::ContentType;

crate struct Context {
pub(crate) struct Context {
/// The root of the template directory.
crate root: PathBuf,
pub(crate) root: PathBuf,
/// Mapping from template name to its information.
crate templates: HashMap<String, TemplateInfo>,
pub(crate) templates: HashMap<String, TemplateInfo>,
/// Loaded template engines
crate engines: Engines,
pub(crate) engines: Engines,
}

impl Context {
Expand Down
8 changes: 4 additions & 4 deletions contrib/lib/src/templates/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use templates::{TemplateInfo, serde::Serialize};
#[cfg(feature = "tera_templates")] use templates::tera::Tera;
#[cfg(feature = "handlebars_templates")] use templates::handlebars::Handlebars;

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

fn init(templates: &[(&str, &TemplateInfo)]) -> Option<Self> where Self: Sized;
Expand Down Expand Up @@ -58,12 +58,12 @@ pub struct Engines {
}

impl Engines {
crate const ENABLED_EXTENSIONS: &'static [&'static str] = &[
pub(crate) const ENABLED_EXTENSIONS: &'static [&'static str] = &[
#[cfg(feature = "tera_templates")] Tera::EXT,
#[cfg(feature = "handlebars_templates")] Handlebars::EXT,
];

crate fn init(templates: &HashMap<String, TemplateInfo>) -> Option<Engines> {
pub(crate) fn init(templates: &HashMap<String, TemplateInfo>) -> Option<Engines> {
fn inner<E: Engine>(templates: &HashMap<String, TemplateInfo>) -> Option<E> {
let named_templates = templates.iter()
.filter(|&(_, i)| i.extension == E::EXT)
Expand All @@ -87,7 +87,7 @@ impl Engines {
})
}

crate fn render<C: Serialize>(
pub(crate) fn render<C: Serialize>(
&self,
name: &str,
info: &TemplateInfo,
Expand Down
22 changes: 11 additions & 11 deletions contrib/lib/src/templates/fairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rocket::Rocket;
use rocket::config::ConfigError;
use rocket::fairing::{Fairing, Info, Kind};

crate use self::context::ContextManager;
pub(crate) use self::context::ContextManager;

#[cfg(not(debug_assertions))]
mod context {
Expand All @@ -13,18 +13,18 @@ mod context {

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

impl ContextManager {
crate fn new(ctxt: Context) -> ContextManager {
pub(crate) fn new(ctxt: Context) -> ContextManager {
ContextManager(ctxt)
}

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

crate fn is_reloading(&self) -> bool {
pub(crate) fn is_reloading(&self) -> bool {
false
}
}
Expand All @@ -44,15 +44,15 @@ mod context {

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

impl ContextManager {
crate fn new(ctxt: Context) -> ContextManager {
pub(crate) fn new(ctxt: Context) -> ContextManager {
let (tx, rx) = channel();
let watcher = raw_watcher(tx).and_then(|mut watcher| {
watcher.watch(ctxt.root.canonicalize()?, RecursiveMode::Recursive)?;
Expand All @@ -75,11 +75,11 @@ mod context {
}
}

crate fn context<'a>(&'a self) -> impl Deref<Target=Context> + 'a {
pub(crate) fn context<'a>(&'a self) -> impl Deref<Target=Context> + 'a {
self.context.read().unwrap()
}

crate fn is_reloading(&self) -> bool {
pub(crate) fn is_reloading(&self) -> bool {
self.watcher.is_some()
}

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

impl Fairing for TemplateFairing {
Expand Down
6 changes: 3 additions & 3 deletions contrib/lib/src/templates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ mod metadata;

pub use self::engine::Engines;
pub use self::metadata::Metadata;
crate use self::context::Context;
crate use self::fairing::ContextManager;
pub(crate) use self::context::Context;
pub(crate) use self::fairing::ContextManager;

use self::engine::Engine;
use self::fairing::TemplateFairing;
Expand Down Expand Up @@ -208,7 +208,7 @@ pub struct Template {
}

#[derive(Debug)]
crate struct TemplateInfo {
pub(crate) struct TemplateInfo {
/// The complete path, including `template_dir`, to this template.
path: PathBuf,
/// The extension for the engine of this template.
Expand Down
2 changes: 1 addition & 1 deletion core/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ proc-macro = true
indexmap = "1.0"
quote = "0.6.1"
rocket_http = { version = "0.4.10", path = "../http/" }
devise = "0.2"
devise = "0.2.1"
glob = "0.3"

[build-dependencies]
Expand Down
18 changes: 9 additions & 9 deletions core/codegen/src/attribute/segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use http::uri::{UriPart, Path};
use http::route::RouteSegment;
use proc_macro_ext::{Diagnostics, StringLit, PResult, DResult};

crate use http::route::{Error, Kind, Source};
pub(crate) use http::route::{Error, Kind, Source};

#[derive(Debug, Clone)]
crate struct Segment {
crate span: Span,
crate kind: Kind,
crate source: Source,
crate name: String,
crate index: Option<usize>,
pub(crate) struct Segment {
pub(crate) span: Span,
pub(crate) kind: Kind,
pub(crate) source: Source,
pub(crate) name: String,
pub(crate) index: Option<usize>,
}

impl Segment {
Expand Down Expand Up @@ -115,7 +115,7 @@ fn into_diagnostic(
}
}

crate fn parse_data_segment(segment: &str, span: Span) -> PResult<Segment> {
pub(crate) fn parse_data_segment(segment: &str, span: Span) -> PResult<Segment> {
<RouteSegment<Path>>::parse_one(segment)
.map(|segment| {
let mut seg = Segment::from(segment, span);
Expand All @@ -126,7 +126,7 @@ crate fn parse_data_segment(segment: &str, span: Span) -> PResult<Segment> {
.map_err(|e| into_diagnostic(segment, segment, span, &e))
}

crate fn parse_segments<P: UriPart>(
pub(crate) fn parse_segments<P: UriPart>(
string: &str,
span: Span
) -> DResult<Vec<Segment>> {
Expand Down
2 changes: 1 addition & 1 deletion core/codegen/src/bang/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod uri;
mod uri_parsing;
mod test_guide;

crate fn prefix_last_segment(path: &mut Path, prefix: &str) {
pub(crate) fn prefix_last_segment(path: &mut Path, prefix: &str) {
let mut last_seg = path.segments.last_mut().expect("syn::Path has segments");
last_seg.value_mut().ident = last_seg.value().ident.prepend(prefix);
}
Expand Down
2 changes: 1 addition & 1 deletion core/codegen/src/bang/test_guide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn entry_to_modules(pat: &LitStr) -> std::result::Result<Vec<TokenStream2>, Box<
let ident = Ident::new(&name, pat.span());
let full_path = Path::new(&manifest_dir).join(&path).display().to_string();
modules.push(quote_spanned!(pat.span() =>
#[doc(include = #full_path)]
#[doc = include_str!(#full_path)]
struct #ident;
))
}
Expand Down
4 changes: 2 additions & 2 deletions core/codegen/src/bang/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ macro_rules! p {
($n:expr, "parameter") => (p!(@go $n, "1 parameter", format!("{} parameters", $n)));
}

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

crate fn _uri_internal_macro(input: TokenStream) -> Result<TokenStream> {
pub(crate) fn _uri_internal_macro(input: TokenStream) -> Result<TokenStream> {
// Parse the internal invocation and the user's URI param expressions.
let internal = syn::parse::<InternalUriParams>(input).map_err(syn_to_diag)?;
let (path_params, query_params) = extract_exprs(&internal)?;
Expand Down
10 changes: 5 additions & 5 deletions core/codegen/src/derive/from_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use proc_macro::{Span, TokenStream};
use devise::{*, ext::{TypeExt, Split3}};

#[derive(FromMeta)]
crate struct Form {
crate field: FormField,
pub(crate) struct Form {
pub(crate) field: FormField,
}

crate struct FormField {
crate span: Span,
crate name: String
pub(crate) struct FormField {
pub(crate) span: Span,
pub(crate) name: String
}

fn is_valid_field_name(s: &str) -> bool {
Expand Down
22 changes: 11 additions & 11 deletions core/codegen/src/http_codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ use attribute::segments::{parse_segments, parse_data_segment, Segment, Kind};
use proc_macro_ext::StringLit;

#[derive(Debug)]
crate struct ContentType(crate http::ContentType);
pub(crate) struct ContentType(pub(crate) http::ContentType);

#[derive(Debug)]
crate struct Status(crate http::Status);
pub(crate) struct Status(pub(crate) http::Status);

#[derive(Debug)]
crate struct MediaType(crate http::MediaType);
pub(crate) struct MediaType(pub(crate) http::MediaType);

#[derive(Debug)]
crate struct Method(crate http::Method);
pub(crate) struct Method(pub(crate) http::Method);

#[derive(Debug)]
crate struct Origin(crate http::uri::Origin<'static>);
pub(crate) struct Origin(pub(crate) http::uri::Origin<'static>);

#[derive(Clone, Debug)]
crate struct DataSegment(crate Segment);
pub(crate) struct DataSegment(pub(crate) Segment);

#[derive(Clone, Debug)]
crate struct Optional<T>(crate Option<T>);
pub(crate) struct Optional<T>(pub(crate) Option<T>);

impl FromMeta for StringLit {
fn from_meta(meta: MetaItem) -> Result<Self> {
Expand All @@ -35,10 +35,10 @@ impl FromMeta for StringLit {
}

#[derive(Debug)]
crate struct RoutePath {
crate origin: Origin,
crate path: Vec<Segment>,
crate query: Option<Vec<Segment>>,
pub(crate) struct RoutePath {
pub(crate) origin: Origin,
pub(crate) path: Vec<Segment>,
pub(crate) query: Option<Vec<Segment>>,
}

impl FromMeta for Status {
Expand Down
15 changes: 7 additions & 8 deletions core/codegen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(proc_macro_diagnostic, proc_macro_span)]
#![feature(crate_visibility_modifier)]
#![recursion_limit="128"]

#![doc(html_root_url = "https://api.rocket.rs/v0.4")]
Expand Down Expand Up @@ -119,14 +118,14 @@ mod syn_ext;

use http::Method;
use proc_macro::TokenStream;
crate use devise::proc_macro2;
pub(crate) use devise::proc_macro2;

crate static ROUTE_STRUCT_PREFIX: &str = "static_rocket_route_info_for_";
crate static CATCH_STRUCT_PREFIX: &str = "static_rocket_catch_info_for_";
crate static CATCH_FN_PREFIX: &str = "rocket_catch_fn_";
crate static ROUTE_FN_PREFIX: &str = "rocket_route_fn_";
crate static URI_MACRO_PREFIX: &str = "rocket_uri_macro_";
crate static ROCKET_PARAM_PREFIX: &str = "__rocket_param_";
pub(crate) static ROUTE_STRUCT_PREFIX: &str = "static_rocket_route_info_for_";
pub(crate) static CATCH_STRUCT_PREFIX: &str = "static_rocket_catch_info_for_";
pub(crate) static CATCH_FN_PREFIX: &str = "rocket_catch_fn_";
pub(crate) static ROUTE_FN_PREFIX: &str = "rocket_route_fn_";
pub(crate) static URI_MACRO_PREFIX: &str = "rocket_uri_macro_";
pub(crate) static ROCKET_PARAM_PREFIX: &str = "__rocket_param_";

macro_rules! emit {
($tokens:expr) => ({
Expand Down
2 changes: 1 addition & 1 deletion core/codegen/src/proc_macro_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl From<Vec<Diagnostic>> for Diagnostics {

use std::ops::Deref;

pub struct StringLit(crate String, crate Literal);
pub struct StringLit(pub(crate) String, pub(crate) Literal);

impl Deref for StringLit {
type Target = str;
Expand Down
2 changes: 1 addition & 1 deletion core/http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ indexmap = { version = "1.5.2", features = ["std"] }
rustls = { version = "0.14", optional = true }
state = "0.4"
cookie = { version = "0.11.3", features = ["percent-encode"] }
pear = "0.1"
pear = "0.1.5"
unicode-xid = "0.1"

[dependencies.hyper-sync-rustls]
Expand Down
2 changes: 1 addition & 1 deletion core/http/src/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl PartialEq for AcceptParams {
/// let response = Response::build().header(Accept::JSON).finalize();
/// ```
#[derive(Debug, Clone, PartialEq)]
pub struct Accept(crate AcceptParams);
pub struct Accept(pub(crate) AcceptParams);

macro_rules! accept_constructor {
($($name:ident ($check:ident): $str:expr, $t:expr,
Expand Down

0 comments on commit 5824f56

Please sign in to comment.