diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_expand/src/proc_macro_server.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/builtin.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_session/src/parse.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/intrinsic.rs | 4 |
5 files changed, 37 insertions, 5 deletions
diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 92315c4d4f6..1d73002710d 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -411,6 +411,10 @@ impl server::FreeFunctions for Rustc<'_> { fn track_env_var(&mut self, var: &str, value: Option<&str>) { self.sess.env_depinfo.borrow_mut().insert((Symbol::intern(var), value.map(Symbol::intern))); } + + fn track_path(&mut self, path: &str) { + self.sess.file_depinfo.borrow_mut().insert(Symbol::intern(path)); + } } impl server::TokenStream for Rustc<'_> { diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 9ea1f88b43f..c0f7ea8df49 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -28,18 +28,18 @@ use rustc_passes::{self, hir_stats, layout_test}; use rustc_plugin_impl as plugin; use rustc_query_impl::Queries as TcxQueries; use rustc_resolve::{Resolver, ResolverArenas}; +use rustc_serialize::json; use rustc_session::config::{CrateType, Input, OutputFilenames, OutputType, PpMode, PpSourceMode}; use rustc_session::lint; use rustc_session::output::{filename_for_input, filename_for_metadata}; use rustc_session::search_paths::PathKind; use rustc_session::Session; use rustc_span::symbol::{Ident, Symbol}; +use rustc_span::FileName; use rustc_trait_selection::traits; use rustc_typeck as typeck; -use tracing::{info, warn}; - -use rustc_serialize::json; use tempfile::Builder as TempFileBuilder; +use tracing::{info, warn}; use std::any::Any; use std::cell::RefCell; @@ -594,6 +594,16 @@ fn write_out_deps( .map(|fmap| escape_dep_filename(&fmap.name.prefer_local().to_string())) .collect(); + // Account for explicitly marked-to-track files + // (e.g. accessed in proc macros). + let file_depinfo = sess.parse_sess.file_depinfo.borrow(); + let extra_tracked_files = file_depinfo.iter().map(|path_sym| { + let path = PathBuf::from(&*path_sym.as_str()); + let file = FileName::from(path); + escape_dep_filename(&file.prefer_local().to_string()) + }); + files.extend(extra_tracked_files); + if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend { files.push(backend.to_string()); } diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 65695fc03de..b303f55cf77 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -984,13 +984,16 @@ impl EarlyLintPass for DeprecatedAttr { } fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &[ast::Attribute]) { + use rustc_ast::token::CommentKind; + let mut attrs = attrs.iter().peekable(); // Accumulate a single span for sugared doc comments. let mut sugared_span: Option<Span> = None; while let Some(attr) = attrs.next() { - if attr.is_doc_comment() { + let is_doc_comment = attr.is_doc_comment(); + if is_doc_comment { sugared_span = Some(sugared_span.map_or(attr.span, |span| span.with_hi(attr.span.hi()))); } @@ -1001,13 +1004,21 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: & let span = sugared_span.take().unwrap_or(attr.span); - if attr.is_doc_comment() || cx.sess().check_name(attr, sym::doc) { + if is_doc_comment || cx.sess().check_name(attr, sym::doc) { cx.struct_span_lint(UNUSED_DOC_COMMENTS, span, |lint| { let mut err = lint.build("unused doc comment"); err.span_label( node_span, format!("rustdoc does not generate documentation for {}", node_kind), ); + match attr.kind { + AttrKind::DocComment(CommentKind::Line, _) | AttrKind::Normal(..) => { + err.help("use `//` for a plain comment"); + } + AttrKind::DocComment(CommentKind::Block, _) => { + err.help("use `/* */` for a plain comment"); + } + } err.emit(); }); } diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 7b7878e9c7f..226fde2343a 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -133,6 +133,8 @@ pub struct ParseSess { pub reached_eof: Lock<bool>, /// Environment variables accessed during the build and their values when they exist. pub env_depinfo: Lock<FxHashSet<(Symbol, Option<Symbol>)>>, + /// File paths accessed during the build. + pub file_depinfo: Lock<FxHashSet<Symbol>>, /// All the type ascriptions expressions that have had a suggestion for likely path typo. pub type_ascription_path_suggestions: Lock<FxHashSet<Span>>, /// Whether cfg(version) should treat the current release as incomplete @@ -165,6 +167,7 @@ impl ParseSess { symbol_gallery: SymbolGallery::default(), reached_eof: Lock::new(false), env_depinfo: Default::default(), + file_depinfo: Default::default(), type_ascription_path_suggestions: Default::default(), assume_incomplete_release: false, proc_macro_quoted_spans: Default::default(), diff --git a/compiler/rustc_typeck/src/check/intrinsic.rs b/compiler/rustc_typeck/src/check/intrinsic.rs index a56aefcef9c..882d5d54b7c 100644 --- a/compiler/rustc_typeck/src/check/intrinsic.rs +++ b/compiler/rustc_typeck/src/check/intrinsic.rs @@ -65,6 +65,10 @@ fn equate_intrinsic_type<'tcx>( /// Returns the unsafety of the given intrinsic. pub fn intrinsic_operation_unsafety(intrinsic: Symbol) -> hir::Unsafety { match intrinsic { + // When adding a new intrinsic to this list, + // it's usually worth updating that intrinsic's documentation + // to note that it's safe to call, since + // safe extern fns are otherwise unprecedented. sym::abort | sym::size_of | sym::min_align_of |
