Skip to content

Commit 60b5ca6

Browse files
committed
Auto merge of rust-lang#123036 - matthiaskrgr:rollup-dj8hra4, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#122842 (Don't emit an error about failing to produce a file with a specific name if user never gave an explicit name) - rust-lang#122881 (Delegation: fix ICE on `bound_vars` divergence) - rust-lang#122910 (Validate that we're only matching on unit struct for path pattern) - rust-lang#122970 (Use `chunk_by` when building `ReverseSccGraph`) - rust-lang#122988 (add even more tests! ) - rust-lang#122999 (Fix unpretty UI test when /tmp does not exist) - rust-lang#123001 (Rename `{enter,exit}_lint_attrs` to `check_attributes{,_post}`) - rust-lang#123022 (Add `async-closures/once.rs` back to cranelift tests) - rust-lang#123034 (Add a bunch of needs-unwind annotations to tests) r? `@ghost` `@rustbot` modify labels: rollup
2 parents cb7c636 + 4369718 commit 60b5ca6

File tree

60 files changed

+744
-77
lines changed

Some content is hidden

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

60 files changed

+744
-77
lines changed

compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::constraints::ConstraintSccIndex;
22
use crate::RegionInferenceContext;
3-
use itertools::Itertools;
43
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
54
use rustc_data_structures::graph::vec_graph::VecGraph;
65
use rustc_data_structures::graph::WithSuccessors;
@@ -48,16 +47,16 @@ impl RegionInferenceContext<'_> {
4847
.universal_regions
4948
.universal_regions()
5049
.map(|region| (self.constraint_sccs.scc(region), region))
51-
.collect_vec();
50+
.collect::<Vec<_>>();
5251
paired_scc_regions.sort();
5352
let universal_regions = paired_scc_regions.iter().map(|&(_, region)| region).collect();
5453

5554
let mut scc_regions = FxIndexMap::default();
5655
let mut start = 0;
57-
for (scc, group) in &paired_scc_regions.into_iter().group_by(|(scc, _)| *scc) {
58-
let group_size = group.count();
59-
scc_regions.insert(scc, start..start + group_size);
60-
start += group_size;
56+
for chunk in paired_scc_regions.chunk_by(|&(scc1, _), &(scc2, _)| scc1 == scc2) {
57+
let (scc, _) = chunk[0];
58+
scc_regions.insert(scc, start..start + chunk.len());
59+
start += chunk.len();
6160
}
6261

6362
self.rev_scc_graph = Some(ReverseSccGraph { graph, scc_regions, universal_regions });

compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh

-16
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,6 @@ rm tests/ui/parser/unclosed-delimiter-in-dep.rs # submodule contains //~ERROR
4141
# missing features
4242
# ================
4343

44-
# requires stack unwinding
45-
# FIXME add needs-unwind to these tests
46-
rm -r tests/run-make/libtest-junit
47-
rm tests/ui/asm/may_unwind.rs
48-
rm tests/ui/stable-mir-print/basic_function.rs
49-
50-
# extra warning about -Cpanic=abort for proc macros
51-
rm tests/ui/proc-macro/crt-static.rs
52-
rm tests/ui/proc-macro/proc-macro-deprecated-attr.rs
53-
rm tests/ui/proc-macro/quote-debug.rs
54-
rm tests/ui/proc-macro/no-missing-docs.rs
55-
rm tests/ui/rust-2018/proc-macro-crate-in-paths.rs
56-
rm tests/ui/proc-macro/allowed-signatures.rs
57-
rm tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs
58-
5944
# vendor intrinsics
6045
rm tests/ui/simd/array-type.rs # "Index argument for `simd_insert` is not a constant"
6146
rm tests/ui/asm/x86_64/evex512-implicit-feature.rs # unimplemented AVX512 x86 vendor intrinsic
@@ -154,7 +139,6 @@ rm tests/ui/codegen/subtyping-enforces-type-equality.rs # assert_assignable bug
154139
# ======================
155140
rm tests/ui/backtrace.rs # TODO warning
156141
rm tests/ui/process/nofile-limit.rs # TODO some AArch64 linking issue
157-
rm tests/ui/async-await/async-closures/once.rs # FIXME bug in the rustc FnAbi calculation code
158142

159143
rm tests/ui/stdio-is-blocking.rs # really slow with unoptimized libstd
160144

compiler/rustc_codegen_ssa/src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ fn produce_final_output_artifacts(
592592
.unwrap()
593593
.to_owned();
594594

595-
if crate_output.outputs.contains_key(&output_type) {
595+
if crate_output.outputs.contains_explicit_name(&output_type) {
596596
// 2) Multiple codegen units, with `--emit foo=some_name`. We have
597597
// no good solution for this case, so warn the user.
598598
sess.dcx().emit_warn(errors::IgnoringEmitPath { extension });

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -793,12 +793,20 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
793793
fd: &'tcx hir::FnDecl<'tcx>,
794794
body_id: hir::BodyId,
795795
_: Span,
796-
_: LocalDefId,
796+
def_id: LocalDefId,
797797
) {
798798
let output = match fd.output {
799799
hir::FnRetTy::DefaultReturn(_) => None,
800800
hir::FnRetTy::Return(ty) => Some(ty),
801801
};
802+
if let Some(ty) = output
803+
&& let hir::TyKind::InferDelegation(sig_id, _) = ty.kind
804+
{
805+
let bound_vars: Vec<_> =
806+
self.tcx.fn_sig(sig_id).skip_binder().bound_vars().iter().collect();
807+
let hir_id = self.tcx.local_def_id_to_hir_id(def_id);
808+
self.map.late_bound_vars.insert(hir_id, bound_vars);
809+
}
802810
self.visit_fn_like_elision(fd.inputs, output, matches!(fk, intravisit::FnKind::Closure));
803811
intravisit::walk_fn_kind(self, fk);
804812
self.visit_nested_body(body_id)

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -2492,13 +2492,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24922492
hir_ty: Option<&hir::Ty<'_>>,
24932493
) -> ty::PolyFnSig<'tcx> {
24942494
let tcx = self.tcx();
2495-
let bound_vars = if let hir::FnRetTy::Return(ret_ty) = decl.output
2496-
&& let hir::TyKind::InferDelegation(sig_id, _) = ret_ty.kind
2497-
{
2498-
tcx.fn_sig(sig_id).skip_binder().bound_vars()
2499-
} else {
2500-
tcx.late_bound_vars(hir_id)
2501-
};
2495+
let bound_vars = tcx.late_bound_vars(hir_id);
25022496
debug!(?bound_vars);
25032497

25042498
// We proactively collect all the inferred type params to emit a single error per fn def.

compiler/rustc_hir_typeck/src/pat.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
919919
let e = report_unexpected_variant_res(tcx, res, qpath, pat.span, E0533, expected);
920920
return Ty::new_error(tcx, e);
921921
}
922-
Res::SelfCtor(..)
923-
| Res::Def(
922+
Res::SelfCtor(def_id) => {
923+
if let ty::Adt(adt_def, _) = *tcx.type_of(def_id).skip_binder().kind()
924+
&& adt_def.is_struct()
925+
&& let Some((CtorKind::Const, _)) = adt_def.non_enum_variant().ctor
926+
{
927+
// Ok, we allow unit struct ctors in patterns only.
928+
} else {
929+
let e = report_unexpected_variant_res(
930+
tcx,
931+
res,
932+
qpath,
933+
pat.span,
934+
E0533,
935+
"unit struct",
936+
);
937+
return Ty::new_error(tcx, e);
938+
}
939+
}
940+
Res::Def(
924941
DefKind::Ctor(_, CtorKind::Const)
925942
| DefKind::Const
926943
| DefKind::AssocConst

compiler/rustc_lint/src/early.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ impl<'a, T: EarlyLintPass> EarlyContextAndPass<'a, T> {
7373

7474
self.inlined_check_id(id);
7575
debug!("early context: enter_attrs({:?})", attrs);
76-
lint_callback!(self, enter_lint_attrs, attrs);
76+
lint_callback!(self, check_attributes, attrs);
7777
ensure_sufficient_stack(|| f(self));
7878
debug!("early context: exit_attrs({:?})", attrs);
79-
lint_callback!(self, exit_lint_attrs, attrs);
79+
lint_callback!(self, check_attributes_post, attrs);
8080
self.context.builder.pop(push);
8181
}
8282
}

compiler/rustc_lint/src/late.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
//! for all lint attributes.
1616
1717
use crate::{passes::LateLintPassObject, LateContext, LateLintPass, LintStore};
18-
use rustc_ast as ast;
1918
use rustc_data_structures::stack::ensure_sufficient_stack;
2019
use rustc_data_structures::sync::{join, Lrc};
2120
use rustc_hir as hir;
@@ -62,13 +61,13 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
6261
let prev = self.context.last_node_with_lint_attrs;
6362
self.context.last_node_with_lint_attrs = id;
6463
debug!("late context: enter_attrs({:?})", attrs);
65-
lint_callback!(self, enter_lint_attrs, attrs);
64+
lint_callback!(self, check_attributes, attrs);
6665
for attr in attrs {
6766
lint_callback!(self, check_attribute, attr);
6867
}
6968
f(self);
7069
debug!("late context: exit_attrs({:?})", attrs);
71-
lint_callback!(self, exit_lint_attrs, attrs);
70+
lint_callback!(self, check_attributes_post, attrs);
7271
self.context.last_node_with_lint_attrs = prev;
7372
}
7473

@@ -310,10 +309,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
310309
lint_callback!(self, check_path, p, id);
311310
hir_visit::walk_path(self, p);
312311
}
313-
314-
fn visit_attribute(&mut self, attr: &'tcx ast::Attribute) {
315-
lint_callback!(self, check_attribute, attr);
316-
}
317312
}
318313

319314
// Combines multiple lint passes into a single pass, at runtime. Each

compiler/rustc_lint/src/passes.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,8 @@ macro_rules! late_lint_methods {
4141
fn check_variant(a: &'tcx rustc_hir::Variant<'tcx>);
4242
fn check_path(a: &rustc_hir::Path<'tcx>, b: rustc_hir::HirId);
4343
fn check_attribute(a: &'tcx rustc_ast::Attribute);
44-
45-
/// Called when entering a syntax node that can have lint attributes such
46-
/// as `#[allow(...)]`. Called with *all* the attributes of that node.
47-
fn enter_lint_attrs(a: &'tcx [rustc_ast::Attribute]);
48-
49-
/// Counterpart to `enter_lint_attrs`.
50-
fn exit_lint_attrs(a: &'tcx [rustc_ast::Attribute]);
44+
fn check_attributes(a: &'tcx [rustc_ast::Attribute]);
45+
fn check_attributes_post(a: &'tcx [rustc_ast::Attribute]);
5146
]);
5247
)
5348
}
@@ -162,16 +157,11 @@ macro_rules! early_lint_methods {
162157
fn check_impl_item(a: &rustc_ast::AssocItem);
163158
fn check_variant(a: &rustc_ast::Variant);
164159
fn check_attribute(a: &rustc_ast::Attribute);
160+
fn check_attributes(a: &[rustc_ast::Attribute]);
161+
fn check_attributes_post(a: &[rustc_ast::Attribute]);
165162
fn check_mac_def(a: &rustc_ast::MacroDef);
166163
fn check_mac(a: &rustc_ast::MacCall);
167164

168-
/// Called when entering a syntax node that can have lint attributes such
169-
/// as `#[allow(...)]`. Called with *all* the attributes of that node.
170-
fn enter_lint_attrs(a: &[rustc_ast::Attribute]);
171-
172-
/// Counterpart to `enter_lint_attrs`.
173-
fn exit_lint_attrs(a: &[rustc_ast::Attribute]);
174-
175165
fn enter_where_predicate(a: &rustc_ast::WherePredicate);
176166
fn exit_where_predicate(a: &rustc_ast::WherePredicate);
177167
]);

compiler/rustc_session/src/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,11 @@ impl OutputTypes {
557557
self.0.contains_key(key)
558558
}
559559

560+
/// Returns `true` if user specified a name and not just produced type
561+
pub fn contains_explicit_name(&self, key: &OutputType) -> bool {
562+
self.0.get(key).map_or(false, |f| f.is_some())
563+
}
564+
560565
pub fn iter(&self) -> BTreeMapIter<'_, OutputType, Option<OutFileName>> {
561566
self.0.iter()
562567
}

src/tools/clippy/clippy_config/src/msrvs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ impl Msrv {
143143
None
144144
}
145145

146-
pub fn enter_lint_attrs(&mut self, sess: &Session, attrs: &[Attribute]) {
146+
pub fn check_attributes(&mut self, sess: &Session, attrs: &[Attribute]) {
147147
if let Some(version) = Self::parse_attr(sess, attrs) {
148148
self.stack.push(version);
149149
}
150150
}
151151

152-
pub fn exit_lint_attrs(&mut self, sess: &Session, attrs: &[Attribute]) {
152+
pub fn check_attributes_post(&mut self, sess: &Session, attrs: &[Attribute]) {
153153
if Self::parse_attr(sess, attrs).is_some() {
154154
self.stack.pop();
155155
}

src/tools/clippy/clippy_lints/src/cognitive_complexity.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ impl<'tcx> LateLintPass<'tcx> for CognitiveComplexity {
158158
}
159159
}
160160

161-
fn enter_lint_attrs(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
161+
fn check_attributes(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
162162
self.limit.push_attrs(cx.sess(), attrs, "cognitive_complexity");
163163
}
164-
fn exit_lint_attrs(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
164+
fn check_attributes_post(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
165165
self.limit.pop_attrs(cx.sess(), attrs, "cognitive_complexity");
166166
}
167167
}

src/tools/clippy/clippy_lints/src/missing_doc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@ impl MissingDoc {
162162
impl_lint_pass!(MissingDoc => [MISSING_DOCS_IN_PRIVATE_ITEMS]);
163163

164164
impl<'tcx> LateLintPass<'tcx> for MissingDoc {
165-
fn enter_lint_attrs(&mut self, _: &LateContext<'tcx>, attrs: &'tcx [ast::Attribute]) {
165+
fn check_attributes(&mut self, _: &LateContext<'tcx>, attrs: &'tcx [ast::Attribute]) {
166166
let doc_hidden = self.doc_hidden() || is_doc_hidden(attrs);
167167
self.doc_hidden_stack.push(doc_hidden);
168168
}
169169

170-
fn exit_lint_attrs(&mut self, _: &LateContext<'tcx>, _: &'tcx [ast::Attribute]) {
170+
fn check_attributes_post(&mut self, _: &LateContext<'tcx>, _: &'tcx [ast::Attribute]) {
171171
self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
172172
}
173173

src/tools/clippy/clippy_lints/src/utils/internal_lints/msrv_attr_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl LateLintPass<'_> for MsrvAttrImpl {
4242
.filter(|t| matches!(t.unpack(), GenericArgKind::Type(_)))
4343
.any(|t| match_type(cx, t.expect_ty(), &paths::MSRV))
4444
})
45-
&& !items.iter().any(|item| item.ident.name == sym!(enter_lint_attrs))
45+
&& !items.iter().any(|item| item.ident.name == sym!(check_attributes))
4646
{
4747
let context = if is_late_pass { "LateContext" } else { "EarlyContext" };
4848
let lint_pass = if is_late_pass { "LateLintPass" } else { "EarlyLintPass" };

src/tools/clippy/clippy_utils/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ use rustc_middle::hir::nested_filter;
131131
#[macro_export]
132132
macro_rules! extract_msrv_attr {
133133
($context:ident) => {
134-
fn enter_lint_attrs(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
134+
fn check_attributes(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
135135
let sess = rustc_lint::LintContext::sess(cx);
136-
self.msrv.enter_lint_attrs(sess, attrs);
136+
self.msrv.check_attributes(sess, attrs);
137137
}
138138

139-
fn exit_lint_attrs(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
139+
fn check_attributes_post(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
140140
let sess = rustc_lint::LintContext::sess(cx);
141-
self.msrv.exit_lint_attrs(sess, attrs);
141+
self.msrv.check_attributes_post(sess, attrs);
142142
}
143143
};
144144
}

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const ENTRY_LIMIT: usize = 900;
1818
// FIXME: The following limits should be reduced eventually.
1919

2020
const ISSUES_ENTRY_LIMIT: usize = 1750;
21-
const ROOT_ENTRY_LIMIT: usize = 859;
21+
const ROOT_ENTRY_LIMIT: usize = 860;
2222

2323
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
2424
"rs", // test source files

tests/run-make/libtest-junit/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# ignore-cross-compile
2+
# needs-unwind contains should_panic test
23
include ../tools.mk
34

45
# Test expected libtest's junit output

tests/ui/asm/may_unwind.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ run-pass
22
//@ needs-asm-support
3+
//@ needs-unwind
34

45
#![feature(asm_unwind)]
56

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ICE cannot convert Refree.. to a region vid
2+
// issue: rust-lang/rust#114464
3+
4+
#![feature(generic_const_exprs)]
5+
#![allow(incomplete_features)]
6+
7+
fn test<const N: usize>() {}
8+
9+
fn wow<'a>() {
10+
test::<{
11+
let _: &'a ();
12+
//~^ ERROR cannot capture late-bound lifetime in constant
13+
3
14+
}>();
15+
}
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: cannot capture late-bound lifetime in constant
2+
--> $DIR/convert-refree-region-vid-ice-114464.rs:11:17
3+
|
4+
LL | fn wow<'a>() {
5+
| -- lifetime defined here
6+
LL | test::<{
7+
LL | let _: &'a ();
8+
| ^^
9+
10+
error: aborting due to 1 previous error
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// ICE no entry found for key generics_of
2+
// issue: rust-lang/rust#113133
3+
4+
#![allow(incomplete_features)]
5+
#![feature(generic_const_exprs, non_lifetime_binders)]
6+
7+
pub fn foo()
8+
where
9+
for<const N: usize = { const fn bar() {} bar(); 1 }> ():,
10+
//~^ ERROR defaults for generic parameters are not allowed in `for<...>` binders
11+
{}
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: defaults for generic parameters are not allowed in `for<...>` binders
2+
--> $DIR/no-entry-found-for-key-ice-gce-nlb-113133.rs:9:9
3+
|
4+
LL | for<const N: usize = { const fn bar() {} bar(); 1 }> ():,
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+

0 commit comments

Comments
 (0)