Skip to content

Commit e1c4858

Browse files
committed
fix tests
1 parent 7b39afd commit e1c4858

File tree

57 files changed

+154
-137
lines changed

Some content is hidden

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

57 files changed

+154
-137
lines changed

compiler/rustc_hir_typeck/src/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::cell::RefCell;
22

33
use rustc_abi::ExternAbi;
4-
use rustc_hir::def::DefKind;
54
use rustc_hir as hir;
5+
use rustc_hir::def::DefKind;
66
use rustc_hir::intravisit::Visitor;
77
use rustc_hir::lang_items::LangItem;
88
use rustc_hir_analysis::check::check_function_signature;

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,10 +782,9 @@ impl MetadataBlob {
782782
)?;
783783
writeln!(
784784
out,
785-
"has_global_allocator {} has_alloc_error_handler {} has_panic_handler {} has_default_lib_allocator {}",
785+
"has_global_allocator {} has_alloc_error_handler {} has_default_lib_allocator {}",
786786
root.has_global_allocator,
787787
root.has_alloc_error_handler,
788-
root.has_panic_handler,
789788
root.has_default_lib_allocator
790789
)?;
791790
writeln!(

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ provide! { tcx, def_id, other, cdata,
348348
is_compiler_builtins => { cdata.root.compiler_builtins }
349349
has_global_allocator => { cdata.root.has_global_allocator }
350350
has_alloc_error_handler => { cdata.root.has_alloc_error_handler }
351-
has_panic_handler => { cdata.root.has_panic_handler }
352351
is_profiler_runtime => { cdata.root.profiler_runtime }
353352
required_panic_strategy => { cdata.root.required_panic_strategy }
354353
panic_in_drop_strategy => { cdata.root.panic_in_drop_strategy }

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
713713
edition: tcx.sess.edition(),
714714
has_global_allocator: tcx.has_global_allocator(LOCAL_CRATE),
715715
has_alloc_error_handler: tcx.has_alloc_error_handler(LOCAL_CRATE),
716-
has_panic_handler: tcx.has_panic_handler(LOCAL_CRATE),
717716
externally_implementable_items,
718717

719718
has_default_lib_allocator: ast::attr::contains_name(

compiler/rustc_metadata/src/rmeta/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ pub(crate) struct CrateRoot {
261261
// TODO: these booleans can be replaced by the entries in `externally_implementable_items`
262262
has_global_allocator: bool,
263263
has_alloc_error_handler: bool,
264-
has_panic_handler: bool,
265264
has_default_lib_allocator: bool,
266265
externally_implementable_items: LazyArray<(DefId, (EIIDecl, Vec<(DefId, EIIImpl)>))>,
267266

compiler/rustc_middle/src/hir/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,9 @@ impl<'tcx> TyCtxt<'tcx> {
10301030
Node::PreciseCapturingNonLifetimeArg(param) => param.ident.span,
10311031
Node::Synthetic => {
10321032
if let Some(EiiMapping { chosen_impl, .. }) =
1033-
self.tcx.get_externally_implementable_item_impls(()).get(&hir_id.owner.def_id)
1033+
self.get_externally_implementable_item_impls(()).get(&hir_id.owner.def_id)
10341034
{
1035-
self.tcx.def_span(chosen_impl)
1035+
self.def_span(chosen_impl)
10361036
} else {
10371037
unreachable!()
10381038
}

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pub fn provide(providers: &mut Providers) {
227227
} else if let Some(EiiMapping { chosen_impl, .. }) =
228228
tcx.get_externally_implementable_item_impls(()).get(&def_id)
229229
{
230-
tcx.fn_arg_names(chosen_impl)
230+
tcx.fn_arg_idents(chosen_impl)
231231
} else {
232232
span_bug!(
233233
tcx.hir_span(tcx.local_def_id_to_hir_id(def_id)),

compiler/rustc_passes/src/errors.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -862,10 +862,6 @@ pub(crate) struct UnknownExternLangItem {
862862
pub lang_item: Symbol,
863863
}
864864

865-
#[derive(Diagnostic)]
866-
#[diag(passes_missing_panic_handler)]
867-
pub(crate) struct MissingPanicHandler;
868-
869865
#[derive(Diagnostic)]
870866
#[diag(passes_panic_unwind_without_std)]
871867
#[help]

compiler/rustc_passes/src/weak_lang_items.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ use rustc_middle::middle::lang_items::required;
99
use rustc_middle::ty::TyCtxt;
1010
use rustc_session::config::CrateType;
1111

12-
use crate::errors::{
13-
MissingLangItem, MissingPanicHandler, PanicUnwindWithoutStd, UnknownExternLangItem,
14-
};
12+
use crate::errors::{MissingLangItem, PanicUnwindWithoutStd, UnknownExternLangItem};
1513

1614
/// Checks the crate for usage of weak lang items, returning a vector of all the
1715
/// lang items required by this crate, but not defined yet.
@@ -83,9 +81,7 @@ fn verify(tcx: TyCtxt<'_>, items: &lang_items::LanguageItems) {
8381

8482
for &item in WEAK_LANG_ITEMS.iter() {
8583
if missing.contains(&item) && required(tcx, item) && items.get(item).is_none() {
86-
if item == LangItem::PanicImpl {
87-
tcx.dcx().emit_err(MissingPanicHandler);
88-
} else if item == LangItem::EhPersonality {
84+
if item == LangItem::EhPersonality {
8985
tcx.dcx().emit_err(PanicUnwindWithoutStd);
9086
} else {
9187
tcx.dcx().emit_err(MissingLangItem { name: item.name() });

compiler/rustc_resolve/src/check_unused.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ impl Resolver<'_, '_> {
402402
!tcx.is_compiler_builtins(cnum)
403403
&& !tcx.is_panic_runtime(cnum)
404404
&& !tcx.has_global_allocator(cnum)
405-
&& !tcx.has_panic_handler(cnum)
406405
}) {
407406
maybe_unused_extern_crates.insert(id, import.span);
408407
}

tests/ui/cfg/cfg_false_no_std-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern crate cfg_false_lib_no_std_before as _;
1010

1111
fn main() {}
1212

13-
//~? ERROR `#[panic_handler]` function required, but not found
13+
//~? ERROR `#[panic_handler]` required, but not found
1414
// FIXME: This error is target-dependent, could be served by some "optional error" annotation
1515
// instead of `dont-require-annotations`.
1616
//FIXME~? ERROR unwinding panics are not supported without std

tests/ui/eii/privacy2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
extern crate codegen3 as codegen;
55

66
// has a span but in the other crate
7-
//~? ERROR couldn't find an implementation for `#[eii2]`
8-
//~? ERROR couldn't find an implementation for `#[eii3]`
7+
//~? ERROR `#[eii2]` required, but not found
8+
//~? ERROR `#[eii3]` required, but not found
99

1010
#[codegen::eii1]
1111
fn eii1_impl(x: u64) {

tests/ui/eii/privacy2.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ note: the function `decl1` is defined here
1616
LL | fn decl1(x: u64);
1717
| ^^^^^^^^^^^^^^^^^
1818

19-
error: couldn't find an implementation for `#[eii2]`
19+
error: `#[eii2]` required, but not found
2020
--> $DIR/auxiliary/codegen3.rs:9:1
2121
|
2222
LL | #[eii(eii2)]
23-
| ^^^^^^^^^^^^ an implementation was expected by this declaration
23+
| ^^^^^^^^^^^^ expected because `#[eii2]` was declared here in crate `codegen3`
2424
|
2525
= help: expected at least one implementation in crate `privacy2` or any of its dependencies
2626

27-
error: couldn't find an implementation for `#[eii3]`
27+
error: `#[eii3]` required, but not found
2828
--> $DIR/auxiliary/codegen3.rs:13:5
2929
|
3030
LL | #[eii(eii3)]
31-
| ^^^^^^^^^^^^ an implementation was expected by this declaration
31+
| ^^^^^^^^^^^^ expected because `#[eii3]` was declared here in crate `codegen3`
3232
|
3333
= help: expected at least one implementation in crate `privacy2` or any of its dependencies
3434

tests/ui/eii/subtype_1.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ compile-flags: --crate-type rlib
2-
//FIXME: known ICE
32
#![feature(eii)]
43
#![feature(decl_macro)]
54
#![feature(rustc_attrs)]
@@ -17,7 +16,7 @@ unsafe extern "Rust" {
1716

1817
#[foo]
1918
fn other<'a, 'b>(x: &'b u64) -> &'b u64 {
20-
//~^ ERROR lifetime parameters or bounds `other` do not match the declaration
19+
//~^ ERROR lifetime parameters or bounds of `other` do not match the declaration
2120
&0
2221
}
2322

tests/ui/eii/subtype_1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
error: lifetime parameters or bounds `other` do not match the declaration
2-
--> $DIR/subtype_1.rs:19:9
1+
error: lifetime parameters or bounds of `other` do not match the declaration
2+
--> $DIR/subtype_1.rs:18:9
33
|
44
LL | safe fn bar<'a, 'b>(x: &'b u64) -> &'a u64;
55
| -------- lifetimes in impl do not match this signature

tests/ui/eii/subtype_2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ unsafe extern "Rust" {
1616

1717
#[foo]
1818
fn other<'a>(x: &'a u64) -> &'static u64 {
19-
//~^ ERROR lifetime parameters or bounds `other` do not match the declaration
19+
//~^ ERROR lifetime parameters or bounds of `other` do not match the declaration
2020
&0
2121
}
2222

tests/ui/eii/subtype_2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: lifetime parameters or bounds `other` do not match the declaration
1+
error: lifetime parameters or bounds of `other` do not match the declaration
22
--> $DIR/subtype_2.rs:18:9
33
|
44
LL | safe fn bar<'a>(x: &'static u64) -> &'a u64;

tests/ui/eii/wrong_ret_ty.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
error[E0053]: function `other` has a type that is incompatible with the declaration
1+
error[E0053]: function `other` has a type that is incompatible with the declaration of `#[foo]`
22
--> $DIR/wrong_ret_ty.rs:18:18
33
|
44
LL | fn other(_x: u64) {
55
| ^ expected `u64`, found `()`
66
|
7+
note: expected this because of this attribute
8+
--> $DIR/wrong_ret_ty.rs:17:1
9+
|
10+
LL | #[foo]
11+
| ^^^^^^
712
note: type in declaration
813
--> $DIR/wrong_ret_ty.rs:14:28
914
|

tests/ui/eii/wrong_ty.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
error[E0053]: function `other` has a type that is incompatible with the declaration
1+
error[E0053]: function `other` has a type that is incompatible with the declaration of `#[foo]`
22
--> $DIR/wrong_ty.rs:18:13
33
|
44
LL | fn other(x: usize) -> u64 {
55
| ^^^^^ expected `u64`, found `usize`
66
|
7+
note: expected this because of this attribute
8+
--> $DIR/wrong_ty.rs:17:1
9+
|
10+
LL | #[foo]
11+
| ^^^^^^
712
note: type in declaration
813
--> $DIR/wrong_ty.rs:14:20
914
|

tests/ui/error-codes/E0152-duplicate-lang-items.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
//!
44
//! Issue: <https://github.com/rust-lang/rust/issues/31788>
55
6-
//@ normalize-stderr: "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib"
6+
//@ normalize-stderr: "loaded from .*libcore-.*.rlib" -> "loaded from SYSROOT/libcore-*.rlib"
77
//@ dont-require-annotations: NOTE
8-
98
#![feature(lang_items)]
109

1110
extern crate core;
1211

1312
use core::panic::PanicInfo;
1413

15-
#[lang = "panic_impl"]
14+
#[lang = "panic_cannot_unwind"]
1615
fn panic_impl(info: &PanicInfo) -> ! {
17-
//~^ ERROR: found duplicate lang item `panic_impl`
18-
//~| NOTE first defined in crate `std`
16+
//~^ ERROR: found duplicate lang item `panic_cannot_unwind` [E0152]
17+
//~| NOTE first defined in crate `core`
1918
loop {}
2019
}
2120

tests/ui/error-codes/E0152-duplicate-lang-items.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
error[E0152]: found duplicate lang item `panic_impl`
2-
--> $DIR/E0152-duplicate-lang-items.rs:16:1
1+
error[E0152]: found duplicate lang item `panic_cannot_unwind`
2+
--> $DIR/E0152-duplicate-lang-items.rs:15:1
33
|
44
LL | / fn panic_impl(info: &PanicInfo) -> ! {
55
LL | |
@@ -8,8 +8,8 @@ LL | | loop {}
88
LL | | }
99
| |_^
1010
|
11-
= note: the lang item is first defined in crate `std` (which `E0152_duplicate_lang_items` depends on)
12-
= note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
11+
= note: the lang item is first defined in crate `core` (which `E0152_duplicate_lang_items` depends on)
12+
= note: first definition in `core` loaded from SYSROOT/libcore-*.rlib
1313
= note: second definition in the local crate (`E0152_duplicate_lang_items`)
1414

1515
error: aborting due to 1 previous error
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
error: extern location for std does not exist:
22

3-
error: `#[panic_handler]` function required, but not found
4-
53
error: unwinding panics are not supported without std
64
|
75
= help: using nightly cargo, use -Zbuild-std with panic="abort" to avoid unwinding
86
= note: since the core library is usually precompiled with panic="unwind", rebuilding your crate with panic="abort" may not be enough to fix the problem
97

8+
error: `#[panic_handler]` required, but not found
9+
--> $SRC_DIR/core/src/panic.rs:LL:COL
10+
|
11+
= note: expected because `#[panic_handler]` was declared here in crate `core`
12+
|
13+
= help: expected at least one implementation in crate `empty_extern_arg` or any of its dependencies
14+
1015
error: aborting due to 3 previous errors
1116

tests/ui/extern-flag/no-force-extern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88

99
fn foo() {} //~ ERROR `main` function not found in crate `no_force_extern`
1010

11-
//~? ERROR `#[panic_handler]` function required, but not found
11+
//~? ERROR `#[panic_handler]` required, but not found
1212
//~? ERROR unwinding panics are not supported without std

tests/ui/lang-items/start_lang_item_with_target_feature.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub trait Sized {}
1111

1212
#[lang = "start"]
1313
#[target_feature(enable = "avx2")]
14-
//~^ ERROR `start` lang item function is not allowed to have `#[target_feature]`
14+
//~^ ERROR `#[start]` is not allowed to have `#[target_feature]`
1515
fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
1616
0
1717
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error: `start` lang item function is not allowed to have `#[target_feature]`
1+
error: `#[start]` is not allowed to have `#[target_feature]`
22
--> $DIR/start_lang_item_with_target_feature.rs:13:1
33
|
44
LL | #[target_feature(enable = "avx2")]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
LL |
77
LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
8-
| ------------------------------------------------------------------------------------------- `start` lang item function is not allowed to have `#[target_feature]`
8+
| ------------------------------------------------------------------------------------------- `#[start]` is not allowed to have `#[target_feature]`
99

1010
error: aborting due to 1 previous error
1111

tests/ui/macros/macro-comma-behavior.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#[cfg(core)] use core::fmt;
1111
#[cfg(core)] #[lang = "eh_personality"] fn eh_personality() {}
1212
#[cfg(core)] #[lang = "eh_catch_typeinfo"] static EH_CATCH_TYPEINFO: u8 = 0;
13-
#[cfg(core)] #[lang = "panic_impl"] fn panic_impl(panic: &core::panic::PanicInfo) -> ! { loop {} }
13+
#[cfg(core)] #[core::panic_handler] fn panic_impl(panic: &core::panic::PanicInfo) -> ! { loop {} }
1414

1515
// (see documentation of the similarly-named test in run-pass)
1616
fn to_format_or_not_to_format() {

tests/ui/panic-handler/panic-handler-bad-signature-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ use core::panic::PanicInfo;
77

88
#[panic_handler]
99
fn panic(info: PanicInfo) -> () {}
10-
//~^ ERROR `#[panic_handler]` function has wrong type [E0308]
10+
//~^ ERROR function `panic` has a type that is incompatible with the declaration of `#[panic_handler]`
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
error[E0308]: `#[panic_handler]` function has wrong type
1+
error[E0053]: function `panic` has a type that is incompatible with the declaration of `#[panic_handler]`
22
--> $DIR/panic-handler-bad-signature-1.rs:9:16
33
|
44
LL | fn panic(info: PanicInfo) -> () {}
55
| ^^^^^^^^^ expected `&PanicInfo<'_>`, found `PanicInfo<'_>`
66
|
7+
note: expected this because of this attribute
8+
--> $DIR/panic-handler-bad-signature-1.rs:8:1
9+
|
10+
LL | #[panic_handler]
11+
| ^^^^^^^^^^^^^^^^
712
= note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !`
8-
found signature `for<'a> fn(PanicInfo<'a>) -> ()`
13+
found signature `fn(PanicInfo<'_>) -> ()`
14+
help: change the parameter type to match the declaration
15+
|
16+
LL - fn panic(info: PanicInfo) -> () {}
17+
LL + fn panic(info: &PanicInfo<'_>) -> () {}
18+
|
919

1020
error: aborting due to 1 previous error
1121

12-
For more information about this error, try `rustc --explain E0308`.
22+
For more information about this error, try `rustc --explain E0053`.

tests/ui/panic-handler/panic-handler-bad-signature-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::panic::PanicInfo;
77

88
#[panic_handler]
99
fn panic(info: &'static PanicInfo) -> !
10-
//~^ ERROR #[panic_handler]` function has wrong type [E0308]
10+
//~^ ERROR mismatched types
1111
{
1212
loop {}
1313
}

tests/ui/panic-handler/panic-handler-bad-signature-2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0308]: `#[panic_handler]` function has wrong type
1+
error[E0308]: mismatched types
22
--> $DIR/panic-handler-bad-signature-2.rs:9:1
33
|
44
LL | fn panic(info: &'static PanicInfo) -> !
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
66
|
77
= note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _`
8-
found signature `for<'a> fn(&'static PanicInfo<'a>) -> _`
8+
found signature `fn(&'static PanicInfo<'_>) -> _`
99

1010
error: aborting due to 1 previous error
1111

tests/ui/panic-handler/panic-handler-bad-signature-3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
use core::panic::PanicInfo;
77

88
#[panic_handler]
9-
fn panic() -> ! { //~ ERROR #[panic_handler]` function has wrong type [E0308]
9+
fn panic() -> ! { //~ ERROR `panic` has 0 parameters but #[panic_handler] requires it to have 1
1010
loop {}
1111
}

0 commit comments

Comments
 (0)