From 8898cdb0862bedac3dc358dcf9911f7c92d7337e Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 22 Jul 2017 00:45:28 +0300 Subject: [PATCH] Address more comments --- src/etc/platform-intrinsics/generator.py | 2 +- src/librustc_driver/driver.rs | 66 ++++++++++++------------ src/librustc_driver/lib.rs | 8 +-- src/librustc_errors/diagnostic.rs | 56 ++++++++++---------- src/librustc_errors/snippet.rs | 2 +- src/librustc_llvm/ffi.rs | 2 +- src/librustc_privacy/lib.rs | 2 +- src/librustc_resolve/lib.rs | 2 +- src/librustc_save_analysis/lib.rs | 26 +++++----- src/librustc_save_analysis/sig.rs | 2 +- src/librustc_trans/back/symbol_export.rs | 2 +- src/librustc_trans/trans_item.rs | 2 +- src/librustc_typeck/diagnostics.rs | 28 +++++----- 13 files changed, 102 insertions(+), 98 deletions(-) diff --git a/src/etc/platform-intrinsics/generator.py b/src/etc/platform-intrinsics/generator.py index e3c08bb35e075..4c8edbef6231c 100644 --- a/src/etc/platform-intrinsics/generator.py +++ b/src/etc/platform-intrinsics/generator.py @@ -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 {{ +pub(crate) fn find(name: &str) -> Option {{ if !name.starts_with("{0}") {{ return None }} Some(match &name["{0}".len()..] {{'''.format(platform.platform_prefix()) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 31309578c55f6..cf9c87b13799f 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -271,7 +271,7 @@ pub fn anon_src() -> String { "".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(), @@ -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, } @@ -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, @@ -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, - pub(crate) registry: Option>, + pub registry: Option>, 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>, pub trans: Option<&'a trans::CrateTranslation>, @@ -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, @@ -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, @@ -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) || @@ -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())); @@ -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 { +pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) + -> Vec { // Unconditionally collect crate types from attributes to make them used let attr_types: Vec = attrs.iter() @@ -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 @@ -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, - ofile: &Option, - attrs: &[ast::Attribute], - sess: &Session) - -> OutputFilenames { +pub fn build_output_filenames(input: &Input, + odir: &Option, + ofile: &Option, + attrs: &[ast::Attribute], + sess: &Session) + -> OutputFilenames { match *ofile { None => { // "-" as input file will cause the parser to read from stdin so we diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index c75e2195626f0..b1ec20e3f34c8 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -273,7 +273,7 @@ pub enum Compilation { } impl Compilation { - fn and_then Compilation>(self, next: F) -> Compilation { + pub fn and_then Compilation>(self, next: F) -> Compilation { match self { Compilation::Stop => Compilation::Stop, Compilation::Continue => next(), @@ -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 { @@ -1016,7 +1016,7 @@ fn print_flag_list(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 { +pub fn handle_options(args: &[String]) -> Option { // Throw away the first argument, the name of the binary let args = &args[1..]; @@ -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(); diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index cb8fedddba57f..f056784b8cf5d 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -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, pub span: MultiSpan, pub children: Vec, @@ -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, } @@ -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() } @@ -81,7 +81,7 @@ impl Diagnostic { Diagnostic::new_with_code(level, None, message) } - pub(crate) fn new_with_code(level: Level, code: Option, message: &str) -> Self { + pub fn new_with_code(level: Level, code: Option, message: &str) -> Self { Diagnostic { level: level, message: vec![(message.to_owned(), Style::NoStyle)], @@ -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 } @@ -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() @@ -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 } @@ -179,12 +179,12 @@ 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>(&mut self, + pub fn span_warn>(&mut self, sp: S, msg: &str) -> &mut Self { @@ -192,12 +192,12 @@ impl Diagnostic { 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>(&mut self, + pub fn span_help>(&mut self, sp: S, msg: &str) -> &mut Self { @@ -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, @@ -231,7 +231,7 @@ impl Diagnostic { self } - pub(crate) fn span_suggestions(&mut self, sp: Span, msg: &str, suggestions: Vec) + pub fn span_suggestions(&mut self, sp: Span, msg: &str, suggestions: Vec) -> &mut Self { self.suggestions.push(CodeSuggestion { substitution_parts: vec![Substitution { @@ -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 } @@ -257,7 +257,7 @@ impl Diagnostic { self.message.iter().map(|i| i.0.to_owned()).collect::() } - pub(crate) fn styled_message(&self) -> &Vec<(String, Style)> { + pub fn styled_message(&self) -> &Vec<(String, Style)> { &self.message } @@ -307,7 +307,7 @@ impl SubDiagnostic { self.message.iter().map(|i| i.0.to_owned()).collect::() } - pub(crate) fn styled_message(&self) -> &Vec<(String, Style)> { + pub fn styled_message(&self) -> &Vec<(String, Style)> { &self.message } } diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index 6f171ad906376..1913d34c7ea82 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -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, diff --git a/src/librustc_llvm/ffi.rs b/src/librustc_llvm/ffi.rs index b11ac664da158..44022052de8a4 100644 --- a/src/librustc_llvm/ffi.rs +++ b/src/librustc_llvm/ffi.rs @@ -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); diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 33a7697a09ff1..5b3aa890ced37 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -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(..) | diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index ff8e1f3cf40d0..c07d8d1f06dcb 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1012,7 +1012,7 @@ impl<'a> NameBinding<'a> { resolver.get_macro(self.def_ignoring_ambiguity()) } - // We sometimes need to treat variants as `pub(crate)` for backwards compatibility + // We sometimes need to treat variants as `pub` for backwards compatibility fn pseudo_vis(&self) -> ty::Visibility { if self.is_variant() { ty::Visibility::Public } else { self.vis } } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 1eaed9dad9b93..0bbdd4d6280d6 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -78,13 +78,13 @@ pub struct SaveContext<'l, 'tcx: 'l> { } #[derive(Debug)] -enum Data { +pub enum Data { RefData(Ref), DefData(Def), RelationData(Relation), } -trait Dump { +pub trait Dump { fn crate_prelude(&mut self, _: CratePreludeData); fn macro_use(&mut self, _: MacroRef) {} fn import(&mut self, _: bool, _: Import); @@ -117,7 +117,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } // List external crates used by the current crate. - fn get_external_crates(&self) -> Vec { + pub fn get_external_crates(&self) -> Vec { let mut result = Vec::new(); for n in self.tcx.sess.cstore.crates() { @@ -139,7 +139,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { result } - fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option { + pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option { let qualname = format!("::{}", self.tcx.node_path_str(item.id)); match item.node { ast::ForeignItemKind::Fn(ref decl, ref generics) => { @@ -187,7 +187,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } - fn get_item_data(&self, item: &ast::Item) -> Option { + pub fn get_item_data(&self, item: &ast::Item) -> Option { match item.node { ast::ItemKind::Fn(ref decl, .., ref generics, _) => { let qualname = format!("::{}", self.tcx.node_path_str(item.id)); @@ -342,7 +342,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } - fn get_field_data(&self, + pub fn get_field_data(&self, field: &ast::StructField, scope: NodeId) -> Option { @@ -379,7 +379,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { // FIXME would be nice to take a MethodItem here, but the ast provides both // trait and impl flavours, so the caller must do the disassembly. - fn get_method_data(&self, + pub fn get_method_data(&self, id: ast::NodeId, name: ast::Name, span: Span) @@ -482,7 +482,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { }) } - fn get_trait_ref_data(&self, + pub fn get_trait_ref_data(&self, trait_ref: &ast::TraitRef) -> Option { self.lookup_ref_id(trait_ref.ref_id).and_then(|def_id| { @@ -501,7 +501,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { }) } - fn get_expr_data(&self, expr: &ast::Expr) -> Option { + pub fn get_expr_data(&self, expr: &ast::Expr) -> Option { let hir_node = self.tcx.hir.expect_expr(expr.id); let ty = self.tables.expr_ty_adjusted_opt(&hir_node); if ty.is_none() || ty.unwrap().sty == ty::TyError { @@ -580,7 +580,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } - fn get_path_def(&self, id: NodeId) -> HirDef { + pub fn get_path_def(&self, id: NodeId) -> HirDef { match self.tcx.hir.get(id) { Node::NodeTraitRef(tr) => tr.path.def, @@ -620,7 +620,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } - fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option { + pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option { let def = self.get_path_def(id); let sub_span = self.span_utils.span_for_last_ident(path.span); filter!(self.span_utils, sub_span, path.span, None); @@ -697,7 +697,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } - fn get_field_ref_data(&self, + pub fn get_field_ref_data(&self, field_ref: &ast::Field, variant: &ty::VariantDef) -> Option { @@ -718,7 +718,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { /// For a given piece of AST defined by the supplied Span and NodeId, /// returns None if the node is not macro-generated or the span is malformed, /// else uses the expansion callsite and callee to return some MacroRef. - fn get_macro_use_data(&self, span: Span) -> Option { + pub fn get_macro_use_data(&self, span: Span) -> Option { if !generated_code(span) { return None; } diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 386eb193abf12..de314eaf1d78a 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -534,7 +534,7 @@ impl Sig for ast::Item { ast::ItemKind::ForeignMod(_) => Err("extern mod"), ast::ItemKind::GlobalAsm(_) => Err("glboal asm"), ast::ItemKind::ExternCrate(_) => Err("extern crate"), - // FIXME should implement this (e.g., pub(crate) use). + // FIXME should implement this (e.g., pub use). ast::ItemKind::Use(_) => Err("import"), ast::ItemKind::Mac(..) | ast::ItemKind::MacroDef(_) => Err("Macro"), diff --git a/src/librustc_trans/back/symbol_export.rs b/src/librustc_trans/back/symbol_export.rs index a091fd543be68..15b59bf0e21a4 100644 --- a/src/librustc_trans/back/symbol_export.rs +++ b/src/librustc_trans/back/symbol_export.rs @@ -113,7 +113,7 @@ impl ExportedSymbols { // Check to see if this crate is a "special runtime crate". These // crates, implementation details of the standard library, typically - // have a bunch of `pub(crate) extern` and `#[no_mangle]` functions as the + // have a bunch of `pub extern` and `#[no_mangle]` functions as the // ABI between them. We don't want their symbols to have a `C` // export level, however, as they're just implementation details. // Down below we'll hardwire all of the symbols to the `Rust` export diff --git a/src/librustc_trans/trans_item.rs b/src/librustc_trans/trans_item.rs index b697346745602..ea4561e06ff3d 100644 --- a/src/librustc_trans/trans_item.rs +++ b/src/librustc_trans/trans_item.rs @@ -286,7 +286,7 @@ impl<'a, 'tcx> TransItem<'tcx> { /// might not be instantiable. For example, a programmer can define this /// public function: /// - /// pub(crate) fn foo<'a>(s: &'a mut ()) where &'a mut (): Clone { + /// pub fn foo<'a>(s: &'a mut ()) where &'a mut (): Clone { /// <&mut () as Clone>::clone(&s); /// } /// diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index f5d0be4742a9a..1e26a734e7640 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -239,10 +239,10 @@ trait_obj.method_one(); trait_obj.method_two(); ``` -You can read more about trait objects in the Trait Object section of the -Reference: +You can read more about trait objects in the [Trait Objects] section of the +Reference. -https://doc.rust-lang.org/reference.html#trait-objects +[Trait Objects]: https://doc.rust-lang.org/reference/types.html#trait-objects "##, E0034: r##" @@ -788,8 +788,9 @@ lvalue expression represents a memory location and can be a variable (with optional namespacing), a dereference, an indexing expression or a field reference. -More details can be found here: -https://doc.rust-lang.org/reference.html#lvalues-rvalues-and-temporaries +More details can be found in the [Expressions] section of the Reference. + +[Expressions]: https://doc.rust-lang.org/reference/expressions.html#lvalues-rvalues-and-temporaries Now, we can go further. Here are some erroneous code examples: @@ -3381,10 +3382,10 @@ struct Foo<'a, T: 'a> { } ``` -PhantomData can also be used to express information about unused type -parameters. You can read more about it in the API documentation: +[PhantomData] can also be used to express information about unused type +parameters. -https://doc.rust-lang.org/std/marker/struct.PhantomData.html +[PhantomData]: https://doc.rust-lang.org/std/marker/struct.PhantomData.html "##, E0393: r##" @@ -4256,7 +4257,9 @@ let variable = Foo { x: 0, y: -12 }; println!("x: {}, y: {}", variable.x, variable.y); ``` -For more information see The Rust Book: https://doc.rust-lang.org/book/ +For more information about primitives and structs, take a look at The Book: +https://doc.rust-lang.org/book/first-edition/primitive-types.html +https://doc.rust-lang.org/book/first-edition/structs.html "##, E0611: r##" @@ -4474,9 +4477,10 @@ unsafe { } ``` -To fix this error, you need to pass variables corresponding to C types as much -as possible. For better explanations, see The Rust Book: -https://doc.rust-lang.org/book/ +Certain Rust types must be cast before passing them to a variadic function, +because of arcane ABI rules dictated by the C standard. To fix the error, +cast the value to the type specified by the error message (which you may need +to import from `std::os::raw`). "##, E0618: r##"