Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cd061c7
Extend `core::char`'s documentation of casing issues
Jules-Bertholet Apr 11, 2026
96fb37a
add : new UI test
lms0806 Apr 15, 2026
be3f77c
resolve : addressing incorrect recommendation methods
lms0806 Apr 15, 2026
6236dde
Remove AttributeSafety from BUILTIN_ATTRIBUTES
JonathanBrouwer Apr 4, 2026
3b123ce
ImproperCTypes: Move erasing_region_normalisation into helper function
niacdoial Jan 24, 2026
a9d7027
rustdoc: percent-encode URL fragments
Jules-Bertholet Apr 14, 2026
9824267
tests/debuginfo/basic-stepping.rs: Remove FIXME related to ZSTs
Enselic Apr 16, 2026
52ad8c0
rustdoc: preserve `doc(cfg)` on locally re-exported type aliases
shivendra02467 Apr 7, 2026
0529b94
Move `Token` impl block.
nnethercote Apr 16, 2026
9e940e4
Merge `Printer` impl blocks.
nnethercote Apr 16, 2026
b8ba400
c-variadic: handle c_int being i16 and c_double being f32 on avr
folkertdev Feb 22, 2026
a875e14
c-variadic: make `VaArgSafe` a lang item
folkertdev Feb 22, 2026
78a465a
Use `box_new` diagnostic item for Box::new suggestions
cijiugechu Apr 16, 2026
d0f5b5c
Replace redundant unwrap with get_or_insert_with
zetanumbers Apr 16, 2026
4645f03
triagebot: notify on diagnostic attribute changes
mejrs Apr 16, 2026
b2d2405
`as_ref_unchecked` docs link fix
oconnor663 Apr 16, 2026
6c4ec59
Tweak how the "copy path" rustdoc button works to allow some accessib…
GuillaumeGomez Apr 16, 2026
b2feddd
Rollup merge of #152980 - folkertdev:c-variadic-avr, r=tgross35
GuillaumeGomez Apr 16, 2026
b4f9f13
Rollup merge of #154491 - Jules-Bertholet:case-docs, r=Mark-Simulacru…
GuillaumeGomez Apr 16, 2026
bcb3346
Rollup merge of #155354 - JonathanBrouwer:attr-safety-port-2, r=mejrs
GuillaumeGomez Apr 16, 2026
c30dcc4
Rollup merge of #154970 - shivendra02467:fix-rustdoc-154921, r=Guilla…
GuillaumeGomez Apr 16, 2026
c76931d
Rollup merge of #155095 - lms0806:issue_155030, r=nnethercote
GuillaumeGomez Apr 16, 2026
a250206
Rollup merge of #155358 - niacdoial:improperctypes-refactor2.1, r=pet…
GuillaumeGomez Apr 16, 2026
5ad01e3
Rollup merge of #155377 - Enselic:stepping-zsts, r=petrochenkov
GuillaumeGomez Apr 16, 2026
68660e1
Rollup merge of #155383 - nnethercote:rearrange-rustc_ast_pretty, r=W…
GuillaumeGomez Apr 16, 2026
419361c
Rollup merge of #155384 - mejrs:pingme, r=jieyouxu
GuillaumeGomez Apr 16, 2026
d5e71a6
Rollup merge of #155386 - cijiugechu:fix-box-new-diagnostic-item, r=K…
GuillaumeGomez Apr 16, 2026
993fa16
Rollup merge of #155391 - zetanumbers:query_latch_oneliner, r=petroch…
GuillaumeGomez Apr 16, 2026
1e297b3
Rollup merge of #155395 - GuillaumeGomez:copy-path-with-ronga, r=notr…
GuillaumeGomez Apr 16, 2026
3b13329
Rollup merge of #155396 - oconnor663:link_typo, r=folkertdev
GuillaumeGomez Apr 16, 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
49 changes: 0 additions & 49 deletions compiler/rustc_ast_pretty/src/helpers.rs

This file was deleted.

1 change: 0 additions & 1 deletion compiler/rustc_ast_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
#![feature(negative_impls)]
// tidy-alphabetical-end

mod helpers;
pub mod pp;
pub mod pprust;
135 changes: 134 additions & 1 deletion compiler/rustc_ast_pretty/src/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@
//! methods called `Printer::scan_*`, and the 'PRINT' process is the
//! method called `Printer::print`.

mod convenience;
mod ring;

use std::borrow::Cow;
Expand Down Expand Up @@ -188,6 +187,12 @@ pub(crate) enum Token {
End,
}

impl Token {
pub(crate) fn is_hardbreak_tok(&self) -> bool {
*self == Printer::hardbreak_tok_offset(0)
}
}

#[derive(Copy, Clone)]
enum PrintFrame {
Fits,
Expand Down Expand Up @@ -479,4 +484,132 @@ impl Printer {
self.out.push_str(string);
self.space -= string.len() as isize;
}

/// Synthesizes a comment that was not textually present in the original
/// source file.
pub fn synth_comment(&mut self, text: impl Into<Cow<'static, str>>) {
self.word("/*");
self.space();
self.word(text);
self.space();
self.word("*/")
}

/// "raw box"
pub fn rbox(&mut self, indent: isize, breaks: Breaks) -> BoxMarker {
self.scan_begin(BeginToken { indent: IndentStyle::Block { offset: indent }, breaks })
}

/// Inconsistent breaking box
pub fn ibox(&mut self, indent: isize) -> BoxMarker {
self.rbox(indent, Breaks::Inconsistent)
}

/// Consistent breaking box
pub fn cbox(&mut self, indent: isize) -> BoxMarker {
self.rbox(indent, Breaks::Consistent)
}

pub fn visual_align(&mut self) -> BoxMarker {
self.scan_begin(BeginToken { indent: IndentStyle::Visual, breaks: Breaks::Consistent })
}

pub fn break_offset(&mut self, n: usize, off: isize) {
self.scan_break(BreakToken {
offset: off,
blank_space: n as isize,
..BreakToken::default()
});
}

pub fn end(&mut self, b: BoxMarker) {
self.scan_end(b)
}

pub fn eof(mut self) -> String {
self.scan_eof();
self.out
}

pub fn word<S: Into<Cow<'static, str>>>(&mut self, wrd: S) {
let string = wrd.into();
self.scan_string(string)
}

pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W) {
self.word(w);
self.space();
}

pub fn nbsp(&mut self) {
self.word(" ")
}

pub fn word_nbsp<S: Into<Cow<'static, str>>>(&mut self, w: S) {
self.word(w);
self.nbsp()
}

fn spaces(&mut self, n: usize) {
self.break_offset(n, 0)
}

pub fn zerobreak(&mut self) {
self.spaces(0)
}

pub fn space(&mut self) {
self.spaces(1)
}

pub fn popen(&mut self) {
self.word("(");
}

pub fn pclose(&mut self) {
self.word(")");
}

pub fn hardbreak(&mut self) {
self.spaces(SIZE_INFINITY as usize)
}

pub fn is_beginning_of_line(&self) -> bool {
match self.last_token() {
Some(last_token) => last_token.is_hardbreak_tok(),
None => true,
}
}

pub fn hardbreak_if_not_bol(&mut self) {
if !self.is_beginning_of_line() {
self.hardbreak()
}
}

pub fn space_if_not_bol(&mut self) {
if !self.is_beginning_of_line() {
self.space();
}
}

pub(crate) fn hardbreak_tok_offset(off: isize) -> Token {
Token::Break(BreakToken {
offset: off,
blank_space: SIZE_INFINITY,
..BreakToken::default()
})
}

pub fn trailing_comma(&mut self) {
self.scan_break(BreakToken { pre_break: Some(','), ..BreakToken::default() });
}

pub fn trailing_comma_or_space(&mut self) {
self.scan_break(BreakToken {
blank_space: 1,
pre_break: Some(','),
..BreakToken::default()
});
}
}
97 changes: 0 additions & 97 deletions compiler/rustc_ast_pretty/src/pp/convenience.rs

This file was deleted.

2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use rustc_session::parse::{ParseSess, feature_err};
use rustc_span::{ErrorGuaranteed, Span, Symbol, sym};
use thin_vec::ThinVec;

use crate::attributes::AttributeSafety;
use crate::context::{AcceptContext, ShouldEmit, Stage};
use crate::parser::{
AllowExprMetavar, ArgParser, MetaItemListParser, MetaItemOrLitParser, NameValueParser,
Expand Down Expand Up @@ -410,6 +411,7 @@ fn parse_cfg_attr_internal<'a>(
attribute.style,
AttrPath { segments: attribute.path().into_boxed_slice(), span: attribute.span },
Some(attribute.get_normal_item().unsafety),
AttributeSafety::Normal,
ParsedDescription::Attribute,
pred_span,
lint_node_id,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/cfg_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use rustc_session::Session;
use rustc_session::lint::builtin::UNREACHABLE_CFG_SELECT_PREDICATES;
use rustc_span::{ErrorGuaranteed, Span, Symbol, sym};

use crate::attributes::AttributeSafety;
use crate::parser::{AllowExprMetavar, MetaItemOrLitParser};
use crate::{AttributeParser, ParsedDescription, ShouldEmit, errors, parse_cfg_entry};

Expand Down Expand Up @@ -105,6 +106,7 @@ pub fn parse_cfg_select(
AttrStyle::Inner,
AttrPath { segments: vec![sym::cfg_select].into_boxed_slice(), span: cfg_span },
None,
AttributeSafety::Normal,
ParsedDescription::Macro,
cfg_span,
lint_node_id,
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use rustc_hir::attrs::{CoverageAttrKind, OptimizeAttr, RtsanSetting, SanitizerSet, UsedBy};
use rustc_session::parse::feature_err;
use rustc_span::edition::Edition::Edition2024;

use super::prelude::*;
use crate::attributes::AttributeSafety;
use crate::session_diagnostics::{
NakedFunctionIncompatibleAttribute, NullOnExport, NullOnObjcClass, NullOnObjcSelector,
ObjcClassExpectedStringLiteral, ObjcSelectorExpectedStringLiteral,
Expand Down Expand Up @@ -103,6 +105,7 @@ pub(crate) struct ExportNameParser;
impl<S: Stage> SingleAttributeParser<S> for ExportNameParser {
const PATH: &[rustc_span::Symbol] = &[sym::export_name];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
const SAFETY: AttributeSafety = AttributeSafety::Unsafe { unsafe_since: Some(Edition2024) };
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Static),
Allow(Target::Fn),
Expand Down Expand Up @@ -220,6 +223,7 @@ impl<S: Stage> AttributeParser<S> for NakedParser {
this.span = Some(cx.attr_span);
}
})];
const SAFETY: AttributeSafety = AttributeSafety::Unsafe { unsafe_since: None };
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Allow(Target::Method(MethodKind::Inherent)),
Expand Down Expand Up @@ -340,6 +344,7 @@ pub(crate) struct NoMangleParser;
impl<S: Stage> NoArgsAttributeParser<S> for NoMangleParser {
const PATH: &[Symbol] = &[sym::no_mangle];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const SAFETY: AttributeSafety = AttributeSafety::Unsafe { unsafe_since: Some(Edition2024) };
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
Allow(Target::Fn),
Allow(Target::Static),
Expand Down Expand Up @@ -542,6 +547,7 @@ pub(crate) struct ForceTargetFeatureParser;
impl<S: Stage> CombineAttributeParser<S> for ForceTargetFeatureParser {
type Item = (Symbol, Span);
const PATH: &[Symbol] = &[sym::force_target_feature];
const SAFETY: AttributeSafety = AttributeSafety::Unsafe { unsafe_since: None };
const CONVERT: ConvertFn<Self::Item> = |items, span| AttributeKind::TargetFeature {
features: items,
attr_span: span,
Expand Down
Loading
Loading