Skip to content

Commit 97ea17b

Browse files
committed
Auto merge of #139194 - matthiaskrgr:rollup-2mhep38, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #138426 (Fix `armv7-sony-vita-newlibeabihf` LLVM target triple) - #138840 (rustc_resolve: Test the order that preludes are resolved) - #139039 (Reduce kw::Empty usage, part 4) - #139151 (tidy: properly check for orphaned unstable_book pages) - #139176 (Remove fragile equal-pointers-unequal/*/print3.rs tests.) - #139179 (Remove me from vacation) - #139181 (Fix invalid link in docs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0b45675 + d492348 commit 97ea17b

File tree

16 files changed

+207
-135
lines changed

16 files changed

+207
-135
lines changed

Diff for: compiler/rustc_middle/src/ty/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ impl<'tcx> rustc_type_ir::Flags for Clauses<'tcx> {
953953
/// environment. `ParamEnv` is the type that represents this information. See the
954954
/// [dev guide chapter][param_env_guide] for more information.
955955
///
956-
/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/param_env/param_env_summary.html
956+
/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/typing_parameter_envs.html
957957
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
958958
#[derive(HashStable, TypeVisitable, TypeFoldable)]
959959
pub struct ParamEnv<'tcx> {
@@ -977,7 +977,7 @@ impl<'tcx> ParamEnv<'tcx> {
977977
/// to use an empty environment. See the [dev guide section][param_env_guide]
978978
/// for information on what a `ParamEnv` is and how to acquire one.
979979
///
980-
/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/param_env/param_env_summary.html
980+
/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/typing_parameter_envs.html
981981
#[inline]
982982
pub fn empty() -> Self {
983983
Self::new(ListWithCachedTypeInfo::empty())

Diff for: compiler/rustc_passes/src/check_attr.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use rustc_session::lint::builtin::{
3535
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_ATTRIBUTES,
3636
};
3737
use rustc_session::parse::feature_err;
38-
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, kw, sym};
38+
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, edition, kw, sym};
3939
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
4040
use rustc_trait_selection::infer::{TyCtxtInferExt, ValuePairs};
4141
use rustc_trait_selection::traits::ObligationCtxt;
@@ -1038,14 +1038,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
10381038
// FIXME: Once rustdoc can handle URL conflicts on case insensitive file systems, we
10391039
// can remove the `SelfTy` case here, remove `sym::SelfTy`, and update the
10401040
// `#[doc(keyword = "SelfTy")` attribute in `library/std/src/keyword_docs.rs`.
1041-
s <= kw::Union || s == sym::SelfTy
1041+
s.is_reserved(|| edition::LATEST_STABLE_EDITION) || s.is_weak() || s == sym::SelfTy
10421042
}
10431043

1044-
let doc_keyword = meta.value_str().unwrap_or(kw::Empty);
1045-
if doc_keyword == kw::Empty {
1046-
self.doc_attr_str_error(meta, "keyword");
1047-
return;
1048-
}
1044+
let doc_keyword = match meta.value_str() {
1045+
Some(value) if value != kw::Empty => value,
1046+
_ => return self.doc_attr_str_error(meta, "keyword"),
1047+
};
1048+
10491049
let item_kind = match self.tcx.hir_node(hir_id) {
10501050
hir::Node::Item(item) => Some(&item.kind),
10511051
_ => None,

Diff for: compiler/rustc_resolve/src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10911091
));
10921092
}
10931093
Scope::BuiltinAttrs => {
1094-
let res = Res::NonMacroAttr(NonMacroAttrKind::Builtin(kw::Empty));
1094+
let res = Res::NonMacroAttr(NonMacroAttrKind::Builtin(sym::dummy));
10951095
if filter_fn(res) {
10961096
suggestions.extend(
10971097
BUILTIN_ATTRIBUTES

Diff for: compiler/rustc_span/src/hygiene.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,8 @@ pub fn decode_syntax_context<D: Decoder, F: FnOnce(&mut D, u32) -> SyntaxContext
14401440
}
14411441
}
14421442
Entry::Vacant(entry) => {
1443-
// We are the first thread to start decoding. Mark the current thread as being progress.
1443+
// We are the first thread to start decoding. Mark the current thread as being
1444+
// progress.
14441445
context.local_in_progress.borrow_mut().insert(raw_id);
14451446

14461447
// Allocate and store SyntaxContext id *before* calling the decoder function,

Diff for: compiler/rustc_span/src/symbol.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ symbols! {
131131
// tidy-alphabetical-end
132132

133133
// Weak keywords, have special meaning only in specific contexts.
134-
// Matching predicates: none
134+
// Matching predicates: `is_weak`
135135
// tidy-alphabetical-start
136136
Auto: "auto",
137137
Builtin: "builtin",
@@ -2725,6 +2725,10 @@ impl Symbol {
27252725
|| self.is_unused_keyword_conditional(edition)
27262726
}
27272727

2728+
pub fn is_weak(self) -> bool {
2729+
self >= kw::Auto && self <= kw::Yeet
2730+
}
2731+
27282732
/// A keyword or reserved identifier that can be used as a path segment.
27292733
pub fn is_path_segment_keyword(self) -> bool {
27302734
self == kw::Super

Diff for: compiler/rustc_target/src/spec/targets/armv7_sony_vita_newlibeabihf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
1515
);
1616

1717
Target {
18-
llvm_target: "thumbv7a-vita-eabihf".into(),
18+
llvm_target: "thumbv7a-sony-vita-eabihf".into(),
1919
metadata: TargetMetadata {
2020
description: Some(
2121
"Armv7-A Cortex-A9 Sony PlayStation Vita (requires VITASDK toolchain)".into(),

Diff for: src/doc/unstable-book/src/library-features/c-variadic.md

-26
This file was deleted.

Diff for: src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs

+16-14
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
7979
if apa.counter <= 1 || !apa.has_expensive_expr_after_last_attr {
8080
continue;
8181
}
82+
let first_bind_ident = apa.first_bind_ident.unwrap();
8283
span_lint_and_then(
8384
cx,
8485
SIGNIFICANT_DROP_TIGHTENING,
85-
apa.first_bind_ident.span,
86+
first_bind_ident.span,
8687
"temporary with significant `Drop` can be early dropped",
8788
|diag| {
8889
match apa.counter {
@@ -91,13 +92,13 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
9192
let indent = " ".repeat(indent_of(cx, apa.last_stmt_span).unwrap_or(0));
9293
let init_method = snippet(cx, apa.first_method_span, "..");
9394
let usage_method = snippet(cx, apa.last_method_span, "..");
94-
let stmt = if apa.last_bind_ident == Ident::empty() {
95-
format!("\n{indent}{init_method}.{usage_method};")
96-
} else {
95+
let stmt = if let Some(last_bind_ident) = apa.last_bind_ident {
9796
format!(
9897
"\n{indent}let {} = {init_method}.{usage_method};",
99-
snippet(cx, apa.last_bind_ident.span, ".."),
98+
snippet(cx, last_bind_ident.span, ".."),
10099
)
100+
} else {
101+
format!("\n{indent}{init_method}.{usage_method};")
101102
};
102103

103104
diag.multipart_suggestion_verbose(
@@ -113,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
113114
format!(
114115
"\n{}drop({});",
115116
" ".repeat(indent_of(cx, apa.last_stmt_span).unwrap_or(0)),
116-
apa.first_bind_ident
117+
first_bind_ident
117118
),
118119
Applicability::MaybeIncorrect,
119120
);
@@ -124,7 +125,7 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
124125
apa.first_block_span,
125126
format!(
126127
"temporary `{}` is currently being dropped at the end of its contained scope",
127-
apa.first_bind_ident
128+
first_bind_ident
128129
),
129130
);
130131
},
@@ -283,7 +284,7 @@ impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> {
283284
let mut apa = AuxParamsAttr {
284285
first_block_hir_id: self.ap.curr_block_hir_id,
285286
first_block_span: self.ap.curr_block_span,
286-
first_bind_ident: ident,
287+
first_bind_ident: Some(ident),
287288
first_method_span: {
288289
let expr_or_init = expr_or_init(self.cx, expr);
289290
if let hir::ExprKind::MethodCall(_, local_expr, _, span) = expr_or_init.kind {
@@ -307,7 +308,7 @@ impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> {
307308
match self.ap.curr_stmt.kind {
308309
hir::StmtKind::Let(local) => {
309310
if let hir::PatKind::Binding(_, _, ident, _) = local.pat.kind {
310-
apa.last_bind_ident = ident;
311+
apa.last_bind_ident = Some(ident);
311312
}
312313
if let Some(local_init) = local.init
313314
&& let hir::ExprKind::MethodCall(_, _, _, span) = local_init.kind
@@ -373,15 +374,15 @@ struct AuxParamsAttr {
373374
first_block_span: Span,
374375
/// The binding or variable that references the initial construction of the type marked with
375376
/// `#[has_significant_drop]`.
376-
first_bind_ident: Ident,
377+
first_bind_ident: Option<Ident>,
377378
/// Similar to `init_bind_ident` but encompasses the right-hand method call.
378379
first_method_span: Span,
379380
/// Similar to `init_bind_ident` but encompasses the whole contained statement.
380381
first_stmt_span: Span,
381382

382383
/// The last visited binding or variable span within a block that had any referenced inner type
383384
/// marked with `#[has_significant_drop]`.
384-
last_bind_ident: Ident,
385+
last_bind_ident: Option<Ident>,
385386
/// Similar to `last_bind_span` but encompasses the right-hand method call.
386387
last_method_span: Span,
387388
/// Similar to `last_bind_span` but encompasses the whole contained statement.
@@ -395,10 +396,10 @@ impl Default for AuxParamsAttr {
395396
has_expensive_expr_after_last_attr: false,
396397
first_block_hir_id: HirId::INVALID,
397398
first_block_span: DUMMY_SP,
398-
first_bind_ident: Ident::empty(),
399+
first_bind_ident: None,
399400
first_method_span: DUMMY_SP,
400401
first_stmt_span: DUMMY_SP,
401-
last_bind_ident: Ident::empty(),
402+
last_bind_ident: None,
402403
last_method_span: DUMMY_SP,
403404
last_stmt_span: DUMMY_SP,
404405
}
@@ -413,7 +414,7 @@ fn dummy_stmt_expr<'any>(expr: &'any hir::Expr<'any>) -> hir::Stmt<'any> {
413414
}
414415
}
415416

416-
fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: &Ident, lcx: &LateContext<'_>) -> bool {
417+
fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: &Option<Ident>, lcx: &LateContext<'_>) -> bool {
417418
if let hir::ExprKind::Call(fun, [first_arg]) = expr.kind
418419
&& let hir::ExprKind::Path(hir::QPath::Resolved(_, fun_path)) = &fun.kind
419420
&& let Res::Def(DefKind::Fn, did) = fun_path.res
@@ -422,6 +423,7 @@ fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: &Ident, lcx: &LateContext<'_
422423
let has_ident = |local_expr: &hir::Expr<'_>| {
423424
if let hir::ExprKind::Path(hir::QPath::Resolved(_, arg_path)) = &local_expr.kind
424425
&& let [first_arg_ps, ..] = arg_path.segments
426+
&& let Some(first_bind_ident) = first_bind_ident
425427
&& &first_arg_ps.ident == first_bind_ident
426428
{
427429
true

Diff for: src/tools/tidy/src/unstable_book.rs

+21-8
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ fn collect_unstable_book_lib_features_section_file_names(base_src_path: &Path) -
7272
collect_unstable_book_section_file_names(&unstable_book_lib_features_path(base_src_path))
7373
}
7474

75+
/// Would switching underscores for dashes work?
76+
fn maybe_suggest_dashes(names: &BTreeSet<String>, feature_name: &str, bad: &mut bool) {
77+
let with_dashes = feature_name.replace('_', "-");
78+
if names.contains(&with_dashes) {
79+
tidy_error!(
80+
bad,
81+
"the file `{}.md` contains underscores; use dashes instead: `{}.md`",
82+
feature_name,
83+
with_dashes,
84+
);
85+
}
86+
}
87+
7588
pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) {
7689
let lang_features = features.lang;
7790
let lib_features = features
@@ -93,14 +106,13 @@ pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) {
93106
// Check for Unstable Book sections that don't have a corresponding unstable feature
94107
for feature_name in &unstable_book_lib_features_section_file_names - &unstable_lib_feature_names
95108
{
96-
if !unstable_lang_feature_names.contains(&feature_name) {
97-
tidy_error!(
98-
bad,
99-
"The Unstable Book has a 'library feature' section '{}' which doesn't \
109+
tidy_error!(
110+
bad,
111+
"The Unstable Book has a 'library feature' section '{}' which doesn't \
100112
correspond to an unstable library feature",
101-
feature_name
102-
);
103-
}
113+
feature_name
114+
);
115+
maybe_suggest_dashes(&unstable_lib_feature_names, &feature_name, bad);
104116
}
105117

106118
// Check for Unstable Book sections that don't have a corresponding unstable feature.
@@ -112,7 +124,8 @@ pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) {
112124
"The Unstable Book has a 'language feature' section '{}' which doesn't \
113125
correspond to an unstable language feature",
114126
feature_name
115-
)
127+
);
128+
maybe_suggest_dashes(&unstable_lang_feature_names, &feature_name, bad);
116129
}
117130

118131
// List unstable features that don't have Unstable Book sections.

Diff for: tests/ui/codegen/equal-pointers-unequal/as-cast/print3.rs

-23
This file was deleted.

Diff for: tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print3.rs

-25
This file was deleted.

Diff for: tests/ui/codegen/equal-pointers-unequal/strict-provenance/print3.rs

-25
This file was deleted.

Diff for: tests/ui/resolve/auxiliary/macro_helpers.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* macro namespace. */
2+
3+
extern crate proc_macro;
4+
use proc_macro::*;
5+
use std::str::FromStr;
6+
7+
const ERROR: &str = "fn helper() { \"helper\" }";
8+
// https://doc.rust-lang.org/nightly/std/prelude/v1/index.html#attributes
9+
// NOTE: all the bang macros in std are currently unstable.
10+
#[proc_macro_attribute] pub fn test // lang.
11+
(_: TokenStream, _: TokenStream) -> TokenStream {
12+
TokenStream::from_str("fn test_macro() { \"\" }").unwrap() }
13+
// https://doc.rust-lang.org/nightly/reference/attributes.html#built-in-attributes-index
14+
#[proc_macro_attribute] pub fn global_allocator // lang.
15+
(_: TokenStream, _: TokenStream) -> TokenStream {
16+
TokenStream::from_str("fn global_allocator_macro() { \"\" }").unwrap() }

0 commit comments

Comments
 (0)