Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
c1b51dd
In `Option::get_or_insert_with()`, forget the `None` instead of dropp…
kpreid Nov 6, 2025
438b126
rustdoc: don't give depreciation notes special handling
lolbinarycat Dec 12, 2025
342ad04
ast_passes: unsupported arch w/ scalable vectors
davidtwco Mar 9, 2026
2c7690e
Mark stable features as used to avoid trigger unused_features
mu001999 Mar 9, 2026
dfd5e90
Bless other tests
mu001999 Mar 9, 2026
28131e1
Update `sysinfo` version to `0.38.4`
GuillaumeGomez Mar 9, 2026
db5599b
Update books
rustbot Mar 9, 2026
c5c8d6b
Ping fmease on parser modifications
fmease Mar 9, 2026
744c503
Add missing `Diag::with_span_suggestion_with_style` method
GuillaumeGomez Mar 9, 2026
a4a37ed
Use `Diag::with_span_suggestion_with_style` method in librustdoc
GuillaumeGomez Mar 9, 2026
cef2175
Rollup merge of #148562 - kpreid:get-init-drop, r=oli-obk
matthiaskrgr Mar 9, 2026
51a9639
Rollup merge of #149931 - lolbinarycat:rustdoc-depr-html-future, r=Gu…
matthiaskrgr Mar 9, 2026
2a4bf0f
Rollup merge of #153608 - davidtwco:sve-unsupported-architecture, r=lqd
matthiaskrgr Mar 9, 2026
a4a57a2
Rollup merge of #153609 - GuillaumeGomez:with_span_suggestion_with_st…
matthiaskrgr Mar 9, 2026
2ffeb9b
Rollup merge of #153610 - mu001999-contrib:fix/unused-stable-features…
matthiaskrgr Mar 9, 2026
1f3b35c
Rollup merge of #153616 - GuillaumeGomez:update-sysinfo, r=lqd
matthiaskrgr Mar 9, 2026
161d75b
Rollup merge of #153619 - rustbot:docs-update, r=ehuss
matthiaskrgr Mar 9, 2026
3c27dde
Rollup merge of #153624 - fmease:ping-me-on-parser-changes, r=fmease
matthiaskrgr Mar 9, 2026
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
12 changes: 6 additions & 6 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2622,9 +2622,9 @@ dependencies = [

[[package]]
name = "objc2-core-foundation"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166"
checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
dependencies = [
"bitflags",
]
Expand All @@ -2637,9 +2637,9 @@ checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"

[[package]]
name = "objc2-io-kit"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71c1c64d6120e51cd86033f67176b1cb66780c2efe34dec55176f77befd93c0a"
checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"
dependencies = [
"libc",
"objc2-core-foundation",
Expand Down Expand Up @@ -5315,9 +5315,9 @@ dependencies = [

[[package]]
name = "sysinfo"
version = "0.38.2"
version = "0.38.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efc19935b4b66baa6f654ac7924c192f55b175c00a7ab72410fc24284dacda8"
checksum = "92ab6a2f8bfe508deb3c6406578252e491d299cbbf3bc0529ecc3313aee4a52f"
dependencies = [
"libc",
"objc2-core-foundation",
Expand Down
15 changes: 10 additions & 5 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1371,11 +1371,16 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
ItemKind::Struct(ident, generics, vdata) => {
self.with_tilde_const(Some(TildeConstReason::Struct { span: item.span }), |this| {
// Scalable vectors can only be tuple structs
let is_scalable_vector =
item.attrs.iter().any(|attr| attr.has_name(sym::rustc_scalable_vector));
if is_scalable_vector && !matches!(vdata, VariantData::Tuple(..)) {
this.dcx()
.emit_err(errors::ScalableVectorNotTupleStruct { span: item.span });
let scalable_vector_attr =
item.attrs.iter().find(|attr| attr.has_name(sym::rustc_scalable_vector));
if let Some(attr) = scalable_vector_attr {
if !matches!(vdata, VariantData::Tuple(..)) {
this.dcx()
.emit_err(errors::ScalableVectorNotTupleStruct { span: item.span });
}
if !self.sess.target.arch.supports_scalable_vectors() {
this.dcx().emit_err(errors::ScalableVectorBadArch { span: attr.span });
}
}

match vdata {
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,3 +1133,10 @@ pub(crate) struct ScalableVectorNotTupleStruct {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("scalable vectors are not supported on this architecture")]
pub(crate) struct ScalableVectorBadArch {
#[primary_span]
pub span: Span,
}
3 changes: 2 additions & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self
} }

with_fn! { with_span_suggestion_with_style,
/// [`Diag::span_suggestion()`] but you can set the [`SuggestionStyle`].
pub fn span_suggestion_with_style(
&mut self,
Expand All @@ -956,7 +957,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
applicability,
});
self
}
} }

with_fn! { with_span_suggestion_verbose,
/// Always show the suggested change.
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,9 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
let mut lang_features = UnordSet::default();
for EnabledLangFeature { gate_name, attr_sp, stable_since } in enabled_lang_features {
if let Some(version) = stable_since {
// Mark the feature as enabled, to ensure that it is not marked as unused.
let _ = tcx.features().enabled(*gate_name);

// Warn if the user has enabled an already-stable lang feature.
unnecessary_stable_feature_lint(tcx, *attr_sp, *gate_name, *version);
}
Expand Down Expand Up @@ -1021,6 +1024,9 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
if let FeatureStability::AcceptedSince(since) = stability
&& let Some(span) = remaining_lib_features.get(&feature)
{
// Mark the feature as enabled, to ensure that it is not marked as unused.
let _ = tcx.features().enabled(feature);

// Warn if the user has enabled an already-stable lib feature.
if let Some(implies) = all_implications.get(&feature) {
unnecessary_partially_stable_feature_lint(tcx, *span, feature, *implies, since);
Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,19 @@ impl Arch {
| X86_64 | Xtensa => true,
}
}

/// Whether `#[rustc_scalable_vector]` is supported for a target architecture
pub fn supports_scalable_vectors(&self) -> bool {
use Arch::*;

match self {
AArch64 | RiscV32 | RiscV64 => true,
AmdGpu | Arm | Arm64EC | Avr | Bpf | CSky | Hexagon | LoongArch32 | LoongArch64
| M68k | Mips | Mips32r6 | Mips64 | Mips64r6 | Msp430 | Nvptx64 | PowerPC
| PowerPC64 | S390x | Sparc | Sparc64 | SpirV | Wasm32 | Wasm64 | X86 | X86_64
| Xtensa | Other(_) => false,
}
}
}

crate::target_spec_enum! {
Expand Down
21 changes: 18 additions & 3 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ impl<T> Option<T> {
#[rustc_const_unstable(feature = "const_option_ops", issue = "143956")]
pub const fn get_or_insert_default(&mut self) -> &mut T
where
T: [const] Default + [const] Destruct,
T: [const] Default,
{
self.get_or_insert_with(T::default)
}
Expand Down Expand Up @@ -1805,10 +1805,25 @@ impl<T> Option<T> {
pub const fn get_or_insert_with<F>(&mut self, f: F) -> &mut T
where
F: [const] FnOnce() -> T + [const] Destruct,
T: [const] Destruct,
{
if let None = self {
*self = Some(f());
// The effect of the following statement is identical to
// *self = Some(f());
// except that it does not drop the old value of `*self`. This is not a leak, because
// we just checked that the old value is `None`, which contains no fields to drop.
// This implementation strategy
//
// * avoids needing a `T: [const] Destruct` bound, to the benefit of `const` callers,
// * and avoids possibly compiling needless drop code (as would sometimes happen in the
// previous implementation), to the benefit of non-`const` callers.
//
// FIXME(const-hack): It would be nice if this weird trick were made obsolete
// (though that is likely to be hard/wontfix).
//
// It could also be expressed as `unsafe { core::ptr::write(self, Some(f())) }`, but
// no reason is currently known to use additional unsafe code here.

mem::forget(mem::replace(self, Some(f())));
}

// SAFETY: a `None` variant for `self` would have been replaced by a `Some`
Expand Down
24 changes: 24 additions & 0 deletions library/coretests/tests/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,30 @@ const fn option_const_mut() {
*/
}

/// Test that `Option::get_or_insert_default` is usable in const contexts, including with types that
/// do not satisfy `T: const Destruct`.
#[test]
fn const_get_or_insert_default() {
const OPT_DEFAULT: Option<Vec<bool>> = {
let mut x = None;
x.get_or_insert_default();
x
};
assert!(OPT_DEFAULT.is_some());
}

/// Test that `Option::get_or_insert_with` is usable in const contexts, including with types that
/// do not satisfy `T: const Destruct`.
#[test]
fn const_get_or_insert_with() {
const OPT_WITH: Option<Vec<bool>> = {
let mut x = None;
x.get_or_insert_with(Vec::new);
x
};
assert!(OPT_WITH.is_some());
}

#[test]
fn test_unwrap_drop() {
struct Dtor<'a> {
Expand Down
12 changes: 6 additions & 6 deletions src/bootstrap/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -472,18 +472,18 @@ dependencies = [

[[package]]
name = "objc2-core-foundation"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166"
checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
dependencies = [
"bitflags",
]

[[package]]
name = "objc2-io-kit"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71c1c64d6120e51cd86033f67176b1cb66780c2efe34dec55176f77befd93c0a"
checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"
dependencies = [
"libc",
"objc2-core-foundation",
Expand Down Expand Up @@ -743,9 +743,9 @@ dependencies = [

[[package]]
name = "sysinfo"
version = "0.38.2"
version = "0.38.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efc19935b4b66baa6f654ac7924c192f55b175c00a7ab72410fc24284dacda8"
checksum = "92ab6a2f8bfe508deb3c6406578252e491d299cbbf3bc0529ecc3313aee4a52f"
dependencies = [
"libc",
"memchr",
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ walkdir = "2.4"
xz2 = "0.1"

# Dependencies needed by the build-metrics feature
sysinfo = { version = "0.38.2", default-features = false, optional = true, features = ["system"] }
sysinfo = { version = "0.38.4", default-features = false, optional = true, features = ["system"] }

# Dependencies needed by the `tracing` feature
chrono = { version = "0.4", default-features = false, optional = true, features = ["now", "std"] }
Expand Down
2 changes: 1 addition & 1 deletion src/doc/nomicon
12 changes: 7 additions & 5 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,15 @@ pub(crate) struct MarkdownWithToc<'a> {
pub(crate) edition: Edition,
pub(crate) playground: &'a Option<Playground>,
}
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags

/// A struct like `Markdown` that renders the markdown escaping HTML tags
/// and includes no paragraph tags.
pub(crate) struct MarkdownItemInfo<'a> {
pub(crate) content: &'a str,
pub(crate) links: &'a [RenderedLink],
pub(crate) ids: &'a mut IdMap,
}

/// A tuple struct like `Markdown` that renders only the first paragraph.
pub(crate) struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]);

Expand Down Expand Up @@ -1490,10 +1492,10 @@ impl<'a> MarkdownItemInfo<'a> {
let p = SpannedLinkReplacer::new(p, links);
let p = footnotes::Footnotes::new(p, existing_footnotes);
let p = TableWrapper::new(p.map(|(ev, _)| ev));
let p = p.filter(|event| {
!matches!(event, Event::Start(Tag::Paragraph) | Event::End(TagEnd::Paragraph))
});
html::write_html_fmt(&mut f, p)
// in legacy wrap mode, strip <p> elements to avoid them inserting newlines
html::write_html_fmt(&mut f, p)?;

Ok(())
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ fn test_markdown_html_escape() {
let mut idmap = IdMap::new();
let mut output = String::new();
MarkdownItemInfo::new(input, &[], &mut idmap).write_into(&mut output).unwrap();
assert_eq!(output, expect, "original: {}", input);
assert_eq!(output, format!("<p>{}</p>\n", expect), "original: {}", input);
}

t("`Struct<'a, T>`", "<code>Struct&lt;'a, T&gt;</code>");
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,6 @@ so that we can apply CSS-filters to change the arrow color in themes */
color: var(--main-color);
background-color: var(--stab-background-color);
width: fit-content;
white-space: pre-wrap;
border-radius: 3px;
display: inline;
vertical-align: baseline;
Expand Down
44 changes: 20 additions & 24 deletions src/librustdoc/passes/lint/redundant_explicit_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn check_inline_or_reference_unknown_redundancy(
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
let Self { explicit_span, display_span, link_span, display_link } = self;

let mut diag = Diag::new(dcx, level, "redundant explicit link target")
Diag::new(dcx, level, "redundant explicit link target")
.with_span_label(
explicit_span,
"explicit target is redundant",
Expand All @@ -176,17 +176,15 @@ fn check_inline_or_reference_unknown_redundancy(
)
.with_note(
"when a link's destination is not specified,\nthe label is used to resolve intra-doc links"
);
// FIXME (GuillaumeGomez): We cannot use `derive(Diagnostic)` because of this method.
// FIXME2 (GuillaumeGomez): Why isn't there a `with_` equivalent for this method?
diag.span_suggestion_with_style(
link_span,
"remove explicit link target",
format!("[{}]", display_link),
Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
);
diag
)
// FIXME (GuillaumeGomez): We cannot use `derive(Diagnostic)` because of this method.
.with_span_suggestion_with_style(
link_span,
"remove explicit link target",
format!("[{}]", display_link),
Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
)
}
}

Expand Down Expand Up @@ -267,7 +265,7 @@ fn check_reference_redundancy(
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
let Self { explicit_span, display_span, def_span, link_span, display_link } = self;

let mut diag = Diag::new(dcx, level, "redundant explicit link target")
Diag::new(dcx, level, "redundant explicit link target")
.with_span_label(explicit_span, "explicit target is redundant")
.with_span_label(
display_span,
Expand All @@ -276,17 +274,15 @@ fn check_reference_redundancy(
.with_span_note(def_span, "referenced explicit link target defined here")
.with_note(
"when a link's destination is not specified,\nthe label is used to resolve intra-doc links"
);
// FIXME (GuillaumeGomez): We cannot use `derive(Diagnostic)` because of this method.
// FIXME2 (GuillaumeGomez): Why isn't there a `with_` equivalent for this method?
diag.span_suggestion_with_style(
link_span,
"remove explicit link target",
format!("[{}]", display_link),
Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
);
diag
)
// FIXME (GuillaumeGomez): We cannot use `derive(Diagnostic)` because of this method.
.with_span_suggestion_with_style(
link_span,
"remove explicit link target",
format!("[{}]", display_link),
Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
)
}
}

Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directives/directive_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-powerpc",
"ignore-powerpc64",
"ignore-remote",
"ignore-riscv32",
"ignore-riscv64",
"ignore-rustc-debug-assertions",
"ignore-rustc_abi-x86-sse2",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/opt-dist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ log = "0.4"
anyhow = "1"
humantime = "2"
humansize = "2"
sysinfo = { version = "0.38.2", default-features = false, features = ["disk"] }
sysinfo = { version = "0.38.4", default-features = false, features = ["disk"] }
fs_extra = "1"
camino = "1"
tar = "0.4"
Expand Down
5 changes: 5 additions & 0 deletions tests/rustdoc-html/deprecated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ pub struct W;
// 'Deprecated: shorthand reason: code$'
#[deprecated = "shorthand reason: `code`"]
pub struct X;

//@ matches deprecated/struct.Y.html '//*[@class="stab deprecated"]//p[1]' 'multiple'
//@ matches deprecated/struct.Y.html '//*[@class="stab deprecated"]//p[2]' 'paragraphs'
#[deprecated = "multiple\n\nparagraphs"]
pub struct Y;
Loading
Loading