Skip to content

Commit fe2b43d

Browse files
committed
Auto merge of #164788 - JonathanBrouwer:rollup-lqRL2vV, r=JonathanBrouwer
Rollup of 5 pull requests Successful merges: - #162395 (Make more float intrinsics generic) - #164636 (Remove `record_*` macros from the metadata encoder) - #164624 (make `RustaceansAreAwesome` satisfy projection clauses) - #164695 ([tiny] Include trait definition line when pointing at assoc function in E0308) - #164744 (some `Attribute`/`AttributeExt` cleanups)
2 parents a0326ca + aac203f commit fe2b43d

126 files changed

Lines changed: 1830 additions & 1746 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎compiler/rustc_ast/src/attr/mod.rs‎

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ impl Attribute {
7777
}
7878

7979
impl AttributeExt for Attribute {
80-
fn id(&self) -> AttrId {
81-
self.id
82-
}
83-
8480
fn value_span(&self) -> Option<Span> {
8581
match &self.kind {
8682
AttrKind::Normal(normal) => match &normal.item.args {
@@ -146,10 +142,6 @@ impl AttributeExt for Attribute {
146142
}
147143
}
148144

149-
fn span(&self) -> Span {
150-
self.span
151-
}
152-
153145
fn is_word(&self) -> bool {
154146
match &self.kind {
155147
AttrKind::Normal(normal) => matches!(normal.item.args, AttrArgs::Empty),
@@ -195,20 +187,24 @@ impl AttributeExt for Attribute {
195187
}
196188
}
197189

198-
/// Returns the documentation and its kind if this is a doc comment or a sugared doc comment.
199-
/// * `///doc` returns `Some(("doc", DocFragmentKind::Sugared(CommentKind::Line)))`.
200-
/// * `/** doc */` returns `Some(("doc", DocFragmentKind::Sugared(CommentKind::Block)))`.
201-
/// * `#[doc = "doc"]` returns `Some(("doc", DocFragmentKind::Raw))`.
190+
/// Returns the documentation, its kind if this is a doc comment or a sugared doc comment
191+
/// and the span of the entire comment (or the entire attribute if raw - see the span in
192+
/// [`DocFragmentKind`] for the literal span.)
193+
/// * `///doc` returns `Some(("doc", DocFragmentKind::Sugared(CommentKind::Line)), _)`.
194+
/// * `/** doc */` returns `Some(("doc", DocFragmentKind::Sugared(CommentKind::Block), _))`.
195+
/// * `#[doc = "doc"]` returns `Some(("doc", DocFragmentKind::Raw), _)`.
202196
/// * `#[doc(...)]` returns `None`.
203-
fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
197+
fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind, Span)> {
204198
match &self.kind {
205-
AttrKind::DocComment(kind, data) => Some((*data, DocFragmentKind::Sugared(*kind))),
199+
AttrKind::DocComment(kind, data) => {
200+
Some((*data, DocFragmentKind::Sugared(*kind), self.span))
201+
}
206202
AttrKind::Normal(normal)
207203
if normal.item.path == sym::doc
208204
&& let Some(value) = normal.item.value_str()
209205
&& let Some(value_span) = normal.item.value_span() =>
210206
{
211-
Some((value, DocFragmentKind::Raw(value_span)))
207+
Some((value, DocFragmentKind::Raw(value_span), self.span))
212208
}
213209
AttrKind::Normal(..) | AttrKind::Synthetic(..) => None,
214210
}
@@ -263,6 +259,14 @@ impl AttributeExt for Attribute {
263259
fn is_rustc_doc_primitive(&self) -> bool {
264260
self.has_name(sym::rustc_doc_primitive)
265261
}
262+
263+
/// Returns whether this attribute is any of the proc macro attributes.
264+
/// i.e. `proc_macro`, `proc_macro_attribute` or `proc_macro_derive`.
265+
fn is_proc_macro_attr(&self) -> bool {
266+
[sym::proc_macro, sym::proc_macro_attribute, sym::proc_macro_derive]
267+
.iter()
268+
.any(|kind| self.has_name(*kind))
269+
}
266270
}
267271

268272
impl Attribute {
@@ -909,9 +913,7 @@ impl MetaItemLit {
909913
}
910914
}
911915

912-
pub trait AttributeExt: Debug {
913-
fn id(&self) -> AttrId;
914-
916+
pub trait AttributeExt: Debug + 'static {
915917
/// For a single-segment attribute (i.e., `#[attr]` and not `#[path::atrr]`),
916918
/// return the name of the attribute; otherwise, returns `None`.
917919
fn name(&self) -> Option<Symbol>;
@@ -948,10 +950,6 @@ pub trait AttributeExt: Debug {
948950
fn has_any_name(&self, names: &[Symbol]) -> bool {
949951
names.iter().any(|&name| self.has_name(name))
950952
}
951-
952-
/// get the span of the entire attribute
953-
fn span(&self) -> Span;
954-
955953
/// Returns whether the attribute is a path, without any arguments.
956954
fn is_word(&self) -> bool;
957955

@@ -972,11 +970,8 @@ pub trait AttributeExt: Debug {
972970

973971
/// Returns whether this attribute is any of the proc macro attributes.
974972
/// i.e. `proc_macro`, `proc_macro_attribute` or `proc_macro_derive`.
975-
fn is_proc_macro_attr(&self) -> bool {
976-
[sym::proc_macro, sym::proc_macro_attribute, sym::proc_macro_derive]
977-
.iter()
978-
.any(|kind| self.has_name(*kind))
979-
}
973+
fn is_proc_macro_attr(&self) -> bool;
974+
980975
/// Returns true if this attribute is `#[automatically_deived]`.
981976
fn is_automatically_derived_attr(&self) -> bool;
982977

@@ -985,7 +980,7 @@ pub trait AttributeExt: Debug {
985980
/// * `/** doc */` returns `Some(("doc", CommentKind::Block))`.
986981
/// * `#[doc = "doc"]` returns `Some(("doc", CommentKind::Line))`.
987982
/// * `#[doc(...)]` returns `None`.
988-
fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)>;
983+
fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind, Span)>;
989984

990985
/// Returns outer or inner if this is a doc attribute or a sugared doc
991986
/// comment, otherwise None.
@@ -1009,10 +1004,6 @@ pub trait AttributeExt: Debug {
10091004
// FIXME(fn_delegation): use function delegation instead of manually forwarding
10101005

10111006
impl Attribute {
1012-
pub fn id(&self) -> AttrId {
1013-
AttributeExt::id(self)
1014-
}
1015-
10161007
pub fn name(&self) -> Option<Symbol> {
10171008
AttributeExt::name(self)
10181009
}
@@ -1048,10 +1039,6 @@ impl Attribute {
10481039
AttributeExt::has_any_name(self, names)
10491040
}
10501041

1051-
pub fn span(&self) -> Span {
1052-
AttributeExt::span(self)
1053-
}
1054-
10551042
pub fn is_word(&self) -> bool {
10561043
AttributeExt::is_word(self)
10571044
}
@@ -1068,7 +1055,7 @@ impl Attribute {
10681055
AttributeExt::is_proc_macro_attr(self)
10691056
}
10701057

1071-
pub fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1058+
pub fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind, Span)> {
10721059
AttributeExt::doc_str_and_fragment_kind(self)
10731060
}
10741061
}

‎compiler/rustc_attr_ir/src/attr.rs‎

Lines changed: 4 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fmt;
22

33
use rustc_ast::attr::AttributeExt;
44
use rustc_ast::token::DocFragmentKind;
5-
use rustc_ast::{AttrStyle, DelimArgs, MetaItemInner, MetaItemLit, ast, join_path_idents};
5+
use rustc_ast::{AttrStyle, DelimArgs, MetaItemLit, ast, join_path_idents};
66
use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHasher};
77
use rustc_error_messages::{DiagArgValue, IntoDiagArg};
88
use rustc_macros::{Decodable, Encodable, StableHash};
@@ -117,13 +117,6 @@ pub enum Attribute {
117117
}
118118

119119
impl Attribute {
120-
pub fn get_normal_item(&self) -> &AttrItem {
121-
match &self {
122-
Attribute::Unparsed(normal) => &normal,
123-
_ => panic!("unexpected parsed attribute"),
124-
}
125-
}
126-
127120
pub fn value_lit(&self) -> Option<&MetaItemLit> {
128121
match &self {
129122
Attribute::Unparsed(n) => match n.as_ref() {
@@ -134,13 +127,6 @@ impl Attribute {
134127
}
135128
}
136129

137-
pub fn is_parsed_attr(&self) -> bool {
138-
match self {
139-
Attribute::Parsed(_) => true,
140-
Attribute::Unparsed(_) => false,
141-
}
142-
}
143-
144130
pub fn is_prefix_attr_for_suggestions(&self) -> bool {
145131
match self {
146132
Attribute::Unparsed(attr) => attr.span.desugaring_kind().is_none(),
@@ -152,14 +138,6 @@ impl Attribute {
152138
}
153139

154140
impl AttributeExt for Attribute {
155-
#[inline]
156-
fn id(&self) -> AttrId {
157-
match &self {
158-
Attribute::Unparsed(u) => u.id.attr_id,
159-
_ => panic!(),
160-
}
161-
}
162-
163141
#[inline]
164142
fn meta_item_list(&self) -> Option<ThinVec<ast::MetaItemInner>> {
165143
match &self {
@@ -215,18 +193,6 @@ impl AttributeExt for Attribute {
215193
}
216194
}
217195

218-
#[inline]
219-
fn span(&self) -> Span {
220-
match &self {
221-
Attribute::Unparsed(u) => u.span,
222-
// FIXME: should not be needed anymore when all attrs are parsed
223-
Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
224-
Attribute::Parsed(AttributeKind::Deprecated { span, .. }) => *span,
225-
Attribute::Parsed(AttributeKind::CfgTrace(cfgs)) => cfgs[0].1,
226-
a => panic!("can't get the span of an arbitrary parsed attribute: {a:?}"),
227-
}
228-
}
229-
230196
#[inline]
231197
fn is_word(&self) -> bool {
232198
match &self {
@@ -265,10 +231,10 @@ impl AttributeExt for Attribute {
265231
}
266232

267233
#[inline]
268-
fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
234+
fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind, Span)> {
269235
match &self {
270-
Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => {
271-
Some((*comment, *kind))
236+
Attribute::Parsed(AttributeKind::DocComment { kind, comment, span, .. }) => {
237+
Some((*comment, *kind, *span))
272238
}
273239
_ => None,
274240
}
@@ -307,81 +273,3 @@ impl AttributeExt for Attribute {
307273
matches!(self, Attribute::Parsed(AttributeKind::RustcDocPrimitive(..)))
308274
}
309275
}
310-
311-
// FIXME(fn_delegation): use function delegation instead of manually forwarding
312-
impl Attribute {
313-
#[inline]
314-
pub fn id(&self) -> AttrId {
315-
AttributeExt::id(self)
316-
}
317-
318-
#[inline]
319-
pub fn name(&self) -> Option<Symbol> {
320-
AttributeExt::name(self)
321-
}
322-
323-
#[inline]
324-
pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
325-
AttributeExt::meta_item_list(self)
326-
}
327-
328-
#[inline]
329-
pub fn value_str(&self) -> Option<Symbol> {
330-
AttributeExt::value_str(self)
331-
}
332-
333-
#[inline]
334-
pub fn value_span(&self) -> Option<Span> {
335-
AttributeExt::value_span(self)
336-
}
337-
338-
#[inline]
339-
pub fn path_matches(&self, name: &[Symbol]) -> bool {
340-
AttributeExt::path_matches(self, name)
341-
}
342-
343-
#[inline]
344-
pub fn is_doc_comment(&self) -> Option<Span> {
345-
AttributeExt::is_doc_comment(self)
346-
}
347-
348-
#[inline]
349-
pub fn has_name(&self, name: Symbol) -> bool {
350-
AttributeExt::has_name(self, name)
351-
}
352-
353-
#[inline]
354-
pub fn has_any_name(&self, names: &[Symbol]) -> bool {
355-
AttributeExt::has_any_name(self, names)
356-
}
357-
358-
#[inline]
359-
pub fn span(&self) -> Span {
360-
AttributeExt::span(self)
361-
}
362-
363-
#[inline]
364-
pub fn is_word(&self) -> bool {
365-
AttributeExt::is_word(self)
366-
}
367-
368-
#[inline]
369-
pub fn path(&self) -> SmallVec<[Symbol; 1]> {
370-
AttributeExt::path(self)
371-
}
372-
373-
#[inline]
374-
pub fn doc_str(&self) -> Option<Symbol> {
375-
AttributeExt::doc_str(self)
376-
}
377-
378-
#[inline]
379-
pub fn is_proc_macro_attr(&self) -> bool {
380-
AttributeExt::is_proc_macro_attr(self)
381-
}
382-
383-
#[inline]
384-
pub fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
385-
AttributeExt::doc_str_and_fragment_kind(self)
386-
}
387-
}

‎compiler/rustc_builtin_macros/src/asm.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn validate_asm_args<'a>(
6565
for arg in args {
6666
for attr in arg.attributes.0.iter() {
6767
if !matches!(attr.name(), Some(sym::cfg | sym::cfg_attr)) {
68-
ecx.dcx().emit_err(diagnostics::AsmAttributeNotSupported { span: attr.span() });
68+
ecx.dcx().emit_err(diagnostics::AsmAttributeNotSupported { span: attr.span });
6969
}
7070
}
7171

‎compiler/rustc_builtin_macros/src/eii.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ fn split_attrs(
237237
}
238238
Some(sym::eii) => unreachable!("should already be filtered out"),
239239
_ => {
240-
ecx.dcx()
241-
.emit_err(EiiAttributeNotSupported { span, attr_span: attr.span() });
240+
ecx.dcx().emit_err(EiiAttributeNotSupported { span, attr_span: attr.span });
242241
}
243242
}
244243
}

‎compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,6 @@ pub(crate) fn neg_f128(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
160160
fx.bcx.ins().bitcast(types::F128, MemFlagsData::new(), bits)
161161
}
162162

163-
pub(crate) fn abs_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
164-
let bits = fx.bcx.ins().bitcast(types::I16, MemFlagsData::new(), value);
165-
let bits = fx.bcx.ins().band_imm_u(bits, 0x7fff);
166-
fx.bcx.ins().bitcast(types::F16, MemFlagsData::new(), bits)
167-
}
168-
169-
pub(crate) fn abs_f128(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
170-
let bits = fx.bcx.ins().bitcast(types::I128, MemFlagsData::new(), value);
171-
let (low, high) = fx.bcx.ins().isplit(bits);
172-
let high = fx.bcx.ins().band_imm_u(high, 0x7fff_ffff_ffff_ffff_u64 as i64);
173-
let bits = fx.bcx.ins().iconcat(low, high);
174-
fx.bcx.ins().bitcast(types::F128, MemFlagsData::new(), bits)
175-
}
176-
177163
pub(crate) fn codegen_cast(
178164
fx: &mut FunctionCx<'_, '_, '_>,
179165
from: Value,

‎compiler/rustc_codegen_cranelift/src/compiler_builtins.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ builtin_functions! {
172172
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
173173
fn rintf128(f: f128) -> f128;
174174
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
175+
fn roundf16(f: f16) -> f16;
176+
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
177+
fn roundf128(f: f128) -> f128;
178+
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
175179
fn sqrtf16(f: f16) -> f16;
176180
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
177181
fn sqrtf128(f: f128) -> f128;

0 commit comments

Comments
 (0)