Auto merge of #86817 - JohnTitor:rollup-rcysc95, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #84029 (add `track_path::path` fn for usage in `proc_macro`s) - #85001 (Merge `sys_common::bytestring` back into `os_str_bytes`) - #86308 (Docs: clarify that certain intrinsics are not unsafe) - #86796 (Add a regression test for issue-70703) - #86803 (Remove & from Command::args calls in documentation) - #86807 (Fix double import in wasm thread ) - #86813 (Add a help message to `unused_doc_comments` lint) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
798baebde1
23 changed files with 410 additions and 58 deletions
|
@ -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<'_> {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue