Skip to content

Commit e2092d7

Browse files
committed
Rename MetaItemParser::path_without_args as MetaItemParser::path.
And avoid the clone.
1 parent 314c12a commit e2092d7

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn parse_unstable<'a>(
5353

5454
for param in list.mixed() {
5555
let param_span = param.span();
56-
if let Some(ident) = param.meta_item().and_then(|i| i.path_without_args().word()) {
56+
if let Some(ident) = param.meta_item().and_then(|i| i.path().word()) {
5757
res.push(ident.name);
5858
} else {
5959
cx.emit_err(session_diagnostics::ExpectsFeatures {

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl SingleAttributeParser for DeprecationParser {
7979
return None;
8080
};
8181

82-
let ident_name = param.path_without_args().word_sym();
82+
let ident_name = param.path().word_sym();
8383

8484
match ident_name {
8585
Some(name @ sym::since) => {
@@ -102,7 +102,7 @@ impl SingleAttributeParser for DeprecationParser {
102102
_ => {
103103
cx.emit_err(session_diagnostics::UnknownMetaItem {
104104
span: param_span,
105-
item: param.path_without_args().to_string(),
105+
item: param.path().to_string(),
106106
expected: if features.deprecated_suggestion() {
107107
&["since", "note", "suggestion"]
108108
} else {

compiler/rustc_attr_parsing/src/attributes/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fn parse_repr(cx: &AcceptContext<'_>, param: &MetaItemParser<'_>) -> Option<Repr
9696

9797
// FIXME(jdonszelmann): invert the parsing here to match on the word first and then the
9898
// structure.
99-
let (name, ident_span) = if let Some(ident) = param.path_without_args().word() {
99+
let (name, ident_span) = if let Some(ident) = param.path().word() {
100100
(Some(ident.name), ident.span)
101101
} else {
102102
(None, rustc_span::DUMMY_SP)

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn insert_value_into_option_or_error(
204204
if item.is_some() {
205205
cx.emit_err(session_diagnostics::MultipleItem {
206206
span: param.span(),
207-
item: param.path_without_args().to_string(),
207+
item: param.path().to_string(),
208208
});
209209
None
210210
} else if let Some(v) = param.args().name_value()
@@ -242,13 +242,13 @@ pub(crate) fn parse_stability(
242242
return None;
243243
};
244244

245-
match param.path_without_args().word_sym() {
245+
match param.path().word_sym() {
246246
Some(sym::feature) => insert_value_into_option_or_error(cx, &param, &mut feature)?,
247247
Some(sym::since) => insert_value_into_option_or_error(cx, &param, &mut since)?,
248248
_ => {
249249
cx.emit_err(session_diagnostics::UnknownMetaItem {
250250
span: param_span,
251-
item: param.path_without_args().to_string(),
251+
item: param.path().to_string(),
252252
expected: &["feature", "since"],
253253
});
254254
return None;
@@ -310,7 +310,7 @@ pub(crate) fn parse_unstability(
310310
return None;
311311
};
312312

313-
match param.path_without_args().word_sym() {
313+
match param.path().word_sym() {
314314
Some(sym::feature) => insert_value_into_option_or_error(cx, &param, &mut feature)?,
315315
Some(sym::reason) => insert_value_into_option_or_error(cx, &param, &mut reason)?,
316316
Some(sym::issue) => {
@@ -349,7 +349,7 @@ pub(crate) fn parse_unstability(
349349
_ => {
350350
cx.emit_err(session_diagnostics::UnknownMetaItem {
351351
span: param.span(),
352-
item: param.path_without_args().to_string(),
352+
item: param.path().to_string(),
353353
expected: &["feature", "reason", "issue", "soft", "implied_by"],
354354
});
355355
return None;

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<'sess> AttributeParser<'sess> {
260260
// }
261261
ast::AttrKind::Normal(n) => {
262262
let parser = MetaItemParser::from_attr(n, self.dcx());
263-
let path = parser.path_without_args();
263+
let path = parser.path();
264264
let args = parser.args();
265265
let parts = path.segments().map(|i| i.name).collect::<Vec<_>>();
266266

compiler/rustc_attr_parsing/src/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ impl<'a> MetaItemParser<'a> {
258258
/// - `#[rustfmt::skip]`: `rustfmt::skip` is a path
259259
/// - `#[allow(clippy::complexity)]`: `clippy::complexity` is a path
260260
/// - `#[inline]`: `inline` is a single segment path
261-
pub fn path_without_args(&self) -> PathParser<'a> {
262-
self.path.clone()
261+
pub fn path(&self) -> &PathParser<'a> {
262+
&self.path
263263
}
264264

265265
/// Gets just the args parser, without caring about the path.
@@ -274,7 +274,7 @@ impl<'a> MetaItemParser<'a> {
274274
/// - `#[rustfmt::skip]`: `rustfmt::skip` is a path,
275275
/// and not a word and should instead be parsed using [`path`](Self::path)
276276
pub fn word_is(&self, sym: Symbol) -> Option<&ArgParser<'a>> {
277-
self.path_without_args().word_is(sym).then(|| self.args())
277+
self.path().word_is(sym).then(|| self.args())
278278
}
279279
}
280280

0 commit comments

Comments
 (0)