Skip to content

Commit 798baeb

Browse files
committed
Auto merge of rust-lang#86817 - JohnTitor:rollup-rcysc95, r=JohnTitor
Rollup of 7 pull requests Successful merges: - rust-lang#84029 (add `track_path::path` fn for usage in `proc_macro`s) - rust-lang#85001 (Merge `sys_common::bytestring` back into `os_str_bytes`) - rust-lang#86308 (Docs: clarify that certain intrinsics are not unsafe) - rust-lang#86796 (Add a regression test for issue-70703) - rust-lang#86803 (Remove & from Command::args calls in documentation) - rust-lang#86807 (Fix double import in wasm thread ) - rust-lang#86813 (Add a help message to `unused_doc_comments` lint) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2545459 + 1b13632 commit 798baeb

File tree

23 files changed

+410
-58
lines changed

23 files changed

+410
-58
lines changed

compiler/rustc_expand/src/proc_macro_server.rs

+4
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ impl server::FreeFunctions for Rustc<'_> {
411411
fn track_env_var(&mut self, var: &str, value: Option<&str>) {
412412
self.sess.env_depinfo.borrow_mut().insert((Symbol::intern(var), value.map(Symbol::intern)));
413413
}
414+
415+
fn track_path(&mut self, path: &str) {
416+
self.sess.file_depinfo.borrow_mut().insert(Symbol::intern(path));
417+
}
414418
}
415419

416420
impl server::TokenStream for Rustc<'_> {

compiler/rustc_interface/src/passes.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ use rustc_passes::{self, hir_stats, layout_test};
2828
use rustc_plugin_impl as plugin;
2929
use rustc_query_impl::Queries as TcxQueries;
3030
use rustc_resolve::{Resolver, ResolverArenas};
31+
use rustc_serialize::json;
3132
use rustc_session::config::{CrateType, Input, OutputFilenames, OutputType, PpMode, PpSourceMode};
3233
use rustc_session::lint;
3334
use rustc_session::output::{filename_for_input, filename_for_metadata};
3435
use rustc_session::search_paths::PathKind;
3536
use rustc_session::Session;
3637
use rustc_span::symbol::{Ident, Symbol};
38+
use rustc_span::FileName;
3739
use rustc_trait_selection::traits;
3840
use rustc_typeck as typeck;
39-
use tracing::{info, warn};
40-
41-
use rustc_serialize::json;
4241
use tempfile::Builder as TempFileBuilder;
42+
use tracing::{info, warn};
4343

4444
use std::any::Any;
4545
use std::cell::RefCell;
@@ -594,6 +594,16 @@ fn write_out_deps(
594594
.map(|fmap| escape_dep_filename(&fmap.name.prefer_local().to_string()))
595595
.collect();
596596

597+
// Account for explicitly marked-to-track files
598+
// (e.g. accessed in proc macros).
599+
let file_depinfo = sess.parse_sess.file_depinfo.borrow();
600+
let extra_tracked_files = file_depinfo.iter().map(|path_sym| {
601+
let path = PathBuf::from(&*path_sym.as_str());
602+
let file = FileName::from(path);
603+
escape_dep_filename(&file.prefer_local().to_string())
604+
});
605+
files.extend(extra_tracked_files);
606+
597607
if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend {
598608
files.push(backend.to_string());
599609
}

compiler/rustc_lint/src/builtin.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -984,13 +984,16 @@ impl EarlyLintPass for DeprecatedAttr {
984984
}
985985

986986
fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &[ast::Attribute]) {
987+
use rustc_ast::token::CommentKind;
988+
987989
let mut attrs = attrs.iter().peekable();
988990

989991
// Accumulate a single span for sugared doc comments.
990992
let mut sugared_span: Option<Span> = None;
991993

992994
while let Some(attr) = attrs.next() {
993-
if attr.is_doc_comment() {
995+
let is_doc_comment = attr.is_doc_comment();
996+
if is_doc_comment {
994997
sugared_span =
995998
Some(sugared_span.map_or(attr.span, |span| span.with_hi(attr.span.hi())));
996999
}
@@ -1001,13 +1004,21 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
10011004

10021005
let span = sugared_span.take().unwrap_or(attr.span);
10031006

1004-
if attr.is_doc_comment() || cx.sess().check_name(attr, sym::doc) {
1007+
if is_doc_comment || cx.sess().check_name(attr, sym::doc) {
10051008
cx.struct_span_lint(UNUSED_DOC_COMMENTS, span, |lint| {
10061009
let mut err = lint.build("unused doc comment");
10071010
err.span_label(
10081011
node_span,
10091012
format!("rustdoc does not generate documentation for {}", node_kind),
10101013
);
1014+
match attr.kind {
1015+
AttrKind::DocComment(CommentKind::Line, _) | AttrKind::Normal(..) => {
1016+
err.help("use `//` for a plain comment");
1017+
}
1018+
AttrKind::DocComment(CommentKind::Block, _) => {
1019+
err.help("use `/* */` for a plain comment");
1020+
}
1021+
}
10111022
err.emit();
10121023
});
10131024
}

compiler/rustc_session/src/parse.rs

+3
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ pub struct ParseSess {
133133
pub reached_eof: Lock<bool>,
134134
/// Environment variables accessed during the build and their values when they exist.
135135
pub env_depinfo: Lock<FxHashSet<(Symbol, Option<Symbol>)>>,
136+
/// File paths accessed during the build.
137+
pub file_depinfo: Lock<FxHashSet<Symbol>>,
136138
/// All the type ascriptions expressions that have had a suggestion for likely path typo.
137139
pub type_ascription_path_suggestions: Lock<FxHashSet<Span>>,
138140
/// Whether cfg(version) should treat the current release as incomplete
@@ -165,6 +167,7 @@ impl ParseSess {
165167
symbol_gallery: SymbolGallery::default(),
166168
reached_eof: Lock::new(false),
167169
env_depinfo: Default::default(),
170+
file_depinfo: Default::default(),
168171
type_ascription_path_suggestions: Default::default(),
169172
assume_incomplete_release: false,
170173
proc_macro_quoted_spans: Default::default(),

compiler/rustc_typeck/src/check/intrinsic.rs

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ fn equate_intrinsic_type<'tcx>(
6565
/// Returns the unsafety of the given intrinsic.
6666
pub fn intrinsic_operation_unsafety(intrinsic: Symbol) -> hir::Unsafety {
6767
match intrinsic {
68+
// When adding a new intrinsic to this list,
69+
// it's usually worth updating that intrinsic's documentation
70+
// to note that it's safe to call, since
71+
// safe extern fns are otherwise unprecedented.
6872
sym::abort
6973
| sym::size_of
7074
| sym::min_align_of

0 commit comments

Comments
 (0)