From 6a47326a0452cc8d5cb57676508b5469d648c67f Mon Sep 17 00:00:00 2001 From: Diego de Oliveira Date: Wed, 14 Sep 2022 15:03:12 -0300 Subject: [PATCH 01/15] Migrated the rustc_passes lint for annotations without effect to the new diagnostic infrastructure --- .../locales/en-US/passes.ftl | 3 +++ compiler/rustc_passes/src/errors.rs | 7 +++++++ compiler/rustc_passes/src/stability.rs | 17 +++++++---------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/passes.ftl b/compiler/rustc_error_messages/locales/en-US/passes.ftl index 556a6452f1a19..995ad4fe25859 100644 --- a/compiler/rustc_error_messages/locales/en-US/passes.ftl +++ b/compiler/rustc_error_messages/locales/en-US/passes.ftl @@ -268,3 +268,6 @@ passes_link_ordinal = attribute should be applied to a foreign function or stati passes_collapse_debuginfo = `collapse_debuginfo` attribute should be applied to macro definitions .label = not a macro definition + +passes_deprecated_annotation_has_no_effect = this `#[deprecated]` annotation has no effect + .suggestion = remove the unnecessary deprecation attribute diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 96cc8ae988cd5..726b5b6cd4d0b 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -658,3 +658,10 @@ pub struct CollapseDebuginfo { #[label] pub defn_span: Span, } + +#[derive(LintDiagnostic)] +#[diag(passes::deprecated_annotation_has_no_effect)] +pub struct DeprecatedAnnotationHasNoEffect { + #[suggestion(applicability = "machine-applicable", code = "")] + pub span: Span, +} diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 9ba1276099db5..3f23b027aef28 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -1,6 +1,7 @@ //! A pass that annotates every item and method with its stability level, //! propagating default levels lexically from parent to children ast nodes. +use crate::errors; use rustc_attr::{ self as attr, rust_version_symbol, ConstStability, Stability, StabilityLevel, Unstable, UnstableReason, VERSION_PLACEHOLDER, @@ -122,16 +123,12 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited { let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id); - self.tcx.struct_span_lint_hir(USELESS_DEPRECATED, hir_id, *span, |lint| { - lint.build("this `#[deprecated]` annotation has no effect") - .span_suggestion_short( - *span, - "remove the unnecessary deprecation attribute", - "", - rustc_errors::Applicability::MachineApplicable, - ) - .emit(); - }); + self.tcx.emit_spanned_lint( + USELESS_DEPRECATED, + hir_id, + *span, + errors::DeprecatedAnnotationHasNoEffect { span: *span }, + ); } // `Deprecation` is just two pointers, no need to intern it From 8477b9b707db74aa97a8390ff562f0e20b5d4d86 Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Sun, 11 Sep 2022 00:46:53 +0200 Subject: [PATCH 02/15] Note if mismatched types have a similar name --- .../src/infer/error_reporting/mod.rs | 52 +++++++++++++++++-- .../fully-qualified-type-name2.stderr | 12 +++++ src/test/ui/issues/issue-56943.stderr | 12 +++++ src/test/ui/mismatched_types/similar_paths.rs | 11 ++++ .../ui/mismatched_types/similar_paths.stderr | 23 ++++++++ .../type/type-mismatch-same-crate-name.stderr | 11 ++++ 6 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/mismatched_types/similar_paths.rs create mode 100644 src/test/ui/mismatched_types/similar_paths.stderr diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 67526c2228937..ab76b48847818 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -51,6 +51,7 @@ use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePa use crate::infer; use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_type; +use crate::infer::ExpectedFound; use crate::traits::error_reporting::report_object_safety_error; use crate::traits::{ IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode, @@ -1653,8 +1654,51 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ), Mismatch::Fixed(s) => (s.into(), s.into(), None), }; - match (&terr, expected == found) { - (TypeError::Sorts(values), extra) => { + let looks_similar = |e: ExpectedFound>| { + // We're only interested in adts + if let (Some(e), Some(f)) = (e.expected.ty_adt_def(), e.found.ty_adt_def()) { + // Only compare the last parts of the path. + // `whatever::Foo` is pretty similar to `blah::Foo` + let e_path = self.tcx.def_path(e.did()).data; + let f_path = self.tcx.def_path(f.did()).data; + if let (Some(e), Some(f)) = (e_path.last(), f_path.last()) { + return e.data == f.data; + } + } + false + }; + + match terr { + // If two types mismatch but have similar names, mention that specifically. + TypeError::Sorts(values) if looks_similar(values) => { + let found_adt = values.found.ty_adt_def().unwrap(); + let expected_adt = values.expected.ty_adt_def().unwrap(); + + let found_name = values.found.sort_string(self.tcx); + let expected_name = values.expected.sort_string(self.tcx); + + diag.note(format!("{found_name} and {expected_name} have similar names, but are actually distinct types")); + + for (adt, name) in [(found_adt, found_name), (expected_adt, expected_name)] { + let defid = adt.did(); + let def_span = self.tcx.def_span(defid); + + let msg = if defid.is_local() { + format!("{name} is defined in the current crate.") + } else if self.tcx.all_diagnostic_items(()).id_to_name.get(&defid).is_some() + { + // if it's a diagnostic item, it's definitely defined in std/core/alloc + // otherwise might be, might not be. + format!("{name} is defined in the standard library.") + } else { + let crate_name = self.tcx.crate_name(defid.krate); + format!("{name} is defined in crate `{crate_name}`.") + }; + diag.span_note(def_span, msg); + } + } + TypeError::Sorts(values) => { + let extra = expected == found; let sort_string = |ty: Ty<'tcx>| match (extra, ty.kind()) { (true, ty::Opaque(def_id, _)) => { let sm = self.tcx.sess.source_map(); @@ -1707,10 +1751,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ); } } - (TypeError::ObjectUnsafeCoercion(_), _) => { + TypeError::ObjectUnsafeCoercion(_) => { diag.note_unsuccessful_coercion(found, expected); } - (_, _) => { + _ => { debug!( "note_type_err: exp_found={:?}, expected={:?} found={:?}", exp_found, expected, found diff --git a/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr b/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr index aed7f72c660df..8729ea1740ce2 100644 --- a/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr +++ b/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr @@ -5,6 +5,18 @@ LL | fn bar(x: x::Foo) -> y::Foo { | ------ expected `y::Foo` because of return type LL | return x; | ^ expected enum `y::Foo`, found enum `x::Foo` + | + = note: enum `x::Foo` and enum `y::Foo` have similar names, but are actually distinct types +note: enum `x::Foo` is defined in the current crate. + --> $DIR/fully-qualified-type-name2.rs:4:5 + | +LL | pub enum Foo { } + | ^^^^^^^^^^^^ +note: enum `y::Foo` is defined in the current crate. + --> $DIR/fully-qualified-type-name2.rs:8:5 + | +LL | pub enum Foo { } + | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-56943.stderr b/src/test/ui/issues/issue-56943.stderr index 74ed5ec0fb6f1..3efa5f6d04093 100644 --- a/src/test/ui/issues/issue-56943.stderr +++ b/src/test/ui/issues/issue-56943.stderr @@ -5,6 +5,18 @@ LL | let _: issue_56943::S = issue_56943::S2; | -------------- ^^^^^^^^^^^^^^^ expected struct `S`, found struct `S2` | | | expected due to this + | + = note: struct `S2` and struct `S` have similar names, but are actually distinct types +note: struct `S2` is defined in crate `issue_56943`. + --> $DIR/auxiliary/issue-56943.rs:2:9 + | +LL | mod m { pub struct S; } + | ^^^^^^^^^^^^ +note: struct `S` is defined in crate `issue_56943`. + --> $DIR/auxiliary/issue-56943.rs:1:1 + | +LL | pub struct S; + | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/mismatched_types/similar_paths.rs b/src/test/ui/mismatched_types/similar_paths.rs new file mode 100644 index 0000000000000..4d3a2a1fcc61c --- /dev/null +++ b/src/test/ui/mismatched_types/similar_paths.rs @@ -0,0 +1,11 @@ +enum Option{ + Some(T), + None, +} + +pub fn foo() -> Option{ + Some(42_u8) + //~^ ERROR mismatched types [E0308] +} + +fn main(){} diff --git a/src/test/ui/mismatched_types/similar_paths.stderr b/src/test/ui/mismatched_types/similar_paths.stderr new file mode 100644 index 0000000000000..c12afd20b9cf5 --- /dev/null +++ b/src/test/ui/mismatched_types/similar_paths.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/similar_paths.rs:7:5 + | +LL | pub fn foo() -> Option{ + | ---------- expected `Option` because of return type +LL | Some(42_u8) + | ^^^^^^^^^^^ expected enum `Option`, found enum `std::option::Option` + | + = note: enum `std::option::Option` and enum `Option` have similar names, but are actually distinct types +note: enum `std::option::Option` is defined in the standard library. + --> $SRC_DIR/core/src/option.rs:LL:COL + | +LL | pub enum Option { + | ^^^^^^^^^^^^^^^^^^ +note: enum `Option` is defined in the current crate. + --> $DIR/similar_paths.rs:1:1 + | +LL | enum Option{ + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type/type-mismatch-same-crate-name.stderr b/src/test/ui/type/type-mismatch-same-crate-name.stderr index 783f747fa6db6..38a36e8940fa1 100644 --- a/src/test/ui/type/type-mismatch-same-crate-name.stderr +++ b/src/test/ui/type/type-mismatch-same-crate-name.stderr @@ -6,6 +6,17 @@ LL | a::try_foo(foo2); | | | arguments to this function are incorrect | + = note: struct `main::a::Foo` and struct `main::a::Foo` have similar names, but are actually distinct types +note: struct `main::a::Foo` is defined in crate `crate_a2`. + --> $DIR/auxiliary/crate_a2.rs:1:1 + | +LL | pub struct Foo; + | ^^^^^^^^^^^^^^ +note: struct `main::a::Foo` is defined in crate `crate_a1`. + --> $DIR/auxiliary/crate_a1.rs:1:1 + | +LL | pub struct Foo; + | ^^^^^^^^^^^^^^ = note: perhaps two different versions of crate `crate_a1` are being used? note: function defined here --> $DIR/auxiliary/crate_a1.rs:10:8 From 3699c2497bc6ff74126ae8c56a06905f49d0300c Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Mon, 12 Sep 2022 22:17:06 +0200 Subject: [PATCH 03/15] Address feedback --- .../src/infer/error_reporting/mod.rs | 171 ++++++++++++++---- compiler/rustc_infer/src/lib.rs | 2 + .../fully-qualified-type-name2.stderr | 4 +- src/test/ui/issues/issue-56943.stderr | 12 -- src/test/ui/mismatched_types/show_module.rs | 18 ++ .../ui/mismatched_types/show_module.stderr | 23 +++ .../ui/mismatched_types/similar_paths.stderr | 4 +- .../similar_paths_primitive.rs | 10 + .../similar_paths_primitive.stderr | 24 +++ .../type/type-mismatch-same-crate-name.stderr | 4 +- 10 files changed, 223 insertions(+), 49 deletions(-) create mode 100644 src/test/ui/mismatched_types/show_module.rs create mode 100644 src/test/ui/mismatched_types/show_module.stderr create mode 100644 src/test/ui/mismatched_types/similar_paths_primitive.rs create mode 100644 src/test/ui/mismatched_types/similar_paths_primitive.stderr diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index ab76b48847818..d4e8e267babe9 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1654,47 +1654,156 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ), Mismatch::Fixed(s) => (s.into(), s.into(), None), }; - let looks_similar = |e: ExpectedFound>| { - // We're only interested in adts - if let (Some(e), Some(f)) = (e.expected.ty_adt_def(), e.found.ty_adt_def()) { - // Only compare the last parts of the path. - // `whatever::Foo` is pretty similar to `blah::Foo` - let e_path = self.tcx.def_path(e.did()).data; - let f_path = self.tcx.def_path(f.did()).data; - if let (Some(e), Some(f)) = (e_path.last(), f_path.last()) { - return e.data == f.data; + + enum Similar<'tcx> { + Adts(ty::AdtDef<'tcx>, ty::AdtDef<'tcx>), + PrimitiveFound(Ty<'tcx>, ty::AdtDef<'tcx>), + PrimitiveExpected(ty::AdtDef<'tcx>, Ty<'tcx>), + } + + let primitive_sym = |kind: &_| match kind { + ty::Bool => Some(sym::bool), + ty::Char => Some(sym::char), + ty::Float(f) => match f { + ty::FloatTy::F32 => Some(sym::f32), + ty::FloatTy::F64 => Some(sym::f64), + }, + ty::Int(f) => match f { + ty::IntTy::Isize => Some(sym::isize), + ty::IntTy::I8 => Some(sym::i8), + ty::IntTy::I16 => Some(sym::i16), + ty::IntTy::I32 => Some(sym::i32), + ty::IntTy::I64 => Some(sym::i64), + ty::IntTy::I128 => Some(sym::i128), + }, + ty::Uint(f) => match f { + ty::UintTy::Usize => Some(sym::usize), + ty::UintTy::U8 => Some(sym::u8), + ty::UintTy::U16 => Some(sym::u16), + ty::UintTy::U32 => Some(sym::u32), + ty::UintTy::U64 => Some(sym::u64), + ty::UintTy::U128 => Some(sym::u128), + }, + _ => None, + }; + + let similarity = |e: ExpectedFound>| { + let (fk, ek) = (e.found.kind(), e.expected.kind()); + match (fk, ek) { + ( + ty::Adt(adt, _), + ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_), + ) => { + let path = self.tcx.def_path(adt.did()).data; + let name = path.last().unwrap().data.get_opt_name(); + let prim_sym = primitive_sym(ek); + + if name == prim_sym { + return Some(Similar::PrimitiveExpected(*adt, e.expected)); + } + None + } + ( + ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_), + ty::Adt(adt, _), + ) => { + let path = self.tcx.def_path(adt.did()).data; + let name = path.last().unwrap().data.get_opt_name(); + let prim_sym = primitive_sym(fk); + + if name == prim_sym { + return Some(Similar::PrimitiveFound(e.expected, *adt)); + } + None + } + (ty::Adt(f, _), ty::Adt(e, _)) => { + if !f.did().is_local() && f.did().krate == e.did().krate { + // Most likely types from different versions of the same crate + // are in play, in which case this message isn't so helpful. + // A "perhaps two different versions..." error is already emitted for that. + return None; + } + let e_path = self.tcx.def_path(e.did()).data; + let f_path = self.tcx.def_path(f.did()).data; + if let (Some(e_last), Some(f_last)) = (e_path.last(), f_path.last()) && e_last == f_last { + return Some(Similar::Adts(*f, *e)); + } + None } + _ => None, } - false }; match terr { // If two types mismatch but have similar names, mention that specifically. - TypeError::Sorts(values) if looks_similar(values) => { - let found_adt = values.found.ty_adt_def().unwrap(); - let expected_adt = values.expected.ty_adt_def().unwrap(); - - let found_name = values.found.sort_string(self.tcx); - let expected_name = values.expected.sort_string(self.tcx); + TypeError::Sorts(values) if let Some(s) = similarity(values) => { + let diagnose_primitive = + |prim: Ty<'tcx>, + shadow: Ty<'tcx>, + defid: DefId, + diagnostic: &mut Diagnostic| { + let name = shadow.sort_string(self.tcx); + diagnostic.note(format!( + "{prim} and {name} have similar names, but are actually distinct types" + )); + diagnostic + .note(format!("{prim} is a primitive defined by the language")); + let def_span = self.tcx.def_span(defid); + let msg = if defid.is_local() { + format!("{name} is defined in the current crate") + } else { + let crate_name = self.tcx.crate_name(defid.krate); + format!("{name} is defined in crate `{crate_name}") + }; + diagnostic.span_note(def_span, msg); + }; - diag.note(format!("{found_name} and {expected_name} have similar names, but are actually distinct types")); + let diagnose_adts = + |found_adt: ty::AdtDef<'tcx>, + expected_adt: ty::AdtDef<'tcx>, + diagnostic: &mut Diagnostic| { + let found_name = values.found.sort_string(self.tcx); + let expected_name = values.expected.sort_string(self.tcx); - for (adt, name) in [(found_adt, found_name), (expected_adt, expected_name)] { - let defid = adt.did(); - let def_span = self.tcx.def_span(defid); + let found_defid = found_adt.did(); + let expected_defid = expected_adt.did(); - let msg = if defid.is_local() { - format!("{name} is defined in the current crate.") - } else if self.tcx.all_diagnostic_items(()).id_to_name.get(&defid).is_some() - { - // if it's a diagnostic item, it's definitely defined in std/core/alloc - // otherwise might be, might not be. - format!("{name} is defined in the standard library.") - } else { - let crate_name = self.tcx.crate_name(defid.krate); - format!("{name} is defined in crate `{crate_name}`.") + diagnostic.note(format!("{found_name} and {expected_name} have similar names, but are actually distinct types")); + for (defid, name) in + [(found_defid, found_name), (expected_defid, expected_name)] + { + let def_span = self.tcx.def_span(defid); + + let msg = if found_defid.is_local() && expected_defid.is_local() { + let module = self + .tcx + .parent_module_from_def_id(defid.expect_local()) + .to_def_id(); + let module_name = + self.tcx.def_path(module).to_string_no_crate_verbose(); + format!( + "{name} is defined in module {module_name} of the current crate" + ) + } else if defid.is_local() { + format!("{name} is defined in the current crate") + } else { + let crate_name = self.tcx.crate_name(defid.krate); + format!("{name} is defined in crate `{crate_name}`") + }; + diagnostic.span_note(def_span, msg); + } }; - diag.span_note(def_span, msg); + + match s { + Similar::Adts(found_adt, expected_adt) => { + diagnose_adts(found_adt, expected_adt, diag) + } + Similar::PrimitiveFound(prim, e) => { + diagnose_primitive(prim, values.expected, e.did(), diag) + } + Similar::PrimitiveExpected(f, prim) => { + diagnose_primitive(prim, values.found, f.did(), diag) + } } } TypeError::Sorts(values) => { diff --git a/compiler/rustc_infer/src/lib.rs b/compiler/rustc_infer/src/lib.rs index ef60d2c918845..5b14e5bdb78cf 100644 --- a/compiler/rustc_infer/src/lib.rs +++ b/compiler/rustc_infer/src/lib.rs @@ -20,6 +20,8 @@ #![cfg_attr(bootstrap, feature(label_break_value))] #![feature(let_chains)] #![cfg_attr(bootstrap, feature(let_else))] +#![feature(let_else)] +#![feature(if_let_guard)] #![feature(min_specialization)] #![feature(never_type)] #![feature(try_blocks)] diff --git a/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr b/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr index 8729ea1740ce2..94c34cf9d04fa 100644 --- a/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr +++ b/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr @@ -7,12 +7,12 @@ LL | return x; | ^ expected enum `y::Foo`, found enum `x::Foo` | = note: enum `x::Foo` and enum `y::Foo` have similar names, but are actually distinct types -note: enum `x::Foo` is defined in the current crate. +note: enum `x::Foo` is defined in module ::x of the current crate --> $DIR/fully-qualified-type-name2.rs:4:5 | LL | pub enum Foo { } | ^^^^^^^^^^^^ -note: enum `y::Foo` is defined in the current crate. +note: enum `y::Foo` is defined in module ::y of the current crate --> $DIR/fully-qualified-type-name2.rs:8:5 | LL | pub enum Foo { } diff --git a/src/test/ui/issues/issue-56943.stderr b/src/test/ui/issues/issue-56943.stderr index 3efa5f6d04093..74ed5ec0fb6f1 100644 --- a/src/test/ui/issues/issue-56943.stderr +++ b/src/test/ui/issues/issue-56943.stderr @@ -5,18 +5,6 @@ LL | let _: issue_56943::S = issue_56943::S2; | -------------- ^^^^^^^^^^^^^^^ expected struct `S`, found struct `S2` | | | expected due to this - | - = note: struct `S2` and struct `S` have similar names, but are actually distinct types -note: struct `S2` is defined in crate `issue_56943`. - --> $DIR/auxiliary/issue-56943.rs:2:9 - | -LL | mod m { pub struct S; } - | ^^^^^^^^^^^^ -note: struct `S` is defined in crate `issue_56943`. - --> $DIR/auxiliary/issue-56943.rs:1:1 - | -LL | pub struct S; - | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/mismatched_types/show_module.rs b/src/test/ui/mismatched_types/show_module.rs new file mode 100644 index 0000000000000..97d45b377bcfb --- /dev/null +++ b/src/test/ui/mismatched_types/show_module.rs @@ -0,0 +1,18 @@ +pub mod blah{ + pub mod baz{ + pub struct Foo; + } +} + +pub mod meh{ + pub struct Foo; +} + +pub type Foo = blah::baz::Foo; + +fn foo() -> Foo { + meh::Foo + //~^ ERROR mismatched types [E0308] +} + +fn main(){} diff --git a/src/test/ui/mismatched_types/show_module.stderr b/src/test/ui/mismatched_types/show_module.stderr new file mode 100644 index 0000000000000..6d8986d1cad2c --- /dev/null +++ b/src/test/ui/mismatched_types/show_module.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/show_module.rs:14:5 + | +LL | fn foo() -> Foo { + | --- expected `baz::Foo` because of return type +LL | meh::Foo + | ^^^^^^^^ expected struct `baz::Foo`, found struct `meh::Foo` + | + = note: struct `meh::Foo` and struct `baz::Foo` have similar names, but are actually distinct types +note: struct `meh::Foo` is defined in module ::meh of the current crate + --> $DIR/show_module.rs:8:5 + | +LL | pub struct Foo; + | ^^^^^^^^^^^^^^ +note: struct `baz::Foo` is defined in module ::blah::baz of the current crate + --> $DIR/show_module.rs:3:9 + | +LL | pub struct Foo; + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/mismatched_types/similar_paths.stderr b/src/test/ui/mismatched_types/similar_paths.stderr index c12afd20b9cf5..16f33e55fea03 100644 --- a/src/test/ui/mismatched_types/similar_paths.stderr +++ b/src/test/ui/mismatched_types/similar_paths.stderr @@ -7,12 +7,12 @@ LL | Some(42_u8) | ^^^^^^^^^^^ expected enum `Option`, found enum `std::option::Option` | = note: enum `std::option::Option` and enum `Option` have similar names, but are actually distinct types -note: enum `std::option::Option` is defined in the standard library. +note: enum `std::option::Option` is defined in crate `core` --> $SRC_DIR/core/src/option.rs:LL:COL | LL | pub enum Option { | ^^^^^^^^^^^^^^^^^^ -note: enum `Option` is defined in the current crate. +note: enum `Option` is defined in the current crate --> $DIR/similar_paths.rs:1:1 | LL | enum Option{ diff --git a/src/test/ui/mismatched_types/similar_paths_primitive.rs b/src/test/ui/mismatched_types/similar_paths_primitive.rs new file mode 100644 index 0000000000000..8f5b7cce46908 --- /dev/null +++ b/src/test/ui/mismatched_types/similar_paths_primitive.rs @@ -0,0 +1,10 @@ +#![allow(non_camel_case_types)] + +struct bool; + +fn foo(_: bool) {} + +fn main() { + foo(true); + //~^ ERROR mismatched types [E0308] +} diff --git a/src/test/ui/mismatched_types/similar_paths_primitive.stderr b/src/test/ui/mismatched_types/similar_paths_primitive.stderr new file mode 100644 index 0000000000000..8a2f73945e841 --- /dev/null +++ b/src/test/ui/mismatched_types/similar_paths_primitive.stderr @@ -0,0 +1,24 @@ +error[E0308]: mismatched types + --> $DIR/similar_paths_primitive.rs:8:9 + | +LL | foo(true); + | --- ^^^^ expected struct `bool`, found `bool` + | | + | arguments to this function are incorrect + | + = note: bool and struct `bool` have similar names, but are actually distinct types + = note: bool is a primitive defined by the language +note: struct `bool` is defined in the current crate + --> $DIR/similar_paths_primitive.rs:3:1 + | +LL | struct bool; + | ^^^^^^^^^^^ +note: function defined here + --> $DIR/similar_paths_primitive.rs:5:4 + | +LL | fn foo(_: bool) {} + | ^^^ ------- + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type/type-mismatch-same-crate-name.stderr b/src/test/ui/type/type-mismatch-same-crate-name.stderr index 38a36e8940fa1..fcafd315ebf54 100644 --- a/src/test/ui/type/type-mismatch-same-crate-name.stderr +++ b/src/test/ui/type/type-mismatch-same-crate-name.stderr @@ -7,12 +7,12 @@ LL | a::try_foo(foo2); | arguments to this function are incorrect | = note: struct `main::a::Foo` and struct `main::a::Foo` have similar names, but are actually distinct types -note: struct `main::a::Foo` is defined in crate `crate_a2`. +note: struct `main::a::Foo` is defined in crate `crate_a2` --> $DIR/auxiliary/crate_a2.rs:1:1 | LL | pub struct Foo; | ^^^^^^^^^^^^^^ -note: struct `main::a::Foo` is defined in crate `crate_a1`. +note: struct `main::a::Foo` is defined in crate `crate_a1` --> $DIR/auxiliary/crate_a1.rs:1:1 | LL | pub struct Foo; From 14e98930239e0a419d9662cde6e4a3aac6564f5a Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Sun, 18 Sep 2022 02:59:32 +0200 Subject: [PATCH 04/15] Print out the proper crate path --- compiler/rustc_infer/src/infer/error_reporting/mod.rs | 7 ++----- compiler/rustc_infer/src/lib.rs | 1 - .../fully-qualified-type/fully-qualified-type-name2.stderr | 4 ++-- src/test/ui/mismatched_types/show_module.stderr | 4 ++-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index d4e8e267babe9..dbe068ff174b3 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1779,11 +1779,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { .tcx .parent_module_from_def_id(defid.expect_local()) .to_def_id(); - let module_name = - self.tcx.def_path(module).to_string_no_crate_verbose(); - format!( - "{name} is defined in module {module_name} of the current crate" - ) + let module_name = self.tcx.def_path(module).to_string_no_crate_verbose(); + format!("{name} is defined in module `crate{module_name}` of the current crate") } else if defid.is_local() { format!("{name} is defined in the current crate") } else { diff --git a/compiler/rustc_infer/src/lib.rs b/compiler/rustc_infer/src/lib.rs index 5b14e5bdb78cf..909a597e22135 100644 --- a/compiler/rustc_infer/src/lib.rs +++ b/compiler/rustc_infer/src/lib.rs @@ -20,7 +20,6 @@ #![cfg_attr(bootstrap, feature(label_break_value))] #![feature(let_chains)] #![cfg_attr(bootstrap, feature(let_else))] -#![feature(let_else)] #![feature(if_let_guard)] #![feature(min_specialization)] #![feature(never_type)] diff --git a/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr b/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr index 94c34cf9d04fa..a8f23f81dea02 100644 --- a/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr +++ b/src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr @@ -7,12 +7,12 @@ LL | return x; | ^ expected enum `y::Foo`, found enum `x::Foo` | = note: enum `x::Foo` and enum `y::Foo` have similar names, but are actually distinct types -note: enum `x::Foo` is defined in module ::x of the current crate +note: enum `x::Foo` is defined in module `crate::x` of the current crate --> $DIR/fully-qualified-type-name2.rs:4:5 | LL | pub enum Foo { } | ^^^^^^^^^^^^ -note: enum `y::Foo` is defined in module ::y of the current crate +note: enum `y::Foo` is defined in module `crate::y` of the current crate --> $DIR/fully-qualified-type-name2.rs:8:5 | LL | pub enum Foo { } diff --git a/src/test/ui/mismatched_types/show_module.stderr b/src/test/ui/mismatched_types/show_module.stderr index 6d8986d1cad2c..5e48e0955aae9 100644 --- a/src/test/ui/mismatched_types/show_module.stderr +++ b/src/test/ui/mismatched_types/show_module.stderr @@ -7,12 +7,12 @@ LL | meh::Foo | ^^^^^^^^ expected struct `baz::Foo`, found struct `meh::Foo` | = note: struct `meh::Foo` and struct `baz::Foo` have similar names, but are actually distinct types -note: struct `meh::Foo` is defined in module ::meh of the current crate +note: struct `meh::Foo` is defined in module `crate::meh` of the current crate --> $DIR/show_module.rs:8:5 | LL | pub struct Foo; | ^^^^^^^^^^^^^^ -note: struct `baz::Foo` is defined in module ::blah::baz of the current crate +note: struct `baz::Foo` is defined in module `crate::blah::baz` of the current crate --> $DIR/show_module.rs:3:9 | LL | pub struct Foo; From c65866000e07270817465f3cbb8b1d01ecdb9a20 Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Mon, 19 Sep 2022 17:19:45 +0200 Subject: [PATCH 05/15] Incorporate feedback --- .../src/infer/error_reporting/mod.rs | 115 ++++++------------ compiler/rustc_middle/src/ty/sty.rs | 31 ++++- src/test/ui/mismatched_types/show_module.rs | 8 +- src/test/ui/mismatched_types/similar_paths.rs | 6 +- .../ui/mismatched_types/similar_paths.stderr | 4 +- 5 files changed, 75 insertions(+), 89 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index dbe068ff174b3..aba2447fa68e9 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1656,82 +1656,39 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }; enum Similar<'tcx> { - Adts(ty::AdtDef<'tcx>, ty::AdtDef<'tcx>), - PrimitiveFound(Ty<'tcx>, ty::AdtDef<'tcx>), - PrimitiveExpected(ty::AdtDef<'tcx>, Ty<'tcx>), - } - - let primitive_sym = |kind: &_| match kind { - ty::Bool => Some(sym::bool), - ty::Char => Some(sym::char), - ty::Float(f) => match f { - ty::FloatTy::F32 => Some(sym::f32), - ty::FloatTy::F64 => Some(sym::f64), - }, - ty::Int(f) => match f { - ty::IntTy::Isize => Some(sym::isize), - ty::IntTy::I8 => Some(sym::i8), - ty::IntTy::I16 => Some(sym::i16), - ty::IntTy::I32 => Some(sym::i32), - ty::IntTy::I64 => Some(sym::i64), - ty::IntTy::I128 => Some(sym::i128), - }, - ty::Uint(f) => match f { - ty::UintTy::Usize => Some(sym::usize), - ty::UintTy::U8 => Some(sym::u8), - ty::UintTy::U16 => Some(sym::u16), - ty::UintTy::U32 => Some(sym::u32), - ty::UintTy::U64 => Some(sym::u64), - ty::UintTy::U128 => Some(sym::u128), - }, - _ => None, - }; - - let similarity = |e: ExpectedFound>| { - let (fk, ek) = (e.found.kind(), e.expected.kind()); - match (fk, ek) { - ( - ty::Adt(adt, _), - ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_), - ) => { - let path = self.tcx.def_path(adt.did()).data; - let name = path.last().unwrap().data.get_opt_name(); - let prim_sym = primitive_sym(ek); + Adts { expected: ty::AdtDef<'tcx>, found: ty::AdtDef<'tcx> }, + PrimitiveFound { expected: ty::AdtDef<'tcx>, found: Ty<'tcx> }, + PrimitiveExpected { expected: Ty<'tcx>, found: ty::AdtDef<'tcx> }, + } - if name == prim_sym { - return Some(Similar::PrimitiveExpected(*adt, e.expected)); - } - None + let similarity = |ExpectedFound { expected, found }: ExpectedFound>| { + if let ty::Adt(expected, _) = expected.kind() && let Some(primitive) = found.primitive_symbol() { + let path = self.tcx.def_path(expected.did()).data; + let name = path.last().unwrap().data.get_opt_name(); + if name == Some(primitive) { + return Some(Similar::PrimitiveFound { expected: *expected, found }); } - ( - ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_), - ty::Adt(adt, _), - ) => { - let path = self.tcx.def_path(adt.did()).data; - let name = path.last().unwrap().data.get_opt_name(); - let prim_sym = primitive_sym(fk); - - if name == prim_sym { - return Some(Similar::PrimitiveFound(e.expected, *adt)); - } - None + } else if let Some(primitive) = expected.primitive_symbol() && let ty::Adt(found, _) = found.kind() { + let path = self.tcx.def_path(found.did()).data; + let name = path.last().unwrap().data.get_opt_name(); + if name == Some(primitive) { + return Some(Similar::PrimitiveExpected { expected, found: *found }); } - (ty::Adt(f, _), ty::Adt(e, _)) => { - if !f.did().is_local() && f.did().krate == e.did().krate { - // Most likely types from different versions of the same crate - // are in play, in which case this message isn't so helpful. - // A "perhaps two different versions..." error is already emitted for that. - return None; - } - let e_path = self.tcx.def_path(e.did()).data; - let f_path = self.tcx.def_path(f.did()).data; - if let (Some(e_last), Some(f_last)) = (e_path.last(), f_path.last()) && e_last == f_last { - return Some(Similar::Adts(*f, *e)); - } - None + } else if let ty::Adt(expected, _) = expected.kind() && let ty::Adt(found, _) = found.kind() { + if !expected.did().is_local() && expected.did().krate == found.did().krate { + // Most likely types from different versions of the same crate + // are in play, in which case this message isn't so helpful. + // A "perhaps two different versions..." error is already emitted for that. + return None; + } + let f_path = self.tcx.def_path(found.did()).data; + let e_path = self.tcx.def_path(expected.did()).data; + + if let (Some(e_last), Some(f_last)) = (e_path.last(), f_path.last()) && e_last == f_last { + return Some(Similar::Adts{expected: *expected, found: *found}); } - _ => None, } + None }; match terr { @@ -1759,8 +1716,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }; let diagnose_adts = - |found_adt: ty::AdtDef<'tcx>, - expected_adt: ty::AdtDef<'tcx>, + |expected_adt : ty::AdtDef<'tcx>, + found_adt: ty::AdtDef<'tcx>, diagnostic: &mut Diagnostic| { let found_name = values.found.sort_string(self.tcx); let expected_name = values.expected.sort_string(self.tcx); @@ -1792,14 +1749,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }; match s { - Similar::Adts(found_adt, expected_adt) => { - diagnose_adts(found_adt, expected_adt, diag) + Similar::Adts{expected, found} => { + diagnose_adts(expected, found, diag) } - Similar::PrimitiveFound(prim, e) => { - diagnose_primitive(prim, values.expected, e.did(), diag) + Similar::PrimitiveFound{expected, found: prim} => { + diagnose_primitive(prim, values.expected, expected.did(), diag) } - Similar::PrimitiveExpected(f, prim) => { - diagnose_primitive(prim, values.found, f.did(), diag) + Similar::PrimitiveExpected{expected: prim, found} => { + diagnose_primitive(prim, values.found, found.did(), diag) } } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 36e5608503904..6583e61931a53 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -19,7 +19,7 @@ use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_index::vec::Idx; use rustc_macros::HashStable; -use rustc_span::symbol::{kw, Symbol}; +use rustc_span::symbol::{kw, sym, Symbol}; use rustc_target::abi::VariantIdx; use rustc_target::spec::abi; use std::borrow::Cow; @@ -2274,6 +2274,35 @@ impl<'tcx> Ty<'tcx> { } } } + + // If `self` is a primitive, return its [`Symbol`]. + pub fn primitive_symbol(self) -> Option { + match self.kind() { + ty::Bool => Some(sym::bool), + ty::Char => Some(sym::char), + ty::Float(f) => match f { + ty::FloatTy::F32 => Some(sym::f32), + ty::FloatTy::F64 => Some(sym::f64), + }, + ty::Int(f) => match f { + ty::IntTy::Isize => Some(sym::isize), + ty::IntTy::I8 => Some(sym::i8), + ty::IntTy::I16 => Some(sym::i16), + ty::IntTy::I32 => Some(sym::i32), + ty::IntTy::I64 => Some(sym::i64), + ty::IntTy::I128 => Some(sym::i128), + }, + ty::Uint(f) => match f { + ty::UintTy::Usize => Some(sym::usize), + ty::UintTy::U8 => Some(sym::u8), + ty::UintTy::U16 => Some(sym::u16), + ty::UintTy::U32 => Some(sym::u32), + ty::UintTy::U64 => Some(sym::u64), + ty::UintTy::U128 => Some(sym::u128), + }, + _ => None, + } + } } /// Extra information about why we ended up with a particular variance. diff --git a/src/test/ui/mismatched_types/show_module.rs b/src/test/ui/mismatched_types/show_module.rs index 97d45b377bcfb..61550b8875520 100644 --- a/src/test/ui/mismatched_types/show_module.rs +++ b/src/test/ui/mismatched_types/show_module.rs @@ -1,10 +1,10 @@ -pub mod blah{ - pub mod baz{ +pub mod blah { + pub mod baz { pub struct Foo; } } -pub mod meh{ +pub mod meh { pub struct Foo; } @@ -15,4 +15,4 @@ fn foo() -> Foo { //~^ ERROR mismatched types [E0308] } -fn main(){} +fn main() {} diff --git a/src/test/ui/mismatched_types/similar_paths.rs b/src/test/ui/mismatched_types/similar_paths.rs index 4d3a2a1fcc61c..4b9157f39bf48 100644 --- a/src/test/ui/mismatched_types/similar_paths.rs +++ b/src/test/ui/mismatched_types/similar_paths.rs @@ -1,11 +1,11 @@ -enum Option{ +enum Option { Some(T), None, } -pub fn foo() -> Option{ +pub fn foo() -> Option { Some(42_u8) //~^ ERROR mismatched types [E0308] } -fn main(){} +fn main() {} diff --git a/src/test/ui/mismatched_types/similar_paths.stderr b/src/test/ui/mismatched_types/similar_paths.stderr index 16f33e55fea03..e65ae58d4ce96 100644 --- a/src/test/ui/mismatched_types/similar_paths.stderr +++ b/src/test/ui/mismatched_types/similar_paths.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types --> $DIR/similar_paths.rs:7:5 | -LL | pub fn foo() -> Option{ +LL | pub fn foo() -> Option { | ---------- expected `Option` because of return type LL | Some(42_u8) | ^^^^^^^^^^^ expected enum `Option`, found enum `std::option::Option` @@ -15,7 +15,7 @@ LL | pub enum Option { note: enum `Option` is defined in the current crate --> $DIR/similar_paths.rs:1:1 | -LL | enum Option{ +LL | enum Option { | ^^^^^^^^^^^^^^ error: aborting due to previous error From e0a2e2d892252ed6e6264ce5cc8dae3dd2800f4a Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 21 Sep 2022 12:31:48 +0000 Subject: [PATCH 06/15] Deduplicate two functions that would soon have been three --- compiler/rustc_typeck/src/check/writeback.rs | 22 ++++---------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_typeck/src/check/writeback.rs b/compiler/rustc_typeck/src/check/writeback.rs index 9ecf34e9ad3e7..680dbf7037fad 100644 --- a/compiler/rustc_typeck/src/check/writeback.rs +++ b/compiler/rustc_typeck/src/check/writeback.rs @@ -717,27 +717,13 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> { Resolver { tcx: fcx.tcx, infcx: fcx, span, body, replaced_with_error: false } } - fn report_type_error(&self, t: Ty<'tcx>) { + fn report_error(&self, p: impl Into>) { if !self.tcx.sess.has_errors().is_some() { self.infcx .emit_inference_failure_err( Some(self.body.id()), self.span.to_span(self.tcx), - t.into(), - E0282, - false, - ) - .emit(); - } - } - - fn report_const_error(&self, c: ty::Const<'tcx>) { - if self.tcx.sess.has_errors().is_none() { - self.infcx - .emit_inference_failure_err( - Some(self.body.id()), - self.span.to_span(self.tcx), - c.into(), + p.into(), E0282, false, ) @@ -782,7 +768,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> { } Err(_) => { debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t); - self.report_type_error(t); + self.report_error(t); self.replaced_with_error = true; self.tcx().ty_error() } @@ -799,7 +785,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> { Ok(ct) => self.tcx.erase_regions(ct), Err(_) => { debug!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct); - self.report_const_error(ct); + self.report_error(ct); self.replaced_with_error = true; self.tcx().const_error(ct.ty()) } From 3d8b3e6ca179dc2ac79c038ad607b2321be70e8d Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Wed, 21 Sep 2022 10:24:16 -0500 Subject: [PATCH 07/15] Set 'exec-env:RUST_BACKTRACE=0' in const-eval-select tests This allows the tests to pass even if the user has RUST_BACKTRACE set when running 'x.py' --- src/test/ui/intrinsics/const-eval-select-backtrace-std.rs | 1 + .../ui/intrinsics/const-eval-select-backtrace-std.run.stderr | 2 +- src/test/ui/intrinsics/const-eval-select-backtrace.rs | 1 + src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace-std.rs b/src/test/ui/intrinsics/const-eval-select-backtrace-std.rs index 29aefe07162b3..1164a3a5b0180 100644 --- a/src/test/ui/intrinsics/const-eval-select-backtrace-std.rs +++ b/src/test/ui/intrinsics/const-eval-select-backtrace-std.rs @@ -1,6 +1,7 @@ // See issue #100696. // run-fail // check-run-results +// exec-env:RUST_BACKTRACE=0 fn main() { &""[1..]; } diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr b/src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr index e53e6034620ca..463cd52c5aa7b 100644 --- a/src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr +++ b/src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'byte index 1 is out of bounds of ``', $DIR/const-eval-select-backtrace-std.rs:5:6 +thread 'main' panicked at 'byte index 1 is out of bounds of ``', $DIR/const-eval-select-backtrace-std.rs:6:6 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace.rs b/src/test/ui/intrinsics/const-eval-select-backtrace.rs index 99f0725200c1d..ef1c7c4195b91 100644 --- a/src/test/ui/intrinsics/const-eval-select-backtrace.rs +++ b/src/test/ui/intrinsics/const-eval-select-backtrace.rs @@ -2,6 +2,7 @@ // See issue #100696. // run-fail // check-run-results +// exec-env:RUST_BACKTRACE=0 #[track_caller] fn uhoh() { diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr b/src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr index 2fd730ac7a68a..54e28db5e533d 100644 --- a/src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr +++ b/src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'Aaah!', $DIR/const-eval-select-backtrace.rs:16:9 +thread 'main' panicked at 'Aaah!', $DIR/const-eval-select-backtrace.rs:17:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace From 5d8083360ad2065a5a412091f5f5b212565c45af Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 21 Sep 2022 11:53:50 -0700 Subject: [PATCH 08/15] Allow full relro on powerpc64-unknown-linux-gnu This was previously limited to partial relro, citing issues on RHEL6, but that's no longer a supported platform since #95026. We have long been enabling full relro in RHEL7's own Rust builds for ppc64, without trouble, so it should be fine to drop this workaround. --- .../rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs index 5413c4f33ff61..1cb9ce40cb1e5 100644 --- a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs @@ -1,5 +1,5 @@ use crate::abi::Endian; -use crate::spec::{LinkerFlavor, RelroLevel, Target, TargetOptions}; +use crate::spec::{LinkerFlavor, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); @@ -7,10 +7,6 @@ pub fn target() -> Target { base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]); base.max_atomic_width = Some(64); - // ld.so in at least RHEL6 on ppc64 has a bug related to BIND_NOW, so only enable partial RELRO - // for now. https://github.com/rust-lang/rust/pull/43170#issuecomment-315411474 - base.relro_level = RelroLevel::Partial; - Target { llvm_target: "powerpc64-unknown-linux-gnu".into(), pointer_width: 64, From ba5f05b1c4cd3a3db4f1f526a911cf76f815c6a2 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 20 Sep 2022 12:07:35 -0700 Subject: [PATCH 09/15] rustdoc: remove unnecessary `max-width` on headers This code was added in 003b2bc1c65251ec2fc80b78ed91c43fb35402ec to prevent these headers from overlapping `.out-of-band` side items. That stopped being a problem when 3f92ff34b5a2fe8dd1a32aa27d437519e63782f0 switched rustdoc over to using `float`, rather than `position: absolute`, to implement this. --- src/librustdoc/html/static/css/rustdoc.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index e985e6c43ade9..c2875f126078d 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -674,7 +674,6 @@ h2.location a { } .method > .code-header, .trait-impl > .code-header { - max-width: calc(100% - 41px); display: block; } From f528d49c23c8d1f50152cbbebe0f1920136fa956 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 21 Sep 2022 17:29:47 -0700 Subject: [PATCH 10/15] rustdoc: update test case for headers without max-width --- src/test/rustdoc-gui/notable-trait.goml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/rustdoc-gui/notable-trait.goml b/src/test/rustdoc-gui/notable-trait.goml index 69088a0774fc4..7eb00d825a5c3 100644 --- a/src/test/rustdoc-gui/notable-trait.goml +++ b/src/test/rustdoc-gui/notable-trait.goml @@ -83,7 +83,7 @@ assert-position: ( ) // Checking on very small mobile. The `i` should be on its own line. -size: (410, 600) +size: (365, 600) compare-elements-position-false: ( "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", From d0a07495be4906db5028a605f650aafeabee1879 Mon Sep 17 00:00:00 2001 From: Dan Johnson Date: Thu, 18 Aug 2022 16:27:16 -0700 Subject: [PATCH 11/15] Split out async_fn_in_trait into a separate feature PR #101224 added support for async fn in trait desuraging behind the return_position_impl_trait_in_trait feature. Split this out so that it's behind its own feature gate, since async fn in trait doesn't need to follow the same stabilization schedule. --- compiler/rustc_ast_lowering/src/lib.rs | 23 +++++++--- compiler/rustc_feature/src/active.rs | 2 + compiler/rustc_span/src/symbol.rs | 1 + src/test/ui/async-await/async-trait-fn.stderr | 6 +-- .../edition-deny-async-fns-2015.stderr | 2 +- .../feature-gate-async_fn_in_trait.rs | 25 +++++++++++ .../feature-gate-async_fn_in_trait.stderr | 42 +++++++++++++++++++ .../ui/async-await/issues/issue-95307.stderr | 2 +- ...ate-return_position_impl_trait_in_trait.rs | 13 ++++++ ...return_position_impl_trait_in_trait.stderr | 22 +++++++++- .../ui/parser/fn-header-semantic-fail.stderr | 8 ++-- ...0736-async-fn-no-body-def-collector.stderr | 4 +- ...incompatible-closure-captures-93117.stderr | 2 +- 13 files changed, 133 insertions(+), 19 deletions(-) create mode 100644 src/test/ui/async-await/feature-gate-async_fn_in_trait.rs create mode 100644 src/test/ui/async-await/feature-gate-async_fn_in_trait.stderr diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index e9c05eb5f455f..a11721ba0213a 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -332,6 +332,15 @@ impl FnDeclKind { _ => false, } } + + fn async_fn_allowed(&self, tcx: TyCtxt<'_>) -> bool { + match self { + FnDeclKind::Fn | FnDeclKind::Inherent => true, + FnDeclKind::Impl if tcx.features().async_fn_in_trait => true, + FnDeclKind::Trait if tcx.features().async_fn_in_trait => true, + _ => false, + } + } } #[derive(Copy, Clone)] @@ -1692,14 +1701,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { })); let output = if let Some((ret_id, span)) = make_ret_async { - if !kind.impl_trait_allowed(self.tcx) { + if !kind.async_fn_allowed(self.tcx) { match kind { FnDeclKind::Trait | FnDeclKind::Impl => { self.tcx .sess .create_feature_err( TraitFnAsync { fn_span, span }, - sym::return_position_impl_trait_in_trait, + sym::async_fn_in_trait, ) .emit(); } @@ -1917,9 +1926,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let future_bound = this.lower_async_fn_output_type_to_future_bound( output, span, - ImplTraitContext::ReturnPositionOpaqueTy { - origin: hir::OpaqueTyOrigin::FnReturn(fn_def_id), - in_trait, + if in_trait && !this.tcx.features().return_position_impl_trait_in_trait { + ImplTraitContext::Disallowed(ImplTraitPosition::TraitReturn) + } else { + ImplTraitContext::ReturnPositionOpaqueTy { + origin: hir::OpaqueTyOrigin::FnReturn(fn_def_id), + in_trait, + } }, ); diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index ad28595ca82b3..4c891fbf16e94 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -312,6 +312,8 @@ declare_features! ( (active, associated_type_defaults, "1.2.0", Some(29661), None), /// Allows `async || body` closures. (active, async_closure, "1.37.0", Some(62290), None), + /// Alows async functions to be declared, implemented, and used in traits. + (incomplete, async_fn_in_trait, "CURRENT_RUSTC_VERSION", Some(91611), None), /// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries. (active, c_unwind, "1.52.0", Some(74990), None), /// Allows using C-variadics. diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 7785d29c15f2c..502ef67fc6767 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -396,6 +396,7 @@ symbols! { assume_init, async_await, async_closure, + async_fn_in_trait, atomic, atomic_mod, atomics, diff --git a/src/test/ui/async-await/async-trait-fn.stderr b/src/test/ui/async-await/async-trait-fn.stderr index e5c584e31e815..4fa54c6e36960 100644 --- a/src/test/ui/async-await/async-trait-fn.stderr +++ b/src/test/ui/async-await/async-trait-fn.stderr @@ -9,7 +9,7 @@ LL | async fn foo() {} = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` --> $DIR/async-trait-fn.rs:5:5 @@ -22,7 +22,7 @@ LL | async fn bar(&self) {} = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` --> $DIR/async-trait-fn.rs:7:5 @@ -35,7 +35,7 @@ LL | async fn baz() { = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0308]: mismatched types --> $DIR/async-trait-fn.rs:3:20 diff --git a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr index 8c2902d9b00d1..62a243e69e743 100644 --- a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr +++ b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr @@ -90,7 +90,7 @@ LL | async fn foo() {} = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0308]: mismatched types --> $DIR/edition-deny-async-fns-2015.rs:18:20 diff --git a/src/test/ui/async-await/feature-gate-async_fn_in_trait.rs b/src/test/ui/async-await/feature-gate-async_fn_in_trait.rs new file mode 100644 index 0000000000000..792f378cb57f1 --- /dev/null +++ b/src/test/ui/async-await/feature-gate-async_fn_in_trait.rs @@ -0,0 +1,25 @@ +// edition:2021 + +// RPITIT is not enough to allow use of async functions +#![allow(incomplete_features)] +#![feature(return_position_impl_trait_in_trait)] + +trait T { + async fn foo(); //~ ERROR functions in traits cannot be declared `async` +} + +// Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also +// feature-gate-return_position_impl_trait_in_trait.rs) +trait T2 { + async fn foo() -> impl Sized; //~ ERROR functions in traits cannot be declared `async` +} + +trait T3 { + fn foo() -> impl std::future::Future; +} + +impl T3 for () { + async fn foo() {} //~ ERROR functions in traits cannot be declared `async` +} + +fn main() {} diff --git a/src/test/ui/async-await/feature-gate-async_fn_in_trait.stderr b/src/test/ui/async-await/feature-gate-async_fn_in_trait.stderr new file mode 100644 index 0000000000000..2a5fbd1ecd03d --- /dev/null +++ b/src/test/ui/async-await/feature-gate-async_fn_in_trait.stderr @@ -0,0 +1,42 @@ +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/feature-gate-async_fn_in_trait.rs:8:5 + | +LL | async fn foo(); + | -----^^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/feature-gate-async_fn_in_trait.rs:14:5 + | +LL | async fn foo() -> impl Sized; + | -----^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/feature-gate-async_fn_in_trait.rs:22:5 + | +LL | async fn foo() {} + | -----^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0706`. diff --git a/src/test/ui/async-await/issues/issue-95307.stderr b/src/test/ui/async-await/issues/issue-95307.stderr index 1c12f1e4862e8..a497cebe3c3d8 100644 --- a/src/test/ui/async-await/issues/issue-95307.stderr +++ b/src/test/ui/async-await/issues/issue-95307.stderr @@ -9,7 +9,7 @@ LL | async fn new() -> [u8; _]; = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error: in expressions, `_` can only be used on the left-hand side of an assignment --> $DIR/issue-95307.rs:7:28 diff --git a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs index de7966c66b057..637765fff11e4 100644 --- a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs +++ b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs @@ -1,5 +1,18 @@ +// edition:2021 + +// async_fn_in_trait is not enough to allow use of RPITIT +#![allow(incomplete_features)] +#![feature(async_fn_in_trait)] + trait Foo { fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return + fn baz() -> Box; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return +} + +// Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also +// feature-gate-async_fn_in_trait.rs) +trait AsyncFoo { + async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return } fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr index 36177bbe15830..aeabed4a6ab66 100644 --- a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr +++ b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr @@ -1,5 +1,5 @@ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return - --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:2:17 + --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:8:17 | LL | fn bar() -> impl Sized; | ^^^^^^^^^^ @@ -7,6 +7,24 @@ LL | fn bar() -> impl Sized; = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error: aborting due to previous error +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return + --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:9:21 + | +LL | fn baz() -> Box; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 for more information + = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return + --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:15:23 + | +LL | async fn bar() -> impl Sized; + | ^^^^^^^^^^ + | + = note: see issue #91611 for more information + = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0562`. diff --git a/src/test/ui/parser/fn-header-semantic-fail.stderr b/src/test/ui/parser/fn-header-semantic-fail.stderr index 36304779df36f..800b5a43a0066 100644 --- a/src/test/ui/parser/fn-header-semantic-fail.stderr +++ b/src/test/ui/parser/fn-header-semantic-fail.stderr @@ -147,7 +147,7 @@ LL | async fn ft1(); = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` --> $DIR/fn-header-semantic-fail.rs:21:9 @@ -160,7 +160,7 @@ LL | const async unsafe extern "C" fn ft5(); = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` --> $DIR/fn-header-semantic-fail.rs:29:9 @@ -173,7 +173,7 @@ LL | async fn ft1() {} = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` --> $DIR/fn-header-semantic-fail.rs:33:9 @@ -186,7 +186,7 @@ LL | const async unsafe extern "C" fn ft5() {} = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0391]: cycle detected when computing type of `main::ff5::{opaque#0}` --> $DIR/fn-header-semantic-fail.rs:12:44 diff --git a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr index 55c3b66f1363d..1354abb4f144b 100644 --- a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr +++ b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr @@ -33,7 +33,7 @@ LL | async fn associated(); = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5 @@ -46,7 +46,7 @@ LL | async fn associated(); = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error: aborting due to 5 previous errors diff --git a/src/test/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.stderr b/src/test/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.stderr index 3814c568e72c1..2c1fa7b36b60e 100644 --- a/src/test/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.stderr +++ b/src/test/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.stderr @@ -51,7 +51,7 @@ LL | trait C{async fn new(val: T) {} = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait = note: see issue #91611 for more information - = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable warning: changes to closure capture in Rust 2021 will affect drop order --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:6:57 From fdd15b1c150fe3b4919b855beda4d1346f8303ad Mon Sep 17 00:00:00 2001 From: Florian Bartels Date: Thu, 22 Sep 2022 12:40:37 +0200 Subject: [PATCH 12/15] Detect panic strategy using `rustc --print cfg` Instead of relying on a command line parameter, detect if a target is able to unwind or not. Ignore tests that require unwinding on targets that don't support it. --- src/tools/compiletest/src/common.rs | 18 ++++++++++++++---- src/tools/compiletest/src/header.rs | 5 ++--- src/tools/compiletest/src/main.rs | 10 +--------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 64df76e27720d..4994fb9bbf941 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -278,10 +278,6 @@ pub struct Config { /// override this setting. pub optimize_tests: bool, - /// What panic strategy the target is built with. Unwind supports Abort, but - /// not vice versa. - pub target_panic: PanicStrategy, - /// Target system to be tested pub target: String, @@ -426,6 +422,10 @@ impl Config { *&self.target_cfg().pointer_width } + pub fn can_unwind(&self) -> bool { + self.target_cfg().panic == PanicStrategy::Unwind + } + pub fn has_asm_support(&self) -> bool { static ASM_SUPPORTED_ARCHS: &[&str] = &[ "x86", "x86_64", "arm", "aarch64", "riscv32", @@ -446,6 +446,7 @@ pub struct TargetCfg { families: Vec, pointer_width: u32, endian: Endian, + panic: PanicStrategy, } #[derive(Eq, PartialEq, Clone, Debug)] @@ -481,6 +482,7 @@ impl TargetCfg { let mut families = Vec::new(); let mut pointer_width = None; let mut endian = None; + let mut panic = None; for line in print_cfg.lines() { if let Some((name, value)) = line.split_once('=') { let value = value.trim_matches('"'); @@ -498,6 +500,13 @@ impl TargetCfg { s => panic!("unexpected {s}"), }) } + "panic" => { + panic = match value { + "abort" => Some(PanicStrategy::Abort), + "unwind" => Some(PanicStrategy::Unwind), + s => panic!("unexpected {s}"), + } + } _ => {} } } @@ -510,6 +519,7 @@ impl TargetCfg { families, pointer_width: pointer_width.unwrap(), endian: endian.unwrap(), + panic: panic.unwrap(), } } } diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 3ff1cbf20cd26..6f85227500361 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; use tracing::*; -use crate::common::{CompareMode, Config, Debugger, FailMode, Mode, PanicStrategy, PassMode}; +use crate::common::{CompareMode, Config, Debugger, FailMode, Mode, PassMode}; use crate::util; use crate::{extract_cdb_version, extract_gdb_version}; @@ -949,8 +949,7 @@ pub fn make_test_description( ignore |= !has_memtag && config.parse_name_directive(ln, "needs-sanitizer-memtag"); ignore |= !has_shadow_call_stack && config.parse_name_directive(ln, "needs-sanitizer-shadow-call-stack"); - ignore |= config.target_panic == PanicStrategy::Abort - && config.parse_name_directive(ln, "needs-unwind"); + ignore |= !config.can_unwind() && config.parse_name_directive(ln, "needs-unwind"); ignore |= config.target == "wasm32-unknown-unknown" && config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS); ignore |= config.debugger == Some(Debugger::Cdb) && ignore_cdb(config, ln); diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 38c7b87fc0d9d..dccfd4e0d9807 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -5,9 +5,7 @@ extern crate test; -use crate::common::{ - expected_output_path, output_base_dir, output_relative_path, PanicStrategy, UI_EXTENSIONS, -}; +use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS}; use crate::common::{CompareMode, Config, Debugger, Mode, PassMode, TestPaths}; use crate::util::logv; use getopts::Options; @@ -105,7 +103,6 @@ pub fn parse_config(args: Vec) -> Config { .optmulti("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS") .optmulti("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS") .optflag("", "optimize-tests", "run tests with optimizations enabled") - .optopt("", "target-panic", "what panic strategy the target supports", "unwind | abort") .optflag("", "verbose", "run tests verbosely, showing all output") .optflag( "", @@ -258,11 +255,6 @@ pub fn parse_config(args: Vec) -> Config { host_rustcflags: Some(matches.opt_strs("host-rustcflags").join(" ")), target_rustcflags: Some(matches.opt_strs("target-rustcflags").join(" ")), optimize_tests: matches.opt_present("optimize-tests"), - target_panic: match matches.opt_str("target-panic").as_deref() { - Some("unwind") | None => PanicStrategy::Unwind, - Some("abort") => PanicStrategy::Abort, - _ => panic!("unknown `--target-panic` option `{}` given", mode), - }, target, host: opt_str2(matches.opt_str("host")), cdb, From e572d513bd2ca1743d141ccee91563d6faf2e19f Mon Sep 17 00:00:00 2001 From: Luca Palmieri Date: Tue, 20 Sep 2022 11:36:36 +0200 Subject: [PATCH 13/15] Distribute rust-json-docs via rustup. --- src/bootstrap/dist.rs | 14 ++++---------- src/tools/build-manifest/src/main.rs | 5 ++++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index c9ee3c1c7d65d..3aff60b03a8be 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -98,29 +98,23 @@ impl Step for JsonDocs { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let default = run.builder.config.docs; - run.alias("rust-json-docs").default_condition(default) + run.alias("rust-docs-json").default_condition(default) } fn make_run(run: RunConfig<'_>) { run.builder.ensure(JsonDocs { host: run.target }); } - /// Builds the `rust-json-docs` installer component. + /// Builds the `rust-docs-json` installer component. fn run(self, builder: &Builder<'_>) -> Option { - // This prevents JSON docs from being built for "dist" or "install" - // on the stable/beta channels. The JSON format is not stable yet and - // should not be included in stable/beta toolchains. - if !builder.build.unstable_features() { - return None; - } - let host = self.host; builder.ensure(crate::doc::JsonStd { stage: builder.top_stage, target: host }); let dest = "share/doc/rust/json"; - let mut tarball = Tarball::new(builder, "rust-json-docs", &host.triple); + let mut tarball = Tarball::new(builder, "rust-docs-json", &host.triple); tarball.set_product_name("Rust Documentation In JSON Format"); + tarball.is_preview(true); tarball.add_bulk_dir(&builder.json_doc_out(host), dest); Some(tarball.generate()) } diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 1a6760d8c68b9..62d6ea4a64221 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -184,7 +184,7 @@ static PKG_INSTALLERS: &[&str] = &["x86_64-apple-darwin", "aarch64-apple-darwin" static MINGW: &[&str] = &["i686-pc-windows-gnu", "x86_64-pc-windows-gnu"]; -static NIGHTLY_ONLY_COMPONENTS: &[&str] = &["miri-preview"]; +static NIGHTLY_ONLY_COMPONENTS: &[&str] = &["miri-preview", "rust-docs-json-preview"]; macro_rules! t { ($e:expr) => { @@ -318,6 +318,7 @@ impl Builder { package!("rust-mingw", MINGW); package!("rust-std", TARGETS); self.package("rust-docs", &mut manifest.pkg, HOSTS, DOCS_FALLBACK); + self.package("rust-docs-json-preview", &mut manifest.pkg, HOSTS, DOCS_FALLBACK); package!("rust-src", &["*"]); package!("rls-preview", HOSTS); package!("rust-analyzer-preview", HOSTS); @@ -403,6 +404,7 @@ impl Builder { rename("rustfmt", "rustfmt-preview"); rename("clippy", "clippy-preview"); rename("miri", "miri-preview"); + rename("rust-docs-json", "rust-docs-json-preview"); rename("rust-analyzer", "rust-analyzer-preview"); } @@ -459,6 +461,7 @@ impl Builder { host_component("rustfmt-preview"), host_component("llvm-tools-preview"), host_component("rust-analysis"), + host_component("rust-docs-json"), ]); extensions.extend( From 681f39bdec7429cfa3d87e5e5539e2cd847a2b89 Mon Sep 17 00:00:00 2001 From: Florian Bartels Date: Thu, 22 Sep 2022 14:25:10 +0200 Subject: [PATCH 14/15] Restore ignore tag This test case actually requires std::process. --- src/test/ui/async-await/async-fn-size-moved-locals.rs | 1 - .../issue-65419/issue-65419-async-fn-resume-after-panic.rs | 1 - src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs | 1 - src/test/ui/builtin-clone-unwind.rs | 1 - src/test/ui/catch-unwind-bang.rs | 1 - src/test/ui/cfg/cfg-panic.rs | 3 --- .../2229_closure_analysis/migrations/mir_calls_to_shims.rs | 1 - src/test/ui/drop/dynamic-drop-async.rs | 1 - src/test/ui/drop/dynamic-drop.rs | 1 - src/test/ui/drop/repeat-drop.rs | 3 --- src/test/ui/extern-flag/empty-extern-arg.rs | 1 - .../issue-64655-allow-unwind-when-calling-panic-directly.rs | 1 - .../ui/extern/issue-64655-extern-rust-must-allow-unwind.rs | 1 - src/test/ui/generator/panic-drops-resume.rs | 2 -- src/test/ui/generator/panic-drops.rs | 1 - src/test/ui/generator/panic-safe.rs | 1 - src/test/ui/generator/resume-after-return.rs | 1 - src/test/ui/intrinsics/panic-uninitialized-zeroed.rs | 1 - src/test/ui/issues/issue-14875.rs | 1 - src/test/ui/issues/issue-29948.rs | 1 - src/test/ui/issues/issue-43853.rs | 1 - src/test/ui/issues/issue-46519.rs | 1 - src/test/ui/iterators/iter-count-overflow-debug.rs | 1 - src/test/ui/iterators/iter-position-overflow-debug.rs | 1 - src/test/ui/iterators/iter-step-overflow-debug.rs | 1 - src/test/ui/iterators/iter-sum-overflow-debug.rs | 1 - src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs | 1 - src/test/ui/macros/macro-comma-behavior-rpass.rs | 1 - src/test/ui/mir/mir_calls_to_shims.rs | 1 - src/test/ui/mir/mir_codegen_calls_diverging_drops.rs | 1 - src/test/ui/mir/mir_drop_order.rs | 1 - src/test/ui/mir/mir_drop_panics.rs | 1 - src/test/ui/mir/mir_let_chains_drop_order.rs | 1 - .../ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs | 1 - src/test/ui/panic-handler/weak-lang-item.rs | 1 - src/test/ui/panic-runtime/need-abort-got-unwind.rs | 1 - src/test/ui/panic-runtime/transitive-link-a-bunch.rs | 1 - src/test/ui/panic-runtime/want-unwind-got-abort.rs | 1 - src/test/ui/panic-runtime/want-unwind-got-abort2.rs | 1 - src/test/ui/panic-while-printing.rs | 1 - src/test/ui/privacy/reachable-unnameable-items.rs | 1 - src/test/ui/proc-macro/expand-with-a-macro.rs | 1 - .../ui/rfc-1937-termination-trait/termination-trait-in-test.rs | 1 - src/test/ui/rfc-2091-track-caller/std-panic-locations.rs | 1 - src/test/ui/rfcs/rfc1857-drop-order.rs | 1 - src/test/ui/runtime/rt-explody-panic-payloads.rs | 3 --- src/test/ui/test-attrs/test-panic-while-printing.rs | 1 - src/test/ui/test-attrs/test-should-fail-good-message.rs | 1 - src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs | 1 - src/test/ui/unwind-no-uwtable.rs | 1 - 50 files changed, 57 deletions(-) diff --git a/src/test/ui/async-await/async-fn-size-moved-locals.rs b/src/test/ui/async-await/async-fn-size-moved-locals.rs index 9e3794b0484e7..79b7239f3590d 100644 --- a/src/test/ui/async-await/async-fn-size-moved-locals.rs +++ b/src/test/ui/async-await/async-fn-size-moved-locals.rs @@ -7,7 +7,6 @@ // // See issue #59123 for a full explanation. -// ignore-emscripten (sizes don't match) // needs-unwind Size of Futures change on panic=abort // run-pass diff --git a/src/test/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs b/src/test/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs index 5e71229beb5f9..b4ea4c9f68664 100644 --- a/src/test/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs +++ b/src/test/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs @@ -6,7 +6,6 @@ // error-pattern: thread 'main' panicked at '`async fn` resumed after panicking' // edition:2018 // ignore-wasm no panic or subprocess support -// ignore-emscripten no panic or subprocess support #![feature(generators, generator_trait)] diff --git a/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs b/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs index 684172ca61cca..0450fe8abbd14 100644 --- a/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs +++ b/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs @@ -3,7 +3,6 @@ // Check that partially moved from function parameters are dropped after the // named bindings that move from them. -// ignore-wasm32-bare compiled with panic=abort by default use std::{panic, cell::RefCell}; diff --git a/src/test/ui/builtin-clone-unwind.rs b/src/test/ui/builtin-clone-unwind.rs index 3623c4a4dd05d..16add6ff2f68f 100644 --- a/src/test/ui/builtin-clone-unwind.rs +++ b/src/test/ui/builtin-clone-unwind.rs @@ -3,7 +3,6 @@ #![allow(unused_variables)] #![allow(unused_imports)] -// ignore-wasm32-bare compiled with panic=abort by default // Test that builtin implementations of `Clone` cleanup everything // in case of unwinding. diff --git a/src/test/ui/catch-unwind-bang.rs b/src/test/ui/catch-unwind-bang.rs index b31b5cab5b724..fb3503937cb54 100644 --- a/src/test/ui/catch-unwind-bang.rs +++ b/src/test/ui/catch-unwind-bang.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default fn worker() -> ! { panic!() diff --git a/src/test/ui/cfg/cfg-panic.rs b/src/test/ui/cfg/cfg-panic.rs index fb3e5059c8199..2de72d54a481a 100644 --- a/src/test/ui/cfg/cfg-panic.rs +++ b/src/test/ui/cfg/cfg-panic.rs @@ -1,9 +1,6 @@ // build-pass // compile-flags: -C panic=unwind // needs-unwind -// ignore-emscripten no panic_unwind implementation -// ignore-wasm32 no panic_unwind implementation -// ignore-wasm64 no panic_unwind implementation #[cfg(panic = "abort")] diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs index 6b0b10521740e..52e96d013a265 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs @@ -3,7 +3,6 @@ #![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here -// ignore-wasm32-bare compiled with panic=abort by default #![feature(fn_traits)] #![feature(never_type)] diff --git a/src/test/ui/drop/dynamic-drop-async.rs b/src/test/ui/drop/dynamic-drop-async.rs index 13bd71ecb3389..8f1cc6691cd8d 100644 --- a/src/test/ui/drop/dynamic-drop-async.rs +++ b/src/test/ui/drop/dynamic-drop-async.rs @@ -6,7 +6,6 @@ // run-pass // needs-unwind // edition:2018 -// ignore-wasm32-bare compiled with panic=abort by default #![allow(unused)] diff --git a/src/test/ui/drop/dynamic-drop.rs b/src/test/ui/drop/dynamic-drop.rs index e706867742337..9e51d3adaaa68 100644 --- a/src/test/ui/drop/dynamic-drop.rs +++ b/src/test/ui/drop/dynamic-drop.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default #![feature(generators, generator_trait)] diff --git a/src/test/ui/drop/repeat-drop.rs b/src/test/ui/drop/repeat-drop.rs index a43612e5d8587..8fd46ecaf4420 100644 --- a/src/test/ui/drop/repeat-drop.rs +++ b/src/test/ui/drop/repeat-drop.rs @@ -1,8 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare no unwinding panic -// ignore-avr no unwinding panic -// ignore-nvptx64 no unwinding panic static mut CHECK: usize = 0; diff --git a/src/test/ui/extern-flag/empty-extern-arg.rs b/src/test/ui/extern-flag/empty-extern-arg.rs index 3170537b0e0a0..a371afb128cab 100644 --- a/src/test/ui/extern-flag/empty-extern-arg.rs +++ b/src/test/ui/extern-flag/empty-extern-arg.rs @@ -1,6 +1,5 @@ // compile-flags: --extern std= // error-pattern: extern location for std does not exist // needs-unwind since it affects the error output -// ignore-emscripten compiled with panic=abort, personality not required fn main() {} diff --git a/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs b/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs index 7a91cbdc2f5d4..233120c92f38b 100644 --- a/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs +++ b/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // ignore-emscripten no threads support // rust-lang/rust#64655: with panic=unwind, a panic from a subroutine diff --git a/src/test/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs b/src/test/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs index e84ff41b344a7..3b263e58cbe84 100644 --- a/src/test/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs +++ b/src/test/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // ignore-emscripten no threads support // rust-lang/rust#64655: with panic=unwind, a panic from a subroutine diff --git a/src/test/ui/generator/panic-drops-resume.rs b/src/test/ui/generator/panic-drops-resume.rs index 8d8eb6a97b15a..4c3caeb14d67e 100644 --- a/src/test/ui/generator/panic-drops-resume.rs +++ b/src/test/ui/generator/panic-drops-resume.rs @@ -2,8 +2,6 @@ // run-pass // needs-unwind -// ignore-wasm no unwind support -// ignore-emscripten no unwind support #![feature(generators, generator_trait)] diff --git a/src/test/ui/generator/panic-drops.rs b/src/test/ui/generator/panic-drops.rs index a9de4e7fc7d25..65001fd879bb0 100644 --- a/src/test/ui/generator/panic-drops.rs +++ b/src/test/ui/generator/panic-drops.rs @@ -1,7 +1,6 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default #![feature(generators, generator_trait)] diff --git a/src/test/ui/generator/panic-safe.rs b/src/test/ui/generator/panic-safe.rs index 14a0c8dbaf1da..3db80bb582151 100644 --- a/src/test/ui/generator/panic-safe.rs +++ b/src/test/ui/generator/panic-safe.rs @@ -1,7 +1,6 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default #![feature(generators, generator_trait)] diff --git a/src/test/ui/generator/resume-after-return.rs b/src/test/ui/generator/resume-after-return.rs index 538609b981adf..01a059a161cea 100644 --- a/src/test/ui/generator/resume-after-return.rs +++ b/src/test/ui/generator/resume-after-return.rs @@ -1,7 +1,6 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default #![feature(generators, generator_trait)] diff --git a/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs b/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs index 255151a96032c..4aa869cca35be 100644 --- a/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs +++ b/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // revisions: mir thir strict // [thir]compile-flags: -Zthir-unsafeck // [strict]compile-flags: -Zstrict-init-checks diff --git a/src/test/ui/issues/issue-14875.rs b/src/test/ui/issues/issue-14875.rs index aaef2aab9fc76..fca3309155d54 100644 --- a/src/test/ui/issues/issue-14875.rs +++ b/src/test/ui/issues/issue-14875.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // Check that values are not leaked when a dtor panics (#14875) diff --git a/src/test/ui/issues/issue-29948.rs b/src/test/ui/issues/issue-29948.rs index 01c3ec64861fe..3ed701480b5ed 100644 --- a/src/test/ui/issues/issue-29948.rs +++ b/src/test/ui/issues/issue-29948.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default use std::panic; diff --git a/src/test/ui/issues/issue-43853.rs b/src/test/ui/issues/issue-43853.rs index 3162c091c8786..dd42c1e3cb831 100644 --- a/src/test/ui/issues/issue-43853.rs +++ b/src/test/ui/issues/issue-43853.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default use std::panic; diff --git a/src/test/ui/issues/issue-46519.rs b/src/test/ui/issues/issue-46519.rs index 9bd3c0948517b..0567923b7fc69 100644 --- a/src/test/ui/issues/issue-46519.rs +++ b/src/test/ui/issues/issue-46519.rs @@ -2,7 +2,6 @@ // compile-flags:--test -O // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default #[test] #[should_panic(expected = "creating inhabited type")] diff --git a/src/test/ui/iterators/iter-count-overflow-debug.rs b/src/test/ui/iterators/iter-count-overflow-debug.rs index 15f25f1ca5373..8e59c11e9dccb 100644 --- a/src/test/ui/iterators/iter-count-overflow-debug.rs +++ b/src/test/ui/iterators/iter-count-overflow-debug.rs @@ -1,7 +1,6 @@ // run-pass // only-32bit too impatient for 2⁶⁴ items // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C debug_assertions=yes -C opt-level=3 use std::panic; diff --git a/src/test/ui/iterators/iter-position-overflow-debug.rs b/src/test/ui/iterators/iter-position-overflow-debug.rs index 65124c282412c..7a871e744c984 100644 --- a/src/test/ui/iterators/iter-position-overflow-debug.rs +++ b/src/test/ui/iterators/iter-position-overflow-debug.rs @@ -1,7 +1,6 @@ // run-pass // only-32bit too impatient for 2⁶⁴ items // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C debug_assertions=yes -C opt-level=3 use std::panic; diff --git a/src/test/ui/iterators/iter-step-overflow-debug.rs b/src/test/ui/iterators/iter-step-overflow-debug.rs index e16f984de79a6..6aa349ebed29b 100644 --- a/src/test/ui/iterators/iter-step-overflow-debug.rs +++ b/src/test/ui/iterators/iter-step-overflow-debug.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C debug_assertions=yes use std::panic; diff --git a/src/test/ui/iterators/iter-sum-overflow-debug.rs b/src/test/ui/iterators/iter-sum-overflow-debug.rs index d8ce43848a77e..24c764ff95873 100644 --- a/src/test/ui/iterators/iter-sum-overflow-debug.rs +++ b/src/test/ui/iterators/iter-sum-overflow-debug.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C debug_assertions=yes use std::panic; diff --git a/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs b/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs index bc8dcbdbb0e03..be45c075d7331 100644 --- a/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs +++ b/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C overflow-checks use std::panic; diff --git a/src/test/ui/macros/macro-comma-behavior-rpass.rs b/src/test/ui/macros/macro-comma-behavior-rpass.rs index dfd58b25d089d..8406b4e78f6be 100644 --- a/src/test/ui/macros/macro-comma-behavior-rpass.rs +++ b/src/test/ui/macros/macro-comma-behavior-rpass.rs @@ -14,7 +14,6 @@ // compile-flags: --test -C debug_assertions=yes // revisions: std core -// ignore-wasm32-bare compiled with panic=abort by default #![cfg_attr(core, no_std)] #[cfg(core)] diff --git a/src/test/ui/mir/mir_calls_to_shims.rs b/src/test/ui/mir/mir_calls_to_shims.rs index 42eaab77da9f1..9dc0acfbfda48 100644 --- a/src/test/ui/mir/mir_calls_to_shims.rs +++ b/src/test/ui/mir/mir_calls_to_shims.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default #![feature(fn_traits)] #![feature(never_type)] diff --git a/src/test/ui/mir/mir_codegen_calls_diverging_drops.rs b/src/test/ui/mir/mir_codegen_calls_diverging_drops.rs index 3d215610593f3..19dba497001cc 100644 --- a/src/test/ui/mir/mir_codegen_calls_diverging_drops.rs +++ b/src/test/ui/mir/mir_codegen_calls_diverging_drops.rs @@ -1,7 +1,6 @@ // run-fail // error-pattern:diverging_fn called // error-pattern:0 dropped -// ignore-emscripten no processes // needs-unwind this test checks that a destructor is called after panicking struct Droppable(u8); diff --git a/src/test/ui/mir/mir_drop_order.rs b/src/test/ui/mir/mir_drop_order.rs index 853efb0fed2b9..75f5b171af352 100644 --- a/src/test/ui/mir/mir_drop_order.rs +++ b/src/test/ui/mir/mir_drop_order.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default use std::cell::RefCell; use std::panic; diff --git a/src/test/ui/mir/mir_drop_panics.rs b/src/test/ui/mir/mir_drop_panics.rs index b4093d704150a..0d00426d6d2d5 100644 --- a/src/test/ui/mir/mir_drop_panics.rs +++ b/src/test/ui/mir/mir_drop_panics.rs @@ -2,7 +2,6 @@ // needs-unwind // error-pattern:panic 1 // error-pattern:drop 2 -// ignore-emscripten no processes struct Droppable(u32); impl Drop for Droppable { diff --git a/src/test/ui/mir/mir_let_chains_drop_order.rs b/src/test/ui/mir/mir_let_chains_drop_order.rs index 6498a51957194..536a84a352a49 100644 --- a/src/test/ui/mir/mir_let_chains_drop_order.rs +++ b/src/test/ui/mir/mir_let_chains_drop_order.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // See `mir_drop_order.rs` for more information diff --git a/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs b/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs index f857d4f4c7f27..79d78da3328a9 100644 --- a/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs +++ b/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs @@ -1,7 +1,6 @@ // run-pass // compile-flags: -C debug_assertions=yes // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // ignore-emscripten dies with an LLVM error use std::panic; diff --git a/src/test/ui/panic-handler/weak-lang-item.rs b/src/test/ui/panic-handler/weak-lang-item.rs index df31e614cf809..aef5e1b2c1c7a 100644 --- a/src/test/ui/panic-handler/weak-lang-item.rs +++ b/src/test/ui/panic-handler/weak-lang-item.rs @@ -2,7 +2,6 @@ // error-pattern: `#[panic_handler]` function required, but not found // error-pattern: language item required, but not found: `eh_personality` // needs-unwind since it affects the error output -// ignore-emscripten compiled with panic=abort, personality not required #![no_std] diff --git a/src/test/ui/panic-runtime/need-abort-got-unwind.rs b/src/test/ui/panic-runtime/need-abort-got-unwind.rs index c72fb96e357f0..e92400931d231 100644 --- a/src/test/ui/panic-runtime/need-abort-got-unwind.rs +++ b/src/test/ui/panic-runtime/need-abort-got-unwind.rs @@ -2,7 +2,6 @@ // needs-unwind // error-pattern:is incompatible with this crate's strategy of `unwind` // aux-build:needs-abort.rs -// ignore-wasm32-bare compiled with panic=abort by default extern crate needs_abort; diff --git a/src/test/ui/panic-runtime/transitive-link-a-bunch.rs b/src/test/ui/panic-runtime/transitive-link-a-bunch.rs index 622535a75aff6..0e74e300f00f0 100644 --- a/src/test/ui/panic-runtime/transitive-link-a-bunch.rs +++ b/src/test/ui/panic-runtime/transitive-link-a-bunch.rs @@ -6,7 +6,6 @@ // aux-build:wants-panic-runtime-abort.rs // aux-build:panic-runtime-lang-items.rs // error-pattern: is not compiled with this crate's panic strategy `unwind` -// ignore-wasm32-bare compiled with panic=abort by default #![no_std] #![no_main] diff --git a/src/test/ui/panic-runtime/want-unwind-got-abort.rs b/src/test/ui/panic-runtime/want-unwind-got-abort.rs index 23bfea6af15c1..b6174dc4efee8 100644 --- a/src/test/ui/panic-runtime/want-unwind-got-abort.rs +++ b/src/test/ui/panic-runtime/want-unwind-got-abort.rs @@ -3,7 +3,6 @@ // error-pattern:is not compiled with this crate's panic strategy `unwind` // aux-build:panic-runtime-abort.rs // aux-build:panic-runtime-lang-items.rs -// ignore-wasm32-bare compiled with panic=abort by default #![no_std] #![no_main] diff --git a/src/test/ui/panic-runtime/want-unwind-got-abort2.rs b/src/test/ui/panic-runtime/want-unwind-got-abort2.rs index 7a2e48e2f10a9..b54babbeffa32 100644 --- a/src/test/ui/panic-runtime/want-unwind-got-abort2.rs +++ b/src/test/ui/panic-runtime/want-unwind-got-abort2.rs @@ -4,7 +4,6 @@ // aux-build:panic-runtime-abort.rs // aux-build:wants-panic-runtime-abort.rs // aux-build:panic-runtime-lang-items.rs -// ignore-wasm32-bare compiled with panic=abort by default #![no_std] #![no_main] diff --git a/src/test/ui/panic-while-printing.rs b/src/test/ui/panic-while-printing.rs index 098f54ac23f6a..3abedf2a764e2 100644 --- a/src/test/ui/panic-while-printing.rs +++ b/src/test/ui/panic-while-printing.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-emscripten no subprocess support #![feature(internal_output_capture)] diff --git a/src/test/ui/privacy/reachable-unnameable-items.rs b/src/test/ui/privacy/reachable-unnameable-items.rs index 1c91541e64229..1babe011996b0 100644 --- a/src/test/ui/privacy/reachable-unnameable-items.rs +++ b/src/test/ui/privacy/reachable-unnameable-items.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-wasm32-bare compiled with panic=abort by default // needs-unwind // aux-build:reachable-unnameable-items.rs diff --git a/src/test/ui/proc-macro/expand-with-a-macro.rs b/src/test/ui/proc-macro/expand-with-a-macro.rs index 21a4547d11e1c..042a283659517 100644 --- a/src/test/ui/proc-macro/expand-with-a-macro.rs +++ b/src/test/ui/proc-macro/expand-with-a-macro.rs @@ -2,7 +2,6 @@ // needs-unwind // aux-build:expand-with-a-macro.rs -// ignore-wasm32-bare compiled with panic=abort by default #![deny(warnings)] diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs index cd57d9bca9429..43888cecedab3 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs @@ -2,7 +2,6 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default #![feature(test)] diff --git a/src/test/ui/rfc-2091-track-caller/std-panic-locations.rs b/src/test/ui/rfc-2091-track-caller/std-panic-locations.rs index b067994a5c6d8..f11456250d874 100644 --- a/src/test/ui/rfc-2091-track-caller/std-panic-locations.rs +++ b/src/test/ui/rfc-2091-track-caller/std-panic-locations.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // revisions: default mir-opt //[mir-opt] compile-flags: -Zmir-opt-level=4 diff --git a/src/test/ui/rfcs/rfc1857-drop-order.rs b/src/test/ui/rfcs/rfc1857-drop-order.rs index 243b7fb6fadec..4c4816c2fbc8d 100644 --- a/src/test/ui/rfcs/rfc1857-drop-order.rs +++ b/src/test/ui/rfcs/rfc1857-drop-order.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default #![allow(dead_code, unreachable_code)] diff --git a/src/test/ui/runtime/rt-explody-panic-payloads.rs b/src/test/ui/runtime/rt-explody-panic-payloads.rs index eb5bf8f67a849..e2221e5df8ea1 100644 --- a/src/test/ui/runtime/rt-explody-panic-payloads.rs +++ b/src/test/ui/runtime/rt-explody-panic-payloads.rs @@ -2,9 +2,6 @@ // needs-unwind // ignore-emscripten no processes // ignore-sgx no processes -// ignore-wasm32-bare no unwinding panic -// ignore-avr no unwinding panic -// ignore-nvptx64 no unwinding panic use std::env; use std::process::Command; diff --git a/src/test/ui/test-attrs/test-panic-while-printing.rs b/src/test/ui/test-attrs/test-panic-while-printing.rs index 01e460da5ab57..033c8beb475df 100644 --- a/src/test/ui/test-attrs/test-panic-while-printing.rs +++ b/src/test/ui/test-attrs/test-panic-while-printing.rs @@ -1,7 +1,6 @@ // compile-flags:--test // run-pass // needs-unwind -// ignore-emscripten no subprocess support use std::fmt; use std::fmt::{Display, Formatter}; diff --git a/src/test/ui/test-attrs/test-should-fail-good-message.rs b/src/test/ui/test-attrs/test-should-fail-good-message.rs index 3260b6938f07d..83519c4524a62 100644 --- a/src/test/ui/test-attrs/test-should-fail-good-message.rs +++ b/src/test/ui/test-attrs/test-should-fail-good-message.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: --test #[test] #[should_panic(expected = "foo")] diff --git a/src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs b/src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs index dadf4b1218784..9a324f00435c7 100644 --- a/src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs +++ b/src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs @@ -1,6 +1,5 @@ // build-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default #![feature(c_unwind)] #![warn(ffi_unwind_calls)] diff --git a/src/test/ui/unwind-no-uwtable.rs b/src/test/ui/unwind-no-uwtable.rs index 0440cf488e8bb..3bc309233a7ac 100644 --- a/src/test/ui/unwind-no-uwtable.rs +++ b/src/test/ui/unwind-no-uwtable.rs @@ -1,7 +1,6 @@ // run-pass // needs-unwind // ignore-windows target requires uwtable -// ignore-wasm32-bare no proper panic=unwind support // compile-flags: -C panic=unwind -C force-unwind-tables=n use std::panic::{self, AssertUnwindSafe}; From 676f62fd8639f5756be838b8dedd397e077f649c Mon Sep 17 00:00:00 2001 From: Florian Bartels Date: Thu, 22 Sep 2022 15:18:17 +0200 Subject: [PATCH 15/15] Adapt test results --- .../migrations/mir_calls_to_shims.fixed | 1 - .../migrations/mir_calls_to_shims.stderr | 2 +- src/test/ui/panic-handler/weak-lang-item.stderr | 2 +- src/test/ui/unwind-abis/ffi-unwind-calls-lint.stderr | 6 +++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed index 89f3931418dac..ff2244a8e31b9 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed @@ -3,7 +3,6 @@ #![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here -// ignore-wasm32-bare compiled with panic=abort by default #![feature(fn_traits)] #![feature(never_type)] diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr index 2648b00435b31..62cfcbe95bc2c 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr @@ -1,5 +1,5 @@ error: changes to closure capture in Rust 2021 will affect which traits the closure implements - --> $DIR/mir_calls_to_shims.rs:21:38 + --> $DIR/mir_calls_to_shims.rs:20:38 | LL | let result = panic::catch_unwind(move || { | ^^^^^^^ diff --git a/src/test/ui/panic-handler/weak-lang-item.stderr b/src/test/ui/panic-handler/weak-lang-item.stderr index 202f3309d035e..3bce1e26fe276 100644 --- a/src/test/ui/panic-handler/weak-lang-item.stderr +++ b/src/test/ui/panic-handler/weak-lang-item.stderr @@ -1,5 +1,5 @@ error[E0259]: the name `core` is defined multiple times - --> $DIR/weak-lang-item.rs:9:1 + --> $DIR/weak-lang-item.rs:8:1 | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ `core` reimported here diff --git a/src/test/ui/unwind-abis/ffi-unwind-calls-lint.stderr b/src/test/ui/unwind-abis/ffi-unwind-calls-lint.stderr index ed41cb74623cb..937a2b3dff8b6 100644 --- a/src/test/ui/unwind-abis/ffi-unwind-calls-lint.stderr +++ b/src/test/ui/unwind-abis/ffi-unwind-calls-lint.stderr @@ -1,17 +1,17 @@ warning: call to foreign function with FFI-unwind ABI - --> $DIR/ffi-unwind-calls-lint.rs:21:14 + --> $DIR/ffi-unwind-calls-lint.rs:20:14 | LL | unsafe { foo(); } | ^^^^^ call to foreign function with FFI-unwind ABI | note: the lint level is defined here - --> $DIR/ffi-unwind-calls-lint.rs:6:9 + --> $DIR/ffi-unwind-calls-lint.rs:5:9 | LL | #![warn(ffi_unwind_calls)] | ^^^^^^^^^^^^^^^^ warning: call to function pointer with FFI-unwind ABI - --> $DIR/ffi-unwind-calls-lint.rs:25:5 + --> $DIR/ffi-unwind-calls-lint.rs:24:5 | LL | ptr(); | ^^^^^ call to function pointer with FFI-unwind ABI