Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #130100

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
893413d
Add a run-make test for checking that certain `rustc_` crates build o…
Kobzol Aug 24, 2024
7957140
inhibit proc-macro2 nightly detection
lqd Aug 24, 2024
d9794a9
run test in tmp dir and emit artifacts there
lqd Aug 24, 2024
2190c28
remove use of RUSTC_BOOTSTRAP and cargo nightly features
lqd Aug 25, 2024
0577035
separate the crates to test from the test setup
lqd Aug 25, 2024
f1df0c5
remove unneeded type ascription
lqd Aug 25, 2024
a178559
address review comments
lqd Sep 2, 2024
7dd1be1
Also emit `missing_docs` lint with `--test` to fulfill expectations
Urgau Sep 6, 2024
f6d2cfc
Add missing `#[allow(missing_docs)]` on hack functions in alloc
Urgau Sep 6, 2024
ae661dd
Don't emit `missing_docs` lint with dummy spans
Urgau Sep 6, 2024
5f367bb
Make `download-ci-llvm = true` check if CI llvm is available
Urgau Aug 23, 2024
c0b0627
Rename variant `AddrOfRegion` of `RegionVariableOrigin` to `BorrowReg…
gurry Sep 7, 2024
f7d4da6
remove 'const' from 'Option::iter'
RalfJung Sep 7, 2024
cfe85a3
Fixes typo in wasm32-wasip2 doc comment
zslayton Sep 7, 2024
3782251
librustdoc::config: removed Input from Options
EtomicBomb Aug 27, 2024
2e1cba6
rfc#3662 changes under unstable flags
EtomicBomb Aug 20, 2024
548b6e1
add tests for behavior in rfc#3662
EtomicBomb Sep 7, 2024
0106b27
Rollup merge of #129337 - EtomicBomb:rfc, r=notriddle
matthiaskrgr Sep 8, 2024
fc87247
Rollup merge of #129473 - Urgau:fix-llvm-if-unchanged, r=onur-ozkan
matthiaskrgr Sep 8, 2024
2f82550
Rollup merge of #129529 - lqd:stable-new-solver, r=Kobzol
matthiaskrgr Sep 8, 2024
5f12177
Rollup merge of #130025 - Urgau:missing_docs-expect, r=petrochenkov
matthiaskrgr Sep 8, 2024
8940640
Rollup merge of #130070 - gurry:rename-regionkind-addof-to-ref, r=com…
matthiaskrgr Sep 8, 2024
1157f40
Rollup merge of #130087 - RalfJung:option-const-iter, r=workingjubilee
matthiaskrgr Sep 8, 2024
e4f8824
Rollup merge of #130092 - zslayton:master, r=jieyouxu
matthiaskrgr Sep 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// this time with enough precision to check that the value
// whose address was taken can actually be made to live as long
// as it needs to live.
let region = self.next_region_var(infer::AddrOfRegion(expr.span));
let region = self.next_region_var(infer::BorrowRegion(expr.span));
Ty::new_ref(self.tcx, region, ty, mutbl)
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ pub enum RegionVariableOrigin {
PatternRegion(Span),

/// Regions created by `&` operator.
///
AddrOfRegion(Span),
BorrowRegion(Span),

/// Regions created as part of an autoref of a method receiver.
Autoref(Span),

Expand Down Expand Up @@ -1741,7 +1741,7 @@ impl RegionVariableOrigin {
match *self {
MiscVariable(a)
| PatternRegion(a)
| AddrOfRegion(a)
| BorrowRegion(a)
| Autoref(a)
| Coercion(a)
| RegionParameterDefinition(a, ..)
Expand Down
15 changes: 4 additions & 11 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,6 @@ impl MissingDoc {
article: &'static str,
desc: &'static str,
) {
// If we're building a test harness, then warning about
// documentation is probably not really relevant right now.
if cx.sess().opts.test {
return;
}

// Only check publicly-visible items, using the result from the privacy pass.
// It's an option so the crate root can also use this function (it doesn't
// have a `NodeId`).
Expand All @@ -444,11 +438,10 @@ impl MissingDoc {
let attrs = cx.tcx.hir().attrs(cx.tcx.local_def_id_to_hir_id(def_id));
let has_doc = attrs.iter().any(has_doc);
if !has_doc {
cx.emit_span_lint(
MISSING_DOCS,
cx.tcx.def_span(def_id),
BuiltinMissingDoc { article, desc },
);
let sp = cx.tcx.def_span(def_id);
if !sp.is_dummy() {
cx.emit_span_lint(MISSING_DOCS, sp, BuiltinMissingDoc { article, desc });
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The `wasm32-wasip2` target is the next evolution of the
//! wasm32-wasi target. While the wasi specification is still under
//! active development, the {review 2 iteration is considered an "island
//! active development, the preview 2 iteration is considered an "island
//! of stability" that should allow users to rely on it indefinitely.
//!
//! The `wasi` target is a proposal to define a standardized set of WebAssembly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let var_description = match var_origin {
infer::MiscVariable(_) => String::new(),
infer::PatternRegion(_) => " for pattern".to_string(),
infer::AddrOfRegion(_) => " for borrow expression".to_string(),
infer::BorrowRegion(_) => " for borrow expression".to_string(),
infer::Autoref(_) => " for autoref".to_string(),
infer::Coercion(_) => " for automatic coercion".to_string(),
infer::BoundRegion(_, br, infer::FnCall) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_type_ir/src/elaborate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub fn supertrait_def_ids<I: Interner>(
cx: I,
trait_def_id: I::DefId,
) -> impl Iterator<Item = I::DefId> {
let mut set: HashSet<I::DefId> = HashSet::default();
let mut set = HashSet::default();
let mut stack = vec![trait_def_id];

set.insert(trait_def_id);
Expand Down
5 changes: 4 additions & 1 deletion config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
# Unless you're developing for a target where Rust CI doesn't build a compiler
# toolchain or changing LLVM locally, you probably want to leave this enabled.
#
# Set this to `true` to download if CI llvm available otherwise it builds
# from `src/llvm-project`.
#
# Set this to `"if-unchanged"` to download only if the llvm-project has not
# been modified. You can also use this if you are unsure whether you're on a
# tier 1 target. All tier 1 targets are currently supported.
Expand Down Expand Up @@ -236,7 +239,7 @@
# Instead of downloading the src/stage0 version of cargo-clippy specified,
# use this cargo-clippy binary instead as the stage0 snapshot cargo-clippy.
#
# Note that this option should be used with the same toolchain as the `rustc` option above.
# Note that this option should be used with the same toolchain as the `rustc` option above.
# Otherwise, clippy is likely to fail due to a toolchain conflict.
#cargo-clippy = "/path/to/cargo-clippy"

Expand Down
2 changes: 2 additions & 0 deletions library/alloc/src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub(crate) mod hack {
// We shouldn't add inline attribute to this since this is used in
// `vec!` macro mostly and causes perf regression. See #71204 for
// discussion and perf results.
#[allow(missing_docs)]
pub fn into_vec<T, A: Allocator>(b: Box<[T], A>) -> Vec<T, A> {
unsafe {
let len = b.len();
Expand All @@ -105,6 +106,7 @@ pub(crate) mod hack {
}

#[cfg(not(no_global_oom_handling))]
#[allow(missing_docs)]
#[inline]
pub fn to_vec<T: ConvertVec, A: Allocator>(s: &[T], alloc: A) -> Vec<T, A> {
T::to_vec(s, alloc)
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ impl String {
// NB see the slice::hack module in slice.rs for more information
#[inline]
#[cfg(test)]
#[allow(missing_docs)]
pub fn from_str(_: &str) -> String {
panic!("not available with cfg(test)");
}
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,9 +1338,8 @@ impl<T> Option<T> {
/// assert_eq!(x.iter().next(), None);
/// ```
#[inline]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[stable(feature = "rust1", since = "1.0.0")]
pub const fn iter(&self) -> Iter<'_, T> {
pub fn iter(&self) -> Iter<'_, T> {
Iter { inner: Item { opt: self.as_ref() } }
}

Expand Down
1 change: 1 addition & 0 deletions library/std/src/io/buffered/bufreader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ impl<R: ?Sized> BufReader<R> {
// This is only used by a test which asserts that the initialization-tracking is correct.
#[cfg(test)]
impl<R: ?Sized> BufReader<R> {
#[allow(missing_docs)]
pub fn initialized(&self) -> usize {
self.buf.initialized()
}
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/defaults/config.compiler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ assertions = false
# Enable warnings during the LLVM compilation (when LLVM is changed, causing a compilation)
enable-warnings = true
# Will download LLVM from CI if available on your platform.
download-ci-llvm = "if-unchanged"
# If you intend to modify `src/llvm-project`, use `"if-unchanged"` or `false` instead.
download-ci-llvm = true
3 changes: 2 additions & 1 deletion src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2781,7 +2781,8 @@ impl Config {
);
}

b
// If download-ci-llvm=true we also want to check that CI llvm is available
b && llvm::is_ci_llvm_available(self, asserts)
}
Some(StringOrBool::String(s)) if s == "if-unchanged" => if_unchanged(),
Some(StringOrBool::String(other)) => {
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/src/utils/change_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
severity: ChangeSeverity::Info,
summary: "New option `llvm.enzyme` to control whether the llvm based autodiff tool (Enzyme) is built.",
},
ChangeInfo {
change_id: 129473,
severity: ChangeSeverity::Warning,
summary: "`download-ci-llvm = true` now checks if CI llvm is available and has become the default for the compiler profile",
},
];
125 changes: 110 additions & 15 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ impl TryFrom<&str> for OutputFormat {
}
}

/// Either an input crate, markdown file, or nothing (--merge=finalize).
pub(crate) enum InputMode {
/// The `--merge=finalize` step does not need an input crate to rustdoc.
NoInputMergeFinalize,
/// A crate or markdown file.
HasFile(Input),
}

/// Configuration options for rustdoc.
#[derive(Clone)]
pub(crate) struct Options {
// Basic options / Options passed directly to rustc
/// The crate root or Markdown file to load.
pub(crate) input: Input,
/// The name of the crate being documented.
pub(crate) crate_name: Option<String>,
/// Whether or not this is a bin crate
Expand Down Expand Up @@ -179,7 +185,6 @@ impl fmt::Debug for Options {
}

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

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -348,7 +359,7 @@ impl Options {
early_dcx: &mut EarlyDiagCtxt,
matches: &getopts::Matches,
args: Vec<String>,
) -> Option<(Options, RenderOptions)> {
) -> Option<(InputMode, Options, RenderOptions)> {
// Check for unstable options.
nightly_options::check_nightly_options(early_dcx, matches, &opts());

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

let input = if describe_lints {
"" // dummy, this won't be used
InputMode::HasFile(make_input(early_dcx, ""))
} else {
match matches.free.as_slice() {
[] if matches.opt_str("merge").as_deref() == Some("finalize") => {
InputMode::NoInputMergeFinalize
}
[] => dcx.fatal("missing file operand"),
[input] => input,
[input] => InputMode::HasFile(make_input(early_dcx, input)),
_ => dcx.fatal("too many file operands"),
}
};
let input = make_input(early_dcx, input);

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

let parts_out_dir =
match matches.opt_str("parts-out-dir").map(|p| PathToParts::from_flag(p)).transpose() {
Ok(parts_out_dir) => parts_out_dir,
Err(e) => dcx.fatal(e),
};
let include_parts_dir = match parse_include_parts_dir(matches) {
Ok(include_parts_dir) => include_parts_dir,
Err(e) => dcx.fatal(e),
};

let default_settings: Vec<Vec<(String, String)>> = vec![
matches
.opt_str("default-theme")
Expand Down Expand Up @@ -735,6 +758,10 @@ impl Options {
let extern_html_root_takes_precedence =
matches.opt_present("extern-html-root-takes-precedence");
let html_no_source = matches.opt_present("html-no-source");
let should_merge = match parse_merge(matches) {
Ok(result) => result,
Err(e) => dcx.fatal(format!("--merge option error: {e}")),
};

if generate_link_to_definition && (show_coverage || output_format != OutputFormat::Html) {
dcx.struct_warn(
Expand All @@ -751,7 +778,6 @@ impl Options {
let unstable_features =
rustc_feature::UnstableFeatures::from_environment(crate_name.as_deref());
let options = Options {
input,
bin_crate,
proc_macro_crate,
error_format,
Expand Down Expand Up @@ -823,16 +849,17 @@ impl Options {
no_emit_shared: false,
html_no_source,
output_to_stdout,
should_merge,
include_parts_dir,
parts_out_dir,
};
Some((options, render_options))
Some((input, options, render_options))
}
}

/// Returns `true` if the file given as `self.input` is a Markdown file.
pub(crate) fn markdown_input(&self) -> Option<&Path> {
self.input
.opt_path()
.filter(|p| matches!(p.extension(), Some(e) if e == "md" || e == "markdown"))
}
/// Returns `true` if the file given as `self.input` is a Markdown file.
pub(crate) fn markdown_input(input: &Input) -> Option<&Path> {
input.opt_path().filter(|p| matches!(p.extension(), Some(e) if e == "md" || e == "markdown"))
}

fn parse_remap_path_prefix(
Expand Down Expand Up @@ -900,3 +927,71 @@ fn parse_extern_html_roots(
}
Ok(externs)
}

/// Path directly to crate-info file.
///
/// For example, `/home/user/project/target/doc.parts/<crate>/crate-info`.
#[derive(Clone, Debug)]
pub(crate) struct PathToParts(pub(crate) PathBuf);

impl PathToParts {
fn from_flag(path: String) -> Result<PathToParts, String> {
let mut path = PathBuf::from(path);
// check here is for diagnostics
if path.exists() && !path.is_dir() {
Err(format!(
"--parts-out-dir and --include-parts-dir expect directories, found: {}",
path.display(),
))
} else {
// if it doesn't exist, we'll create it. worry about that in write_shared
path.push("crate-info");
Ok(PathToParts(path))
}
}
}

/// Reports error if --include-parts-dir / crate-info is not a file
fn parse_include_parts_dir(m: &getopts::Matches) -> Result<Vec<PathToParts>, String> {
let mut ret = Vec::new();
for p in m.opt_strs("include-parts-dir") {
let p = PathToParts::from_flag(p)?;
// this is just for diagnostic
if !p.0.is_file() {
return Err(format!("--include-parts-dir expected {} to be a file", p.0.display()));
}
ret.push(p);
}
Ok(ret)
}

/// Controls merging of cross-crate information
#[derive(Debug, Clone)]
pub(crate) struct ShouldMerge {
/// Should we append to existing cci in the doc root
pub(crate) read_rendered_cci: bool,
/// Should we write cci to the doc root
pub(crate) write_rendered_cci: bool,
}

/// Extracts read_rendered_cci and write_rendered_cci from command line arguments, or
/// reports an error if an invalid option was provided
fn parse_merge(m: &getopts::Matches) -> Result<ShouldMerge, &'static str> {
match m.opt_str("merge").as_deref() {
// default = read-write
None => Ok(ShouldMerge { read_rendered_cci: true, write_rendered_cci: true }),
Some("none") if m.opt_present("include-parts-dir") => {
Err("--include-parts-dir not allowed if --merge=none")
}
Some("none") => Ok(ShouldMerge { read_rendered_cci: false, write_rendered_cci: false }),
Some("shared") if m.opt_present("parts-out-dir") || m.opt_present("include-parts-dir") => {
Err("--parts-out-dir and --include-parts-dir not allowed if --merge=shared")
}
Some("shared") => Ok(ShouldMerge { read_rendered_cci: true, write_rendered_cci: true }),
Some("finalize") if m.opt_present("parts-out-dir") => {
Err("--parts-out-dir not allowed if --merge=finalize")
}
Some("finalize") => Ok(ShouldMerge { read_rendered_cci: false, write_rendered_cci: true }),
Some(_) => Err("argument to --merge must be `none`, `shared`, or `finalize`"),
}
}
4 changes: 2 additions & 2 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rustc_interface::interface;
use rustc_lint::{late_lint_mod, MissingDoc};
use rustc_middle::hir::nested_filter;
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
use rustc_session::config::{self, CrateType, ErrorOutputType, ResolveDocLinks};
use rustc_session::config::{self, CrateType, ErrorOutputType, Input, ResolveDocLinks};
pub(crate) use rustc_session::config::{Options, UnstableOptions};
use rustc_session::{lint, Session};
use rustc_span::symbol::sym;
Expand Down Expand Up @@ -177,8 +177,8 @@ pub(crate) fn new_dcx(

/// Parse, resolve, and typecheck the given crate.
pub(crate) fn create_config(
input: Input,
RustdocOptions {
input,
crate_name,
proc_macro_crate,
error_format,
Expand Down
Loading
Loading