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

Lines changed: 5 additions & 6 deletions
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

Lines changed: 0 additions & 16 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 9 additions & 1 deletion
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

Lines changed: 1 addition & 7 deletions
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

Lines changed: 19 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 7 deletions
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

Lines changed: 4 additions & 14 deletions
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

Lines changed: 5 additions & 0 deletions
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
}

0 commit comments

Comments
 (0)