Skip to content
Merged
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
0229150
feat(num): improve error messages for `TryFromIntError`
sorairolake May 6, 2026
93f4a70
core: implement `Rng` for references
joboet Jul 17, 2026
1c7eaf9
Make `Global` and `System` allocators implement `const Clone + const …
kpreid Jul 17, 2026
ce323cd
Replace `jemalloc` bootstrap options with `override-allocator`
Zoxc Apr 21, 2026
a388f03
macroless_generic_const_args
khyperia Jul 20, 2026
011da65
Keep `jemalloc` option for a grace period
Zoxc Jul 18, 2026
8fa2ebf
Add a doc comment to `Attribute::span`
nnethercote Jul 16, 2026
efbdd60
Add a comment about why we collect tokens
nnethercote Jul 21, 2026
7396a59
Augment comment on `Annotatable`
nnethercote Jul 21, 2026
c266b1c
Fix an indefinite article in an error message
nnethercote Jul 16, 2026
4e2ebd6
Remove some dead code
oli-obk Jul 20, 2026
3c4b83c
Rollup merge of #155617 - Zoxc:allocator-feature-rename, r=Mark-Simul…
JonathanBrouwer Jul 21, 2026
8b7e46a
Rollup merge of #156225 - sorairolake:improve-try-from-int-error-desc…
JonathanBrouwer Jul 21, 2026
fd4b1d5
Rollup merge of #159058 - khyperia:macroless_generic_const_args, r=Bo…
JonathanBrouwer Jul 21, 2026
4430314
Rollup merge of #159435 - joboet:rng_ref, r=dtolnay
JonathanBrouwer Jul 21, 2026
66dc1b3
Rollup merge of #159471 - kpreid:constalloc, r=clarfonthey
JonathanBrouwer Jul 21, 2026
82d262f
Rollup merge of #159590 - oli-obk:unsafe_attrs_old, r=petrochenkov
JonathanBrouwer Jul 21, 2026
ef36323
Rollup merge of #159636 - nnethercote:some-comments, r=petrochenkov
JonathanBrouwer Jul 21, 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
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ See [the rustc-dev-guide for more info][sysllvm].
--set llvm.libzstd=true \
--set llvm.ninja=false \
--set rust.debug-assertions=false \
--set rust.jemalloc \
--set rust.override-allocator=jemalloc \
--set rust.bootstrap-override-lld=true \
--set rust.lto=thin \
--set rust.codegen-units=1
Expand Down
15 changes: 12 additions & 3 deletions bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -853,9 +853,15 @@
# Useful for reproducible builds. Generally only set for releases
#rust.remap-debuginfo = false

# Link the compiler and LLVM against `jemalloc` instead of the default libc allocator.
# Link the compiler and LLVM against the specified allocator instead of the default libc allocator.
# This option is only tested on Linux and OSX. It can also be configured per-target in the
# [target.<tuple>] section.
# Possible options: "jemalloc"
#rust.override-allocator = "jemalloc"

# Deprecated alias for `rust.override-allocator`. Setting this to `true` is
# equivalent to `rust.override-allocator = "jemalloc"`. If both are set, they
# must agree.
#rust.jemalloc = false

# Run tests in various test suites with the "nll compare mode" in addition to
Expand Down Expand Up @@ -1164,8 +1170,11 @@
# order to run `x check`.
#optimized-compiler-builtins = build.optimized-compiler-builtins (bool or path)

# Link the compiler and LLVM against `jemalloc` instead of the default libc allocator.
# This overrides the global `rust.jemalloc` option. See that option for more info.
# Link the compiler and LLVM against the specified allocator instead of the default libc allocator.
# This overrides the global `rust.override-allocator` option. See that option for more info.
#override-allocator = rust.override-allocator (string)

# Deprecated alias for `override-allocator`. See `rust.jemalloc` for more info.
#jemalloc = rust.jemalloc (bool)

# The linker configuration that will *override* the default linker used for Linux
Expand Down
23 changes: 23 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3413,6 +3413,29 @@ pub struct Attribute {
/// Denotes if the attribute decorates the following construct (outer)
/// or the construct this attribute is contained within (inner).
pub style: AttrStyle,

/// The carets in the examples below show the spans for various cases.
/// ```text
/// #[foo] - A vanilla parsed attribute.
/// ^^^^^^ - Its span covers it all.
///
/// /** abc */ /// xyz - A parsed doc comment.
/// ^^^^^^^^^^ ^^^^^^^ - Its span covers the text and comment marker(s).
/// - The same span is also used if the doc comment is desugared (into
/// a new normal `#[doc = r"..."]` attribute) by
/// `desugar_doc_comments` before being passed to a macro (which
/// is done so that `#[$m:meta]` will match).
///
/// #[cfg_attr(pred, foo)] - A parsed `cfg_attr` attribute.
/// ^^^^^^^^^^^^^^^^^^^^^^ - Its span covers it all.
/// ^^^ - Span of the new replacement attribute (equivalent to `#[foo]`)
/// created by `cfg_attr` expansion (if `pred` is true).
/// ^^^^^^^^^^^^^^^^^^^^^^ - Span of the synthetic `CfgAttrTrace` attribute created by
/// `cfg_attr` expansion. (`CfgTrace` is derived from `#[cfg(..)]` and
/// handled similarly.)
/// ```
/// Finally, for compiler-generated attributes the span is whatever the construction site
/// chooses. Usually `DUMMY_SP` or some relevant span from the source code.
pub span: Span,
}

Expand Down
59 changes: 23 additions & 36 deletions compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::fmt::Debug;
use std::sync::atomic::{AtomicU32, Ordering};

use rustc_index::bit_set::GrowableBitSet;
use rustc_span::{Ident, Span, Symbol, kw, sym};
use rustc_span::{Ident, Span, Symbol, sym};
use smallvec::{SmallVec, smallvec};
use thin_vec::{ThinVec, thin_vec};

Expand Down Expand Up @@ -748,29 +748,9 @@ pub fn mk_attr_from_item(

fn mk_attr_tokens(
style: AttrStyle,
unsafety: Safety,
item_tokens: AttrTokenStream,
span: Span,
) -> LazyAttrTokenStream {
let safety_kw = match unsafety {
Safety::Default => None,
Safety::Unsafe(span) => Some((kw::Unsafe, span)),
Safety::Safe(span) => Some((kw::Safe, span)),
};
let item_tokens = if let Some((kw, kw_span)) = safety_kw {
AttrTokenStream::new(vec![
AttrTokenTree::Token(Token::from_ast_ident(Ident::new(kw, kw_span)), Spacing::Alone),
AttrTokenTree::Delimited(
DelimSpan::from_single(span),
DelimSpacing::new(Spacing::JointHidden, Spacing::Alone),
Delimiter::Parenthesis,
item_tokens,
),
])
} else {
item_tokens
};

let mut tokens = match style {
AttrStyle::Outer => {
vec![AttrTokenTree::Token(Token::new(token::Pound, span), Spacing::JointHidden)]
Expand All @@ -792,35 +772,33 @@ fn mk_attr_tokens(

// `span` is used for the `Attribute` and everything within it (except for any span within
// `unsafety`).
pub fn mk_attr_word(
g: &AttrIdGenerator,
style: AttrStyle,
unsafety: Safety,
name: Symbol,
span: Span,
) -> Attribute {
pub fn mk_attr_word(g: &AttrIdGenerator, style: AttrStyle, name: Symbol, span: Span) -> Attribute {
let path = Path::from_ident(Ident::new(name, span));
let args = AttrArgs::Empty;

let tokens = Some(mk_attr_tokens(
style,
unsafety,
AttrTokenStream::new(vec![AttrTokenTree::Token(
Token::from_ast_ident(Ident::new(name, span)),
Spacing::Alone,
)]),
span,
));

mk_attr_from_item(g, AttrItem { unsafety, path, args, span }, tokens, style, span)
mk_attr_from_item(
g,
AttrItem { unsafety: Safety::Default, path, args, span },
tokens,
style,
span,
)
}

// `span` is used for the `Attribute` and everything within it (except for any span within
// `unsafety`).
pub fn mk_attr_nested_word(
g: &AttrIdGenerator,
style: AttrStyle,
unsafety: Safety,
outer: Symbol,
inner: Symbol,
span: Span,
Expand All @@ -839,7 +817,6 @@ pub fn mk_attr_nested_word(

let tokens = Some(mk_attr_tokens(
style,
unsafety,
AttrTokenStream::new(vec![
AttrTokenTree::Token(Token::from_ast_ident(Ident::new(outer, span)), Spacing::Alone),
AttrTokenTree::Delimited(
Expand All @@ -855,15 +832,20 @@ pub fn mk_attr_nested_word(
span,
));

mk_attr_from_item(g, AttrItem { unsafety, path, args: attr_args, span }, tokens, style, span)
mk_attr_from_item(
g,
AttrItem { unsafety: Safety::Default, path, args: attr_args, span },
tokens,
style,
span,
)
}

// `span` is used for the `Attribute` and everything within it (except for any span within
// `unsafety`).
pub fn mk_attr_name_value_str(
g: &AttrIdGenerator,
style: AttrStyle,
unsafety: Safety,
name: Symbol,
val: Symbol,
span: Span,
Expand All @@ -881,7 +863,6 @@ pub fn mk_attr_name_value_str(

let tokens = Some(mk_attr_tokens(
style,
unsafety,
AttrTokenStream::new(vec![
AttrTokenTree::Token(Token::from_ast_ident(Ident::new(name, span)), Spacing::Alone),
AttrTokenTree::Token(Token::new(token::Eq, span), Spacing::Alone),
Expand All @@ -893,7 +874,13 @@ pub fn mk_attr_name_value_str(
span,
));

mk_attr_from_item(g, AttrItem { unsafety, path, args, span }, tokens, style, span)
mk_attr_from_item(
g,
AttrItem { unsafety: Safety::Default, path, args, span },
tokens,
style,
span,
)
}

pub fn filter_by_name(attrs: &[Attribute], name: Symbol) -> impl Iterator<Item = &Attribute> {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2323,7 +2323,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
let attr = attr::mk_attr_nested_word(
&self.tcx.sess.psess.attr_id_generator,
AttrStyle::Outer,
Safety::Default,
sym::allow,
sym::unreachable_code,
span,
Expand Down
Loading
Loading