Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #123036

Merged
merged 29 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d1ba632
Delegation: fix ICE on `bound_vars` divergence
Bryanskiy Mar 22, 2024
bf12aa4
Don't emit an error about failing to produce a file with a specific name
pacak Mar 21, 2024
b84326e
tests/ui: Add a directory for warnings, add a test
pacak Mar 22, 2024
08235b1
Validate that we're only matching on unit struct for path pattern
compiler-errors Mar 22, 2024
87808e7
Use `chunk_by` when building `ReverseSccGraph`
cuviper Mar 24, 2024
127c36c
add test for https://github.com/rust-lang/rust/issues/119731
matthiaskrgr Mar 24, 2024
db68dc2
add test for #116599
matthiaskrgr Mar 24, 2024
8ed5e67
add test for #114464
matthiaskrgr Mar 24, 2024
cdea6d8
add test for ICE: no entry found for key for const function in gener…
matthiaskrgr Mar 24, 2024
b151e06
add test for ICE: min_specialization: Ok(['?0, Const { ty: usize, ki…
matthiaskrgr Mar 24, 2024
6203ebe
add test for ICE with associated_const_equality #108220
matthiaskrgr Mar 24, 2024
5e0d8c3
add test for ICE: no errors encountered even though delay_span_bug i…
matthiaskrgr Mar 24, 2024
56ea366
add test for Failed to normalize closure with TAIT #109020
matthiaskrgr Mar 24, 2024
e800b99
add tests for ICE in mir building with captured value of unresolved t…
matthiaskrgr Mar 24, 2024
e4d816e
add tests for ICE: 'broken MIR: bad assignment: NoSolution' on trait …
matthiaskrgr Mar 24, 2024
4719293
Fix unpretty UI test when /tmp does not exist
Alexendoo Mar 24, 2024
2cb5347
Rename `{enter,exit}_lint_attrs` to `check_attributes{,_post}`
Alexendoo Mar 24, 2024
e6918b1
Add async-closures/once.rs back to cranelift tests
compiler-errors Mar 25, 2024
3733dcc
Add needs-unwind annotations to a couple of tests
bjorn3 Mar 25, 2024
5f5dcae
Add needs-unwind for proc macro tests
bjorn3 Mar 25, 2024
ded16b3
Rollup merge of #122842 - pacak:explicit_name, r=michaelwoerister
matthiaskrgr Mar 25, 2024
ccc5310
Rollup merge of #122881 - Bryanskiy:delegation-fixes-2, r=petrochenkov
matthiaskrgr Mar 25, 2024
e9ec442
Rollup merge of #122910 - compiler-errors:unit-struct-in-path-pat-onl…
matthiaskrgr Mar 25, 2024
9b4ee1b
Rollup merge of #122970 - cuviper:use-chunk_by, r=Mark-Simulacrum
matthiaskrgr Mar 25, 2024
877f293
Rollup merge of #122988 - matthiaskrgr:icetests, r=petrochenkov
matthiaskrgr Mar 25, 2024
657dd0b
Rollup merge of #122999 - Alexendoo:unpretty-avoid-crash-test, r=petr…
matthiaskrgr Mar 25, 2024
10daf8a
Rollup merge of #123001 - Alexendoo:check-attributes, r=oli-obk
matthiaskrgr Mar 25, 2024
11f168f
Rollup merge of #123022 - compiler-errors:clif-tests-async-closure, r…
matthiaskrgr Mar 25, 2024
4369718
Rollup merge of #123034 - bjorn3:test_ignores, r=compiler-errors
matthiaskrgr Mar 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::constraints::ConstraintSccIndex;
use crate::RegionInferenceContext;
use itertools::Itertools;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::graph::vec_graph::VecGraph;
use rustc_data_structures::graph::WithSuccessors;
Expand Down Expand Up @@ -48,16 +47,16 @@ impl RegionInferenceContext<'_> {
.universal_regions
.universal_regions()
.map(|region| (self.constraint_sccs.scc(region), region))
.collect_vec();
.collect::<Vec<_>>();
paired_scc_regions.sort();
let universal_regions = paired_scc_regions.iter().map(|&(_, region)| region).collect();

let mut scc_regions = FxIndexMap::default();
let mut start = 0;
for (scc, group) in &paired_scc_regions.into_iter().group_by(|(scc, _)| *scc) {
let group_size = group.count();
scc_regions.insert(scc, start..start + group_size);
start += group_size;
for chunk in paired_scc_regions.chunk_by(|&(scc1, _), &(scc2, _)| scc1 == scc2) {
let (scc, _) = chunk[0];
scc_regions.insert(scc, start..start + chunk.len());
start += chunk.len();
}

self.rev_scc_graph = Some(ReverseSccGraph { graph, scc_regions, universal_regions });
Expand Down
16 changes: 0 additions & 16 deletions compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,6 @@ rm tests/ui/parser/unclosed-delimiter-in-dep.rs # submodule contains //~ERROR
# missing features
# ================

# requires stack unwinding
# FIXME add needs-unwind to these tests
rm -r tests/run-make/libtest-junit
rm tests/ui/asm/may_unwind.rs
rm tests/ui/stable-mir-print/basic_function.rs

# extra warning about -Cpanic=abort for proc macros
rm tests/ui/proc-macro/crt-static.rs
rm tests/ui/proc-macro/proc-macro-deprecated-attr.rs
rm tests/ui/proc-macro/quote-debug.rs
rm tests/ui/proc-macro/no-missing-docs.rs
rm tests/ui/rust-2018/proc-macro-crate-in-paths.rs
rm tests/ui/proc-macro/allowed-signatures.rs
rm tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs

# vendor intrinsics
rm tests/ui/simd/array-type.rs # "Index argument for `simd_insert` is not a constant"
rm tests/ui/asm/x86_64/evex512-implicit-feature.rs # unimplemented AVX512 x86 vendor intrinsic
Expand Down Expand Up @@ -154,7 +139,6 @@ rm tests/ui/codegen/subtyping-enforces-type-equality.rs # assert_assignable bug
# ======================
rm tests/ui/backtrace.rs # TODO warning
rm tests/ui/process/nofile-limit.rs # TODO some AArch64 linking issue
rm tests/ui/async-await/async-closures/once.rs # FIXME bug in the rustc FnAbi calculation code

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

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ fn produce_final_output_artifacts(
.unwrap()
.to_owned();

if crate_output.outputs.contains_key(&output_type) {
if crate_output.outputs.contains_explicit_name(&output_type) {
// 2) Multiple codegen units, with `--emit foo=some_name`. We have
// no good solution for this case, so warn the user.
sess.dcx().emit_warn(errors::IgnoringEmitPath { extension });
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,20 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
fd: &'tcx hir::FnDecl<'tcx>,
body_id: hir::BodyId,
_: Span,
_: LocalDefId,
def_id: LocalDefId,
) {
let output = match fd.output {
hir::FnRetTy::DefaultReturn(_) => None,
hir::FnRetTy::Return(ty) => Some(ty),
};
if let Some(ty) = output
&& let hir::TyKind::InferDelegation(sig_id, _) = ty.kind
{
let bound_vars: Vec<_> =
self.tcx.fn_sig(sig_id).skip_binder().bound_vars().iter().collect();
let hir_id = self.tcx.local_def_id_to_hir_id(def_id);
self.map.late_bound_vars.insert(hir_id, bound_vars);
}
self.visit_fn_like_elision(fd.inputs, output, matches!(fk, intravisit::FnKind::Closure));
intravisit::walk_fn_kind(self, fk);
self.visit_nested_body(body_id)
Expand Down
8 changes: 1 addition & 7 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2492,13 +2492,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
hir_ty: Option<&hir::Ty<'_>>,
) -> ty::PolyFnSig<'tcx> {
let tcx = self.tcx();
let bound_vars = if let hir::FnRetTy::Return(ret_ty) = decl.output
&& let hir::TyKind::InferDelegation(sig_id, _) = ret_ty.kind
{
tcx.fn_sig(sig_id).skip_binder().bound_vars()
} else {
tcx.late_bound_vars(hir_id)
};
let bound_vars = tcx.late_bound_vars(hir_id);
debug!(?bound_vars);

// We proactively collect all the inferred type params to emit a single error per fn def.
Expand Down
21 changes: 19 additions & 2 deletions compiler/rustc_hir_typeck/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let e = report_unexpected_variant_res(tcx, res, qpath, pat.span, E0533, expected);
return Ty::new_error(tcx, e);
}
Res::SelfCtor(..)
| Res::Def(
Res::SelfCtor(def_id) => {
if let ty::Adt(adt_def, _) = *tcx.type_of(def_id).skip_binder().kind()
&& adt_def.is_struct()
&& let Some((CtorKind::Const, _)) = adt_def.non_enum_variant().ctor
{
// Ok, we allow unit struct ctors in patterns only.
} else {
let e = report_unexpected_variant_res(
tcx,
res,
qpath,
pat.span,
E0533,
"unit struct",
);
return Ty::new_error(tcx, e);
}
}
Res::Def(
DefKind::Ctor(_, CtorKind::Const)
| DefKind::Const
| DefKind::AssocConst
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ impl<'a, T: EarlyLintPass> EarlyContextAndPass<'a, T> {

self.inlined_check_id(id);
debug!("early context: enter_attrs({:?})", attrs);
lint_callback!(self, enter_lint_attrs, attrs);
lint_callback!(self, check_attributes, attrs);
ensure_sufficient_stack(|| f(self));
debug!("early context: exit_attrs({:?})", attrs);
lint_callback!(self, exit_lint_attrs, attrs);
lint_callback!(self, check_attributes_post, attrs);
self.context.builder.pop(push);
}
}
Expand Down
9 changes: 2 additions & 7 deletions compiler/rustc_lint/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//! for all lint attributes.

use crate::{passes::LateLintPassObject, LateContext, LateLintPass, LintStore};
use rustc_ast as ast;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::{join, Lrc};
use rustc_hir as hir;
Expand Down Expand Up @@ -62,13 +61,13 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
let prev = self.context.last_node_with_lint_attrs;
self.context.last_node_with_lint_attrs = id;
debug!("late context: enter_attrs({:?})", attrs);
lint_callback!(self, enter_lint_attrs, attrs);
lint_callback!(self, check_attributes, attrs);
for attr in attrs {
lint_callback!(self, check_attribute, attr);
}
f(self);
debug!("late context: exit_attrs({:?})", attrs);
lint_callback!(self, exit_lint_attrs, attrs);
lint_callback!(self, check_attributes_post, attrs);
self.context.last_node_with_lint_attrs = prev;
}

Expand Down Expand Up @@ -310,10 +309,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
lint_callback!(self, check_path, p, id);
hir_visit::walk_path(self, p);
}

fn visit_attribute(&mut self, attr: &'tcx ast::Attribute) {
lint_callback!(self, check_attribute, attr);
}
}

// Combines multiple lint passes into a single pass, at runtime. Each
Expand Down
18 changes: 4 additions & 14 deletions compiler/rustc_lint/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,8 @@ macro_rules! late_lint_methods {
fn check_variant(a: &'tcx rustc_hir::Variant<'tcx>);
fn check_path(a: &rustc_hir::Path<'tcx>, b: rustc_hir::HirId);
fn check_attribute(a: &'tcx rustc_ast::Attribute);

/// Called when entering a syntax node that can have lint attributes such
/// as `#[allow(...)]`. Called with *all* the attributes of that node.
fn enter_lint_attrs(a: &'tcx [rustc_ast::Attribute]);

/// Counterpart to `enter_lint_attrs`.
fn exit_lint_attrs(a: &'tcx [rustc_ast::Attribute]);
fn check_attributes(a: &'tcx [rustc_ast::Attribute]);
fn check_attributes_post(a: &'tcx [rustc_ast::Attribute]);
]);
)
}
Expand Down Expand Up @@ -162,16 +157,11 @@ macro_rules! early_lint_methods {
fn check_impl_item(a: &rustc_ast::AssocItem);
fn check_variant(a: &rustc_ast::Variant);
fn check_attribute(a: &rustc_ast::Attribute);
fn check_attributes(a: &[rustc_ast::Attribute]);
fn check_attributes_post(a: &[rustc_ast::Attribute]);
fn check_mac_def(a: &rustc_ast::MacroDef);
fn check_mac(a: &rustc_ast::MacCall);

/// Called when entering a syntax node that can have lint attributes such
/// as `#[allow(...)]`. Called with *all* the attributes of that node.
fn enter_lint_attrs(a: &[rustc_ast::Attribute]);

/// Counterpart to `enter_lint_attrs`.
fn exit_lint_attrs(a: &[rustc_ast::Attribute]);

fn enter_where_predicate(a: &rustc_ast::WherePredicate);
fn exit_where_predicate(a: &rustc_ast::WherePredicate);
]);
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,11 @@ impl OutputTypes {
self.0.contains_key(key)
}

/// Returns `true` if user specified a name and not just produced type
pub fn contains_explicit_name(&self, key: &OutputType) -> bool {
self.0.get(key).map_or(false, |f| f.is_some())
}

pub fn iter(&self) -> BTreeMapIter<'_, OutputType, Option<OutFileName>> {
self.0.iter()
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_config/src/msrvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ impl Msrv {
None
}

pub fn enter_lint_attrs(&mut self, sess: &Session, attrs: &[Attribute]) {
pub fn check_attributes(&mut self, sess: &Session, attrs: &[Attribute]) {
if let Some(version) = Self::parse_attr(sess, attrs) {
self.stack.push(version);
}
}

pub fn exit_lint_attrs(&mut self, sess: &Session, attrs: &[Attribute]) {
pub fn check_attributes_post(&mut self, sess: &Session, attrs: &[Attribute]) {
if Self::parse_attr(sess, attrs).is_some() {
self.stack.pop();
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/src/cognitive_complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ impl<'tcx> LateLintPass<'tcx> for CognitiveComplexity {
}
}

fn enter_lint_attrs(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
fn check_attributes(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
self.limit.push_attrs(cx.sess(), attrs, "cognitive_complexity");
}
fn exit_lint_attrs(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
fn check_attributes_post(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
self.limit.pop_attrs(cx.sess(), attrs, "cognitive_complexity");
}
}
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/src/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ impl MissingDoc {
impl_lint_pass!(MissingDoc => [MISSING_DOCS_IN_PRIVATE_ITEMS]);

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl LateLintPass<'_> for MsrvAttrImpl {
.filter(|t| matches!(t.unpack(), GenericArgKind::Type(_)))
.any(|t| match_type(cx, t.expect_ty(), &paths::MSRV))
})
&& !items.iter().any(|item| item.ident.name == sym!(enter_lint_attrs))
&& !items.iter().any(|item| item.ident.name == sym!(check_attributes))
{
let context = if is_late_pass { "LateContext" } else { "EarlyContext" };
let lint_pass = if is_late_pass { "LateLintPass" } else { "EarlyLintPass" };
Expand Down
8 changes: 4 additions & 4 deletions src/tools/clippy/clippy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ use rustc_middle::hir::nested_filter;
#[macro_export]
macro_rules! extract_msrv_attr {
($context:ident) => {
fn enter_lint_attrs(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
fn check_attributes(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
let sess = rustc_lint::LintContext::sess(cx);
self.msrv.enter_lint_attrs(sess, attrs);
self.msrv.check_attributes(sess, attrs);
}

fn exit_lint_attrs(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
fn check_attributes_post(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
let sess = rustc_lint::LintContext::sess(cx);
self.msrv.exit_lint_attrs(sess, attrs);
self.msrv.check_attributes_post(sess, attrs);
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ENTRY_LIMIT: usize = 900;
// FIXME: The following limits should be reduced eventually.

const ISSUES_ENTRY_LIMIT: usize = 1750;
const ROOT_ENTRY_LIMIT: usize = 859;
const ROOT_ENTRY_LIMIT: usize = 860;

const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files
Expand Down
1 change: 1 addition & 0 deletions tests/run-make/libtest-junit/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ignore-cross-compile
# needs-unwind contains should_panic test
include ../tools.mk

# Test expected libtest's junit output
Expand Down
1 change: 1 addition & 0 deletions tests/ui/asm/may_unwind.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@ run-pass
//@ needs-asm-support
//@ needs-unwind

#![feature(asm_unwind)]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ICE cannot convert Refree.. to a region vid
// issue: rust-lang/rust#114464

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

fn test<const N: usize>() {}

fn wow<'a>() {
test::<{
let _: &'a ();
//~^ ERROR cannot capture late-bound lifetime in constant
3
}>();
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error: cannot capture late-bound lifetime in constant
--> $DIR/convert-refree-region-vid-ice-114464.rs:11:17
|
LL | fn wow<'a>() {
| -- lifetime defined here
LL | test::<{
LL | let _: &'a ();
| ^^

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// ICE no entry found for key generics_of
// issue: rust-lang/rust#113133

#![allow(incomplete_features)]
#![feature(generic_const_exprs, non_lifetime_binders)]

pub fn foo()
where
for<const N: usize = { const fn bar() {} bar(); 1 }> ():,
//~^ ERROR defaults for generic parameters are not allowed in `for<...>` binders
{}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: defaults for generic parameters are not allowed in `for<...>` binders
--> $DIR/no-entry-found-for-key-ice-gce-nlb-113133.rs:9:9
|
LL | for<const N: usize = { const fn bar() {} bar(); 1 }> ():,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

Loading
Loading