Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ed6c958

Browse files
committed
Auto merge of #95760 - Dylan-DPC:rollup-uskzggh, r=Dylan-DPC
Rollup of 4 pull requests Successful merges: - #95189 (Stop flagging unexpected inner attributes as outer ones in certain diagnostics) - #95752 (Regression test for #82866) - #95753 (Correct safety reasoning in `str::make_ascii_{lower,upper}case()`) - #95757 (Use gender neutral terms) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents f565016 + d907ab8 commit ed6c958

File tree

15 files changed

+86
-34
lines changed

15 files changed

+86
-34
lines changed

‎compiler/rustc_builtin_macros/src/source_util.rs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,20 @@ pub fn expand_include<'cx>(
141141

142142
fn make_items(mut self: Box<ExpandResult<'a>>) -> Option<SmallVec<[P<ast::Item>; 1]>> {
143143
let mut ret = SmallVec::new();
144-
whileself.p.token != token::Eof {
144+
loop {
145145
match self.p.parse_item(ForceCollect::No) {
146146
Err(mut err) => {
147147
err.emit();
148148
break;
149149
}
150150
Ok(Some(item)) => ret.push(item),
151151
Ok(None) => {
152-
let token = pprust::token_to_string(&self.p.token);
153-
let msg = format!("expected item, found `{}`", token);
154-
self.p.struct_span_err(self.p.token.span, &msg).emit();
152+
if self.p.token != token::Eof {
153+
let token = pprust::token_to_string(&self.p.token);
154+
let msg = format!("expected item, found `{}`", token);
155+
self.p.struct_span_err(self.p.token.span, &msg).emit();
156+
}
157+
155158
break;
156159
}
157160
}

‎compiler/rustc_expand/src/mbe/macro_parser.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ pub(super) fn count_metavar_decls(matcher: &[TokenTree]) -> usize {
315315
/// only on the nesting depth of repetitions in the originating token tree it
316316
/// was derived from.
317317
///
318-
/// In layman's terms: `NamedMatch` will form a tree representing nested matches of a particular
318+
/// In layperson's terms: `NamedMatch` will form a tree representing nested matches of a particular
319319
/// meta variable. For example, if we are matching the following macro against the following
320320
/// invocation...
321321
///

‎compiler/rustc_parse/src/parser/attr.rs‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use tracing::debug;
1313
#[derive(Debug)]
1414
pub enum InnerAttrPolicy<'a> {
1515
Permitted,
16-
Forbidden { reason: &'a str, saw_doc_comment: bool, prev_attr_sp: Option<Span> },
16+
Forbidden { reason: &'a str, saw_doc_comment: bool, prev_outer_attr_sp: Option<Span> },
1717
}
1818

1919
const DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG: &str = "an inner attribute is not \
@@ -22,7 +22,7 @@ const DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG: &str = "an inner attribute is not \
2222
pub(super) const DEFAULT_INNER_ATTR_FORBIDDEN: InnerAttrPolicy<'_> = InnerAttrPolicy::Forbidden {
2323
reason: DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG,
2424
saw_doc_comment: false,
25-
prev_attr_sp: None,
25+
prev_outer_attr_sp: None,
2626
};
2727

2828
enum OuterAttributeType {
@@ -34,22 +34,24 @@ enum OuterAttributeType {
3434
impl<'a> Parser<'a> {
3535
/// Parses attributes that appear before an item.
3636
pub(super) fn parse_outer_attributes(&mut self) -> PResult<'a, AttrWrapper> {
37-
let mut attrs: Vec<ast::Attribute> = Vec::new();
37+
let mut outer_attrs: Vec<ast::Attribute> = Vec::new();
3838
let mut just_parsed_doc_comment = false;
3939
let start_pos = self.token_cursor.num_next_calls;
4040
loop {
4141
let attr = if self.check(&token::Pound) {
42+
let prev_outer_attr_sp = outer_attrs.last().map(|attr| attr.span);
43+
4244
let inner_error_reason = if just_parsed_doc_comment {
4345
"an inner attribute is not permitted following an outer doc comment"
44-
} else if !attrs.is_empty() {
46+
} else if prev_outer_attr_sp.is_some() {
4547
"an inner attribute is not permitted following an outer attribute"
4648
} else {
4749
DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG
4850
};
4951
let inner_parse_policy = InnerAttrPolicy::Forbidden {
5052
reason: inner_error_reason,
5153
saw_doc_comment: just_parsed_doc_comment,
52-
prev_attr_sp: attrs.last().map(|a| a.span),
54+
prev_outer_attr_sp,
5355
};
5456
just_parsed_doc_comment = false;
5557
Some(self.parse_attribute(inner_parse_policy)?)
@@ -97,12 +99,14 @@ impl<'a> Parser<'a> {
9799
};
98100

99101
if let Some(attr) = attr {
100-
attrs.push(attr);
102+
if attr.style == ast::AttrStyle::Outer {
103+
outer_attrs.push(attr);
104+
}
101105
} else {
102106
break;
103107
}
104108
}
105-
Ok(AttrWrapper::new(attrs.into(), start_pos))
109+
Ok(AttrWrapper::new(outer_attrs.into(), start_pos))
106110
}
107111

108112
/// Matches `attribute = # ! [ meta_item ]`.
@@ -215,15 +219,15 @@ impl<'a> Parser<'a> {
215219
}
216220

217221
pub(super) fn error_on_forbidden_inner_attr(&self, attr_sp: Span, policy: InnerAttrPolicy<'_>) {
218-
if let InnerAttrPolicy::Forbidden { reason, saw_doc_comment, prev_attr_sp } = policy {
219-
let prev_attr_note =
222+
if let InnerAttrPolicy::Forbidden { reason, saw_doc_comment, prev_outer_attr_sp } = policy {
223+
let prev_outer_attr_note =
220224
if saw_doc_comment { "previous doc comment" } else { "previous outer attribute" };
221225

222226
let mut diag = self.struct_span_err(attr_sp, reason);
223227

224-
if let Some(prev_attr_sp) = prev_attr_sp {
228+
if let Some(prev_outer_attr_sp) = prev_outer_attr_sp {
225229
diag.span_label(attr_sp, "not permitted following an outer attribute")
226-
.span_label(prev_attr_sp, prev_attr_note);
230+
.span_label(prev_outer_attr_sp, prev_outer_attr_note);
227231
}
228232

229233
diag.note(

‎compiler/rustc_typeck/src/check/wfcheck.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ fn receiver_is_valid<'fcx, 'tcx>(
16571657
}
16581658
} else {
16591659
debug!("receiver_is_valid: type `{:?}` does not deref to `{:?}`", receiver_ty, self_ty);
1660-
// If he receiver already has errors reported due to it, consider it valid to avoid
1660+
// If the receiver already has errors reported due to it, consider it valid to avoid
16611661
// unnecessary errors (#58712).
16621662
return receiver_ty.references_error();
16631663
}

‎compiler/rustc_typeck/src/collect.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2700,7 +2700,7 @@ fn linkage_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: &str) -> Linkage {
27002700
// Use the names from src/llvm/docs/LangRef.rst here. Most types are only
27012701
// applicable to variable declarations and may not really make sense for
27022702
// Rust code in the first place but allow them anyway and trust that the
2703-
// user knows what s/he's doing. Who knows, unanticipated use cases may pop
2703+
// user knows what they're doing. Who knows, unanticipated use cases may pop
27042704
// up in the future.
27052705
//
27062706
// ghost, dllimport, dllexport and linkonce_odr_autohide are not supported

‎library/core/src/str/mod.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ impl str {
24062406
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
24072407
#[inline]
24082408
pub fn make_ascii_uppercase(&mut self) {
2409-
// SAFETY: safe because we transmute two types with the same layout.
2409+
// SAFETY: changing ASCII letters only does not invalidate UTF-8.
24102410
let me = unsafe { self.as_bytes_mut() };
24112411
me.make_ascii_uppercase()
24122412
}
@@ -2433,7 +2433,7 @@ impl str {
24332433
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
24342434
#[inline]
24352435
pub fn make_ascii_lowercase(&mut self) {
2436-
// SAFETY: safe because we transmute two types with the same layout.
2436+
// SAFETY: changing ASCII letters only does not invalidate UTF-8.
24372437
let me = unsafe { self.as_bytes_mut() };
24382438
me.make_ascii_lowercase()
24392439
}

‎library/std/src/fs/tests.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,9 @@ fn recursive_rmdir_toctou() {
644644
// Test for time-of-check to time-of-use issues.
645645
//
646646
// Scenario:
647-
// The attacker wants to get directory contents deleted, to which he does not have access.
648-
// He has a way to get a privileged Rust binary call `std::fs::remove_dir_all()` on a
649-
// directory he controls, e.g. in his home directory.
647+
// The attacker wants to get directory contents deleted, to which they do not have access.
648+
// They have a way to get a privileged Rust binary call `std::fs::remove_dir_all()` on a
649+
// directory they control, e.g. in their home directory.
650650
//
651651
// The POC sets up the `attack_dest/attack_file` which the attacker wants to have deleted.
652652
// The attacker repeatedly creates a directory and replaces it with a symlink from

‎library/std/src/thread/local.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ pub mod fast {
980980
unsafe fn try_initialize<F: FnOnce() -> T>(&self, init: F) -> Option<&'static T> {
981981
// SAFETY: See comment above (this function doc).
982982
if !mem::needs_drop::<T>() || unsafe { self.try_register_dtor() } {
983-
// SAFETY: See comment above (his function doc).
983+
// SAFETY: See comment above (this function doc).
984984
Some(unsafe { self.inner.initialize(init) })
985985
} else {
986986
None

‎src/test/ui/match/issue-82866.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
match x {
3+
//~^ ERROR cannot find value `x` in this scope
4+
Some::<v>(v) => (),
5+
//~^ ERROR cannot find type `v` in this scope
6+
}
7+
}

‎src/test/ui/match/issue-82866.stderr‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0425]: cannot find value `x` in this scope
2+
--> $DIR/issue-82866.rs:2:11
3+
|
4+
LL | match x {
5+
| ^ not found in this scope
6+
7+
error[E0412]: cannot find type `v` in this scope
8+
--> $DIR/issue-82866.rs:4:16
9+
|
10+
LL | Some::<v>(v) => (),
11+
| ^ not found in this scope
12+
13+
error: aborting due to 2 previous errors
14+
15+
Some errors have detailed explanations: E0412, E0425.
16+
For more information about an error, try `rustc --explain E0412`.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /