Skip to content

Commit 537e9e5

Browse files
committed
Auto merge of #130100 - matthiaskrgr:rollup-nk36g91, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #129337 (rustdoc rfc#3662 changes under unstable flags) - #129473 (use `download-ci-llvm=true` in the default compiler config) - #129529 (Add test to build crates used by r-a on stable) - #130025 (Also emit `missing_docs` lint with `--test` to fulfil expectations) - #130070 (Rename variant `AddrOfRegion` of `RegionVariableOrigin` to `BorrowRegion`) - #130087 (remove 'const' from 'Option::iter') - #130092 (Fixes typo in wasm32-wasip2 doc comment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents adf8d16 + e4f8824 commit 537e9e5

File tree

71 files changed

+1047
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1047
-195
lines changed

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
447447
// this time with enough precision to check that the value
448448
// whose address was taken can actually be made to live as long
449449
// as it needs to live.
450-
let region = self.next_region_var(infer::AddrOfRegion(expr.span));
450+
let region = self.next_region_var(infer::BorrowRegion(expr.span));
451451
Ty::new_ref(self.tcx, region, ty, mutbl)
452452
}
453453
}

compiler/rustc_infer/src/infer/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ pub enum RegionVariableOrigin {
458458
PatternRegion(Span),
459459

460460
/// Regions created by `&` operator.
461-
///
462-
AddrOfRegion(Span),
461+
BorrowRegion(Span),
462+
463463
/// Regions created as part of an autoref of a method receiver.
464464
Autoref(Span),
465465

@@ -1741,7 +1741,7 @@ impl RegionVariableOrigin {
17411741
match *self {
17421742
MiscVariable(a)
17431743
| PatternRegion(a)
1744-
| AddrOfRegion(a)
1744+
| BorrowRegion(a)
17451745
| Autoref(a)
17461746
| Coercion(a)
17471747
| RegionParameterDefinition(a, ..)

compiler/rustc_lint/src/builtin.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,6 @@ impl MissingDoc {
426426
article: &'static str,
427427
desc: &'static str,
428428
) {
429-
// If we're building a test harness, then warning about
430-
// documentation is probably not really relevant right now.
431-
if cx.sess().opts.test {
432-
return;
433-
}
434-
435429
// Only check publicly-visible items, using the result from the privacy pass.
436430
// It's an option so the crate root can also use this function (it doesn't
437431
// have a `NodeId`).
@@ -444,11 +438,10 @@ impl MissingDoc {
444438
let attrs = cx.tcx.hir().attrs(cx.tcx.local_def_id_to_hir_id(def_id));
445439
let has_doc = attrs.iter().any(has_doc);
446440
if !has_doc {
447-
cx.emit_span_lint(
448-
MISSING_DOCS,
449-
cx.tcx.def_span(def_id),
450-
BuiltinMissingDoc { article, desc },
451-
);
441+
let sp = cx.tcx.def_span(def_id);
442+
if !sp.is_dummy() {
443+
cx.emit_span_lint(MISSING_DOCS, sp, BuiltinMissingDoc { article, desc });
444+
}
452445
}
453446
}
454447
}

compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! The `wasm32-wasip2` target is the next evolution of the
22
//! wasm32-wasi target. While the wasi specification is still under
3-
//! active development, the {review 2 iteration is considered an "island
3+
//! active development, the preview 2 iteration is considered an "island
44
//! of stability" that should allow users to rely on it indefinitely.
55
//!
66
//! The `wasi` target is a proposal to define a standardized set of WebAssembly

compiler/rustc_trait_selection/src/error_reporting/infer/region.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
10181018
let var_description = match var_origin {
10191019
infer::MiscVariable(_) => String::new(),
10201020
infer::PatternRegion(_) => " for pattern".to_string(),
1021-
infer::AddrOfRegion(_) => " for borrow expression".to_string(),
1021+
infer::BorrowRegion(_) => " for borrow expression".to_string(),
10221022
infer::Autoref(_) => " for autoref".to_string(),
10231023
infer::Coercion(_) => " for automatic coercion".to_string(),
10241024
infer::BoundRegion(_, br, infer::FnCall) => {

compiler/rustc_type_ir/src/elaborate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ pub fn supertrait_def_ids<I: Interner>(
237237
cx: I,
238238
trait_def_id: I::DefId,
239239
) -> impl Iterator<Item = I::DefId> {
240-
let mut set: HashSet<I::DefId> = HashSet::default();
240+
let mut set = HashSet::default();
241241
let mut stack = vec![trait_def_id];
242242

243243
set.insert(trait_def_id);

config.example.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
# Unless you're developing for a target where Rust CI doesn't build a compiler
4343
# toolchain or changing LLVM locally, you probably want to leave this enabled.
4444
#
45+
# Set this to `true` to download if CI llvm available otherwise it builds
46+
# from `src/llvm-project`.
47+
#
4548
# Set this to `"if-unchanged"` to download only if the llvm-project has not
4649
# been modified. You can also use this if you are unsure whether you're on a
4750
# tier 1 target. All tier 1 targets are currently supported.
@@ -236,7 +239,7 @@
236239
# Instead of downloading the src/stage0 version of cargo-clippy specified,
237240
# use this cargo-clippy binary instead as the stage0 snapshot cargo-clippy.
238241
#
239-
# Note that this option should be used with the same toolchain as the `rustc` option above.
242+
# Note that this option should be used with the same toolchain as the `rustc` option above.
240243
# Otherwise, clippy is likely to fail due to a toolchain conflict.
241244
#cargo-clippy = "/path/to/cargo-clippy"
242245

library/alloc/src/slice.rs

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ pub(crate) mod hack {
9696
// We shouldn't add inline attribute to this since this is used in
9797
// `vec!` macro mostly and causes perf regression. See #71204 for
9898
// discussion and perf results.
99+
#[allow(missing_docs)]
99100
pub fn into_vec<T, A: Allocator>(b: Box<[T], A>) -> Vec<T, A> {
100101
unsafe {
101102
let len = b.len();
@@ -105,6 +106,7 @@ pub(crate) mod hack {
105106
}
106107

107108
#[cfg(not(no_global_oom_handling))]
109+
#[allow(missing_docs)]
108110
#[inline]
109111
pub fn to_vec<T: ConvertVec, A: Allocator>(s: &[T], alloc: A) -> Vec<T, A> {
110112
T::to_vec(s, alloc)

library/alloc/src/string.rs

+1
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ impl String {
508508
// NB see the slice::hack module in slice.rs for more information
509509
#[inline]
510510
#[cfg(test)]
511+
#[allow(missing_docs)]
511512
pub fn from_str(_: &str) -> String {
512513
panic!("not available with cfg(test)");
513514
}

library/core/src/option.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1338,9 +1338,8 @@ impl<T> Option<T> {
13381338
/// assert_eq!(x.iter().next(), None);
13391339
/// ```
13401340
#[inline]
1341-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
13421341
#[stable(feature = "rust1", since = "1.0.0")]
1343-
pub const fn iter(&self) -> Iter<'_, T> {
1342+
pub fn iter(&self) -> Iter<'_, T> {
13441343
Iter { inner: Item { opt: self.as_ref() } }
13451344
}
13461345

library/std/src/io/buffered/bufreader.rs

+1
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ impl<R: ?Sized> BufReader<R> {
267267
// This is only used by a test which asserts that the initialization-tracking is correct.
268268
#[cfg(test)]
269269
impl<R: ?Sized> BufReader<R> {
270+
#[allow(missing_docs)]
270271
pub fn initialized(&self) -> usize {
271272
self.buf.initialized()
272273
}

src/bootstrap/defaults/config.compiler.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ assertions = false
2727
# Enable warnings during the LLVM compilation (when LLVM is changed, causing a compilation)
2828
enable-warnings = true
2929
# Will download LLVM from CI if available on your platform.
30-
download-ci-llvm = "if-unchanged"
30+
# If you intend to modify `src/llvm-project`, use `"if-unchanged"` or `false` instead.
31+
download-ci-llvm = true

src/bootstrap/src/core/config/config.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2781,7 +2781,8 @@ impl Config {
27812781
);
27822782
}
27832783

2784-
b
2784+
// If download-ci-llvm=true we also want to check that CI llvm is available
2785+
b && llvm::is_ci_llvm_available(self, asserts)
27852786
}
27862787
Some(StringOrBool::String(s)) if s == "if-unchanged" => if_unchanged(),
27872788
Some(StringOrBool::String(other)) => {

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
250250
severity: ChangeSeverity::Info,
251251
summary: "New option `llvm.enzyme` to control whether the llvm based autodiff tool (Enzyme) is built.",
252252
},
253+
ChangeInfo {
254+
change_id: 129473,
255+
severity: ChangeSeverity::Warning,
256+
summary: "`download-ci-llvm = true` now checks if CI llvm is available and has become the default for the compiler profile",
257+
},
253258
];

src/librustdoc/config.rs

+110-15
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,18 @@ impl TryFrom<&str> for OutputFormat {
5353
}
5454
}
5555

56+
/// Either an input crate, markdown file, or nothing (--merge=finalize).
57+
pub(crate) enum InputMode {
58+
/// The `--merge=finalize` step does not need an input crate to rustdoc.
59+
NoInputMergeFinalize,
60+
/// A crate or markdown file.
61+
HasFile(Input),
62+
}
63+
5664
/// Configuration options for rustdoc.
5765
#[derive(Clone)]
5866
pub(crate) struct Options {
5967
// Basic options / Options passed directly to rustc
60-
/// The crate root or Markdown file to load.
61-
pub(crate) input: Input,
6268
/// The name of the crate being documented.
6369
pub(crate) crate_name: Option<String>,
6470
/// Whether or not this is a bin crate
@@ -179,7 +185,6 @@ impl fmt::Debug for Options {
179185
}
180186

181187
f.debug_struct("Options")
182-
.field("input", &self.input.source_name())
183188
.field("crate_name", &self.crate_name)
184189
.field("bin_crate", &self.bin_crate)
185190
.field("proc_macro_crate", &self.proc_macro_crate)
@@ -289,6 +294,12 @@ pub(crate) struct RenderOptions {
289294
/// This field is only used for the JSON output. If it's set to true, no file will be created
290295
/// and content will be displayed in stdout directly.
291296
pub(crate) output_to_stdout: bool,
297+
/// Whether we should read or write rendered cross-crate info in the doc root.
298+
pub(crate) should_merge: ShouldMerge,
299+
/// Path to crate-info for external crates.
300+
pub(crate) include_parts_dir: Vec<PathToParts>,
301+
/// Where to write crate-info
302+
pub(crate) parts_out_dir: Option<PathToParts>,
292303
}
293304

294305
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@@ -348,7 +359,7 @@ impl Options {
348359
early_dcx: &mut EarlyDiagCtxt,
349360
matches: &getopts::Matches,
350361
args: Vec<String>,
351-
) -> Option<(Options, RenderOptions)> {
362+
) -> Option<(InputMode, Options, RenderOptions)> {
352363
// Check for unstable options.
353364
nightly_options::check_nightly_options(early_dcx, matches, &opts());
354365

@@ -478,22 +489,34 @@ impl Options {
478489
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(early_dcx, matches);
479490

480491
let input = if describe_lints {
481-
"" // dummy, this won't be used
492+
InputMode::HasFile(make_input(early_dcx, ""))
482493
} else {
483494
match matches.free.as_slice() {
495+
[] if matches.opt_str("merge").as_deref() == Some("finalize") => {
496+
InputMode::NoInputMergeFinalize
497+
}
484498
[] => dcx.fatal("missing file operand"),
485-
[input] => input,
499+
[input] => InputMode::HasFile(make_input(early_dcx, input)),
486500
_ => dcx.fatal("too many file operands"),
487501
}
488502
};
489-
let input = make_input(early_dcx, input);
490503

491504
let externs = parse_externs(early_dcx, matches, &unstable_opts);
492505
let extern_html_root_urls = match parse_extern_html_roots(matches) {
493506
Ok(ex) => ex,
494507
Err(err) => dcx.fatal(err),
495508
};
496509

510+
let parts_out_dir =
511+
match matches.opt_str("parts-out-dir").map(|p| PathToParts::from_flag(p)).transpose() {
512+
Ok(parts_out_dir) => parts_out_dir,
513+
Err(e) => dcx.fatal(e),
514+
};
515+
let include_parts_dir = match parse_include_parts_dir(matches) {
516+
Ok(include_parts_dir) => include_parts_dir,
517+
Err(e) => dcx.fatal(e),
518+
};
519+
497520
let default_settings: Vec<Vec<(String, String)>> = vec![
498521
matches
499522
.opt_str("default-theme")
@@ -735,6 +758,10 @@ impl Options {
735758
let extern_html_root_takes_precedence =
736759
matches.opt_present("extern-html-root-takes-precedence");
737760
let html_no_source = matches.opt_present("html-no-source");
761+
let should_merge = match parse_merge(matches) {
762+
Ok(result) => result,
763+
Err(e) => dcx.fatal(format!("--merge option error: {e}")),
764+
};
738765

739766
if generate_link_to_definition && (show_coverage || output_format != OutputFormat::Html) {
740767
dcx.struct_warn(
@@ -751,7 +778,6 @@ impl Options {
751778
let unstable_features =
752779
rustc_feature::UnstableFeatures::from_environment(crate_name.as_deref());
753780
let options = Options {
754-
input,
755781
bin_crate,
756782
proc_macro_crate,
757783
error_format,
@@ -823,16 +849,17 @@ impl Options {
823849
no_emit_shared: false,
824850
html_no_source,
825851
output_to_stdout,
852+
should_merge,
853+
include_parts_dir,
854+
parts_out_dir,
826855
};
827-
Some((options, render_options))
856+
Some((input, options, render_options))
828857
}
858+
}
829859

830-
/// Returns `true` if the file given as `self.input` is a Markdown file.
831-
pub(crate) fn markdown_input(&self) -> Option<&Path> {
832-
self.input
833-
.opt_path()
834-
.filter(|p| matches!(p.extension(), Some(e) if e == "md" || e == "markdown"))
835-
}
860+
/// Returns `true` if the file given as `self.input` is a Markdown file.
861+
pub(crate) fn markdown_input(input: &Input) -> Option<&Path> {
862+
input.opt_path().filter(|p| matches!(p.extension(), Some(e) if e == "md" || e == "markdown"))
836863
}
837864

838865
fn parse_remap_path_prefix(
@@ -900,3 +927,71 @@ fn parse_extern_html_roots(
900927
}
901928
Ok(externs)
902929
}
930+
931+
/// Path directly to crate-info file.
932+
///
933+
/// For example, `/home/user/project/target/doc.parts/<crate>/crate-info`.
934+
#[derive(Clone, Debug)]
935+
pub(crate) struct PathToParts(pub(crate) PathBuf);
936+
937+
impl PathToParts {
938+
fn from_flag(path: String) -> Result<PathToParts, String> {
939+
let mut path = PathBuf::from(path);
940+
// check here is for diagnostics
941+
if path.exists() && !path.is_dir() {
942+
Err(format!(
943+
"--parts-out-dir and --include-parts-dir expect directories, found: {}",
944+
path.display(),
945+
))
946+
} else {
947+
// if it doesn't exist, we'll create it. worry about that in write_shared
948+
path.push("crate-info");
949+
Ok(PathToParts(path))
950+
}
951+
}
952+
}
953+
954+
/// Reports error if --include-parts-dir / crate-info is not a file
955+
fn parse_include_parts_dir(m: &getopts::Matches) -> Result<Vec<PathToParts>, String> {
956+
let mut ret = Vec::new();
957+
for p in m.opt_strs("include-parts-dir") {
958+
let p = PathToParts::from_flag(p)?;
959+
// this is just for diagnostic
960+
if !p.0.is_file() {
961+
return Err(format!("--include-parts-dir expected {} to be a file", p.0.display()));
962+
}
963+
ret.push(p);
964+
}
965+
Ok(ret)
966+
}
967+
968+
/// Controls merging of cross-crate information
969+
#[derive(Debug, Clone)]
970+
pub(crate) struct ShouldMerge {
971+
/// Should we append to existing cci in the doc root
972+
pub(crate) read_rendered_cci: bool,
973+
/// Should we write cci to the doc root
974+
pub(crate) write_rendered_cci: bool,
975+
}
976+
977+
/// Extracts read_rendered_cci and write_rendered_cci from command line arguments, or
978+
/// reports an error if an invalid option was provided
979+
fn parse_merge(m: &getopts::Matches) -> Result<ShouldMerge, &'static str> {
980+
match m.opt_str("merge").as_deref() {
981+
// default = read-write
982+
None => Ok(ShouldMerge { read_rendered_cci: true, write_rendered_cci: true }),
983+
Some("none") if m.opt_present("include-parts-dir") => {
984+
Err("--include-parts-dir not allowed if --merge=none")
985+
}
986+
Some("none") => Ok(ShouldMerge { read_rendered_cci: false, write_rendered_cci: false }),
987+
Some("shared") if m.opt_present("parts-out-dir") || m.opt_present("include-parts-dir") => {
988+
Err("--parts-out-dir and --include-parts-dir not allowed if --merge=shared")
989+
}
990+
Some("shared") => Ok(ShouldMerge { read_rendered_cci: true, write_rendered_cci: true }),
991+
Some("finalize") if m.opt_present("parts-out-dir") => {
992+
Err("--parts-out-dir not allowed if --merge=finalize")
993+
}
994+
Some("finalize") => Ok(ShouldMerge { read_rendered_cci: false, write_rendered_cci: true }),
995+
Some(_) => Err("argument to --merge must be `none`, `shared`, or `finalize`"),
996+
}
997+
}

src/librustdoc/core.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_interface::interface;
2020
use rustc_lint::{late_lint_mod, MissingDoc};
2121
use rustc_middle::hir::nested_filter;
2222
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
23-
use rustc_session::config::{self, CrateType, ErrorOutputType, ResolveDocLinks};
23+
use rustc_session::config::{self, CrateType, ErrorOutputType, Input, ResolveDocLinks};
2424
pub(crate) use rustc_session::config::{Options, UnstableOptions};
2525
use rustc_session::{lint, Session};
2626
use rustc_span::symbol::sym;
@@ -177,8 +177,8 @@ pub(crate) fn new_dcx(
177177

178178
/// Parse, resolve, and typecheck the given crate.
179179
pub(crate) fn create_config(
180+
input: Input,
180181
RustdocOptions {
181-
input,
182182
crate_name,
183183
proc_macro_crate,
184184
error_format,

0 commit comments

Comments
 (0)