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

Reinstate some delayed bugs. #121116

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
)
}
ExprKind::Yield(opt_expr) => self.lower_expr_yield(e.span, opt_expr.as_deref()),
ExprKind::Err => hir::ExprKind::Err(self.dcx().has_errors().unwrap()),
ExprKind::Err => {
hir::ExprKind::Err(self.dcx().span_delayed_bug(e.span, "lowered ExprKind::Err"))
}
ExprKind::Try(sub_expr) => self.lower_expr_try(e.span, sub_expr),

ExprKind::Paren(_) | ExprKind::ForLoop { .. } => {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def: LocalDefId) -> ConstQualifs {
let body = &tcx.mir_const(def).borrow();

if body.return_ty().references_error() {
assert!(tcx.dcx().has_errors().is_some(), "mir_const_qualif: MIR had errors");
// It's possible to reach here without an error being emitted (#121103).
tcx.dcx().span_delayed_bug(body.span, "mir_const_qualif: MIR had errors");
return Default::default();
}

Expand Down
9 changes: 9 additions & 0 deletions tests/ui/lowering/issue-121108.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![derive(Clone, Copy)] //~ ERROR `derive` attribute cannot be used at crate level

use std::ptr::addr_of;

const UNINHABITED_VARIANT: () = unsafe {
let v = *addr_of!(data).cast(); //~ ERROR cannot determine resolution for the macro `addr_of`
};

fn main() {}
25 changes: 25 additions & 0 deletions tests/ui/lowering/issue-121108.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error: `derive` attribute cannot be used at crate level
--> $DIR/issue-121108.rs:1:1
|
LL | #![derive(Clone, Copy)]
| ^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | use std::ptr::addr_of;
| ------- the inner attribute doesn't annotate this `use` import
|
help: perhaps you meant to use an outer attribute
|
LL - #![derive(Clone, Copy)]
LL + #[derive(Clone, Copy)]
|

error: cannot determine resolution for the macro `addr_of`
--> $DIR/issue-121108.rs:6:14
|
LL | let v = *addr_of!(data).cast();
| ^^^^^^^
|
= note: import resolution is stuck, try simplifying macro imports

error: aborting due to 2 previous errors

3 changes: 3 additions & 0 deletions tests/ui/mir/issue-121103.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main(_: <lib2::GenericType<42> as lib2::TypeFn>::Output) {}
//~^ ERROR failed to resolve: use of undeclared crate or module `lib2`
//~| ERROR failed to resolve: use of undeclared crate or module `lib2`
15 changes: 15 additions & 0 deletions tests/ui/mir/issue-121103.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0433]: failed to resolve: use of undeclared crate or module `lib2`
--> $DIR/issue-121103.rs:1:38
|
LL | fn main(_: <lib2::GenericType<42> as lib2::TypeFn>::Output) {}
| ^^^^ use of undeclared crate or module `lib2`

error[E0433]: failed to resolve: use of undeclared crate or module `lib2`
--> $DIR/issue-121103.rs:1:13
|
LL | fn main(_: <lib2::GenericType<42> as lib2::TypeFn>::Output) {}
| ^^^^ use of undeclared crate or module `lib2`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0433`.
Loading