Skip to content

Commit

Permalink
Address more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jul 21, 2017
1 parent b9b1013 commit 8898cdb
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 98 deletions.
2 changes: 1 addition & 1 deletion src/etc/platform-intrinsics/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ def open(platform):
// The default inlining settings trigger a pathological behaviour in
// LLVM, which causes makes compilation very slow. See #28273.
#[inline(never)]
pub fn find(name: &str) -> Option<Intrinsic> {{
pub(crate) fn find(name: &str) -> Option<Intrinsic> {{
if !name.starts_with("{0}") {{ return None }}
Some(match &name["{0}".len()..] {{'''.format(platform.platform_prefix())

Expand Down
66 changes: 33 additions & 33 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub fn anon_src() -> String {
"<anon>".to_string()
}

pub(crate) fn source_name(input: &Input) -> String {
pub fn source_name(input: &Input) -> String {
match *input {
// FIXME (#9639): This needs to handle non-utf8 paths
Input::File(ref ifile) => ifile.to_str().unwrap().to_string(),
Expand All @@ -295,11 +295,11 @@ pub(crate) fn source_name(input: &Input) -> String {
/// Expect more entry points to be added in the future.
pub struct CompileController<'a> {
pub after_parse: PhaseController<'a>,
pub(crate) after_expand: PhaseController<'a>,
pub after_expand: PhaseController<'a>,
pub after_hir_lowering: PhaseController<'a>,
pub after_analysis: PhaseController<'a>,
pub after_llvm: PhaseController<'a>,
pub(crate) compilation_done: PhaseController<'a>,
pub compilation_done: PhaseController<'a>,

pub make_glob_map: MakeGlobMap,
}
Expand Down Expand Up @@ -327,7 +327,7 @@ pub struct PhaseController<'a> {
}

impl<'a> PhaseController<'a> {
pub(crate) fn basic() -> PhaseController<'a> {
pub fn basic() -> PhaseController<'a> {
PhaseController {
stop: Compilation::Continue,
run_callback_on_error: false,
Expand All @@ -340,19 +340,19 @@ impl<'a> PhaseController<'a> {
/// during compilation the callback is made. See the various constructor methods
/// (`state_*`) in the impl to see which data is provided for any given entry point.
pub struct CompileState<'a, 'tcx: 'a> {
pub(crate) input: &'a Input,
pub input: &'a Input,
pub session: &'tcx Session,
pub krate: Option<ast::Crate>,
pub(crate) registry: Option<Registry<'a>>,
pub registry: Option<Registry<'a>>,
pub crate_name: Option<&'a str>,
pub(crate) out_dir: Option<&'a Path>,
pub(crate) out_file: Option<&'a Path>,
pub(crate) arena: Option<&'tcx DroplessArena>,
pub(crate) arenas: Option<&'tcx GlobalArenas<'tcx>>,
pub out_dir: Option<&'a Path>,
pub out_file: Option<&'a Path>,
pub arena: Option<&'tcx DroplessArena>,
pub arenas: Option<&'tcx GlobalArenas<'tcx>>,
pub expanded_crate: Option<&'a ast::Crate>,
pub hir_crate: Option<&'a hir::Crate>,
pub(crate) hir_map: Option<&'a hir_map::Map<'tcx>>,
pub(crate) resolutions: Option<&'a Resolutions>,
pub hir_map: Option<&'a hir_map::Map<'tcx>>,
pub resolutions: Option<&'a Resolutions>,
pub analysis: Option<&'a ty::CrateAnalysis>,
pub tcx: Option<TyCtxt<'a, 'tcx, 'tcx>>,
pub trans: Option<&'a trans::CrateTranslation>,
Expand Down Expand Up @@ -534,7 +534,7 @@ fn count_nodes(krate: &ast::Crate) -> usize {
// modified

pub struct ExpansionResult {
pub(crate) expanded_crate: ast::Crate,
pub expanded_crate: ast::Crate,
pub defs: hir_map::Definitions,
pub analysis: ty::CrateAnalysis,
pub resolutions: Resolutions,
Expand Down Expand Up @@ -1041,11 +1041,11 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,

/// Run the translation phase to LLVM, after which the AST and analysis can
/// be discarded.
pub(crate) fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
analysis: ty::CrateAnalysis,
incremental_hashes_map: &IncrementalHashesMap,
output_filenames: &OutputFilenames)
-> trans::CrateTranslation {
pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
analysis: ty::CrateAnalysis,
incremental_hashes_map: &IncrementalHashesMap,
output_filenames: &OutputFilenames)
-> trans::CrateTranslation {
let time_passes = tcx.sess.time_passes();

time(time_passes,
Expand All @@ -1072,9 +1072,9 @@ pub(crate) fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

/// Run LLVM itself, producing a bitcode file, assembly file or object file
/// as a side effect.
pub(crate) fn phase_5_run_llvm_passes(sess: &Session,
trans: &trans::CrateTranslation,
outputs: &OutputFilenames) -> CompileResult {
pub fn phase_5_run_llvm_passes(sess: &Session,
trans: &trans::CrateTranslation,
outputs: &OutputFilenames) -> CompileResult {
if sess.opts.cg.no_integrated_as ||
(sess.target.target.options.no_integrated_as &&
(outputs.outputs.contains_key(&OutputType::Object) ||
Expand Down Expand Up @@ -1116,9 +1116,9 @@ pub(crate) fn phase_5_run_llvm_passes(sess: &Session,

/// Run the linker on any artifacts that resulted from the LLVM run.
/// This should produce either a finished executable or library.
pub(crate) fn phase_6_link_output(sess: &Session,
trans: &trans::CrateTranslation,
outputs: &OutputFilenames) {
pub fn phase_6_link_output(sess: &Session,
trans: &trans::CrateTranslation,
outputs: &OutputFilenames) {
time(sess.time_passes(),
"linking",
|| link::link_binary(sess, trans, outputs, &trans.crate_name.as_str()));
Expand Down Expand Up @@ -1188,8 +1188,8 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, crate_name: &str) {
}
}

pub(crate) fn collect_crate_types(session: &Session, attrs: &[ast::Attribute])
-> Vec<config::CrateType> {
pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute])
-> Vec<config::CrateType> {
// Unconditionally collect crate types from attributes to make them used
let attr_types: Vec<config::CrateType> =
attrs.iter()
Expand Down Expand Up @@ -1269,7 +1269,7 @@ pub(crate) fn collect_crate_types(session: &Session, attrs: &[ast::Attribute])
.collect()
}

pub(crate) fn compute_crate_disambiguator(session: &Session) -> String {
pub fn compute_crate_disambiguator(session: &Session) -> String {
use std::hash::Hasher;

// The crate_disambiguator is a 128 bit hash. The disambiguator is fed
Expand Down Expand Up @@ -1304,12 +1304,12 @@ pub(crate) fn compute_crate_disambiguator(session: &Session) -> String {
format!("{}{}", hasher.finish().to_hex(), if is_exe { "-exe" } else {""})
}

pub(crate) fn build_output_filenames(input: &Input,
odir: &Option<PathBuf>,
ofile: &Option<PathBuf>,
attrs: &[ast::Attribute],
sess: &Session)
-> OutputFilenames {
pub fn build_output_filenames(input: &Input,
odir: &Option<PathBuf>,
ofile: &Option<PathBuf>,
attrs: &[ast::Attribute],
sess: &Session)
-> OutputFilenames {
match *ofile {
None => {
// "-" as input file will cause the parser to read from stdin so we
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pub enum Compilation {
}

impl Compilation {
fn and_then<F: FnOnce() -> Compilation>(self, next: F) -> Compilation {
pub fn and_then<F: FnOnce() -> Compilation>(self, next: F) -> Compilation {
match self {
Compilation::Stop => Compilation::Stop,
Compilation::Continue => next(),
Expand Down Expand Up @@ -617,7 +617,7 @@ fn save_analysis_format(sess: &Session) -> save::Format {
}

impl RustcDefaultCalls {
fn list_metadata(sess: &Session, matches: &getopts::Matches, input: &Input) -> Compilation {
pub fn list_metadata(sess: &Session, matches: &getopts::Matches, input: &Input) -> Compilation {
let r = matches.opt_strs("Z");
if r.contains(&("ls".to_string())) {
match input {
Expand Down Expand Up @@ -1016,7 +1016,7 @@ fn print_flag_list<T>(cmdline_opt: &str,
///
/// So with all that in mind, the comments below have some more detail about the
/// contortions done here to get things to work out correctly.
fn handle_options(args: &[String]) -> Option<getopts::Matches> {
pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
// Throw away the first argument, the name of the binary
let args = &args[1..];

Expand Down Expand Up @@ -1200,7 +1200,7 @@ fn exit_on_err() -> ! {
panic!();
}

fn diagnostics_registry() -> errors::registry::Registry {
pub fn diagnostics_registry() -> errors::registry::Registry {
use errors::registry::Registry;

let mut all_errors = Vec::new();
Expand Down
56 changes: 28 additions & 28 deletions src/librustc_errors/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use snippet::Style;
#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
pub struct Diagnostic {
pub level: Level,
pub(crate) message: Vec<(String, Style)>,
pub message: Vec<(String, Style)>,
pub code: Option<String>,
pub span: MultiSpan,
pub children: Vec<SubDiagnostic>,
Expand All @@ -31,7 +31,7 @@ pub struct Diagnostic {
#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
pub struct SubDiagnostic {
pub level: Level,
pub(crate) message: Vec<(String, Style)>,
pub message: Vec<(String, Style)>,
pub span: MultiSpan,
pub render_span: Option<RenderSpan>,
}
Expand Down Expand Up @@ -69,7 +69,7 @@ pub enum StringPart {
}

impl StringPart {
pub(crate) fn content(&self) -> String {
pub fn content(&self) -> String {
match self {
&StringPart::Normal(ref s) | & StringPart::Highlighted(ref s) => s.to_owned()
}
Expand All @@ -81,7 +81,7 @@ impl Diagnostic {
Diagnostic::new_with_code(level, None, message)
}

pub(crate) fn new_with_code(level: Level, code: Option<String>, message: &str) -> Self {
pub fn new_with_code(level: Level, code: Option<String>, message: &str) -> Self {
Diagnostic {
level: level,
message: vec![(message.to_owned(), Style::NoStyle)],
Expand All @@ -101,7 +101,7 @@ impl Diagnostic {
self.level = Level::Cancelled;
}

pub(crate) fn cancelled(&self) -> bool {
pub fn cancelled(&self) -> bool {
self.level == Level::Cancelled
}

Expand All @@ -116,22 +116,22 @@ impl Diagnostic {
self
}

pub(crate) fn note_expected_found(&mut self,
label: &fmt::Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString)
-> &mut Self
pub fn note_expected_found(&mut self,
label: &fmt::Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString)
-> &mut Self
{
self.note_expected_found_extra(label, expected, found, &"", &"")
}

pub(crate) fn note_expected_found_extra(&mut self,
label: &fmt::Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &fmt::Display,
found_extra: &fmt::Display)
-> &mut Self
pub fn note_expected_found_extra(&mut self,
label: &fmt::Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &fmt::Display,
found_extra: &fmt::Display)
-> &mut Self
{
let mut msg: Vec<_> = vec![(format!("expected {} `", label), Style::NoStyle)];
msg.extend(expected.0.iter()
Expand Down Expand Up @@ -161,12 +161,12 @@ impl Diagnostic {
self
}

pub(crate) fn note(&mut self, msg: &str) -> &mut Self {
pub fn note(&mut self, msg: &str) -> &mut Self {
self.sub(Level::Note, msg, MultiSpan::new(), None);
self
}

pub(crate) fn highlighted_note(&mut self, msg: Vec<(String, Style)>) -> &mut Self {
pub fn highlighted_note(&mut self, msg: Vec<(String, Style)>) -> &mut Self {
self.sub_with_highlights(Level::Note, msg, MultiSpan::new(), None);
self
}
Expand All @@ -179,25 +179,25 @@ impl Diagnostic {
self
}

pub(crate) fn warn(&mut self, msg: &str) -> &mut Self {
pub fn warn(&mut self, msg: &str) -> &mut Self {
self.sub(Level::Warning, msg, MultiSpan::new(), None);
self
}

pub(crate) fn span_warn<S: Into<MultiSpan>>(&mut self,
pub fn span_warn<S: Into<MultiSpan>>(&mut self,
sp: S,
msg: &str)
-> &mut Self {
self.sub(Level::Warning, msg, sp.into(), None);
self
}

pub(crate) fn help(&mut self , msg: &str) -> &mut Self {
pub fn help(&mut self , msg: &str) -> &mut Self {
self.sub(Level::Help, msg, MultiSpan::new(), None);
self
}

pub(crate) fn span_help<S: Into<MultiSpan>>(&mut self,
pub fn span_help<S: Into<MultiSpan>>(&mut self,
sp: S,
msg: &str)
-> &mut Self {
Expand All @@ -220,7 +220,7 @@ impl Diagnostic {
/// * may contain a name of a function, variable or type, but not whole expressions
///
/// See `diagnostic::CodeSuggestion` for more information.
pub(crate) fn span_suggestion(&mut self, sp: Span, msg: &str, suggestion: String) -> &mut Self {
pub fn span_suggestion(&mut self, sp: Span, msg: &str, suggestion: String) -> &mut Self {
self.suggestions.push(CodeSuggestion {
substitution_parts: vec![Substitution {
span: sp,
Expand All @@ -231,7 +231,7 @@ impl Diagnostic {
self
}

pub(crate) fn span_suggestions(&mut self, sp: Span, msg: &str, suggestions: Vec<String>)
pub fn span_suggestions(&mut self, sp: Span, msg: &str, suggestions: Vec<String>)
-> &mut Self {
self.suggestions.push(CodeSuggestion {
substitution_parts: vec![Substitution {
Expand All @@ -248,7 +248,7 @@ impl Diagnostic {
self
}

pub(crate) fn code(&mut self, s: String) -> &mut Self {
pub fn code(&mut self, s: String) -> &mut Self {
self.code = Some(s);
self
}
Expand All @@ -257,7 +257,7 @@ impl Diagnostic {
self.message.iter().map(|i| i.0.to_owned()).collect::<String>()
}

pub(crate) fn styled_message(&self) -> &Vec<(String, Style)> {
pub fn styled_message(&self) -> &Vec<(String, Style)> {
&self.message
}

Expand Down Expand Up @@ -307,7 +307,7 @@ impl SubDiagnostic {
self.message.iter().map(|i| i.0.to_owned()).collect::<String>()
}

pub(crate) fn styled_message(&self) -> &Vec<(String, Style)> {
pub fn styled_message(&self) -> &Vec<(String, Style)> {
&self.message
}
}
2 changes: 1 addition & 1 deletion src/librustc_errors/snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub(crate) struct StyledString {
}

#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
pub(crate) enum Style {
pub enum Style {
HeaderMsg,
LineAndColumn,
LineNumber,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ extern "C" {
pub fn LLVMRustSetLinkage(Global: ValueRef, RustLinkage: Linkage);
pub(crate) fn LLVMGetSection(Global: ValueRef) -> *const c_char;
pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
pub(crate) fn LLVMRustGetVisibility(Global: ValueRef) -> Visibility;
pub fn LLVMRustGetVisibility(Global: ValueRef) -> Visibility;
pub fn LLVMRustSetVisibility(Global: ValueRef, Viz: Visibility);
pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
hir::ItemForeignMod(..) => {
self.prev_level
}
// Other `pub(crate)` items inherit levels from parents
// Other `pub` items inherit levels from parents
hir::ItemConst(..) | hir::ItemEnum(..) | hir::ItemExternCrate(..) |
hir::ItemGlobalAsm(..) | hir::ItemFn(..) | hir::ItemMod(..) |
hir::ItemStatic(..) | hir::ItemStruct(..) | hir::ItemTrait(..) |
Expand Down
Loading

0 comments on commit 8898cdb

Please sign in to comment.