Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6bd68fc
Run filecheck on dest-prop/branch.rs
CastilloDel Apr 14, 2024
f238eba
Run filecheck on dest-prop/copy_propagation.rs
CastilloDel Apr 14, 2024
853311c
Run filecheck on dest-prop/cycle.rs
CastilloDel Apr 14, 2024
0692090
Run filecheck on dest-prop/dead_stores_79191.rs and dead_stores_bette…
CastilloDel Apr 14, 2024
f0f867e
Run filecheck on dest-prop/simple.rs
CastilloDel Apr 14, 2024
2d5a483
Acknowledge comments
CastilloDel Jun 26, 2024
a5dc082
Use windows_targets macro for alloc
ChrisDenton Jul 5, 2024
e136f08
Add experimental raw-dylib feature to std
ChrisDenton Jul 5, 2024
4819270
use "bootstrap" instead of "rustbuild" in comments and docs
onur-ozkan Jul 6, 2024
99721c8
Clear `inner_attr_ranges` regularly.
nnethercote Jul 8, 2024
a47ae57
Use an `@` pattern to shorten some code.
nnethercote Jul 8, 2024
b162013
Use iterator normally in `make_attr_token_stream`.
nnethercote Jul 8, 2024
a88c4d6
Split the stack in `make_attr_token_stream`.
nnethercote Jul 8, 2024
f552794
Move `Spacing` into `FlatToken`.
nnethercote Jul 8, 2024
2a3e22b
Promote the `wasm32-wasip2` target to Tier 2
alexcrichton Jun 24, 2024
1afdd45
Update how wasm-component-ld is built
alexcrichton Jul 9, 2024
4cd6eee
Unconditionally use stage0 build compiler
alexcrichton Jul 9, 2024
8a390ba
Change empty replace range condition.
nnethercote Jul 10, 2024
fee1525
Rework `Attribute::get_tokens`.
nnethercote Jul 10, 2024
d8b6aa6
Use `cfg_attr` as a name more.
nnethercote Jul 10, 2024
d6ebbbf
Factor out `AttrsTarget` flattening code.
nnethercote Jul 10, 2024
478ba59
Add some comments.
nnethercote Jul 10, 2024
7fc6943
Use ManuallyDrop in BufWriter::into_parts
saethlin Jul 12, 2024
fc0d1dc
use `ModeToolBootstrap` for run-make-support's crate tests
onur-ozkan Jul 13, 2024
41070bd
explain why we use in-tree std for compiletest
onur-ozkan Jul 13, 2024
4e12172
Add 1.80 release notes
BoxyUwU Jun 29, 2024
88a7cdb
Rollup merge of #122300 - CastilloDel:master, r=cjgillot
workingjubilee Jul 13, 2024
a85818e
Rollup merge of #126967 - alexcrichton:wasm32-wasip2-tier-2, r=Mark-S…
workingjubilee Jul 13, 2024
06788aa
Rollup merge of #127083 - BoxyUwU:relnotes_1_80, r=Mark-Simulacrum
workingjubilee Jul 13, 2024
6820acf
Rollup merge of #127370 - ChrisDenton:win-sys, r=Mark-Simulacrum
workingjubilee Jul 13, 2024
6a44d83
Rollup merge of #127434 - onur-ozkan:use-bootstrap-instead-of-rustbui…
workingjubilee Jul 13, 2024
fce04fa
Rollup merge of #127477 - nnethercote:tweak-inner_attr_ranges, r=petr…
workingjubilee Jul 13, 2024
90cee91
Rollup merge of #127558 - nnethercote:more-Attribute-cleanups, r=petr…
workingjubilee Jul 13, 2024
7321530
Rollup merge of #127659 - saethlin:manually-drop-bufwriter, r=joboet
workingjubilee Jul 13, 2024
a02a776
Rollup merge of #127677 - onur-ozkan:use-correct-modes, r=Kobzol
workingjubilee Jul 13, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use cfg_attr as a name more.
In various functions where the attribute being processed is known to be a `#[cfg_attr(...)]` attribute. I find this a helpful reminder.
  • Loading branch information
nnethercote committed Jul 10, 2024
commit d8b6aa6d0dabc0c102f16f9f9bb35f687a63101c
22 changes: 11 additions & 11 deletions compiler/rustc_expand/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ impl<'a> StripUnconfigured<'a> {
/// Gives a compiler warning when the `cfg_attr` contains no attributes and
/// is in the original source file. Gives a compiler error if the syntax of
/// the attribute is incorrect.
pub(crate) fn expand_cfg_attr(&self, attr: &Attribute, recursive: bool) -> Vec<Attribute> {
pub(crate) fn expand_cfg_attr(&self, cfg_attr: &Attribute, recursive: bool) -> Vec<Attribute> {
let Some((cfg_predicate, expanded_attrs)) =
rustc_parse::parse_cfg_attr(attr, &self.sess.psess)
rustc_parse::parse_cfg_attr(cfg_attr, &self.sess.psess)
else {
return vec![];
};
Expand All @@ -264,7 +264,7 @@ impl<'a> StripUnconfigured<'a> {
if expanded_attrs.is_empty() {
self.sess.psess.buffer_lint(
rustc_lint_defs::builtin::UNUSED_ATTRIBUTES,
attr.span,
cfg_attr.span,
ast::CRATE_NODE_ID,
BuiltinLintDiag::CfgAttrNoAttributes,
);
Expand All @@ -280,16 +280,16 @@ impl<'a> StripUnconfigured<'a> {
// `#[cfg_attr(false, cfg_attr(true, some_attr))]`.
expanded_attrs
.into_iter()
.flat_map(|item| self.process_cfg_attr(&self.expand_cfg_attr_item(attr, item)))
.flat_map(|item| self.process_cfg_attr(&self.expand_cfg_attr_item(cfg_attr, item)))
.collect()
} else {
expanded_attrs.into_iter().map(|item| self.expand_cfg_attr_item(attr, item)).collect()
expanded_attrs.into_iter().map(|item| self.expand_cfg_attr_item(cfg_attr, item)).collect()
}
}

fn expand_cfg_attr_item(
&self,
attr: &Attribute,
cfg_attr: &Attribute,
(item, item_span): (ast::AttrItem, Span),
) -> Attribute {
// We are taking an attribute of the form `#[cfg_attr(pred, attr)]`
Expand All @@ -300,11 +300,11 @@ impl<'a> StripUnconfigured<'a> {

// Use the `#` in `#[cfg_attr(pred, attr)]` as the `#` token
// for `attr` when we expand it to `#[attr]`
let mut orig_trees = attr.token_trees().into_iter();
let mut orig_trees = cfg_attr.token_trees().into_iter();
let TokenTree::Token(pound_token @ Token { kind: TokenKind::Pound, .. }, _) =
orig_trees.next().unwrap().clone()
else {
panic!("Bad tokens for attribute {attr:?}");
panic!("Bad tokens for attribute {cfg_attr:?}");
};

// We don't really have a good span to use for the synthesized `[]`
Expand All @@ -318,12 +318,12 @@ impl<'a> StripUnconfigured<'a> {
.unwrap_or_else(|| panic!("Missing tokens for {item:?}"))
.to_attr_token_stream(),
);
let trees = if attr.style == AttrStyle::Inner {
let trees = if cfg_attr.style == AttrStyle::Inner {
// For inner attributes, we do the same thing for the `!` in `#![some_attr]`
let TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _) =
orig_trees.next().unwrap().clone()
else {
panic!("Bad tokens for attribute {attr:?}");
panic!("Bad tokens for attribute {cfg_attr:?}");
};
vec![
AttrTokenTree::Token(pound_token, Spacing::Joint),
Expand All @@ -338,7 +338,7 @@ impl<'a> StripUnconfigured<'a> {
&self.sess.psess.attr_id_generator,
item,
tokens,
attr.style,
cfg_attr.style,
item_span,
);
if attr.has_name(sym::crate_type) {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ pub fn fake_token_stream_for_crate(psess: &ParseSess, krate: &ast::Crate) -> Tok
}

pub fn parse_cfg_attr(
attr: &Attribute,
cfg_attr: &Attribute,
psess: &ParseSess,
) -> Option<(MetaItem, Vec<(AttrItem, Span)>)> {
const CFG_ATTR_GRAMMAR_HELP: &str = "#[cfg_attr(condition, attribute, other_attribute, ...)]";
const CFG_ATTR_NOTE_REF: &str = "for more information, visit \
<https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>";

match attr.get_normal_item().args {
match cfg_attr.get_normal_item().args {
ast::AttrArgs::Delimited(ast::DelimArgs { dspan, delim, ref tokens })
if !tokens.is_empty() =>
{
Expand All @@ -180,7 +180,7 @@ pub fn parse_cfg_attr(
}
_ => {
psess.dcx().emit_err(errors::MalformedCfgAttr {
span: attr.span,
span: cfg_attr.span,
sugg: CFG_ATTR_GRAMMAR_HELP,
});
}
Expand Down