Skip to content

Commit 8f429c5

Browse files
committed
Auto merge of rust-lang#130109 - matthiaskrgr:rollup-tnuoj7e, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#129473 (use `download-ci-llvm=true` in the default compiler config) - rust-lang#129529 (Add test to build crates used by r-a on stable) - rust-lang#130025 (Also emit `missing_docs` lint with `--test` to fulfil expectations) - rust-lang#130048 (run-make-support: Add llvm-pdbutil) - rust-lang#130070 (Rename variant `AddrOfRegion` of `RegionVariableOrigin` to `BorrowRegion`) - rust-lang#130087 (remove 'const' from 'Option::iter') - rust-lang#130092 (Fixes typo in wasm32-wasip2 doc comment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents adf8d16 + d4e2ba4 commit 8f429c5

File tree

21 files changed

+118
-26
lines changed

21 files changed

+118
-26
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
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use crate::command::Command;
2+
use crate::env_var;
3+
4+
/// Returns a command that can be used to invoke Cargo.
5+
pub fn cargo() -> Command {
6+
Command::new(env_var("BOOTSTRAP_CARGO"))
7+
}

src/tools/run-make-support/src/external_deps/llvm.rs

+24
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ pub struct LlvmDwarfdump {
110110
cmd: Command,
111111
}
112112

113+
/// A `llvm-pdbutil` invocation builder.
114+
#[derive(Debug)]
115+
#[must_use]
116+
pub struct LlvmPdbutil {
117+
cmd: Command,
118+
}
119+
113120
crate::macros::impl_common_helpers!(LlvmReadobj);
114121
crate::macros::impl_common_helpers!(LlvmProfdata);
115122
crate::macros::impl_common_helpers!(LlvmFilecheck);
@@ -118,6 +125,7 @@ crate::macros::impl_common_helpers!(LlvmAr);
118125
crate::macros::impl_common_helpers!(LlvmNm);
119126
crate::macros::impl_common_helpers!(LlvmBcanalyzer);
120127
crate::macros::impl_common_helpers!(LlvmDwarfdump);
128+
crate::macros::impl_common_helpers!(LlvmPdbutil);
121129

122130
/// Generate the path to the bin directory of LLVM.
123131
#[must_use]
@@ -360,3 +368,19 @@ impl LlvmDwarfdump {
360368
self
361369
}
362370
}
371+
372+
impl LlvmPdbutil {
373+
/// Construct a new `llvm-pdbutil` invocation. This assumes that `llvm-pdbutil` is available
374+
/// at `$LLVM_BIN_DIR/llvm-pdbutil`.
375+
pub fn new() -> Self {
376+
let llvm_pdbutil = llvm_bin_dir().join("llvm-pdbutil");
377+
let cmd = Command::new(llvm_pdbutil);
378+
Self { cmd }
379+
}
380+
381+
/// Provide an input file.
382+
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
383+
self.cmd.arg(path.as_ref());
384+
self
385+
}
386+
}

src/tools/run-make-support/src/external_deps/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! such as `cc` or `python`.
33
44
pub mod c_build;
5+
pub mod cargo;
56
pub mod cc;
67
pub mod clang;
78
pub mod htmldocck;

src/tools/run-make-support/src/external_deps/rustc.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ pub struct Rustc {
3636

3737
crate::macros::impl_common_helpers!(Rustc);
3838

39+
pub fn rustc_path() -> String {
40+
env_var("RUSTC")
41+
}
42+
3943
#[track_caller]
4044
fn setup_common() -> Command {
41-
let rustc = env_var("RUSTC");
42-
let mut cmd = Command::new(rustc);
45+
let mut cmd = Command::new(rustc_path());
4346
set_host_rpath(&mut cmd);
4447
cmd
4548
}

src/tools/run-make-support/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub use external_deps::{c_build, cc, clang, htmldocck, llvm, python, rustc, rust
5050
// These rely on external dependencies.
5151
pub use cc::{cc, cxx, extra_c_flags, extra_cxx_flags, Cc};
5252
pub use c_build::{build_native_dynamic_lib, build_native_static_lib, build_native_static_lib_optimized, build_native_static_lib_cxx};
53+
pub use cargo::cargo;
5354
pub use clang::{clang, Clang};
5455
pub use htmldocck::htmldocck;
5556
pub use llvm::{
@@ -58,7 +59,7 @@ pub use llvm::{
5859
LlvmProfdata, LlvmReadobj,
5960
};
6061
pub use python::python_command;
61-
pub use rustc::{aux_build, bare_rustc, rustc, Rustc};
62+
pub use rustc::{aux_build, bare_rustc, rustc, rustc_path, Rustc};
6263
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
6364

6465
/// [`diff`][mod@diff] is implemented in terms of the [similar] library.
@@ -98,3 +99,4 @@ pub use assertion_helpers::{
9899
pub use string::{
99100
count_regex_matches_in_files_with_extension, invalid_utf8_contains, invalid_utf8_not_contains,
100101
};
102+
use crate::external_deps::cargo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//! Checks if selected rustc crates can be compiled on the stable channel (or a "simulation" of it).
2+
//! These crates are designed to be used by downstream users.
3+
4+
use run_make_support::{cargo, rustc_path, source_root};
5+
6+
fn main() {
7+
// Use the stage0 beta cargo for the compilation (it shouldn't really matter which cargo we use)
8+
cargo()
9+
// Ensure `proc-macro2`'s nightly detection is disabled
10+
.env("RUSTC_STAGE", "0")
11+
.env("RUSTC", rustc_path())
12+
// We want to disallow all nightly features to simulate a stable build
13+
.env("RUSTFLAGS", "-Zallow-features=")
14+
.arg("build")
15+
.arg("--manifest-path")
16+
.arg(source_root().join("Cargo.toml"))
17+
.args(&[
18+
// Avoid depending on transitive rustc crates
19+
"--no-default-features",
20+
// Emit artifacts in this temporary directory, not in the source_root's `target` folder
21+
"--target-dir",
22+
"target",
23+
])
24+
// Check that these crates can be compiled on "stable"
25+
.args(&[
26+
"-p",
27+
"rustc_type_ir",
28+
"-p",
29+
"rustc_next_trait_solver",
30+
"-p",
31+
"rustc_pattern_analysis",
32+
"-p",
33+
"rustc_lexer",
34+
])
35+
.run();
36+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Make sure that `#[expect(missing_docs)]` is always correctly fulfilled.
2+
3+
//@ check-pass
4+
//@ revisions: lib bin test
5+
//@ [lib]compile-flags: --crate-type lib
6+
//@ [bin]compile-flags: --crate-type bin
7+
//@ [test]compile-flags: --test
8+
9+
#[expect(missing_docs)]
10+
pub fn foo() {}
11+
12+
#[cfg(bin)]
13+
fn main() {}

0 commit comments

Comments
 (0)