Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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;
17 changes: 17 additions & 0 deletions tests/ui/lint/unused-features/stable-features.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ check-pass

#![deny(warnings)]
#![allow(stable_features)]

// Lang feature
#![feature(lint_reasons)]

// Lib feature
#![feature(euclidean_division)]

#[allow(unused_variables, reason = "my reason")]
fn main() {
let x = ();

let _ = 42.0_f32.div_euclid(3.0);
}
3 changes: 1 addition & 2 deletions tests/ui/lint/unused-features/unused-library-features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
#![feature(step_trait)]
//~^ ERROR feature `step_trait` is declared but not used
#![feature(is_sorted)]
//~^ ERROR feature `is_sorted` is declared but not used
//~^^ WARN the feature `is_sorted` has been stable since 1.82.0 and no longer requires an attribute to enable
//~^ WARN the feature `is_sorted` has been stable since 1.82.0 and no longer requires an attribute to enable

// Enabled via cfg_attr, unused
#![cfg_attr(all(), feature(slice_ptr_get))]
Expand Down
10 changes: 2 additions & 8 deletions tests/ui/lint/unused-features/unused-library-features.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@ note: the lint level is defined here
LL | #![deny(unused_features)]
| ^^^^^^^^^^^^^^^

error: feature `is_sorted` is declared but not used
--> $DIR/unused-library-features.rs:7:12
|
LL | #![feature(is_sorted)]
| ^^^^^^^^^

error: feature `slice_ptr_get` is declared but not used
--> $DIR/unused-library-features.rs:12:28
--> $DIR/unused-library-features.rs:11:28
|
LL | #![cfg_attr(all(), feature(slice_ptr_get))]
| ^^^^^^^^^^^^^

error: aborting due to 3 previous errors; 1 warning emitted
error: aborting due to 2 previous errors; 1 warning emitted

13 changes: 13 additions & 0 deletions tests/ui/scalable-vectors/bad-architectures.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ ignore-aarch64
//@ ignore-riscv32
//@ ignore-riscv64

// Confirm that non-AArch64 and non-RISC-V targets error when compiling scalable vectors
// (see #153593)

#![crate_type = "lib"]
#![feature(rustc_attrs)]

#[rustc_scalable_vector(4)]
//~^ ERROR: scalable vectors are not supported on this architecture
struct ScalableVec(i32);
8 changes: 8 additions & 0 deletions tests/ui/scalable-vectors/bad-architectures.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: scalable vectors are not supported on this architecture
--> $DIR/bad-architectures.rs:11:1
|
LL | #[rustc_scalable_vector(4)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

Loading
Loading