Rollup merge of #158075 - oli-obk:confusing-stability, r=mejrs Point to the unstable segment of an import path instead of to the whole path Brought to you by me being confused why a stable item reported an instability error.
diff --git a/.github/renovate.json5 b/.github/renovate.json5 index d6c7455..6d45e9a 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5
@@ -1,14 +1,25 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ + "config:recommended", + // Open a PR to migrate the config when Renovate deprecates syntax + ":configMigration", + // Refresh lock files on the first day of each month + // (still gated by dashboard approval for now) + ":maintainLockFilesMonthly", // Pin GitHub Actions to their commit SHA digests, resolving floating tags // (e.g. `v4`) to the full SemVer version (e.g. `v4.1.2`) "helpers:pinGitHubActionDigestsToSemver" ], - // Let Renovatebot keep an opened issue that tracks our dependencies - "dependencyDashboard": true, // Require manual approval from the Dependency Dashboard before opening PRs "dependencyDashboardApproval": true, + "packageRules": [ + { + // No dashboard approval necessary for GitHub Actions updates + "matchManagers": ["github-actions"], + "dependencyDashboardApproval": false + } + ], // Don't manage dependencies inside subtrees. They are updated upstream and // synced in. See `src/doc/rustc-dev-guide/src/external-repos.md` for the list. "ignorePaths": [
diff --git a/Cargo.lock b/Cargo.lock index 6b17c0d..b678484 100644 --- a/Cargo.lock +++ b/Cargo.lock
@@ -785,6 +785,15 @@ ] [[package]] +name = "cobs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" +dependencies = [ + "thiserror 2.0.17", +] + +[[package]] name = "codespan-reporting" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1331,6 +1340,18 @@ ] [[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + +[[package]] name = "ena" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3056,6 +3077,18 @@ ] [[package]] +name = "postcard" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" +dependencies = [ + "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", + "serde", +] + +[[package]] name = "potential_utf" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4978,7 +5011,7 @@ name = "rustdoc-json-types" version = "0.1.0" dependencies = [ - "bincode", + "postcard", "rkyv", "rustc-hash 2.1.1", "serde", @@ -5554,9 +5587,9 @@ [[package]] name = "thin-vec" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da322882471314edc77fa5232c587bcb87c9df52bfd0d7d4826f8868ead61899" +checksum = "b0f7e269b48f0a7dd0146680fa24b50cc67fc0373f086a5b2f99bd084639b482" [[package]] name = "thiserror"
diff --git a/compiler/rustc_ast/Cargo.toml b/compiler/rustc_ast/Cargo.toml index 9725696..a09c36e 100644 --- a/compiler/rustc_ast/Cargo.toml +++ b/compiler/rustc_ast/Cargo.toml
@@ -15,6 +15,6 @@ rustc_serialize = { path = "../rustc_serialize" } rustc_span = { path = "../rustc_span" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" # tidy-alphabetical-end
diff --git a/compiler/rustc_ast_lowering/Cargo.toml b/compiler/rustc_ast_lowering/Cargo.toml index f9c08de..0fefc0d 100644 --- a/compiler/rustc_ast_lowering/Cargo.toml +++ b/compiler/rustc_ast_lowering/Cargo.toml
@@ -22,6 +22,6 @@ rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" # tidy-alphabetical-end
diff --git a/compiler/rustc_ast_passes/Cargo.toml b/compiler/rustc_ast_passes/Cargo.toml index 42cbd7b..da9b463 100644 --- a/compiler/rustc_ast_passes/Cargo.toml +++ b/compiler/rustc_ast_passes/Cargo.toml
@@ -18,5 +18,5 @@ rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } -thin-vec = "0.2.15" +thin-vec = "0.2.18" # tidy-alphabetical-end
diff --git a/compiler/rustc_ast_pretty/Cargo.toml b/compiler/rustc_ast_pretty/Cargo.toml index 957fc12..70da6ba 100644 --- a/compiler/rustc_ast_pretty/Cargo.toml +++ b/compiler/rustc_ast_pretty/Cargo.toml
@@ -13,5 +13,5 @@ [dev-dependencies] # tidy-alphabetical-start -thin-vec = "0.2.15" +thin-vec = "0.2.18" # tidy-alphabetical-end
diff --git a/compiler/rustc_attr_parsing/Cargo.toml b/compiler/rustc_attr_parsing/Cargo.toml index fccc36a..2e8c912 100644 --- a/compiler/rustc_attr_parsing/Cargo.toml +++ b/compiler/rustc_attr_parsing/Cargo.toml
@@ -20,5 +20,5 @@ rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } -thin-vec = "0.2.15" +thin-vec = "0.2.18" # tidy-alphabetical-end
diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs index 0bed40c..435367e7 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs
@@ -460,6 +460,7 @@ fn parse_arg( (Mode::DiagnosticOnTypeError, sym::Found) => FormatArg::Found, (Mode::DiagnosticOnTypeError, sym::Expected) => FormatArg::Expected, + (Mode::DiagnosticOnUnknown, sym::Unresolved) => FormatArg::Unresolved, // Some diagnostic attributes can use `{This}` to refer to the annotated item. // For those that don't, we continue and maybe use it as a generic parameter.
diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs index 0cc8d3e..f1e4b84 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs
@@ -5,7 +5,7 @@ use crate::ShouldEmit; use crate::attributes::diagnostic::*; use crate::attributes::prelude::*; -use crate::diagnostics::DiagnosticOnUnknownOnlyForImports; +use crate::diagnostics::DiagnosticOnUnknownInvalidTarget; #[derive(Default)] pub(crate) struct OnUnknownParser { @@ -29,11 +29,11 @@ fn parse<'sess>(&mut self, cx: &mut AcceptContext<'_, 'sess>, args: &ArgParser, // Therefore, only do target checking if we can emit. let early = matches!(cx.should_emit, ShouldEmit::Nothing); - if !early && !matches!(cx.target, Target::Use) { + if !early && !matches!(cx.target, Target::Use | Target::Mod | Target::Crate) { let target_span = cx.target_span; cx.emit_lint( MISPLACED_DIAGNOSTIC_ATTRIBUTES, - DiagnosticOnUnknownOnlyForImports { target_span }, + DiagnosticOnUnknownInvalidTarget { target_span }, span, ); return;
diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs index a80a46e..acd5b46 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs
@@ -45,6 +45,35 @@ fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<Attribute } } +pub(crate) struct RustcDumpGenericsParser; + +impl NoArgsAttributeParser for RustcDumpGenericsParser { + const PATH: &[Symbol] = &[sym::rustc_dump_generics]; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::Struct), + Allow(Target::Enum), + Allow(Target::Union), + Allow(Target::Trait), + Allow(Target::TraitAlias), + Allow(Target::Fn), + Allow(Target::Closure), + Allow(Target::TyAlias), + Allow(Target::Const), + Allow(Target::AssocConst), + Allow(Target::AssocTy), + Allow(Target::Impl { of_trait: false }), + Allow(Target::Impl { of_trait: true }), + Allow(Target::Method(MethodKind::Inherent)), + Allow(Target::Method(MethodKind::Trait { body: false })), + Allow(Target::Method(MethodKind::Trait { body: true })), + Allow(Target::Method(MethodKind::TraitImpl)), + Allow(Target::Delegation { mac: false }), + Allow(Target::Delegation { mac: true }), + ]); + const STABILITY: AttributeStability = unstable!(rustc_attrs); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpGenerics; +} + pub(crate) struct RustcDumpHiddenTypeOfOpaquesParser; impl NoArgsAttributeParser for RustcDumpHiddenTypeOfOpaquesParser {
diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 2811bc8..14e443c 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs
@@ -283,6 +283,7 @@ macro_rules! attribute_parsers { Single<WithoutArgs<RustcDenyExplicitImplParser>>, Single<WithoutArgs<RustcDoNotConstCheckParser>>, Single<WithoutArgs<RustcDumpDefParentsParser>>, + Single<WithoutArgs<RustcDumpGenericsParser>>, Single<WithoutArgs<RustcDumpHiddenTypeOfOpaquesParser>>, Single<WithoutArgs<RustcDumpInferredOutlivesParser>>, Single<WithoutArgs<RustcDumpItemBoundsParser>>,
diff --git a/compiler/rustc_attr_parsing/src/diagnostics.rs b/compiler/rustc_attr_parsing/src/diagnostics.rs index 98b72f2..8ffd228 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs
@@ -295,9 +295,11 @@ pub(crate) struct DiagnosticOnConstOnlyForTraitImpls { pub(crate) struct DiagnosticOnUnimplementedOnlyForTraits; #[derive(Diagnostic)] -#[diag("`#[diagnostic::on_unknown]` can only be applied to `use` statements")] -pub(crate) struct DiagnosticOnUnknownOnlyForImports { - #[label("not an import")] +#[diag( + "`#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations" +)] +pub(crate) struct DiagnosticOnUnknownInvalidTarget { + #[label("not an import or module")] pub target_span: Span, }
diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index 27ee3f6..e96dc44 100644 --- a/compiler/rustc_borrowck/src/region_infer/values.rs +++ b/compiler/rustc_borrowck/src/region_infer/values.rs
@@ -9,7 +9,7 @@ use rustc_middle::mir::{BasicBlock, Location}; use rustc_middle::ty::{self, RegionVid}; use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex}; -use tracing::debug; +use tracing::{debug, instrument}; use crate::BorrowIndex; use crate::polonius::LiveLoans; @@ -116,37 +116,43 @@ pub(crate) fn live_regions_unordered(&self) -> impl Iterator<Item = RegionVid> { /// Records `region` as being live at the given `location`. pub(crate) fn add_location(&mut self, region: RegionVid, location: Location) { let point = self.location_map.point_from_location(location); + // This is a debug assert despite being cheap because it drops + // the current `point_in_range()` uses to 0 when debugging is off. + debug_assert!( + self.location_map.point_in_range(point), + "Tried inserting region {region:?} whose location {location:?} does not belong to this body!" + ); debug!("LivenessValues::add_location(region={:?}, location={:?})", region, location); match &mut self.live_regions { LiveRegions::AtPoints(points) => { points.insert(region, point); } - LiveRegions::InBody(live_regions) if self.location_map.point_in_range(point) => { + LiveRegions::InBody(live_regions) => { live_regions.insert(region); } - - LiveRegions::InBody(_) => (), }; } /// Records `region` as being live at all the given `points`. pub(crate) fn add_points(&mut self, region: RegionVid, points: &IntervalSet<PointIndex>) { + debug_assert!( + points.iter().all(|point| self.location_map.point_in_range(point)), + "Tried inserting region {region:?} with some points not belonging to this body!" + ); debug!("LivenessValues::add_points(region={:?}, points={:?})", region, points); match &mut self.live_regions { LiveRegions::AtPoints(these_points) => { these_points.union_row(region, points); } - LiveRegions::InBody(live_regions) - if points.iter().any(|point| self.location_map.point_in_range(point)) => - { + LiveRegions::InBody(live_regions) => { live_regions.insert(region); } - LiveRegions::InBody(_) => (), }; } /// Records `region` as being live at all the control-flow points. + #[instrument(skip(self))] pub(crate) fn add_all_points(&mut self, region: RegionVid) { match &mut self.live_regions { LiveRegions::AtPoints(points) => points.insert_all_into_row(region), @@ -172,10 +178,7 @@ pub(crate) fn is_live_at_point(&self, region: RegionVid, point: PointIndex) -> b /// Returns an iterator of all the points where `region` is live. fn live_points(&self, region: RegionVid) -> impl Iterator<Item = PointIndex> { - self.point_liveness(region) - .into_iter() - .flat_map(|set| set.iter()) - .take_while(|&p| self.location_map.point_in_range(p)) + self.point_liveness(region).into_iter().flat_map(|set| set.iter()) } /// For debugging purposes, returns a pretty-printed string of the points where the `region` is @@ -343,11 +346,10 @@ pub(crate) fn contains_points(&self, sup_region: N, sub_region: N) -> bool { /// Returns the locations contained within a given region `r`. pub(crate) fn locations_outlived_by(&self, r: N) -> impl Iterator<Item = Location> { - self.points.row(r).into_iter().flat_map(move |set| { - set.iter() - .take_while(move |&p| self.location_map.point_in_range(p)) - .map(move |p| self.location_map.to_location(p)) - }) + self.points + .row(r) + .into_iter() + .flat_map(move |set| set.iter().map(move |p| self.location_map.to_location(p))) } /// Returns just the universal regions that are contained in a given region's value. @@ -413,11 +415,7 @@ pub(crate) fn pretty_print_points( points: impl IntoIterator<Item = PointIndex>, ) -> String { pretty_print_region_elements( - points - .into_iter() - .take_while(|&p| location_map.point_in_range(p)) - .map(|p| location_map.to_location(p)) - .map(RegionElement::Location), + points.into_iter().map(|p| location_map.to_location(p)).map(RegionElement::Location), ) }
diff --git a/compiler/rustc_builtin_macros/Cargo.toml b/compiler/rustc_builtin_macros/Cargo.toml index ebf25d6..f5dbc4a 100644 --- a/compiler/rustc_builtin_macros/Cargo.toml +++ b/compiler/rustc_builtin_macros/Cargo.toml
@@ -29,7 +29,7 @@ rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" # tidy-alphabetical-end
diff --git a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs index c411954..2a55cbe 100644 --- a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs +++ b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs
@@ -10,7 +10,7 @@ use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; use rustc_middle::ty::{Instance, Ty}; use rustc_middle::{bug, mir, ty}; -use rustc_session::config::DebugInfo; +use rustc_session::config::{DebugInfo, OptLevel}; use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, hygiene, sym}; use super::operand::{OperandRef, OperandValue}; @@ -456,6 +456,18 @@ pub(crate) fn debug_introduce_local(&self, bx: &mut Bx, local: mir::Local) { LocalRef::UnsizedPlace(_) => return, }; + // FIXME(arm-maintainers): LLVM uses GlobalISel with -O0 that doesn't support scalable + // vectors. It normally falls back to SDAG which does support scalable vectors, but there's + // a bug that means that isn't happening for debuginfo - so temporarily don't emit debuginfo + // for scalable vector locals when there are no optimisations until that bug is + // fixed. See <https://github.com/llvm/llvm-project/issues/204585>. + if base.layout.peel_transparent_wrappers(bx).ty.is_scalable_vector() + && bx.tcx().backend_optimization_level(()) == OptLevel::No + && bx.sess().opts.debuginfo != DebugInfo::None + { + return; + } + let vars = vars.iter().cloned().chain(fallback_var); for var in vars {
diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml index c428810..6db3a62 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml
@@ -30,7 +30,7 @@ ] } stacker = "0.1.17" tempfile = "3.2" -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" # tidy-alphabetical-end
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index e9bb670..08b0199 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs
@@ -366,7 +366,7 @@ struct DiagCtxtInner { /// stored along side the main panic backtrace. ice_file: Option<PathBuf>, - /// Controlled by `-Z lint-rust-version`; this allows avoiding emitting lints which would raise MSRV. + /// Controlled by `-Z hint-msrv`; this allows avoiding emitting lints which would raise MSRV. msrv: Option<RustcVersion>, }
diff --git a/compiler/rustc_expand/Cargo.toml b/compiler/rustc_expand/Cargo.toml index 0154d05..068c84d 100644 --- a/compiler/rustc_expand/Cargo.toml +++ b/compiler/rustc_expand/Cargo.toml
@@ -30,6 +30,6 @@ rustc_span = { path = "../rustc_span" } scoped-tls = "1.0" smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" # tidy-alphabetical-end
diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 2e13b77..e081c29 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs
@@ -390,6 +390,7 @@ pub enum AttributeStability { sym::rustc_strict_coherence, sym::rustc_dump_variances, sym::rustc_dump_variances_of_opaques, + sym::rustc_dump_generics, sym::rustc_dump_hidden_type_of_opaques, sym::rustc_dump_layout, sym::rustc_abi,
diff --git a/compiler/rustc_hir/Cargo.toml b/compiler/rustc_hir/Cargo.toml index c9e54c9..5765163 100644 --- a/compiler/rustc_hir/Cargo.toml +++ b/compiler/rustc_hir/Cargo.toml
@@ -23,6 +23,6 @@ rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" # tidy-alphabetical-end
diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index e419c63..7c125c3 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs
@@ -1387,6 +1387,9 @@ pub enum AttributeKind { /// Represents `#[rustc_dump_def_path]` RustcDumpDefPath(Span), + /// Represents `#[rustc_dump_generics]` + RustcDumpGenerics, + /// Represents `#[rustc_dump_hidden_type_of_opaques]` RustcDumpHiddenTypeOfOpaques,
diff --git a/compiler/rustc_hir/src/attrs/diagnostic.rs b/compiler/rustc_hir/src/attrs/diagnostic.rs index 3426fd5..d29b5f8 100644 --- a/compiler/rustc_hir/src/attrs/diagnostic.rs +++ b/compiler/rustc_hir/src/attrs/diagnostic.rs
@@ -92,7 +92,7 @@ pub struct CustomDiagnostic { } impl CustomDiagnostic { - fn update(&mut self, di: &Directive, args: &FormatArgs) { + pub fn update(&mut self, di: &Directive, args: &FormatArgs) { if self.message.is_none() { self.message = di.message.as_ref().map(|m| m.1.format(args)); } @@ -153,6 +153,9 @@ fn format(&self, args: &FormatArgs) -> String { Piece::Arg(FormatArg::Found) => ret.push_str(&args.found), Piece::Arg(FormatArg::Expected) => ret.push_str(&args.expected), + // only for on_unknown + Piece::Arg(FormatArg::Unresolved) => ret.push_str(&args.unresolved), + // It's only `rustc_onunimplemented` from here Piece::Arg(FormatArg::ThisPath) => ret.push_str(&args.this_path), Piece::Arg(FormatArg::ThisResolved) => { @@ -215,6 +218,7 @@ pub struct FormatArgs { pub this_path: String = String::new(), pub found: String = String::new(), pub expected: String = String::new(), + pub unresolved: String = String::new(), pub item_context: &'static str = "", pub generic_args: Vec<(Symbol, String)> = Vec::new(), } @@ -248,6 +252,8 @@ pub enum FormatArg { Found, /// {Expected} in diagnostic::on_type_error Expected, + /// {Unresolved} in diagnostic::on_unknown + Unresolved, } /// Represents the `on` filter in `#[rustc_on_unimplemented]`.
diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index fb6d7e4..f5a6eee 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs
@@ -129,6 +129,7 @@ pub fn encode_cross_crate(&self) -> EncodeCrossCrate { RustcDummy => No, RustcDumpDefParents => No, RustcDumpDefPath(..) => No, + RustcDumpGenerics => No, RustcDumpHiddenTypeOfOpaques => No, RustcDumpInferredOutlives => No, RustcDumpItemBounds => No,
diff --git a/compiler/rustc_hir_analysis/src/collect/dump.rs b/compiler/rustc_hir_analysis/src/collect/dump.rs index 8776953..09ec108 100644 --- a/compiler/rustc_hir_analysis/src/collect/dump.rs +++ b/compiler/rustc_hir_analysis/src/collect/dump.rs
@@ -6,6 +6,25 @@ use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt, Unnormalized}; use rustc_span::sym; +pub(crate) fn generics(tcx: TyCtxt<'_>) { + for did in tcx.hir_crate_items(()).definitions() { + if did == hir::def_id::CRATE_DEF_ID { + continue; + } + + if find_attr!(tcx, did, RustcDumpGenerics) { + let span = tcx.def_span(did); + + let mut diag = + tcx.dcx().struct_span_err(span, format!("{}: {did:?}", sym::rustc_dump_generics)); + + let generics = tcx.generics_of(did); + diag.span_note(tcx.def_span(did), format!("{generics:#?}")); + diag.emit(); + } + } +} + pub(crate) fn opaque_hidden_types(tcx: TyCtxt<'_>) { if !find_attr!(tcx, crate, RustcDumpHiddenTypeOfOpaques) { return; @@ -101,10 +120,9 @@ fn visit_anon_const(&mut self, c: &'tcx rustc_hir::AnonConst) { for did in [did].into_iter().chain(anon_ct_finder.anon_consts) { let span = tcx.def_span(did); - let mut diag = tcx.dcx().struct_span_err( - span, - format!("{}: {did:?}", sym::rustc_dump_def_parents.as_str()), - ); + let mut diag = tcx + .dcx() + .struct_span_err(span, format!("{}: {did:?}", sym::rustc_dump_def_parents)); let mut current_did = did.to_def_id(); while let Some(parent_did) = tcx.opt_parent(current_did) {
diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 14961ab..c5a6ce7 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs
@@ -202,6 +202,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) { tcx.sess.time("dumping_rustc_attr_data", || { outlives::dump::inferred_outlives(tcx); variance::dump::variances(tcx); + collect::dump::generics(tcx); collect::dump::opaque_hidden_types(tcx); collect::dump::predicates_and_item_bounds(tcx); collect::dump::def_parents(tcx);
diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index a924a81..7b39b95 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs
@@ -727,7 +727,8 @@ fn walk_adjustment(&self, expr: &hir::Expr<'_>) -> Result<(), Cx::Error> { let typeck_results = self.cx.typeck_results(); let adjustments = typeck_results.expr_adjustments(expr); let mut place_with_id = self.cat_expr_unadjusted(expr)?; - for adjustment in adjustments { + for (adjustment_index, adjustment) in adjustments.iter().enumerate() { + let is_last_adjustment = adjustment_index + 1 == adjustments.len(); debug!("walk_adjustment expr={:?} adj={:?}", expr, adjustment); match adjustment.kind { adjustment::Adjust::NeverToAny | adjustment::Adjust::Pointer(_) => { @@ -752,13 +753,13 @@ fn walk_adjustment(&self, expr: &hir::Expr<'_>) -> Result<(), Cx::Error> { self.walk_autoref(expr, &place_with_id, autoref); } - adjustment::Adjust::GenericReborrow(_reborrow) => { - // To build an expression as a place expression, it needs to be a field - // projection or deref at the outmost layer. So it is field projection or deref - // on an adjusted value. But this means that adjustment is applied on a - // subexpression that is not the final operand/rvalue for function call or - // assignment. This is a contradiction. - unreachable!("Reborrow trait usage during adjustment walk"); + adjustment::Adjust::GenericReborrow(mutability) if is_last_adjustment => { + let bk = ty::BorrowKind::from_mutbl(mutability); + self.delegate.borrow_mut().borrow(&place_with_id, place_with_id.hir_id, bk); + } + + adjustment::Adjust::GenericReborrow(_) => { + span_bug!(expr.span, "generic reborrow adjustment must be terminal"); } } place_with_id = self.cat_expr_adjusted(expr, place_with_id, adjustment)?;
diff --git a/compiler/rustc_infer/Cargo.toml b/compiler/rustc_infer/Cargo.toml index 1896ce1..33f7e2f 100644 --- a/compiler/rustc_infer/Cargo.toml +++ b/compiler/rustc_infer/Cargo.toml
@@ -17,6 +17,6 @@ rustc_span = { path = "../rustc_span" } rustc_type_ir = { path = "../rustc_type_ir" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" # tidy-alphabetical-end
diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 0d93e14..df2412f 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs
@@ -251,6 +251,10 @@ pub struct InferCtxt<'tcx> { /// Whether this inference context should care about region obligations in /// the root universe. Most notably, this is used during HIR typeck as region /// solving is left to borrowck instead. + /// + /// This is used in the old solver to enable the generation of regions constraints. + /// In the new solver its only used inside the InferCtxt's `Drop` implementation: + /// if we're considering regions, and new opaques are registered, we panic. pub considering_regions: bool, /// `-Znext-solver`: Whether this inference context is used by HIR typeck. If so, we /// need to make sure we don't rely on region identity in the trait solver or when
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index b230fe3..ce99b01 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs
@@ -89,7 +89,7 @@ fn pre_expansion_lint<'a>( features: &Features, lint_store: &LintStore, registered_tools: &RegisteredTools, - check_node: impl EarlyCheckNode<'a>, + check_node: EarlyCheckNode<'a>, node_name: Symbol, ) { sess.prof.generic_activity_with_arg("pre_AST_expansion_lint_checks", node_name.as_str()).run( @@ -122,7 +122,8 @@ fn pre_expansion_lint( items: &[Box<ast::Item>], name: Symbol, ) { - pre_expansion_lint(sess, features, self.0, registered_tools, (node_id, attrs, items), name); + let check_node = EarlyCheckNode::LoadedMod(node_id, attrs, items); + pre_expansion_lint(sess, features, self.0, registered_tools, check_node, name); } } @@ -141,13 +142,12 @@ fn configure_and_expand( let features = tcx.features(); let lint_store = unerased_lint_store(sess); let crate_name = tcx.crate_name(LOCAL_CRATE); - let lint_check_node = (&krate, pre_configured_attrs); pre_expansion_lint( sess, features, lint_store, tcx.registered_tools(()), - lint_check_node, + EarlyCheckNode::CrateRoot(&krate, pre_configured_attrs), crate_name, ); rustc_builtin_macros::register_builtin_macros(resolver); @@ -480,7 +480,7 @@ const fn as_str(self) -> &'static str { tcx.registered_tools(()), Some(lint_buffer), rustc_lint::BuiltinCombinedEarlyLintPass::new(), - (&*krate, &*krate.attrs), + EarlyCheckNode::CrateRoot(&*krate, &*krate.attrs), ) }
diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index df6683c..9cc4f34 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs
@@ -27,7 +27,7 @@ macro_rules! lint_callback { ($cx:expr, $f:ident, $($args:expr),*) => ({ /// Implements the AST traversal for early lint passes. `T` provides the /// `check_*` methods. -pub struct EarlyContextAndPass<'ecx, T: EarlyLintPass> { +struct EarlyContextAndPass<'ecx, T: EarlyLintPass> { context: EarlyContext<'ecx>, pass: T, } @@ -276,36 +276,36 @@ impl EarlyLintPass for RuntimeCombinedEarlyLintPass<'_> { /// Early lints work on different nodes - either on the crate root, or on freshly loaded modules. /// This trait generalizes over those nodes. -pub trait EarlyCheckNode<'a>: Copy { - fn id(self) -> ast::NodeId; - fn attrs(self) -> &'a [ast::Attribute]; - fn check<'ecx, T: EarlyLintPass>(self, cx: &mut EarlyContextAndPass<'ecx, T>); +pub enum EarlyCheckNode<'a> { + CrateRoot(&'a ast::Crate, &'a [ast::Attribute]), + LoadedMod(ast::NodeId, &'a [ast::Attribute], &'a [Box<ast::Item>]), } -impl<'a> EarlyCheckNode<'a> for (&'a ast::Crate, &'a [ast::Attribute]) { - fn id(self) -> ast::NodeId { - ast::CRATE_NODE_ID +impl<'a> EarlyCheckNode<'a> { + fn id(&self) -> ast::NodeId { + match self { + EarlyCheckNode::CrateRoot(_crate, _attrs) => ast::CRATE_NODE_ID, + EarlyCheckNode::LoadedMod(id, _attrs, _items) => *id, + } } - fn attrs(self) -> &'a [ast::Attribute] { - self.1 + fn attrs(&self) -> &'a [ast::Attribute] { + match self { + EarlyCheckNode::CrateRoot(_crate, attrs) => attrs, + EarlyCheckNode::LoadedMod(_id, attrs, _items) => attrs, + } } - fn check<'ecx, T: EarlyLintPass>(self, cx: &mut EarlyContextAndPass<'ecx, T>) { - lint_callback!(cx, check_crate, self.0); - ast_visit::walk_crate(cx, self.0); - lint_callback!(cx, check_crate_post, self.0); - } -} - -impl<'a> EarlyCheckNode<'a> for (ast::NodeId, &'a [ast::Attribute], &'a [Box<ast::Item>]) { - fn id(self) -> ast::NodeId { - self.0 - } - fn attrs(self) -> &'a [ast::Attribute] { - self.1 - } - fn check<'ecx, T: EarlyLintPass>(self, cx: &mut EarlyContextAndPass<'ecx, T>) { - walk_list!(cx, visit_attribute, self.1); - walk_list!(cx, visit_item, self.2); + fn check<'ecx, T: EarlyLintPass>(&self, cx: &mut EarlyContextAndPass<'ecx, T>) { + match self { + EarlyCheckNode::CrateRoot(crate_, _attrs) => { + lint_callback!(cx, check_crate, crate_); + ast_visit::walk_crate(cx, crate_); + lint_callback!(cx, check_crate_post, crate_); + } + EarlyCheckNode::LoadedMod(_id, attrs, items) => { + walk_list!(cx, visit_attribute, *attrs); + walk_list!(cx, visit_item, *items); + } + } } } @@ -317,7 +317,7 @@ pub fn check_ast_node<'a>( registered_tools: &RegisteredTools, lint_buffer: Option<LintBuffer>, builtin_lints: impl EarlyLintPass + 'static, - check_node: impl EarlyCheckNode<'a>, + check_node: EarlyCheckNode<'a>, ) { let context = EarlyContext::new( sess, @@ -345,7 +345,7 @@ pub fn check_ast_node<'a>( fn check_ast_node_inner<'a, T: EarlyLintPass>( sess: &Session, - check_node: impl EarlyCheckNode<'a>, + check_node: EarlyCheckNode<'a>, context: EarlyContext<'_>, pass: T, ) {
diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 6d69421..ab09c64 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs
@@ -189,6 +189,18 @@ fn lint_mod(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) { ] ); +early_lint_methods!( + declare_combined_early_lint_pass, + [ + InternalCombinedEarlyLintPass, + [ + LintPassImpl: LintPassImpl, + ImplicitSysrootCrateImport: ImplicitSysrootCrateImport, + BadUseOfFindAttr: BadUseOfFindAttr, + ] + ] +); + late_lint_methods!( declare_combined_late_lint_pass, [ @@ -260,6 +272,24 @@ fn lint_mod(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) { ] ); +late_lint_methods!( + declare_combined_late_lint_pass, + [ + InternalCombinedModuleLateLintPass, + [ + DefaultHashTypes: DefaultHashTypes, + QueryStability: QueryStability, + TyTyKind: TyTyKind, + TypeIr: TypeIr, + BadOptAccess: BadOptAccess, + DisallowedPassByRef: DisallowedPassByRef, + SpanUseEqCtxt: SpanUseEqCtxt, + SymbolInternStringLiteral: SymbolInternStringLiteral, + RustcMustMatchExhaustively: RustcMustMatchExhaustively, + ] + ] +); + pub fn new_lint_store(internal_lints: bool) -> LintStore { let mut lint_store = LintStore::new(); @@ -663,30 +693,12 @@ macro_rules! add_lint_group { } fn register_internals(store: &mut LintStore) { - store.register_lints(&LintPassImpl::lint_vec()); - store.register_early_pass(|| Box::new(LintPassImpl)); - store.register_lints(&ImplicitSysrootCrateImport::lint_vec()); - store.register_early_pass(|| Box::new(ImplicitSysrootCrateImport)); - store.register_lints(&BadUseOfFindAttr::lint_vec()); - store.register_early_pass(|| Box::new(BadUseOfFindAttr)); - store.register_lints(&DefaultHashTypes::lint_vec()); - store.register_late_mod_pass(|_| Box::new(DefaultHashTypes)); - store.register_lints(&QueryStability::lint_vec()); - store.register_late_mod_pass(|_| Box::new(QueryStability)); - store.register_lints(&TyTyKind::lint_vec()); - store.register_late_mod_pass(|_| Box::new(TyTyKind)); - store.register_lints(&TypeIr::lint_vec()); - store.register_late_mod_pass(|_| Box::new(TypeIr)); - store.register_lints(&BadOptAccess::lint_vec()); - store.register_late_mod_pass(|_| Box::new(BadOptAccess)); - store.register_lints(&DisallowedPassByRef::lint_vec()); - store.register_late_mod_pass(|_| Box::new(DisallowedPassByRef)); - store.register_lints(&SpanUseEqCtxt::lint_vec()); - store.register_late_mod_pass(|_| Box::new(SpanUseEqCtxt)); - store.register_lints(&SymbolInternStringLiteral::lint_vec()); - store.register_late_mod_pass(|_| Box::new(SymbolInternStringLiteral)); - store.register_lints(&RustcMustMatchExhaustively::lint_vec()); - store.register_late_pass(|_| Box::new(RustcMustMatchExhaustively)); + store.register_lints(&InternalCombinedEarlyLintPass::lint_vec()); + store.register_early_pass(|| Box::new(InternalCombinedEarlyLintPass::new())); + + store.register_lints(&InternalCombinedModuleLateLintPass::lint_vec()); + store.register_late_mod_pass(|_| Box::new(InternalCombinedModuleLateLintPass::new())); + store.register_group( false, "rustc::internal",
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 1cc789f..bd3b244 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs
@@ -1274,6 +1274,10 @@ fn get_mod_child(&self, tcx: TyCtxt<'_>, id: DefIndex) -> ModChild { /// including both proper items and reexports. /// Module here is understood in name resolution sense - it can be a `mod` item, /// or a crate root, or an enum, or a trait. + /// + /// # Panics + /// + /// May panic if the provided `id` does not refer to a module. fn get_module_children(&self, tcx: TyCtxt<'_>, id: DefIndex) -> impl Iterator<Item = ModChild> { gen move { if let Some(data) = &self.root.proc_macro_data { @@ -1287,7 +1291,9 @@ fn get_module_children(&self, tcx: TyCtxt<'_>, id: DefIndex) -> impl Iterator<It } else { // Iterate over all children. let non_reexports = self.root.tables.module_children_non_reexports.get(self, id); - for child_index in non_reexports.unwrap().decode((self, tcx)) { + let non_reexports = + non_reexports.expect("provided `DefIndex` must refer to a module-like item"); + for child_index in non_reexports.decode((self, tcx)) { yield self.get_mod_child(tcx, child_index); }
diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index f0e47e0..6ead1c5 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml
@@ -33,7 +33,7 @@ rustc_thread_pool = { path = "../rustc_thread_pool" } rustc_type_ir = { path = "../rustc_type_ir" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" # tidy-alphabetical-end
diff --git a/compiler/rustc_middle/src/queries.rs b/compiler/rustc_middle/src/queries.rs index c01ff3d..d481788 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs
@@ -2161,6 +2161,15 @@ desc { "fetching what a crate is named" } separate_provide_extern } + + /// Iterates over all named children of the given module, + /// including both proper items and reexports. + /// Module here is understood in name resolution sense - it can be a `mod` item, + /// or a crate root, or an enum, or a trait. + /// + /// # Panics + /// + /// May panic if the provided `id` does not refer to a module. query module_children(def_id: DefId) -> &'tcx [ModChild] { desc { "collecting child items of module `{}`", tcx.def_path_str(def_id) } separate_provide_extern
diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs index a96f4e9..24aa4ac 100644 --- a/compiler/rustc_middle/src/thir/visit.rs +++ b/compiler/rustc_middle/src/thir/visit.rs
@@ -187,7 +187,9 @@ pub fn walk_expr<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>( } ThreadLocalRef(_) => {} Yield { value } => visitor.visit_expr(&visitor.thir()[value]), - Reborrow { .. } => {} + Reborrow { source, mutability: _, target: _ } => { + visitor.visit_expr(&visitor.thir()[source]) + } } }
diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index 84e0b37..6eb5e83 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs
@@ -114,7 +114,7 @@ pub struct GenericParamCount { /// /// The ordering of parameters is the same as in [`ty::GenericArg`] (excluding child generics): /// `Self` (optionally), `Lifetime` params..., `Type` params... -#[derive(Clone, Debug, TyEncodable, TyDecodable, StableHash)] +#[derive(Clone, TyEncodable, TyDecodable, StableHash)] pub struct Generics { pub parent: Option<DefId>, pub parent_count: usize, @@ -128,6 +128,23 @@ pub struct Generics { pub has_late_bound_regions: Option<Span>, } +impl std::fmt::Debug for Generics { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + // ironically, we get this warning because of what we're trying to fix. + #[expect(rustc::potential_query_instability)] + let mut stabilized_hashmap = self.param_def_id_to_index.iter().collect::<Vec<_>>(); + stabilized_hashmap.sort_by_key(|(_, v)| **v); + f.debug_struct("Generics") + .field("parent", &self.parent) + .field("parent_count", &self.parent_count) + .field("own_params", &self.own_params) + .field("param_def_id_to_index", &stabilized_hashmap) + .field("has_self", &self.has_self) + .field("has_late_bound_regions", &self.has_late_bound_regions) + .finish() + } +} + impl<'tcx> rustc_type_ir::inherent::GenericsOf<TyCtxt<'tcx>> for &'tcx Generics { fn count(&self) -> usize { self.parent_count + self.own_params.len()
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 3d8ab41..10a5f38 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -118,7 +118,7 @@ use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason}; use crate::metadata::{AmbigModChild, ModChild}; use crate::middle::privacy::EffectiveVisibilities; -use crate::mir::{Body, CoroutineLayout, CoroutineSavedLocal, SourceInfo}; +use crate::mir::{Body, CoroutineLayout, CoroutineSavedLocal, MirPhase, SourceInfo}; use crate::query::{IntoQueryKey, Providers}; use crate::ty; use crate::ty::codec::{TyDecoder, TyEncoder}; @@ -1777,7 +1777,7 @@ pub fn expect_variant_res(self, res: Res) -> &'tcx VariantDef { /// Returns the possibly-auto-generated MIR of a [`ty::InstanceKind`]. #[instrument(skip(self), level = "debug")] pub fn instance_mir(self, instance: ty::InstanceKind<'tcx>) -> &'tcx Body<'tcx> { - match instance { + let body = match instance { ty::InstanceKind::Item(def) => { debug!("calling def_kind on def: {:?}", def); let def_kind = self.def_kind(def); @@ -1816,7 +1816,15 @@ pub fn instance_mir(self, instance: ty::InstanceKind<'tcx>) -> &'tcx Body<'tcx> | ty::InstanceKind::FnPtrAddrShim(..) | ty::InstanceKind::AsyncDropGlueCtorShim(..) | ty::InstanceKind::AsyncDropGlue(..) => self.mir_shims(instance), - } + }; + + assert!( + matches!(body.phase, MirPhase::Runtime(_)), + "body: {body:?} instance: {instance:?} {:?}", + if let ty::InstanceKind::Item(d) = instance { Some(self.def_kind(d)) } else { None }, + ); + + body } /// Gets all attributes with the given name.
diff --git a/compiler/rustc_mir_dataflow/src/points.rs b/compiler/rustc_mir_dataflow/src/points.rs index e3d1e04..8568f32 100644 --- a/compiler/rustc_mir_dataflow/src/points.rs +++ b/compiler/rustc_mir_dataflow/src/points.rs
@@ -31,7 +31,8 @@ pub fn new(body: &Body<'_>) -> Self { for (bb, bb_data) in body.basic_blocks.iter_enumerated() { basic_blocks.extend((0..=bb_data.statements.len()).map(|_| bb)); } - + // Invariant: no block is preceded by more than all statements. + debug_assert!(*statements_before_block.iter().max().unwrap() < num_points); Self { statements_before_block, basic_blocks, num_points } } @@ -42,10 +43,14 @@ pub fn num_points(&self) -> usize { } /// Converts a `Location` into a `PointIndex`. O(1). + /// [[`Self::point_in_range()`]] guaranteed for the returned index. #[inline] pub fn point_from_location(&self, location: Location) -> PointIndex { let Location { block, statement_index } = location; let start_index = self.statements_before_block[block]; + // Note the invariant in [`Self::new()`]; if the indexing + // operation above did not panic then this holds by construction. + debug_assert!(start_index < self.num_points); PointIndex::new(start_index + statement_index) }
diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index 50782c5..6d9b8fe 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs
@@ -1074,7 +1074,12 @@ pub(super) fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> { // so this would otherwise not get filled). body.set_mentioned_items(Vec::new()); - crate::pass_manager::dump_mir_for_phase_change(tcx, &body); + pm::run_passes_no_validate( + tcx, + &mut body, + &[], + Some(MirPhase::Runtime(RuntimePhase::Optimized)), + ); body }
diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs index 97aaf07..6273506 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
@@ -590,6 +590,16 @@ pub(super) fn evaluate_goal_raw( )); } + self.evaluate_goal_cold(source, goal) + } + + #[cold] + #[inline(never)] + pub(super) fn evaluate_goal_cold( + &mut self, + source: GoalSource, + goal: Goal<I, I::Predicate>, + ) -> Result<(NestedNormalizationGoals<I>, GoalEvaluation<I>), NoSolutionOrRerunNonErased> { // We only care about one entry per `OpaqueTypeKey` here, // so we only canonicalize the lookup table and ignore // duplicate entries.
diff --git a/compiler/rustc_parse/Cargo.toml b/compiler/rustc_parse/Cargo.toml index 53727ef..22ec842 100644 --- a/compiler/rustc_parse/Cargo.toml +++ b/compiler/rustc_parse/Cargo.toml
@@ -17,7 +17,7 @@ rustc_macros = { path = "../rustc_macros" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" unicode-normalization = "0.1.25" unicode-width = "0.2.2"
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index d6104c7..16fed9c 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs
@@ -659,7 +659,7 @@ fn parse_item_impl( defaultness: Defaultness, is_reuse: bool, ) -> PResult<'a, ItemKind> { - let mut constness = self.parse_constness(Case::Sensitive); + let constness = self.parse_constness(Case::Sensitive); let safety = self.parse_safety(Case::Sensitive); self.expect_keyword(exp!(Impl))?; @@ -674,11 +674,6 @@ fn parse_item_impl( generics }; - if let Const::No = constness { - // FIXME(const_trait_impl): disallow `impl const Trait` - constness = self.parse_constness(Case::Sensitive); - } - if let Const::Yes(span) = constness { self.psess.gated_spans.gate(sym::const_trait_impl, span); }
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 01c31d6..dd950cc 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs
@@ -345,6 +345,7 @@ fn check_one_parsed_attribute( AttributeKind::RustcDummy => (), AttributeKind::RustcDumpDefParents => (), AttributeKind::RustcDumpDefPath(..) => (), + AttributeKind::RustcDumpGenerics => (), AttributeKind::RustcDumpHiddenTypeOfOpaques => (), AttributeKind::RustcDumpInferredOutlives => (), AttributeKind::RustcDumpItemBounds => (),
diff --git a/compiler/rustc_resolve/Cargo.toml b/compiler/rustc_resolve/Cargo.toml index 2fc251e..cb52c21 100644 --- a/compiler/rustc_resolve/Cargo.toml +++ b/compiler/rustc_resolve/Cargo.toml
@@ -26,6 +26,6 @@ rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" # tidy-alphabetical-end
diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index eb72ebe..911c614 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs
@@ -31,8 +31,8 @@ use crate::Namespace::{MacroNS, TypeNS, ValueNS}; use crate::def_collector::DefCollector; -use crate::error_helper::StructCtor; -use crate::imports::{ImportData, ImportKind, OnUnknownData}; +use crate::error_helper::{OnUnknownData, StructCtor}; +use crate::imports::{ImportData, ImportKind}; use crate::macros::{MacroRulesDecl, MacroRulesScope, MacroRulesScopeRef}; use crate::ref_mut::CmCell; use crate::{ @@ -548,7 +548,7 @@ fn add_import( root_id, vis, vis_span: item.vis.span, - on_unknown_attr: OnUnknownData::from_attrs(self.r.tcx, item), + on_unknown_attr: OnUnknownData::from_attrs(self.r.tcx, &item.attrs), }); self.r.indeterminate_imports.push(import); @@ -863,6 +863,9 @@ fn build_reduced_graph_for_item(&mut self, item: &'a Item, feed: TyCtxtFeed<'tcx || ast::attr::contains_name(&item.attrs, sym::no_implicit_prelude), ); self.parent_scope.module = module.to_module(); + if let Some(directive) = OnUnknownData::from_attrs(self.r.tcx, &item.attrs) { + self.r.on_unknown_data.insert(local_def_id, directive); + } } // These items live in the value namespace. @@ -1037,7 +1040,7 @@ fn build_reduced_graph_for_extern_crate( module_path: Vec::new(), vis, vis_span: item.vis.span, - on_unknown_attr: OnUnknownData::from_attrs(self.r.tcx, item), + on_unknown_attr: OnUnknownData::from_attrs(self.r.tcx, &item.attrs), }); if used { self.r.import_use_map.insert(import, Used::Other); @@ -1169,7 +1172,7 @@ fn process_macro_use_imports(&mut self, item: &Item, module: Module<'ra>) -> boo module_path: Vec::new(), vis: Visibility::Restricted(CRATE_DEF_ID), vis_span: item.vis.span, - on_unknown_attr: OnUnknownData::from_attrs(this.r.tcx, item), + on_unknown_attr: OnUnknownData::from_attrs(this.r.tcx, &item.attrs), }) }; @@ -1350,7 +1353,7 @@ fn define_macro( module_path: Vec::new(), vis, vis_span: item.vis.span, - on_unknown_attr: OnUnknownData::from_attrs(self.r.tcx, item), + on_unknown_attr: OnUnknownData::from_attrs(self.r.tcx, &item.attrs), }); self.r.import_use_map.insert(import, Used::Other); let import_decl = self.r.new_import_decl(decl, import);
diff --git a/compiler/rustc_resolve/src/error_helper.rs b/compiler/rustc_resolve/src/error_helper.rs index 3f62f3b..81c1b6f 100644 --- a/compiler/rustc_resolve/src/error_helper.rs +++ b/compiler/rustc_resolve/src/error_helper.rs
@@ -9,19 +9,21 @@ join_path_idents, }; use rustc_ast_pretty::pprust; +use rustc_attr_parsing::AttributeParser; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_errors::codes::*; use rustc_errors::{ Applicability, Diag, DiagCtxtHandle, Diagnostic, ErrorGuaranteed, MultiSpan, SuggestionStyle, - struct_span_code_err, + pluralize, struct_span_code_err, }; use rustc_feature::BUILTIN_ATTRIBUTES; -use rustc_hir::attrs::{CfgEntry, StrippedCfgItem}; +use rustc_hir::attrs::diagnostic::{CustomDiagnostic, Directive, FormatArgs}; +use rustc_hir::attrs::{AttributeKind, CfgEntry, StrippedCfgItem}; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{CtorKind, CtorOf, DefKind, MacroKinds, NonMacroAttrKind, PerNS}; use rustc_hir::def_id::{CRATE_DEF_ID, DefId}; -use rustc_hir::{PrimTy, Stability, StabilityLevel, find_attr}; +use rustc_hir::{Attribute, PrimTy, Stability, StabilityLevel, find_attr}; use rustc_middle::bug; use rustc_middle::ty::{TyCtxt, Visibility}; use rustc_session::Session; @@ -46,7 +48,7 @@ MaybeMissingMacroRulesName, }; use crate::hygiene::Macros20NormalizedSyntaxContext; -use crate::imports::{Import, ImportKind}; +use crate::imports::{Import, ImportKind, UnresolvedImportError, import_path_to_string}; use crate::late::{DiagMetadata, PatternSource, Rib}; use crate::{ AmbiguityError, AmbiguityKind, AmbiguityWarning, BindingError, BindingKey, Decl, DeclKind, @@ -134,6 +136,200 @@ fn reduce_impl_span_to_impl_keyword(sm: &SourceMap, impl_span: Span) -> Span { } impl<'ra, 'tcx> Resolver<'ra, 'tcx> { + /// Reports unresolved imports. + /// + /// Multiple unresolved import errors within the same use tree are combined into a single + /// diagnostic. + pub(crate) fn throw_unresolved_import_error( + &mut self, + mut errors: Vec<(Import<'_>, UnresolvedImportError)>, + glob_error: bool, + ) { + errors.retain(|(_import, err)| match err.module { + // Skip `use` errors for `use foo::Bar;` if `foo.rs` has unrecovered parse errors. + Some(def_id) if self.mods_with_parse_errors.contains(&def_id) => false, + // If we've encountered something like `use _;`, we've already emitted an error stating + // that `_` is not a valid identifier, so we ignore that resolve error. + _ => err.segment.map(|s| s.name) != Some(kw::Underscore), + }); + if errors.is_empty() { + self.tcx.dcx().delayed_bug("expected a parse or \"`_` can't be an identifier\" error"); + return; + } + + let span = MultiSpan::from_spans(errors.iter().map(|(_, err)| err.span).collect()); + + let paths = errors + .iter() + .map(|(import, err)| { + let path = import_path_to_string( + &import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(), + &import.kind, + err.span, + ); + format!("`{path}`") + }) + .collect::<Vec<_>>(); + let default_message = + format!("unresolved import{} {}", pluralize!(paths.len()), paths.join(", "),); + + // Process `import` use of the `#[diagnostic::on_unknown]` attribute. + // + // We don't need to check feature gates here; that happens on initialization of the + // `on_unknown_attr` fields. + let (mut message, label, mut notes) = + if let Some(directive) = errors[0].1.on_unknown_attr.as_ref().map(|a| &a.directive) { + let this = errors + .iter() + .map(|(_import, err)| { + // Is this unwrap_or reachable? + err.segment.map(|s| s.name).unwrap_or(kw::Underscore) + }) + .join(", "); + + let args = FormatArgs { unresolved: this.clone(), this, .. }; + + let CustomDiagnostic { message, label, notes, parent_label: _dead } = + directive.eval(None, &args); + + (message, label, notes) + } else { + (None, None, Vec::new()) + }; + + // `module` use of the `#[diagnostic::on_unknown]` attribute. + // We assume that someone who put the attribute on the import has more information than + // the person who put it on the module, so we choose to prioritize the import attribute. + let mut mod_diagnostics: Vec<CustomDiagnostic> = errors + .iter() + .map(|(import, import_error)| { + if let Some(ModuleOrUniformRoot::Module(module_data)) = import.imported_module.get() + && let ModuleKind::Def(DefKind::Mod, def_id, _, name) = module_data.kind + { + let Some(directive) = self.on_unknown_data(def_id) else { + return CustomDiagnostic::default(); + }; + + let this = if let Some(name) = name { + name.to_string() + } else if let Some(crate_name) = &self.tcx.sess.opts.crate_name { + crate_name.to_string() + } else { + "<unnamed crate>".to_string() + }; + let unresolved = import_error.segment.map(|s| s.name).unwrap_or(kw::Underscore); + let args = FormatArgs { this, unresolved: unresolved.to_string(), .. }; + + directive.eval(None, &args) + } else { + CustomDiagnostic::default() + } + }) + .collect(); + + // If there is no import attribute with a message, + // but all mod messages are the same, use that. + let mod_message = + mod_diagnostics.iter_mut().flat_map(|d| d.message.take()).all_equal_value(); + if message.is_none() + && let Ok(mod_msg) = mod_message + { + message = Some(mod_msg); + } + + let mut diag = if let Some(message) = message { + struct_span_code_err!(self.dcx(), span, E0432, "{message}").with_note(default_message) + } else { + struct_span_code_err!(self.dcx(), span, E0432, "{default_message}") + }; + + for mod_diag in mod_diagnostics.iter_mut() { + for mod_note in mod_diag.notes.drain(..) { + if !notes.contains(&mod_note) { + notes.push(mod_note); + } + } + } + + if !notes.is_empty() { + for note in notes { + diag.note(note); + } + } else if let Some((_, UnresolvedImportError { note: Some(note), .. })) = + errors.iter().last() + { + diag.note(note.clone()); + } + + /// Upper limit on the number of `span_label` messages. + const MAX_LABEL_COUNT: usize = 10; + let mod_labels = mod_diagnostics.into_iter().map(|cd| cd.label); + + for ((import, err), mod_label) in errors.into_iter().zip(mod_labels).take(MAX_LABEL_COUNT) { + let label_span = match err.segment { + Some(segment) => segment.span, + None => err.span, + }; + if let Some(label) = &label { + diag.span_label(label_span, label.clone()); + } else if let Some(label) = mod_label { + diag.span_label(label_span, label); + } else if let Some(label) = &err.label { + diag.span_label(label_span, label.clone()); + } + + if let Some((suggestions, msg, applicability)) = err.suggestion { + if suggestions.is_empty() { + diag.help(msg); + continue; + } + diag.multipart_suggestion(msg, suggestions, applicability); + } + + if let Some(candidates) = &err.candidates { + match &import.kind { + ImportKind::Single { nested: false, source, target, .. } => import_candidates( + self.tcx, + &mut diag, + Some(err.span), + candidates, + DiagMode::Import { append: false, unresolved_import: true }, + (source != target) + .then(|| format!(" as {target}")) + .as_deref() + .unwrap_or(""), + ), + ImportKind::Single { nested: true, source, target, .. } => { + import_candidates( + self.tcx, + &mut diag, + None, + candidates, + DiagMode::Normal, + (source != target) + .then(|| format!(" as {target}")) + .as_deref() + .unwrap_or(""), + ); + } + _ => {} + } + } + + if matches!(import.kind, ImportKind::Single { .. }) + && let Some(segment) = err.segment + && let Some(module) = err.module + { + self.find_cfg_stripped(&mut diag, &segment.name, module) + } + } + + let guar = diag.emit(); + if glob_error { + self.glob_error = Some(guar); + } + } + pub(crate) fn dcx(&self) -> DiagCtxtHandle<'tcx> { self.tcx.dcx() } @@ -3405,6 +3601,14 @@ pub(crate) fn struct_ctor(&self, def_id: DefId) -> Option<StructCtor> { } } } + + /// Gets the `#[diagnostic::on_unknown]` attribute data associated with this `DefId`. + fn on_unknown_data(&self, def_id: DefId) -> Option<&Directive> { + match def_id.as_local() { + Some(local) => Some(self.on_unknown_data.get(&local)?.directive.as_ref()), + None => find_attr!(self.tcx, def_id, OnUnknown{ directive } => directive)?.as_deref(), + } + } } /// Given a `binding_span` of a binding within a use statement: @@ -3933,3 +4137,24 @@ fn is_span_suitable_for_use_injection(s: Span) -> bool { // import or other generated ones !s.from_expansion() } + +#[derive(Debug, Clone, Default)] +pub(crate) struct OnUnknownData { + pub(crate) directive: Box<Directive>, +} + +impl OnUnknownData { + pub(crate) fn from_attrs<'tcx>( + tcx: TyCtxt<'tcx>, + attrs: &[ast::Attribute], + ) -> Option<OnUnknownData> { + if tcx.features().diagnostic_on_unknown() + && let Some(Attribute::Parsed(AttributeKind::OnUnknown { directive, .. })) = + AttributeParser::parse_limited(tcx.sess, attrs, &[sym::diagnostic, sym::on_unknown]) + { + Some(Self { directive: directive? }) + } else { + None + } + } +}
diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index a6c7d2f..d823da9 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs
@@ -3,24 +3,16 @@ use std::cmp::Ordering; use std::mem; -use itertools::Itertools; -use rustc_ast::{Item, NodeId}; -use rustc_attr_parsing::AttributeParser; +use rustc_ast::NodeId; use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; use rustc_data_structures::intern::Interned; -use rustc_errors::codes::*; -use rustc_errors::{ - Applicability, BufferedEarlyLint, Diagnostic, MultiSpan, pluralize, struct_span_code_err, -}; +use rustc_errors::{Applicability, BufferedEarlyLint, Diagnostic}; use rustc_expand::base::SyntaxExtensionKind; -use rustc_hir::Attribute; -use rustc_hir::attrs::AttributeKind; -use rustc_hir::attrs::diagnostic::{CustomDiagnostic, Directive, FormatArgs}; use rustc_hir::def::{self, DefKind, PartialRes}; use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdMap}; use rustc_middle::metadata::{AmbigModChild, ModChild, Reexport}; use rustc_middle::span_bug; -use rustc_middle::ty::{TyCtxt, Visibility}; +use rustc_middle::ty::Visibility; use rustc_session::errors::feature_err; use rustc_session::lint::LintId; use rustc_session::lint::builtin::{ @@ -39,7 +31,7 @@ CannotGlobImportAllCrates, ConsiderAddingMacroExport, ConsiderMarkingAsPub, ConsiderMarkingAsPubCrate, }; -use crate::error_helper::{DiagMode, Suggestion, import_candidates}; +use crate::error_helper::{OnUnknownData, Suggestion}; use crate::ref_mut::CmCell; use crate::{ AmbiguityError, BindingKey, CmResolver, Decl, DeclData, DeclKind, Determinacy, Finalize, @@ -164,28 +156,6 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { } } -#[derive(Debug, Clone, Default)] -pub(crate) struct OnUnknownData { - directive: Box<Directive>, -} - -impl OnUnknownData { - pub(crate) fn from_attrs<'tcx>(tcx: TyCtxt<'tcx>, item: &Item) -> Option<OnUnknownData> { - if tcx.features().diagnostic_on_unknown() - && let Some(Attribute::Parsed(AttributeKind::OnUnknown { directive, .. })) = - AttributeParser::parse_limited( - tcx.sess, - &item.attrs, - &[sym::diagnostic, sym::on_unknown], - ) - { - Some(Self { directive: directive? }) - } else { - None - } - } -} - /// One import. #[derive(Debug, Clone)] pub(crate) struct ImportData<'ra> { @@ -353,16 +323,16 @@ pub(crate) fn best_decl(&self) -> Option<Decl<'ra>> { /// An error that may be transformed into a diagnostic later. Used to combine multiple unresolved /// import errors within the same use tree into a single diagnostic. #[derive(Debug, Clone)] -struct UnresolvedImportError { - span: Span, - label: Option<String>, - note: Option<String>, - suggestion: Option<Suggestion>, - candidates: Option<Vec<ImportSuggestion>>, - segment: Option<Ident>, +pub(crate) struct UnresolvedImportError { + pub(crate) span: Span, + pub(crate) label: Option<String>, + pub(crate) note: Option<String>, + pub(crate) suggestion: Option<Suggestion>, + pub(crate) candidates: Option<Vec<ImportSuggestion>>, + pub(crate) segment: Option<Ident>, /// comes from `PathRes::Failed { module }` - module: Option<DefId>, - on_unknown_attr: Option<OnUnknownData>, + pub(crate) module: Option<DefId>, + pub(crate) on_unknown_attr: Option<OnUnknownData>, } // Reexports of the form `pub use foo as bar;` where `foo` is `extern crate foo;` @@ -1080,141 +1050,6 @@ pub(crate) fn lint_reexports(&mut self, exported_ambiguities: FxHashSet<Decl<'ra } } - fn throw_unresolved_import_error( - &mut self, - mut errors: Vec<(Import<'_>, UnresolvedImportError)>, - glob_error: bool, - ) { - errors.retain(|(_import, err)| match err.module { - // Skip `use` errors for `use foo::Bar;` if `foo.rs` has unrecovered parse errors. - Some(def_id) if self.mods_with_parse_errors.contains(&def_id) => false, - // If we've encountered something like `use _;`, we've already emitted an error stating - // that `_` is not a valid identifier, so we ignore that resolve error. - _ => err.segment.map(|s| s.name) != Some(kw::Underscore), - }); - if errors.is_empty() { - self.tcx.dcx().delayed_bug("expected a parse or \"`_` can't be an identifier\" error"); - return; - } - - let span = MultiSpan::from_spans(errors.iter().map(|(_, err)| err.span).collect()); - - let paths = errors - .iter() - .map(|(import, err)| { - let path = import_path_to_string( - &import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(), - &import.kind, - err.span, - ); - format!("`{path}`") - }) - .collect::<Vec<_>>(); - let default_message = - format!("unresolved import{} {}", pluralize!(paths.len()), paths.join(", "),); - let (message, label, notes) = - // Feature gating for `on_unknown_attr` happens initialization of the field - if let Some(directive) = errors[0].1.on_unknown_attr.as_ref().map(|a| &a.directive) { - let this = errors.iter().map(|(_import, err)| { - - // Is this unwrap_or reachable? - err.segment.map(|s|s.name).unwrap_or(kw::Underscore) - }).join(", "); - - let args = FormatArgs { - this, - .. - }; - let CustomDiagnostic { message, label, notes, .. } = directive.eval(None, &args); - - (message, label, notes) - } else { - (None, None, Vec::new()) - }; - let has_custom_message = message.is_some(); - let message = message.as_deref().unwrap_or(default_message.as_str()); - - let mut diag = struct_span_code_err!(self.dcx(), span, E0432, "{message}"); - if has_custom_message { - diag.note(default_message); - } - - if !notes.is_empty() { - for note in notes { - diag.note(note); - } - } else if let Some((_, UnresolvedImportError { note: Some(note), .. })) = - errors.iter().last() - { - diag.note(note.clone()); - } - - /// Upper limit on the number of `span_label` messages. - const MAX_LABEL_COUNT: usize = 10; - - for (import, err) in errors.into_iter().take(MAX_LABEL_COUNT) { - let label_span = match err.segment { - Some(segment) => segment.span, - None => err.span, - }; - if let Some(label) = &label { - diag.span_label(label_span, label.clone()); - } else if let Some(label) = &err.label { - diag.span_label(label_span, label.clone()); - } - - if let Some((suggestions, msg, applicability)) = err.suggestion { - if suggestions.is_empty() { - diag.help(msg); - continue; - } - diag.multipart_suggestion(msg, suggestions, applicability); - } - - if let Some(candidates) = &err.candidates { - match &import.kind { - ImportKind::Single { nested: false, source, target, .. } => import_candidates( - self.tcx, - &mut diag, - Some(err.span), - candidates, - DiagMode::Import { append: false, unresolved_import: true }, - (source != target) - .then(|| format!(" as {target}")) - .as_deref() - .unwrap_or(""), - ), - ImportKind::Single { nested: true, source, target, .. } => { - import_candidates( - self.tcx, - &mut diag, - None, - candidates, - DiagMode::Normal, - (source != target) - .then(|| format!(" as {target}")) - .as_deref() - .unwrap_or(""), - ); - } - _ => {} - } - } - - if matches!(import.kind, ImportKind::Single { .. }) - && let Some(segment) = err.segment - && let Some(module) = err.module - { - self.find_cfg_stripped(&mut diag, &segment.name, module) - } - } - - let guar = diag.emit(); - if glob_error { - self.glob_error = Some(guar); - } - } - /// Attempts to resolve the given import, returning: /// - `0` means its resolution is determined. /// - Other values mean that indeterminate exists under certain namespaces. @@ -2029,7 +1864,11 @@ fn finalize_resolutions_in( } } -fn import_path_to_string(names: &[Ident], import_kind: &ImportKind<'_>, span: Span) -> String { +pub(crate) fn import_path_to_string( + names: &[Ident], + import_kind: &ImportKind<'_>, + span: Span, +) -> String { let pos = names.iter().position(|p| span == p.span && p.name != kw::PathRoot); let global = !names.is_empty() && names[0].name == kw::PathRoot; if let Some(pos) = pos {
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index c7b4686..061471c 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs
@@ -35,6 +35,7 @@ ForwardGenericParamBanReason, HasGenericParams, PathSource, PatternSource, UnnecessaryQualification, }; +pub use macros::registered_tools_ast; use macros::{MacroRulesDecl, MacroRulesScope, MacroRulesScopeRef}; use rustc_arena::{DroplessArena, TypedArena}; use rustc_ast::node_id::NodeMap; @@ -75,7 +76,8 @@ use smallvec::{SmallVec, smallvec}; use tracing::{debug, instrument}; -type Res = def::Res<NodeId>; +use crate::error_helper::OnUnknownData; +use crate::ref_mut::{CmCell, CmRefCell}; mod build_reduced_graph; mod check_unused; @@ -89,9 +91,7 @@ mod macros; pub mod rustdoc; -pub use macros::registered_tools_ast; - -use crate::ref_mut::{CmCell, CmRefCell}; +type Res = def::Res<NodeId>; #[derive(Copy, Clone, PartialEq, Debug)] enum Determinacy { @@ -1548,6 +1548,9 @@ pub struct Resolver<'ra, 'tcx> { // that were encountered during resolution. These names are used to generate item names // for APITs, so we don't want to leak details of resolution into these names. impl_trait_names: FxHashMap<NodeId, Symbol> = default::fx_hash_map(), + + /// Stores `#[diagnostic::on_unknown]` attributes placed on module declarations. + on_unknown_data: FxHashMap<LocalDefId, OnUnknownData>, } /// This provides memory for the rest of the crate. The `'ra` lifetime that is @@ -1805,6 +1808,11 @@ pub fn new( let registered_tools = tcx.registered_tools(()); let edition = tcx.sess.edition(); + let mut on_unknown_data = default::fx_hash_map(); + if let Some(directive) = OnUnknownData::from_attrs(tcx, attrs) { + on_unknown_data.insert(CRATE_DEF_ID, directive); + } + let mut resolver = Resolver { tcx, @@ -1872,6 +1880,7 @@ pub fn new( current_crate_outer_attr_insert_span, disambiguators: Default::default(), delegation_infos: Default::default(), + on_unknown_data, .. };
diff --git a/compiler/rustc_serialize/Cargo.toml b/compiler/rustc_serialize/Cargo.toml index 193c89a..4e11d87 100644 --- a/compiler/rustc_serialize/Cargo.toml +++ b/compiler/rustc_serialize/Cargo.toml
@@ -8,7 +8,7 @@ indexmap = "2.0.0" rustc_hashes = { path = "../rustc_hashes" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.15" +thin-vec = "0.2.18" # tidy-alphabetical-end [dev-dependencies]
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 73ce528..897aa91 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs
@@ -2418,6 +2418,8 @@ pub(crate) fn parse_rust_version(slot: &mut Option<RustcVersion>, v: Option<&str "allow deducing higher-ranked outlives assumptions from coroutines when proving auto traits"), hint_mostly_unused: bool = (false, parse_bool, [TRACKED], "hint that most of this crate will go unused, to minimize work for uncalled functions"), + hint_msrv: Option<RustcVersion> = (None, parse_rust_version, [TRACKED], + "control the minimum rust version for lints"), human_readable_cgu_names: bool = (false, parse_bool, [TRACKED], "generate human-readable, predictable names for codegen units (default: no)"), identify_regions: bool = (false, parse_bool, [UNTRACKED], @@ -2486,8 +2488,6 @@ pub(crate) fn parse_rust_version(slot: &mut Option<RustcVersion>, v: Option<&str "lint LLVM IR (default: no)"), lint_mir: bool = (false, parse_bool, [UNTRACKED], "lint MIR before and after each transformation"), - lint_rust_version: Option<RustcVersion> = (None, parse_rust_version, [TRACKED], - "control the minimum rust version for lints"), llvm_module_flag: Vec<(String, u32, String)> = (Vec::new(), parse_llvm_module_flag, [TRACKED], "a list of module flags to pass to LLVM (space separated)"), llvm_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index c19a2d7..4cf1521 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs
@@ -1040,7 +1040,7 @@ pub fn build_session( dcx = dcx.with_ice_file(ice_file); } - if let Some(msrv) = sopts.unstable_opts.lint_rust_version { + if let Some(msrv) = sopts.unstable_opts.hint_msrv { dcx = dcx.with_msrv(msrv); }
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index c2c7041..827e33d 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs
@@ -335,6 +335,7 @@ TyKind, Type, Union, + Unresolved, Unsize, Vec, Wrapper, @@ -1772,6 +1773,7 @@ rustc_dummy, rustc_dump_def_parents, rustc_dump_def_path, + rustc_dump_generics, rustc_dump_hidden_type_of_opaques, rustc_dump_inferred_outlives, rustc_dump_item_bounds,
diff --git a/compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs b/compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs index 42f0a6a..0fa7ae2 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs
@@ -60,7 +60,7 @@ pub(crate) fn target() -> Target { options.features = "+atomics,+bulk-memory,+mutable-globals".into(); Target { - llvm_target: "wasm32-wasi".into(), + llvm_target: "wasm32-wasip1-threads".into(), metadata: TargetMetadata { description: None, tier: Some(2),
diff --git a/compiler/rustc_trait_selection/Cargo.toml b/compiler/rustc_trait_selection/Cargo.toml index 802fdda..3ce76d7 100644 --- a/compiler/rustc_trait_selection/Cargo.toml +++ b/compiler/rustc_trait_selection/Cargo.toml
@@ -19,6 +19,6 @@ rustc_span = { path = "../rustc_span" } rustc_transmute = { path = "../rustc_transmute", features = ["rustc"] } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" # tidy-alphabetical-end
diff --git a/compiler/rustc_traits/src/normalize_erasing_regions.rs b/compiler/rustc_traits/src/normalize_erasing_regions.rs index d3a2c4d..1e6089d 100644 --- a/compiler/rustc_traits/src/normalize_erasing_regions.rs +++ b/compiler/rustc_traits/src/normalize_erasing_regions.rs
@@ -22,7 +22,7 @@ fn try_normalize_after_erasing_regions<'tcx, T: TypeFoldable<TyCtxt<'tcx>> + Par goal: PseudoCanonicalInput<'tcx, T>, ) -> Result<T, NoSolution> { let PseudoCanonicalInput { typing_env, value } = goal; - let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(typing_env); + let (infcx, param_env) = tcx.infer_ctxt().ignoring_regions().build_with_typing_env(typing_env); let cause = ObligationCause::dummy(); match infcx.at(&cause, param_env).query_normalize(value) { Ok(Normalized { value: normalized_value, obligations: normalized_obligations }) => {
diff --git a/compiler/rustc_type_ir/Cargo.toml b/compiler/rustc_type_ir/Cargo.toml index 7b0b4aa..97cddd8 100644 --- a/compiler/rustc_type_ir/Cargo.toml +++ b/compiler/rustc_type_ir/Cargo.toml
@@ -23,7 +23,7 @@ smallvec = { version = "1.8.1", default-features = false, features = [ "const_generics", ] } -thin-vec = "0.2.15" +thin-vec = "0.2.18" tracing = "0.1" # tidy-alphabetical-end
diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 7d99435..0a1f773 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs
@@ -2594,7 +2594,8 @@ fn hash<H: Hasher>(&self, state: &mut H) { } #[stable(feature = "rust1", since = "1.0.0")] -impl<K, V> Default for BTreeMap<K, V> { +#[rustc_const_unstable(feature = "const_default", issue = "143894")] +const impl<K, V> Default for BTreeMap<K, V> { /// Creates an empty `BTreeMap`. fn default() -> BTreeMap<K, V> { BTreeMap::new()
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 7c6befa..22951480 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs
@@ -775,7 +775,6 @@ pub fn from_utf16_lossy(v: &[u16]) -> String { /// Basic usage: /// /// ``` - /// #![feature(str_from_utf16_endian)] /// // 𝄞music /// let v = &[0x34, 0xD8, 0x1E, 0xDD, 0x6d, 0x00, 0x75, 0x00, /// 0x73, 0x00, 0x69, 0x00, 0x63, 0x00]; @@ -788,7 +787,7 @@ pub fn from_utf16_lossy(v: &[u16]) -> String { /// assert!(String::from_utf16le(v).is_err()); /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "str_from_utf16_endian", issue = "116258")] + #[stable(feature = "str_from_utf16_endian", since = "CURRENT_RUSTC_VERSION")] pub fn from_utf16le(v: &[u8]) -> Result<String, FromUtf16Error> { let (chunks, []) = v.as_chunks::<2>() else { return Err(FromUtf16Error { kind: FromUtf16ErrorKind::OddBytes }); @@ -817,7 +816,6 @@ pub fn from_utf16le(v: &[u8]) -> Result<String, FromUtf16Error> { /// Basic usage: /// /// ``` - /// #![feature(str_from_utf16_endian)] /// // 𝄞mus<invalid>ic<invalid> /// let v = &[0x34, 0xD8, 0x1E, 0xDD, 0x6d, 0x00, 0x75, 0x00, /// 0x73, 0x00, 0x1E, 0xDD, 0x69, 0x00, 0x63, 0x00, @@ -827,7 +825,7 @@ pub fn from_utf16le(v: &[u8]) -> Result<String, FromUtf16Error> { /// String::from_utf16le_lossy(v)); /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "str_from_utf16_endian", issue = "116258")] + #[stable(feature = "str_from_utf16_endian", since = "CURRENT_RUSTC_VERSION")] pub fn from_utf16le_lossy(v: &[u8]) -> String { match (cfg!(target_endian = "little"), unsafe { v.align_to::<u16>() }) { (true, ([], v, [])) => Self::from_utf16_lossy(v), @@ -850,7 +848,6 @@ pub fn from_utf16le_lossy(v: &[u8]) -> String { /// Basic usage: /// /// ``` - /// #![feature(str_from_utf16_endian)] /// // 𝄞music /// let v = &[0xD8, 0x34, 0xDD, 0x1E, 0x00, 0x6d, 0x00, 0x75, /// 0x00, 0x73, 0x00, 0x69, 0x00, 0x63]; @@ -863,7 +860,7 @@ pub fn from_utf16le_lossy(v: &[u8]) -> String { /// assert!(String::from_utf16be(v).is_err()); /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "str_from_utf16_endian", issue = "116258")] + #[stable(feature = "str_from_utf16_endian", since = "CURRENT_RUSTC_VERSION")] pub fn from_utf16be(v: &[u8]) -> Result<String, FromUtf16Error> { let (chunks, []) = v.as_chunks::<2>() else { return Err(FromUtf16Error { kind: FromUtf16ErrorKind::OddBytes }); @@ -892,7 +889,6 @@ pub fn from_utf16be(v: &[u8]) -> Result<String, FromUtf16Error> { /// Basic usage: /// /// ``` - /// #![feature(str_from_utf16_endian)] /// // 𝄞mus<invalid>ic<invalid> /// let v = &[0xD8, 0x34, 0xDD, 0x1E, 0x00, 0x6d, 0x00, 0x75, /// 0x00, 0x73, 0xDD, 0x1E, 0x00, 0x69, 0x00, 0x63, @@ -902,7 +898,7 @@ pub fn from_utf16be(v: &[u8]) -> Result<String, FromUtf16Error> { /// String::from_utf16be_lossy(v)); /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "str_from_utf16_endian", issue = "116258")] + #[stable(feature = "str_from_utf16_endian", since = "CURRENT_RUSTC_VERSION")] pub fn from_utf16be_lossy(v: &[u8]) -> String { match (cfg!(target_endian = "big"), unsafe { v.align_to::<u16>() }) { (true, ([], v, [])) => Self::from_utf16_lossy(v),
diff --git a/library/alloc/src/task.rs b/library/alloc/src/task.rs index bc668f7..0e36c91 100644 --- a/library/alloc/src/task.rs +++ b/library/alloc/src/task.rs
@@ -37,6 +37,10 @@ /// link ../../std/task/struct.Waker.html#impl-From%3CArc%3CW,+Global%3E%3E-for-Waker /// without getting a link-checking error in CI. --> /// +/// # Memory Ordering +/// +/// To avoid missed wakeups, all executors must adhere to the requirement described for [`Waker::wake`]. +/// /// # Examples /// /// A basic `block_on` function that takes a future and runs it to completion on
diff --git a/library/alloc/src/vec/partial_eq.rs b/library/alloc/src/vec/partial_eq.rs index 204e567..943c930 100644 --- a/library/alloc/src/vec/partial_eq.rs +++ b/library/alloc/src/vec/partial_eq.rs
@@ -6,7 +6,7 @@ macro_rules! __impl_slice_eq1 { ($($const:ident, )? [$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?, $(#[$stability:meta])+ ) => { $(#[$stability])+ - impl<T, U, $($vars)*> $($const)? PartialEq<$rhs> for $lhs + $($const)? impl<T, U, $($vars)*> PartialEq<$rhs> for $lhs where T: $([$const])? PartialEq<U>, $($ty: $bound)?
diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs index 590f559..83b017b 100644 --- a/library/alloctests/lib.rs +++ b/library/alloctests/lib.rs
@@ -20,6 +20,7 @@ #![feature(const_alloc_error)] #![feature(const_cmp)] #![feature(const_convert)] +#![feature(const_default)] #![feature(const_destruct)] #![feature(const_heap)] #![feature(const_option_ops)]
diff --git a/library/core/src/ascii/ascii_char.rs b/library/core/src/ascii/ascii_char.rs index c8c05ee..abd80ae 100644 --- a/library/core/src/ascii/ascii_char.rs +++ b/library/core/src/ascii/ascii_char.rs
@@ -1165,7 +1165,7 @@ macro_rules! into_int_impl { $( #[unstable(feature = "ascii_char", issue = "110998")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const From<AsciiChar> for $ty { + const impl From<AsciiChar> for $ty { #[inline] fn from(chr: AsciiChar) -> $ty { chr as u8 as $ty
diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs index 898138e..a67dc9d 100644 --- a/library/core/src/clone.rs +++ b/library/core/src/clone.rs
@@ -710,7 +710,7 @@ macro_rules! impl_clone { $( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] - impl const Clone for $t { + const impl Clone for $t { #[inline(always)] fn clone(&self) -> Self { *self @@ -720,7 +720,7 @@ fn clone(&self) -> Self { #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] - unsafe impl const TrivialClone for $t {} + const unsafe impl TrivialClone for $t {} )* } }
diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index b699c7a..3371b2c 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs
@@ -1873,7 +1873,7 @@ macro_rules! partial_eq_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] - impl const PartialEq for $t { + const impl PartialEq for $t { #[inline] fn eq(&self, other: &Self) -> bool { *self == *other } #[inline] @@ -1903,7 +1903,7 @@ macro_rules! eq_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] - impl const Eq for $t {} + const impl Eq for $t {} )*) } @@ -1952,7 +1952,7 @@ macro_rules! partial_ord_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] - impl const PartialOrd for $t { + const impl PartialOrd for $t { #[inline] fn partial_cmp(&self, other: &Self) -> Option<Ordering> { match (*self <= *other, *self >= *other) { @@ -1994,7 +1994,7 @@ macro_rules! ord_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] - impl const PartialOrd for $t { + const impl PartialOrd for $t { #[inline] fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(crate::intrinsics::three_way_compare(*self, *other)) @@ -2005,7 +2005,7 @@ fn partial_cmp(&self, other: &Self) -> Option<Ordering> { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] - impl const Ord for $t { + const impl Ord for $t { #[inline] fn cmp(&self, other: &Self) -> Ordering { crate::intrinsics::three_way_compare(*self, *other)
diff --git a/library/core/src/cmp/bytewise.rs b/library/core/src/cmp/bytewise.rs index f0f5f65..88b83b5 100644 --- a/library/core/src/cmp/bytewise.rs +++ b/library/core/src/cmp/bytewise.rs
@@ -24,7 +24,7 @@ macro_rules! is_bytewise_comparable { ($($t:ty),+ $(,)?) => {$( - unsafe impl const BytewiseEq for $t {} + const unsafe impl BytewiseEq for $t {} )+}; }
diff --git a/library/core/src/convert/num.rs b/library/core/src/convert/num.rs index 19398b4..1125f43 100644 --- a/library/core/src/convert/num.rs +++ b/library/core/src/convert/num.rs
@@ -34,7 +34,7 @@ macro_rules! impl_from_bool { ($($int:ty)*) => {$( #[stable(feature = "from_bool", since = "1.28.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const From<bool> for $int { + const impl From<bool> for $int { /// Converts from [`bool`] to #[doc = concat!("[`", stringify!($int), "`]")] /// , by turning `false` into `0` and `true` into `1`. @@ -63,7 +63,7 @@ macro_rules! impl_from { ($small:ty => $large:ty, $(#[$attrs:meta]),+) => { $(#[$attrs])+ #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const From<$small> for $large { + const impl From<$small> for $large { #[doc = concat!("Converts from [`", stringify!($small), "`] to [`", stringify!($large), "`] losslessly.")] #[inline(always)] fn from(small: $small) -> Self { @@ -185,7 +185,7 @@ macro_rules! impl_float_from_bool { ) => { #[stable(feature = "float_from_bool", since = "1.68.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const From<bool> for $float { + const impl From<bool> for $float { #[doc = concat!("Converts a [`bool`] to [`", stringify!($float),"`] losslessly.")] /// The resulting value is positive `0.0` for `false` and `1.0` for `true` values. /// @@ -238,7 +238,7 @@ macro_rules! impl_try_from_unbounded { ($source:ty => $($target:ty),+) => {$( #[stable(feature = "try_from", since = "1.34.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const TryFrom<$source> for $target { + const impl TryFrom<$source> for $target { type Error = TryFromIntError; /// Tries to create the target number type from a source @@ -257,7 +257,7 @@ macro_rules! impl_try_from_lower_bounded { ($source:ty => $($target:ty),+) => {$( #[stable(feature = "try_from", since = "1.34.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const TryFrom<$source> for $target { + const impl TryFrom<$source> for $target { type Error = TryFromIntError; /// Tries to create the target number type from a source @@ -280,7 +280,7 @@ macro_rules! impl_try_from_upper_bounded { ($source:ty => $($target:ty),+) => {$( #[stable(feature = "try_from", since = "1.34.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const TryFrom<$source> for $target { + const impl TryFrom<$source> for $target { type Error = TryFromIntError; /// Tries to create the target number type from a source @@ -303,7 +303,7 @@ macro_rules! impl_try_from_both_bounded { ($source:ty => $($target:ty),+) => {$( #[stable(feature = "try_from", since = "1.34.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const TryFrom<$source> for $target { + const impl TryFrom<$source> for $target { type Error = TryFromIntError; /// Tries to create the target number type from a source @@ -330,7 +330,7 @@ macro_rules! impl_try_from_integer_for_bool { ($signedness:ident $($int:ty)+) => {$( #[stable(feature = "bool_try_from_int", since = "1.95.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const TryFrom<$int> for bool { + const impl TryFrom<$int> for bool { type Error = TryFromIntError; /// Tries to create a bool from an integer type. @@ -585,7 +585,7 @@ macro_rules! impl_nonzero_int_try_from_nonzero_int { ($source:ty => $($target:ty),+) => {$( #[stable(feature = "nzint_try_from_nzint_conv", since = "1.49.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const TryFrom<NonZero<$source>> for NonZero<$target> { + const impl TryFrom<NonZero<$source>> for NonZero<$target> { type Error = TryFromIntError; // Rustdocs on the impl block show a "[+] show undocumented items" toggle. @@ -674,7 +674,7 @@ macro_rules! impl_int_cast { ($Src:ty as [$($Dst:ty),*]) => {$( #[unstable(feature = "integer_casts", issue = "157388")] #[rustc_const_unstable(feature = "integer_casts", issue = "157388")] - impl const CheckedCastFromInt<$Src> for $Dst { + const impl CheckedCastFromInt<$Src> for $Dst { #[inline] fn checked_cast_from(value: $Src) -> Option<Self> { value.try_into().ok() @@ -698,7 +698,7 @@ fn strict_cast_from(value: $Src) -> Self { #[unstable(feature = "integer_casts", issue = "157388")] #[rustc_const_unstable(feature = "integer_casts", issue = "157388")] - impl const BoundedCastFromInt<$Src> for $Dst { + const impl BoundedCastFromInt<$Src> for $Dst { #[inline(always)] fn wrapping_cast_from(value: $Src) -> Self { value as Self
diff --git a/library/core/src/internal_macros.rs b/library/core/src/internal_macros.rs index f90818c..0d0ff23 100644 --- a/library/core/src/internal_macros.rs +++ b/library/core/src/internal_macros.rs
@@ -3,7 +3,7 @@ macro_rules! forward_ref_unop { (impl $imp:ident, $method:ident for $t:ty, $(#[$attr:meta])+) => { $(#[$attr])+ - impl const $imp for &$t { + const impl $imp for &$t { type Output = <$t as $imp>::Output; #[inline] @@ -19,7 +19,7 @@ fn $method(self) -> <$t as $imp>::Output { macro_rules! forward_ref_binop { (impl $imp:ident, $method:ident for $t:ty, $u:ty, $(#[$attr:meta])+) => { $(#[$attr])+ - impl const $imp<$u> for &$t { + const impl $imp<$u> for &$t { type Output = <$t as $imp<$u>>::Output; #[inline] @@ -30,7 +30,7 @@ fn $method(self, other: $u) -> <$t as $imp<$u>>::Output { } $(#[$attr])+ - impl const $imp<&$u> for $t { + const impl $imp<&$u> for $t { type Output = <$t as $imp<$u>>::Output; #[inline] @@ -41,7 +41,7 @@ fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output { } $(#[$attr])+ - impl const $imp<&$u> for &$t { + const impl $imp<&$u> for &$t { type Output = <$t as $imp<$u>>::Output; #[inline] @@ -58,7 +58,7 @@ fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output { macro_rules! forward_ref_op_assign { (impl $imp:ident, $method:ident for $t:ty, $u:ty, $(#[$attr:meta])+) => { $(#[$attr])+ - impl const $imp<&$u> for $t { + const impl $imp<&$u> for $t { #[inline] #[track_caller] fn $method(&mut self, other: &$u) {
diff --git a/library/core/src/intrinsics/fallback.rs b/library/core/src/intrinsics/fallback.rs index bc415ec..a477c2e 100644 --- a/library/core/src/intrinsics/fallback.rs +++ b/library/core/src/intrinsics/fallback.rs
@@ -21,7 +21,7 @@ fn carrying_mul_add( macro_rules! impl_carrying_mul_add_by_widening { ($($t:ident $u:ident $w:ident,)+) => {$( #[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")] - impl const CarryingMulAdd for $t { + const impl CarryingMulAdd for $t { type Unsigned = $u; #[inline] fn carrying_mul_add(self, a: Self, b: Self, c: Self) -> ($u, $t) { @@ -127,7 +127,7 @@ macro_rules! zero { macro_rules! impl_disjoint_bitor { ($($t:ident,)+) => {$( #[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")] - impl const DisjointBitOr for $t { + const impl DisjointBitOr for $t { #[cfg_attr(miri, track_caller)] #[inline] unsafe fn disjoint_bitor(self, other: Self) -> Self { @@ -161,7 +161,7 @@ pub const trait FunnelShift: Copy + 'static { macro_rules! impl_funnel_shifts { ($($type:ident),*) => {$( #[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")] - impl const FunnelShift for $type { + const impl FunnelShift for $type { #[cfg_attr(miri, track_caller)] #[inline] unsafe fn unchecked_funnel_shl(self, rhs: Self, shift: u32) -> Self { @@ -229,7 +229,7 @@ pub const trait CarrylessMul: Copy + 'static { macro_rules! impl_carryless_mul{ ($($type:ident),*) => {$( #[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")] - impl const CarrylessMul for $type { + const impl CarrylessMul for $type { #[inline] fn carryless_mul(self, rhs: Self) -> Self { let mut result = 0;
diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index 949295a..273b891 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs
@@ -263,7 +263,7 @@ macro_rules! step_integer_impls { #[allow(unreachable_patterns)] #[unstable(feature = "step_trait", issue = "42168")] #[rustc_const_unstable(feature = "step_trait", issue = "42168")] - impl const Step for $u_narrower { + const impl Step for $u_narrower { step_identical_methods!(); step_unsigned_methods!(); @@ -298,7 +298,7 @@ fn backward_checked(start: Self, n: usize) -> Option<Self> { #[allow(unreachable_patterns)] #[unstable(feature = "step_trait", issue = "42168")] #[rustc_const_unstable(feature = "step_trait", issue = "42168")] - impl const Step for $i_narrower { + const impl Step for $i_narrower { step_identical_methods!(); step_signed_methods!($u_narrower); @@ -365,7 +365,7 @@ fn backward_checked(start: Self, n: usize) -> Option<Self> { #[allow(unreachable_patterns)] #[unstable(feature = "step_trait", issue = "42168")] #[rustc_const_unstable(feature = "step_trait", issue = "42168")] - impl const Step for $u_wider { + const impl Step for $u_wider { step_identical_methods!(); step_unsigned_methods!(); @@ -396,7 +396,7 @@ fn backward_checked(start: Self, n: usize) -> Option<Self> { #[allow(unreachable_patterns)] #[unstable(feature = "step_trait", issue = "42168")] #[rustc_const_unstable(feature = "step_trait", issue = "42168")] - impl const Step for $i_wider { + const impl Step for $i_wider { step_identical_methods!(); step_signed_methods!($u_wider); @@ -514,7 +514,7 @@ macro_rules! step_nonzero_impls { #[allow(unreachable_patterns)] #[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")] #[rustc_const_unstable(feature = "step_trait", issue = "42168")] - impl const Step for NonZero<$narrower> { + const impl Step for NonZero<$narrower> { step_nonzero_identical_methods!($narrower); #[inline] @@ -540,7 +540,7 @@ fn backward_checked(start: Self, n: usize) -> Option<Self> { #[allow(unreachable_patterns)] #[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")] #[rustc_const_unstable(feature = "step_trait", issue = "42168")] - impl const Step for NonZero<$wider> { + const impl Step for NonZero<$wider> { step_nonzero_identical_methods!($wider); #[inline]
diff --git a/library/core/src/net/ip_addr.rs b/library/core/src/net/ip_addr.rs index f2d91b9..4e380a9 100644 --- a/library/core/src/net/ip_addr.rs +++ b/library/core/src/net/ip_addr.rs
@@ -2468,7 +2468,7 @@ macro_rules! bitop_impls { )*) => { $( $(#[$attr])* - impl const $BitOpAssign for $ty { + const impl $BitOpAssign for $ty { fn $bitop_assign(&mut self, rhs: $ty) { let mut idx = 0; while idx < self.octets.len() { @@ -2479,14 +2479,14 @@ fn $bitop_assign(&mut self, rhs: $ty) { } $(#[$attr])* - impl const $BitOpAssign<&'_ $ty> for $ty { + const impl $BitOpAssign<&'_ $ty> for $ty { fn $bitop_assign(&mut self, rhs: &'_ $ty) { self.$bitop_assign(*rhs); } } $(#[$attr])* - impl const $BitOp for $ty { + const impl $BitOp for $ty { type Output = $ty; #[inline] @@ -2497,7 +2497,7 @@ fn $bitop(mut self, rhs: $ty) -> $ty { } $(#[$attr])* - impl const $BitOp<&'_ $ty> for $ty { + const impl $BitOp<&'_ $ty> for $ty { type Output = $ty; #[inline] @@ -2508,7 +2508,7 @@ fn $bitop(mut self, rhs: &'_ $ty) -> $ty { } $(#[$attr])* - impl const $BitOp<$ty> for &'_ $ty { + const impl $BitOp<$ty> for &'_ $ty { type Output = $ty; #[inline] @@ -2520,7 +2520,7 @@ fn $bitop(self, rhs: $ty) -> $ty { } $(#[$attr])* - impl const $BitOp<&'_ $ty> for &'_ $ty { + const impl $BitOp<&'_ $ty> for &'_ $ty { type Output = $ty; #[inline]
diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 59c2b11..002c560 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs
@@ -1587,7 +1587,7 @@ macro_rules! from_str_int_impl { ($signedness:ident $($int_ty:ty)+) => {$( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const FromStr for $int_ty { + const impl FromStr for $int_ty { type Err = ParseIntError; /// Parses an integer from a string slice with decimal digits.
diff --git a/library/core/src/num/saturating.rs b/library/core/src/num/saturating.rs index 365a82a..efe96a9 100644 --- a/library/core/src/num/saturating.rs +++ b/library/core/src/num/saturating.rs
@@ -214,7 +214,7 @@ macro_rules! saturating_impl { ($($t:ty)*) => ($( #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Add for Saturating<$t> { + const impl Add for Saturating<$t> { type Output = Saturating<$t>; #[inline] @@ -228,7 +228,7 @@ fn add(self, other: Saturating<$t>) -> Saturating<$t> { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const AddAssign for Saturating<$t> { + const impl AddAssign for Saturating<$t> { #[inline] fn add_assign(&mut self, other: Saturating<$t>) { *self = *self + other; @@ -240,7 +240,7 @@ fn add_assign(&mut self, other: Saturating<$t>) { #[stable(feature = "saturating_int_assign_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const AddAssign<$t> for Saturating<$t> { + const impl AddAssign<$t> for Saturating<$t> { #[inline] fn add_assign(&mut self, other: $t) { *self = *self + Saturating(other); @@ -252,7 +252,7 @@ fn add_assign(&mut self, other: $t) { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Sub for Saturating<$t> { + const impl Sub for Saturating<$t> { type Output = Saturating<$t>; #[inline] @@ -266,7 +266,7 @@ fn sub(self, other: Saturating<$t>) -> Saturating<$t> { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const SubAssign for Saturating<$t> { + const impl SubAssign for Saturating<$t> { #[inline] fn sub_assign(&mut self, other: Saturating<$t>) { *self = *self - other; @@ -278,7 +278,7 @@ fn sub_assign(&mut self, other: Saturating<$t>) { #[stable(feature = "saturating_int_assign_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const SubAssign<$t> for Saturating<$t> { + const impl SubAssign<$t> for Saturating<$t> { #[inline] fn sub_assign(&mut self, other: $t) { *self = *self - Saturating(other); @@ -290,7 +290,7 @@ fn sub_assign(&mut self, other: $t) { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Mul for Saturating<$t> { + const impl Mul for Saturating<$t> { type Output = Saturating<$t>; #[inline] @@ -304,7 +304,7 @@ fn mul(self, other: Saturating<$t>) -> Saturating<$t> { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const MulAssign for Saturating<$t> { + const impl MulAssign for Saturating<$t> { #[inline] fn mul_assign(&mut self, other: Saturating<$t>) { *self = *self * other; @@ -316,7 +316,7 @@ fn mul_assign(&mut self, other: Saturating<$t>) { #[stable(feature = "saturating_int_assign_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const MulAssign<$t> for Saturating<$t> { + const impl MulAssign<$t> for Saturating<$t> { #[inline] fn mul_assign(&mut self, other: $t) { *self = *self * Saturating(other); @@ -343,7 +343,7 @@ fn mul_assign(&mut self, other: $t) { /// ``` #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Div for Saturating<$t> { + const impl Div for Saturating<$t> { type Output = Saturating<$t>; #[inline] @@ -357,7 +357,7 @@ fn div(self, other: Saturating<$t>) -> Saturating<$t> { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const DivAssign for Saturating<$t> { + const impl DivAssign for Saturating<$t> { #[inline] fn div_assign(&mut self, other: Saturating<$t>) { *self = *self / other; @@ -369,7 +369,7 @@ fn div_assign(&mut self, other: Saturating<$t>) { #[stable(feature = "saturating_int_assign_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const DivAssign<$t> for Saturating<$t> { + const impl DivAssign<$t> for Saturating<$t> { #[inline] fn div_assign(&mut self, other: $t) { *self = *self / Saturating(other); @@ -381,7 +381,7 @@ fn div_assign(&mut self, other: $t) { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Rem for Saturating<$t> { + const impl Rem for Saturating<$t> { type Output = Saturating<$t>; #[inline] @@ -395,7 +395,7 @@ fn rem(self, other: Saturating<$t>) -> Saturating<$t> { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const RemAssign for Saturating<$t> { + const impl RemAssign for Saturating<$t> { #[inline] fn rem_assign(&mut self, other: Saturating<$t>) { *self = *self % other; @@ -407,7 +407,7 @@ fn rem_assign(&mut self, other: Saturating<$t>) { #[stable(feature = "saturating_int_assign_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const RemAssign<$t> for Saturating<$t> { + const impl RemAssign<$t> for Saturating<$t> { #[inline] fn rem_assign(&mut self, other: $t) { *self = *self % Saturating(other); @@ -419,7 +419,7 @@ fn rem_assign(&mut self, other: $t) { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Not for Saturating<$t> { + const impl Not for Saturating<$t> { type Output = Saturating<$t>; #[inline] @@ -433,7 +433,7 @@ fn not(self) -> Saturating<$t> { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitXor for Saturating<$t> { + const impl BitXor for Saturating<$t> { type Output = Saturating<$t>; #[inline] @@ -447,7 +447,7 @@ fn bitxor(self, other: Saturating<$t>) -> Saturating<$t> { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitXorAssign for Saturating<$t> { + const impl BitXorAssign for Saturating<$t> { #[inline] fn bitxor_assign(&mut self, other: Saturating<$t>) { *self = *self ^ other; @@ -459,7 +459,7 @@ fn bitxor_assign(&mut self, other: Saturating<$t>) { #[stable(feature = "saturating_int_assign_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitXorAssign<$t> for Saturating<$t> { + const impl BitXorAssign<$t> for Saturating<$t> { #[inline] fn bitxor_assign(&mut self, other: $t) { *self = *self ^ Saturating(other); @@ -471,7 +471,7 @@ fn bitxor_assign(&mut self, other: $t) { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitOr for Saturating<$t> { + const impl BitOr for Saturating<$t> { type Output = Saturating<$t>; #[inline] @@ -485,7 +485,7 @@ fn bitor(self, other: Saturating<$t>) -> Saturating<$t> { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitOrAssign for Saturating<$t> { + const impl BitOrAssign for Saturating<$t> { #[inline] fn bitor_assign(&mut self, other: Saturating<$t>) { *self = *self | other; @@ -497,7 +497,7 @@ fn bitor_assign(&mut self, other: Saturating<$t>) { #[stable(feature = "saturating_int_assign_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitOrAssign<$t> for Saturating<$t> { + const impl BitOrAssign<$t> for Saturating<$t> { #[inline] fn bitor_assign(&mut self, other: $t) { *self = *self | Saturating(other); @@ -509,7 +509,7 @@ fn bitor_assign(&mut self, other: $t) { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitAnd for Saturating<$t> { + const impl BitAnd for Saturating<$t> { type Output = Saturating<$t>; #[inline] @@ -523,7 +523,7 @@ fn bitand(self, other: Saturating<$t>) -> Saturating<$t> { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitAndAssign for Saturating<$t> { + const impl BitAndAssign for Saturating<$t> { #[inline] fn bitand_assign(&mut self, other: Saturating<$t>) { *self = *self & other; @@ -535,7 +535,7 @@ fn bitand_assign(&mut self, other: Saturating<$t>) { #[stable(feature = "saturating_int_assign_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitAndAssign<$t> for Saturating<$t> { + const impl BitAndAssign<$t> for Saturating<$t> { #[inline] fn bitand_assign(&mut self, other: $t) { *self = *self & Saturating(other); @@ -1001,7 +1001,7 @@ pub const fn is_negative(self) -> bool { #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Neg for Saturating<$t> { + const impl Neg for Saturating<$t> { type Output = Self; #[inline] fn neg(self) -> Self {
diff --git a/library/core/src/num/traits.rs b/library/core/src/num/traits.rs index 2a5818e..8f5daf2 100644 --- a/library/core/src/num/traits.rs +++ b/library/core/src/num/traits.rs
@@ -41,7 +41,7 @@ macro_rules! impl_truncate { #[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")] #[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")] - impl const TruncateTarget<$to> for $from { + const impl TruncateTarget<$to> for $from { #[inline] fn internal_truncate(self) -> $to { self as _ @@ -88,7 +88,7 @@ macro_rules! impl_widen { #[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")] #[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")] - impl const WidenTarget<$to> for $from { + const impl WidenTarget<$to> for $from { fn internal_widen(self) -> $to { self as _ }
diff --git a/library/core/src/num/wrapping.rs b/library/core/src/num/wrapping.rs index 68c5baf..1ab95b1 100644 --- a/library/core/src/num/wrapping.rs +++ b/library/core/src/num/wrapping.rs
@@ -231,7 +231,7 @@ macro_rules! wrapping_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Add for Wrapping<$t> { + const impl Add for Wrapping<$t> { type Output = Wrapping<$t>; #[inline] @@ -245,7 +245,7 @@ fn add(self, other: Wrapping<$t>) -> Wrapping<$t> { #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const AddAssign for Wrapping<$t> { + const impl AddAssign for Wrapping<$t> { #[inline] fn add_assign(&mut self, other: Wrapping<$t>) { *self = *self + other; @@ -257,7 +257,7 @@ fn add_assign(&mut self, other: Wrapping<$t>) { #[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const AddAssign<$t> for Wrapping<$t> { + const impl AddAssign<$t> for Wrapping<$t> { #[inline] fn add_assign(&mut self, other: $t) { *self = *self + Wrapping(other); @@ -269,7 +269,7 @@ fn add_assign(&mut self, other: $t) { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Sub for Wrapping<$t> { + const impl Sub for Wrapping<$t> { type Output = Wrapping<$t>; #[inline] @@ -283,7 +283,7 @@ fn sub(self, other: Wrapping<$t>) -> Wrapping<$t> { #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const SubAssign for Wrapping<$t> { + const impl SubAssign for Wrapping<$t> { #[inline] fn sub_assign(&mut self, other: Wrapping<$t>) { *self = *self - other; @@ -295,7 +295,7 @@ fn sub_assign(&mut self, other: Wrapping<$t>) { #[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const SubAssign<$t> for Wrapping<$t> { + const impl SubAssign<$t> for Wrapping<$t> { #[inline] fn sub_assign(&mut self, other: $t) { *self = *self - Wrapping(other); @@ -307,7 +307,7 @@ fn sub_assign(&mut self, other: $t) { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Mul for Wrapping<$t> { + const impl Mul for Wrapping<$t> { type Output = Wrapping<$t>; #[inline] @@ -321,7 +321,7 @@ fn mul(self, other: Wrapping<$t>) -> Wrapping<$t> { #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const MulAssign for Wrapping<$t> { + const impl MulAssign for Wrapping<$t> { #[inline] fn mul_assign(&mut self, other: Wrapping<$t>) { *self = *self * other; @@ -333,7 +333,7 @@ fn mul_assign(&mut self, other: Wrapping<$t>) { #[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const MulAssign<$t> for Wrapping<$t> { + const impl MulAssign<$t> for Wrapping<$t> { #[inline] fn mul_assign(&mut self, other: $t) { *self = *self * Wrapping(other); @@ -345,7 +345,7 @@ fn mul_assign(&mut self, other: $t) { #[stable(feature = "wrapping_div", since = "1.3.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Div for Wrapping<$t> { + const impl Div for Wrapping<$t> { type Output = Wrapping<$t>; #[inline] @@ -359,7 +359,7 @@ fn div(self, other: Wrapping<$t>) -> Wrapping<$t> { #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const DivAssign for Wrapping<$t> { + const impl DivAssign for Wrapping<$t> { #[inline] fn div_assign(&mut self, other: Wrapping<$t>) { *self = *self / other; @@ -371,7 +371,7 @@ fn div_assign(&mut self, other: Wrapping<$t>) { #[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const DivAssign<$t> for Wrapping<$t> { + const impl DivAssign<$t> for Wrapping<$t> { #[inline] fn div_assign(&mut self, other: $t) { *self = *self / Wrapping(other); @@ -383,7 +383,7 @@ fn div_assign(&mut self, other: $t) { #[stable(feature = "wrapping_impls", since = "1.7.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Rem for Wrapping<$t> { + const impl Rem for Wrapping<$t> { type Output = Wrapping<$t>; #[inline] @@ -397,7 +397,7 @@ fn rem(self, other: Wrapping<$t>) -> Wrapping<$t> { #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const RemAssign for Wrapping<$t> { + const impl RemAssign for Wrapping<$t> { #[inline] fn rem_assign(&mut self, other: Wrapping<$t>) { *self = *self % other; @@ -409,7 +409,7 @@ fn rem_assign(&mut self, other: Wrapping<$t>) { #[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const RemAssign<$t> for Wrapping<$t> { + const impl RemAssign<$t> for Wrapping<$t> { #[inline] fn rem_assign(&mut self, other: $t) { *self = *self % Wrapping(other); @@ -421,7 +421,7 @@ fn rem_assign(&mut self, other: $t) { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Not for Wrapping<$t> { + const impl Not for Wrapping<$t> { type Output = Wrapping<$t>; #[inline] @@ -435,7 +435,7 @@ fn not(self) -> Wrapping<$t> { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitXor for Wrapping<$t> { + const impl BitXor for Wrapping<$t> { type Output = Wrapping<$t>; #[inline] @@ -449,7 +449,7 @@ fn bitxor(self, other: Wrapping<$t>) -> Wrapping<$t> { #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitXorAssign for Wrapping<$t> { + const impl BitXorAssign for Wrapping<$t> { #[inline] fn bitxor_assign(&mut self, other: Wrapping<$t>) { *self = *self ^ other; @@ -461,7 +461,7 @@ fn bitxor_assign(&mut self, other: Wrapping<$t>) { #[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitXorAssign<$t> for Wrapping<$t> { + const impl BitXorAssign<$t> for Wrapping<$t> { #[inline] fn bitxor_assign(&mut self, other: $t) { *self = *self ^ Wrapping(other); @@ -473,7 +473,7 @@ fn bitxor_assign(&mut self, other: $t) { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitOr for Wrapping<$t> { + const impl BitOr for Wrapping<$t> { type Output = Wrapping<$t>; #[inline] @@ -487,7 +487,7 @@ fn bitor(self, other: Wrapping<$t>) -> Wrapping<$t> { #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitOrAssign for Wrapping<$t> { + const impl BitOrAssign for Wrapping<$t> { #[inline] fn bitor_assign(&mut self, other: Wrapping<$t>) { *self = *self | other; @@ -499,7 +499,7 @@ fn bitor_assign(&mut self, other: Wrapping<$t>) { #[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitOrAssign<$t> for Wrapping<$t> { + const impl BitOrAssign<$t> for Wrapping<$t> { #[inline] fn bitor_assign(&mut self, other: $t) { *self = *self | Wrapping(other); @@ -511,7 +511,7 @@ fn bitor_assign(&mut self, other: $t) { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitAnd for Wrapping<$t> { + const impl BitAnd for Wrapping<$t> { type Output = Wrapping<$t>; #[inline] @@ -525,7 +525,7 @@ fn bitand(self, other: Wrapping<$t>) -> Wrapping<$t> { #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitAndAssign for Wrapping<$t> { + const impl BitAndAssign for Wrapping<$t> { #[inline] fn bitand_assign(&mut self, other: Wrapping<$t>) { *self = *self & other; @@ -537,7 +537,7 @@ fn bitand_assign(&mut self, other: Wrapping<$t>) { #[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitAndAssign<$t> for Wrapping<$t> { + const impl BitAndAssign<$t> for Wrapping<$t> { #[inline] fn bitand_assign(&mut self, other: $t) { *self = *self & Wrapping(other); @@ -549,7 +549,7 @@ fn bitand_assign(&mut self, other: $t) { #[stable(feature = "wrapping_neg", since = "1.10.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Neg for Wrapping<$t> { + const impl Neg for Wrapping<$t> { type Output = Self; #[inline] fn neg(self) -> Self {
diff --git a/library/core/src/ops/arith.rs b/library/core/src/ops/arith.rs index afb814d..34af7d9 100644 --- a/library/core/src/ops/arith.rs +++ b/library/core/src/ops/arith.rs
@@ -95,7 +95,7 @@ macro_rules! add_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Add for $t { + const impl Add for $t { type Output = $t; #[inline] @@ -207,7 +207,7 @@ macro_rules! sub_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Sub for $t { + const impl Sub for $t { type Output = $t; #[inline] @@ -341,7 +341,7 @@ macro_rules! mul_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Mul for $t { + const impl Mul for $t { type Output = $t; #[inline] @@ -485,7 +485,7 @@ macro_rules! div_impl_integer { #[doc = $panic] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Div for $t { + const impl Div for $t { type Output = $t; #[inline] @@ -508,7 +508,7 @@ macro_rules! div_impl_float { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Div for $t { + const impl Div for $t { type Output = $t; #[inline] @@ -594,7 +594,7 @@ macro_rules! rem_impl_integer { #[doc = $panic] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Rem for $t { + const impl Rem for $t { type Output = $t; #[inline] @@ -632,7 +632,7 @@ macro_rules! rem_impl_float { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Rem for $t { + const impl Rem for $t { type Output = $t; #[inline] @@ -710,7 +710,7 @@ macro_rules! neg_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Neg for $t { + const impl Neg for $t { type Output = $t; #[inline] @@ -783,7 +783,7 @@ macro_rules! add_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const AddAssign for $t { + const impl AddAssign for $t { #[inline] #[track_caller] #[rustc_inherit_overflow_checks] @@ -854,7 +854,7 @@ macro_rules! sub_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const SubAssign for $t { + const impl SubAssign for $t { #[inline] #[track_caller] #[rustc_inherit_overflow_checks] @@ -916,7 +916,7 @@ macro_rules! mul_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const MulAssign for $t { + const impl MulAssign for $t { #[inline] #[track_caller] #[rustc_inherit_overflow_checks] @@ -978,7 +978,7 @@ macro_rules! div_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const DivAssign for $t { + const impl DivAssign for $t { #[inline] #[track_caller] fn div_assign(&mut self, other: $t) { *self /= other } @@ -1043,7 +1043,7 @@ macro_rules! rem_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const RemAssign for $t { + const impl RemAssign for $t { #[inline] #[track_caller] fn rem_assign(&mut self, other: $t) { *self %= other }
diff --git a/library/core/src/ops/bit.rs b/library/core/src/ops/bit.rs index b6daa0f..7c00853 100644 --- a/library/core/src/ops/bit.rs +++ b/library/core/src/ops/bit.rs
@@ -56,7 +56,7 @@ macro_rules! not_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const Not for $t { + const impl Not for $t { type Output = $t; #[inline] @@ -171,7 +171,7 @@ macro_rules! bitand_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitAnd for $t { + const impl BitAnd for $t { type Output = $t; #[inline] @@ -275,7 +275,7 @@ macro_rules! bitor_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitOr for $t { + const impl BitOr for $t { type Output = $t; #[inline] @@ -379,7 +379,7 @@ macro_rules! bitxor_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitXor for $t { + const impl BitXor for $t { type Output = $t; #[inline] @@ -743,7 +743,7 @@ macro_rules! bitand_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitAndAssign for $t { + const impl BitAndAssign for $t { #[inline] fn bitand_assign(&mut self, other: $t) { *self &= other } } @@ -818,7 +818,7 @@ macro_rules! bitor_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitOrAssign for $t { + const impl BitOrAssign for $t { #[inline] fn bitor_assign(&mut self, other: $t) { *self |= other } } @@ -893,7 +893,7 @@ macro_rules! bitxor_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] #[rustc_const_unstable(feature = "const_ops", issue = "143802")] - impl const BitXorAssign for $t { + const impl BitXorAssign for $t { #[inline] fn bitxor_assign(&mut self, other: $t) { *self ^= other } }
diff --git a/library/core/src/pat.rs b/library/core/src/pat.rs index 77fbea5..0cf9f10 100644 --- a/library/core/src/pat.rs +++ b/library/core/src/pat.rs
@@ -44,7 +44,7 @@ macro_rules! impl_range_pat { ($($ty:ty,)*) => { $( #[rustc_const_unstable(feature = "pattern_type_range_trait", issue = "123646")] - impl const RangePattern for $ty { + const impl RangePattern for $ty { const MIN: $ty = <$ty>::MIN; const MAX: $ty = <$ty>::MAX; fn sub_one(self) -> Self {
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index ede5985..9b077f1 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs
@@ -5298,7 +5298,6 @@ pub fn element_offset(&self, element: &T) -> Option<usize> { /// # Examples /// Basic usage: /// ``` - /// #![feature(substr_range)] /// use core::range::Range; /// /// let nums = &[0, 5, 10, 0, 0, 5]; @@ -5313,7 +5312,7 @@ pub fn element_offset(&self, element: &T) -> Option<usize> { /// assert_eq!(iter.next(), Some(Range { start: 5, end: 6 })); /// ``` #[must_use] - #[unstable(feature = "substr_range", issue = "126769")] + #[stable(feature = "substr_range", since = "CURRENT_RUSTC_VERSION")] pub fn subslice_range(&self, subslice: &[T]) -> Option<core::range::Range<usize>> { if T::IS_ZST { panic!("elements are zero-sized");
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 68cdb69..78cb8ca 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs
@@ -3193,7 +3193,6 @@ pub fn escape_unicode(&self) -> EscapeUnicode<'_> { /// /// # Examples /// ``` - /// #![feature(substr_range)] /// use core::range::Range; /// /// let data = "a, b, b, a"; @@ -3205,7 +3204,7 @@ pub fn escape_unicode(&self) -> EscapeUnicode<'_> { /// assert_eq!(iter.next(), Some(Range { start: 9, end: 10 })); /// ``` #[must_use] - #[unstable(feature = "substr_range", issue = "126769")] + #[stable(feature = "substr_range", since = "CURRENT_RUSTC_VERSION")] pub fn substr_range(&self, substr: &str) -> Option<Range<usize>> { self.as_bytes().subslice_range(substr.as_bytes()) }
diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 4f22e01..e886582 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs
@@ -2593,7 +2593,7 @@ fn default() -> Self { #[$stable_from] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] - impl const From<$int_type> for $atomic_type { + const impl From<$int_type> for $atomic_type { #[doc = concat!("Converts an `", stringify!($int_type), "` into an `", stringify!($atomic_type), "`.")] #[inline] fn from(v: $int_type) -> Self { Self::new(v) }
diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 14f0980..63b76915 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs
@@ -418,15 +418,16 @@ unsafe impl Sync for Waker {} impl Waker { /// Wakes up the task associated with this `Waker`. /// - /// As long as the executor keeps running and the task is not finished, it is - /// guaranteed that each invocation of [`wake()`](Self::wake) (or + /// As long as the executor keeps running and the task is not finished, + /// it is guaranteed that each invocation of [`wake()`](Self::wake) (or /// [`wake_by_ref()`](Self::wake_by_ref)) will be followed by at least one - /// [`poll()`] of the task to which this `Waker` belongs. This makes - /// it possible to temporarily yield to other tasks while running potentially - /// unbounded processing loops. + /// [`poll()`] of the task to which this `Waker` belongs, such that the call to + /// [`wake()`](Self::wake) (or [`wake_by_ref()`](Self::wake_by_ref)) _happens-before_ + /// the beginning of the invocation of [`poll()`]. This makes it possible to temporarily + /// yield to other tasks while running potentially unbounded processing loops. /// /// Note that the above implies that multiple wake-ups may be coalesced into a - /// single [`poll()`] invocation by the runtime. + /// single [`poll()`] invocation by the executor. /// /// Also note that yielding to competing tasks is not guaranteed: it is the /// executor’s choice which task to run and the executor may choose to run the
diff --git a/library/core/src/tuple.rs b/library/core/src/tuple.rs index adfb027..6dd26d3 100644 --- a/library/core/src/tuple.rs +++ b/library/core/src/tuple.rs
@@ -25,7 +25,7 @@ macro_rules! tuple_impls { $($T)+ @ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] - impl<$($T: [const] PartialEq),+> const PartialEq for ($($T,)+) { + const impl<$($T: [const] PartialEq),+> PartialEq for ($($T,)+) { #[inline] fn eq(&self, other: &($($T,)+)) -> bool { $( ${ignore($T)} self.${index()} == other.${index()} )&&+ @@ -41,7 +41,7 @@ fn ne(&self, other: &($($T,)+)) -> bool { $($T)+ @ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] - impl<$($T: [const] Eq),+> const Eq for ($($T,)+) + const impl<$($T: [const] Eq),+> Eq for ($($T,)+) {} } @@ -63,7 +63,7 @@ impl<$($T),+> StructuralPartialEq for ($($T,)+) $($T)+ @ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] - impl<$($T: [const] PartialOrd),+> const PartialOrd for ($($T,)+) + const impl<$($T: [const] PartialOrd),+> PartialOrd for ($($T,)+) { #[inline] fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> { @@ -108,7 +108,7 @@ fn __chaining_ge(&self, other: &($($T,)+)) -> ControlFlow<bool> { $($T)+ @ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] - impl<$($T: [const] Ord),+> const Ord for ($($T,)+) + const impl<$($T: [const] Ord),+> Ord for ($($T,)+) { #[inline] fn cmp(&self, other: &($($T,)+)) -> Ordering { @@ -121,7 +121,7 @@ fn cmp(&self, other: &($($T,)+)) -> Ordering { $($T)+ @ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_default", issue = "143894")] - impl<$($T: [const] Default),+> const Default for ($($T,)+) { + const impl<$($T: [const] Default),+> Default for ($($T,)+) { #[inline] fn default() -> ($($T,)+) { ($({ let x: $T = Default::default(); x},)+)
diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index e335fe1..98b00c6 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs
@@ -197,6 +197,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// Errors returned when trying to retrieve a literal unescaped value. #[unstable(feature = "proc_macro_value", issue = "136652")] #[derive(Debug, PartialEq, Eq)] +#[non_exhaustive] pub enum ConversionErrorKind { /// The literal failed to be escaped, take a look at [`EscapeError`] for more information. FailedToUnescape(EscapeError),
diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index 2e8779e..b673abd 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs
@@ -876,6 +876,29 @@ pub fn try_clone(&self) -> io::Result<TcpListener> { /// is established. When established, the corresponding [`TcpStream`] and the /// remote peer's address will be returned. /// + /// # Errors + /// + /// Some errors this function returns do not indicate a problem with the + /// listener itself, and a program serving a long-lived listener will + /// usually want to handle them and keep accepting connections rather than + /// treat them as fatal. These include, but are not limited to: + /// + /// - An error specific to a single incoming connection that failed before + /// it could be accepted, such as one aborted by the peer + /// ([`ConnectionAborted`]). A later call may succeed immediately. + /// - An error from reaching the per-process or system-wide open file + /// descriptor limit. The call can be retried once other file descriptors + /// have been closed, typically after a short delay. + /// - An error from failing to allocate memory while accepting a connection + /// ([`OutOfMemory`]). + /// + /// Which errors can occur is platform-specific. On Unix, [`Interrupted`] + /// errors are retried internally rather than being returned. + /// + /// [`ConnectionAborted`]: io::ErrorKind::ConnectionAborted + /// [`OutOfMemory`]: io::ErrorKind::OutOfMemory + /// [`Interrupted`]: io::ErrorKind::Interrupted + /// /// # Examples /// /// ```no_run @@ -902,6 +925,11 @@ pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> { /// the peer's [`SocketAddr`] structure. Iterating over it is equivalent to /// calling [`TcpListener::accept`] in a loop. /// + /// # Errors + /// + /// Each connection yielded by the iterator can fail for the same reasons as + /// [`TcpListener::accept`]; see its documentation for details. + /// /// # Examples /// /// ```no_run @@ -937,6 +965,11 @@ pub fn incoming(&self) -> Incoming<'_> { /// the peer's [`SocketAddr`] structure. Iterating over it is equivalent to /// calling [`TcpListener::accept`] in a loop. /// + /// # Errors + /// + /// Each connection yielded by the iterator can fail for the same reasons as + /// [`TcpListener::accept`]; see its documentation for details. + /// /// # Examples /// /// ```no_run
diff --git a/library/std/src/path.rs b/library/std/src/path.rs index cfcaabf..2687a12 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs
@@ -3176,7 +3176,9 @@ fn _with_extension(&self, extension: &OsStr) -> PathBuf { /// Creates an owned [`PathBuf`] like `self` but with the extension added. /// - /// See [`PathBuf::add_extension`] for more details. + /// See [`PathBuf::add_extension`] for more details. The return value of + /// [`PathBuf::add_extension`] is ignored, which means no extension + /// will be added to paths with no [`Path::file_name`]. /// /// # Examples /// @@ -3190,6 +3192,13 @@ fn _with_extension(&self, extension: &OsStr) -> PathBuf { /// assert_eq!(path.with_added_extension(""), PathBuf::from("foo.tar.gz")); /// assert_eq!(path.with_added_extension("xz"), PathBuf::from("foo.tar.gz.xz")); /// assert_eq!(path.with_added_extension("").with_added_extension("txt"), PathBuf::from("foo.tar.gz.txt")); + /// + /// let path = Path::new("/"); + /// assert_eq!(path.with_added_extension("gz"), PathBuf::from("/")); + /// let path = Path::new("/dir/"); + /// assert_eq!(path.with_added_extension("gz"), PathBuf::from("/dir.gz")); + /// let path = Path::new("/dir/.."); + /// assert_eq!(path.with_added_extension("gz"), PathBuf::from("/dir/..")); /// ``` #[stable(feature = "path_add_extension", since = "1.91.0")] pub fn with_added_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {
diff --git a/library/std/src/sync/once_lock.rs b/library/std/src/sync/once_lock.rs index 8e69e7a..c75a974 100644 --- a/library/std/src/sync/once_lock.rs +++ b/library/std/src/sync/once_lock.rs
@@ -656,10 +656,10 @@ impl<T> From<T> for OnceLock<T> { /// ``` #[inline] fn from(value: T) -> Self { - let cell = Self::new(); - match cell.set(value) { - Ok(()) => cell, - Err(_) => unreachable!(), + OnceLock { + once: Once::new_complete(), + value: UnsafeCell::new(MaybeUninit::new(value)), + _marker: PhantomData, } } }
diff --git a/library/std/src/sys/process/unix/unix.rs b/library/std/src/sys/process/unix/unix.rs index eff522f..529cdaf 100644 --- a/library/std/src/sys/process/unix/unix.rs +++ b/library/std/src/sys/process/unix/unix.rs
@@ -881,7 +881,7 @@ union Cmsg { // we send the 0-length message even if we failed to acquire the pidfd // so we get a consistent SEQPACKET order - match cvt_r(|| libc::sendmsg(sock.as_raw(), &msg, 0)) { + match cvt_r(|| libc::sendmsg(sock.as_raw(), &msg, libc::MSG_EOR)) { Ok(0) => {} other => rtabort!("failed to communicate with parent process. {:?}", other), }
diff --git a/library/stdarch/crates/core_arch/src/loongarch64/simd.rs b/library/stdarch/crates/core_arch/src/loongarch64/simd.rs index 2c4a0f8..32f1915 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/simd.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/simd.rs
@@ -18,7 +18,7 @@ pub(super) const trait SimdExt: Sized { macro_rules! impl_simd_ext { ($v:ident, $e:ty) => { #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] - impl const SimdExt for crate::core_arch::simd::$v { + const impl SimdExt for crate::core_arch::simd::$v { type Elem = $e; #[inline(always)]
diff --git a/library/stdarch/crates/core_arch/src/simd.rs b/library/stdarch/crates/core_arch/src/simd.rs index 9a756ee..30c3125 100644 --- a/library/stdarch/crates/core_arch/src/simd.rs +++ b/library/stdarch/crates/core_arch/src/simd.rs
@@ -88,7 +88,7 @@ fn clone(&self) -> Self { #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] #[rustfmt::skip] // FIXME: https://github.com/rust-lang/stdarch/pull/2133#issuecomment-4524350350 -impl<T: SimdElement, const N: usize> const crate::cmp::PartialEq for Simd<T, N> { +const impl<T: SimdElement, const N: usize> crate::cmp::PartialEq for Simd<T, N> { #[inline] fn eq(&self, other: &Self) -> bool { self.as_array() == other.as_array() @@ -301,7 +301,7 @@ fn clone(&self) -> Self { #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] #[rustfmt::skip] // FIXME: https://github.com/rust-lang/stdarch/pull/2133#issuecomment-4524350350 -impl<T: SimdElement, const N: usize> const crate::cmp::PartialEq for SimdM<T, N> { +const impl<T: SimdElement, const N: usize> crate::cmp::PartialEq for SimdM<T, N> { #[inline] fn eq(&self, other: &Self) -> bool { self.as_array() == other.as_array()
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index fd3e88e..2231e08 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs
@@ -2120,9 +2120,11 @@ pub fn is_forced_compiler(&self) -> bool { } fn envify(s: &str) -> String { + // Converting foo-bar to FOO_BAR is a fairly idomatic mapping to an environment variable name. + // We also convert '.' to '_' to fix https://github.com/rust-lang/rust/issues/158090 s.chars() .map(|c| match c { - '-' => '_', + '-' | '.' => '_', c => c, }) .flat_map(|c| c.to_uppercase())
diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-pre-stabilization/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-next-trait-solver-polonius/Dockerfile similarity index 78% rename from src/ci/docker/host-x86_64/x86_64-gnu-pre-stabilization/Dockerfile rename to src/ci/docker/host-x86_64/x86_64-gnu-next-trait-solver-polonius/Dockerfile index 8b61470..4198092 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-pre-stabilization/Dockerfile +++ b/src/ci/docker/host-x86_64/x86_64-gnu-next-trait-solver-polonius/Dockerfile
@@ -25,5 +25,5 @@ ENV RUST_CONFIGURE_ARGS="--build=x86_64-unknown-linux-gnu" -COPY scripts/x86_64-gnu-pre-stabilization.sh /scripts/ -ENV SCRIPT="/scripts/x86_64-gnu-pre-stabilization.sh" +COPY scripts/x86_64-gnu-next-trait-solver-polonius.sh /scripts/ +ENV SCRIPT="/scripts/x86_64-gnu-next-trait-solver-polonius.sh"
diff --git a/src/ci/docker/scripts/x86_64-gnu-pre-stabilization.sh b/src/ci/docker/scripts/x86_64-gnu-next-trait-solver-polonius.sh similarity index 75% rename from src/ci/docker/scripts/x86_64-gnu-pre-stabilization.sh rename to src/ci/docker/scripts/x86_64-gnu-next-trait-solver-polonius.sh index 81c1c43..9d1bc8d 100755 --- a/src/ci/docker/scripts/x86_64-gnu-pre-stabilization.sh +++ b/src/ci/docker/scripts/x86_64-gnu-next-trait-solver-polonius.sh
@@ -5,12 +5,14 @@ # This script tests features intended to be stabilized in 2026. We want to # ensure they don't regress until then. -# 1. For the new trait solver, we want to: +# 1. For the next trait solver, we want to: # - ensure it can build the standard library +# - ensure it actually bootstraps # -# FIXME: we also need to ensure it actually bootstraps. +# We test both by building the _stage 2_ library with the next solver enabled +# at stage 1 via rustflags. -RUSTFLAGS_NOT_BOOTSTRAP="-Znext-solver=globally" ../x build library --stage 1 +RUSTFLAGS_NOT_BOOTSTRAP="-Znext-solver=globally" ../x build library --stage 2 # 2. For the polonius alpha, we run the UI tests under the polonius # compare-mode.
diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 2f92a300..25593f1 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml
@@ -159,8 +159,8 @@ # This job tests features we want to stabilize soon, to ensure they don't # regress. - - name: x86_64-gnu-pre-stabilization - doc_url: https://rustc-dev-guide.rust-lang.org/tests/pre-stabilization-ci-job.html + - name: x86_64-gnu-next-trait-solver-polonius + doc_url: https://rustc-dev-guide.rust-lang.org/tests/x86_64-gnu-next-trait-solver-polonius-ci-job.html env: CODEGEN_BACKENDS: llvm <<: *job-linux-4c
diff --git a/src/doc/rustc-dev-guide/src/compiler-debugging.md b/src/doc/rustc-dev-guide/src/compiler-debugging.md index dc9d4b9..1750dee 100644 --- a/src/doc/rustc-dev-guide/src/compiler-debugging.md +++ b/src/doc/rustc-dev-guide/src/compiler-debugging.md
@@ -275,6 +275,7 @@ |----------------|-------------| | `rustc_dump_def_parents` | Dumps the chain of `DefId` parents of certain definitions. | | `rustc_dump_def_path` | Dumps the [`def_path_str`] of an item. | +| `rustc_dump_generics` | Dumps the generics of an item. | | `rustc_dump_hidden_type_of_opaques` | Dumps the [hidden type of each opaque types][opaq] in the crate. | | `rustc_dump_inferred_outlives` | Dumps implied bounds of an item. More precisely, the [`inferred_outlives_of`] an item. | | `rustc_dump_item_bounds` | Dumps the [`item_bounds`] of an item. |
diff --git a/src/doc/rustc/src/platform-support/wasm32-wasip1-threads.md b/src/doc/rustc/src/platform-support/wasm32-wasip1-threads.md index cc66b2f..9e83356 100644 --- a/src/doc/rustc/src/platform-support/wasm32-wasip1-threads.md +++ b/src/doc/rustc/src/platform-support/wasm32-wasip1-threads.md
@@ -19,7 +19,6 @@ ## Target maintainers [@g0djan](https://github.com/g0djan) -[@abrown](https://github.com/abrown) [@loganek](https://github.com/loganek) ## Requirements
diff --git a/src/doc/unstable-book/src/compiler-flags/lint-rust-version.md b/src/doc/unstable-book/src/compiler-flags/hint-msrv.md similarity index 93% rename from src/doc/unstable-book/src/compiler-flags/lint-rust-version.md rename to src/doc/unstable-book/src/compiler-flags/hint-msrv.md index ecc0e7f..456c50f 100644 --- a/src/doc/unstable-book/src/compiler-flags/lint-rust-version.md +++ b/src/doc/unstable-book/src/compiler-flags/hint-msrv.md
@@ -1,4 +1,4 @@ -# `lint-rust-version` +# `hint-msrv` The tracking issue for this feature is: [#157574](https://github.com/rust-lang/rust/issues/157574).
diff --git a/src/librustdoc/html/span_map.rs b/src/librustdoc/html/span_map.rs index 517b538..6b187a6 100644 --- a/src/librustdoc/html/span_map.rs +++ b/src/librustdoc/html/span_map.rs
@@ -144,6 +144,10 @@ fn handle_path(&mut self, path: &hir::Path<'_>, only_use_last_segment: bool) { let span = path.segments.last().map_or(path.span, |seg| seg.ident.span); // In case the path ends with generics, we remove them from the span. let span = if only_use_last_segment { + if path.span.from_expansion() { + // For now we don't handle span from macro expansions so nothing to do here. + return; + } span } else { // In `use` statements, the included item is not in the path segments. However,
diff --git a/src/rustdoc-json-types/Cargo.toml b/src/rustdoc-json-types/Cargo.toml index 7e4e53c..9e18691 100644 --- a/src/rustdoc-json-types/Cargo.toml +++ b/src/rustdoc-json-types/Cargo.toml
@@ -18,4 +18,4 @@ [dev-dependencies] serde_json = "1.0" -bincode = "1" +postcard = { version = "1", default-features = false, features = ["alloc"] }
diff --git a/src/rustdoc-json-types/tests.rs b/src/rustdoc-json-types/tests.rs index e878350..844dc45 100644 --- a/src/rustdoc-json-types/tests.rs +++ b/src/rustdoc-json-types/tests.rs
@@ -13,9 +13,9 @@ fn test_struct_info_roundtrip() { let de_s = serde_json::from_str(&struct_json).unwrap(); assert_eq!(s, de_s); - // Bincode - let encoded: Vec<u8> = bincode::serialize(&s).unwrap(); - let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap(); + // Postcard + let encoded: Vec<u8> = postcard::to_allocvec(&s).unwrap(); + let decoded: ItemEnum = postcard::from_bytes(&encoded).unwrap(); assert_eq!(s, decoded); } @@ -33,9 +33,9 @@ fn test_union_info_roundtrip() { let de_u = serde_json::from_str(&union_json).unwrap(); assert_eq!(u, de_u); - // Bincode - let encoded: Vec<u8> = bincode::serialize(&u).unwrap(); - let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap(); + // Postcard + let encoded: Vec<u8> = postcard::to_allocvec(&u).unwrap(); + let decoded: ItemEnum = postcard::from_bytes(&encoded).unwrap(); assert_eq!(u, decoded); } @@ -59,7 +59,7 @@ mod rkyv { /// A test to exercise the (de)serialization roundtrip for a representative selection of types, /// covering most of the rkyv-specific attributes we had to had. fn test_rkyv_roundtrip() { - // Standard derives: a plain struct and union, mirroring the existing serde/bincode tests. + // Standard derives: a plain struct and union, mirroring the existing serde/postcard tests. let s = ItemEnum::Struct(Struct { generics: Generics { params: vec![], where_predicates: vec![] }, kind: StructKind::Plain { fields: vec![Id(1), Id(2)], has_stripped_fields: false },
diff --git a/src/tools/rustfmt/tests/source/impls.rs b/src/tools/rustfmt/tests/source/impls.rs index dcd1f0c..8baa704 100644 --- a/src/tools/rustfmt/tests/source/impls.rs +++ b/src/tools/rustfmt/tests/source/impls.rs
@@ -170,7 +170,7 @@ fn foo() {} impl<'seq1, 'seq2, 'body, 'scope, Channel> Adc12< Dual, MasterRunningDma<'seq1, 'body, 'scope, Channel>, SlaveRunningDma<'seq2, 'body, 'scope>, > where Channel: DmaChannel, {} // #4084 -impl const std::default::Default for Struct { +const impl std::default::Default for Struct { #[inline] fn default() -> Self { Self { f: 12.5 }
diff --git a/src/tools/rustfmt/tests/source/type.rs b/src/tools/rustfmt/tests/source/type.rs index 09ec22c..752cf2e 100644 --- a/src/tools/rustfmt/tests/source/type.rs +++ b/src/tools/rustfmt/tests/source/type.rs
@@ -146,7 +146,7 @@ trait T: [ const ] Super {} const fn not_quite_const<S: [ const ] T>() -> i32 { <S as T>::CONST } -impl const T for U {} +const impl T for U {} fn apit(_: impl [ const ] T) {}
diff --git a/tests/assembly-llvm/riscv-redundant-memory-stores.rs b/tests/assembly-llvm/riscv-redundant-memory-stores.rs deleted file mode 100644 index acdb69d..0000000 --- a/tests/assembly-llvm/riscv-redundant-memory-stores.rs +++ /dev/null
@@ -1,33 +0,0 @@ -//! Regression test for <https://github.com/rust-lang/rust/issues/149762>: - -//@ assembly-output: emit-asm -//@ compile-flags: -Copt-level=3 --target riscv64gc-unknown-linux-gnu -//@ needs-llvm-components: riscv -//@ only-riscv64 - -pub struct SomeComplexType { - a: u64, - b: u64, - c: u64, -} - -// CHECK-LABEL: with_mut_param -#[no_mangle] -pub fn with_mut_param(mut a: SomeComplexType) -> SomeComplexType { - // CHECK: ld a2, 0(a1) - // CHECK-NEXT: ld a3, 8(a1) - // CHECK-NEXT: ld a4, 16(a1) - // CHECK-NEXT: addi a2, a2, 10 - // CHECK-NEXT: addi a3, a3, 2 - // CHECK-NEXT: sd a2, 0(a1) - // CHECK-NEXT: sd a3, 8(a1) - // CHECK-NEXT: sd a2, 0(a0) - // CHECK-NEXT: sd a3, 8(a0) - // CHECK-NEXT: sd a4, 16(a0) - // CHECK-NEXT: ret - a.a += 10; - a.b += 2; - a -} - -fn main() {}
diff --git a/tests/auxiliary/minisimd.rs b/tests/auxiliary/minisimd.rs index 38e2621..e6851b5 100644 --- a/tests/auxiliary/minisimd.rs +++ b/tests/auxiliary/minisimd.rs
@@ -170,20 +170,20 @@ pub const fn splat(a: T) -> Self macro_rules! impl_traits { ($($const_:ident)?) => { - impl<T: $([$const_])? PartialEq, const N: usize> $($const_)? PartialEq for Simd<T, N> { + $($const_)? impl<T: $([$const_])? PartialEq, const N: usize> PartialEq for Simd<T, N> { fn eq(&self, other: &Self) -> bool { self.as_array() == other.as_array() } } - impl<T, const N: usize> $($const_)? core::ops::Index<usize> for Simd<T, N> { + $($const_)? impl<T, const N: usize> core::ops::Index<usize> for Simd<T, N> { type Output = T; fn index(&self, i: usize) -> &T { &self.as_array()[i] } } - impl<T: $([$const_])? PartialEq, const N: usize> $($const_)? PartialEq for PackedSimd<T, N> + $($const_)? impl<T: $([$const_])? PartialEq, const N: usize> PartialEq for PackedSimd<T, N> { fn eq(&self, other: &Self) -> bool { self.as_array() == other.as_array()
diff --git "a/tests/mir-opt/unusual_item_types.Test-X-\173constructor\0430\175.built.after.mir" "b/tests/mir-opt/unusual_item_types.Test-X-\173constructor\0430\175.runtime-optimized.after.mir" similarity index 72% rename from "tests/mir-opt/unusual_item_types.Test-X-\173constructor\0430\175.built.after.mir" rename to "tests/mir-opt/unusual_item_types.Test-X-\173constructor\0430\175.runtime-optimized.after.mir" index 1e497b4..527089e 100644 --- "a/tests/mir-opt/unusual_item_types.Test-X-\173constructor\0430\175.built.after.mir" +++ "b/tests/mir-opt/unusual_item_types.Test-X-\173constructor\0430\175.runtime-optimized.after.mir"
@@ -1,4 +1,4 @@ -// MIR for `Test::X` after built +// MIR for `Test::X` after runtime-optimized fn Test::X(_1: usize) -> Test { let mut _0: Test;
diff --git a/tests/mir-opt/unusual_item_types.rs b/tests/mir-opt/unusual_item_types.rs index 8ec15b4..e547246 100644 --- a/tests/mir-opt/unusual_item_types.rs +++ b/tests/mir-opt/unusual_item_types.rs
@@ -11,7 +11,7 @@ impl A { } // See #59021 -// EMIT_MIR unusual_item_types.Test-X-{constructor#0}.built.after.mir +// EMIT_MIR unusual_item_types.Test-X-{constructor#0}.runtime-optimized.after.mir enum Test { X(usize), Y { a: usize },
diff --git a/tests/rustdoc-html/constant/const-trait-and-impl-methods.rs b/tests/rustdoc-html/constant/const-trait-and-impl-methods.rs index 987a816..c2ac9d1 100644 --- a/tests/rustdoc-html/constant/const-trait-and-impl-methods.rs +++ b/tests/rustdoc-html/constant/const-trait-and-impl-methods.rs
@@ -20,7 +20,7 @@ pub struct NonConstImpl {} //@ !has - '//*[@id="method.required"]' 'const' //@ has - '//*[@id="method.defaulted"]' 'fn defaulted()' //@ !has - '//*[@id="method.defaulted"]' 'const' -impl const Tr for ConstImpl { +const impl Tr for ConstImpl { fn required() {} }
diff --git a/tests/rustdoc-html/constant/rfc-2632-const-trait-impl.rs b/tests/rustdoc-html/constant/rfc-2632-const-trait-impl.rs index f263410..c304080 100644 --- a/tests/rustdoc-html/constant/rfc-2632-const-trait-impl.rs +++ b/tests/rustdoc-html/constant/rfc-2632-const-trait-impl.rs
@@ -36,7 +36,7 @@ fn a<A: /* [const] */ Fn() /* + [const] Destruct */>() //@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn' //@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '[const]' //@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/div[@class="where"]' ': Fn' -impl<T: /* [const] */ Fn() /* + [const] Destruct */> const Tr<T> for T +const impl<T: /* [const] */ Fn() /* + [const] Destruct */> Tr<T> for T where Option<T>: /* [const] */ Fn() /* + [const] Destruct */, {
diff --git a/tests/rustdoc-html/jump-to-def/item-with-derive.rs b/tests/rustdoc-html/jump-to-def/item-with-derive.rs new file mode 100644 index 0000000..a3e034f --- /dev/null +++ b/tests/rustdoc-html/jump-to-def/item-with-derive.rs
@@ -0,0 +1,21 @@ +// This test ensures that the item name will link to its item's page even if there +// is a `#[derive(...)]`. +// This is a regression test for <https://github.com/rust-lang/rust/issues/158050>. + +//@ compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +//@ has 'src/foo/item-with-derive.rs.html' +//@ has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' +#[derive(Debug)] +pub struct Bar { + x: u8, +} + +// Same test with an enum just in case... +//@ has - '//a[@href="../../foo/enum.Blob.html"]' 'Blob' +#[derive(Debug)] +pub enum Blob { + X, +}
diff --git a/tests/ui/attributes/dump_generics.rs b/tests/ui/attributes/dump_generics.rs new file mode 100644 index 0000000..8456bcc --- /dev/null +++ b/tests/ui/attributes/dump_generics.rs
@@ -0,0 +1,94 @@ +//@ normalize-stderr: "DefId\(.+?\)" -> "DefId(..)" + +#![feature(rustc_attrs)] +#![feature(trait_alias)] +#![feature(stmt_expr_attributes)] + +#[rustc_dump_generics] +trait NiceOfTheFoundation<'_a: '_a, '_b, const N: usize, T, U: Clone> { + //~^ ERROR: rustc_dump_generics: DefId(0:3 ~ dump_generics[c1f6]::NiceOfTheFoundation) + + #[rustc_dump_generics] + type ToInviteUs<V: PartialEq>; + //~^ ERROR: rustc_dump_generics: DefId(0:9 ~ dump_generics[c1f6]::NiceOfTheFoundation::ToInviteUs) + + #[rustc_dump_generics] + const OVER_FOR: usize; + //~^ ERROR: rustc_dump_generics: DefId(0:11 ~ dump_generics[c1f6]::NiceOfTheFoundation::OVER_FOR) + + #[rustc_dump_generics] + fn a_picnic<const NN: usize>( //~ ERROR: rustc_dump_generics: DefId(0:12 ~ dump_generics[c1f6]::NiceOfTheFoundation::a_picnic) + &self, + eh: [u8; N], + ferris: [u32; NN] + ) { } +} + +#[rustc_dump_generics] +pub trait IHopeItMadeLotsOfCode<'a, 'b, const N: usize, T, U: Clone> +//~^ ERROR: rustc_dump_generics: DefId(0:16 ~ dump_generics[c1f6]::IHopeItMadeLotsOfCode) + = NiceOfTheFoundation<'a, 'b, N, T, U>; + +#[rustc_dump_generics] +struct LookItsFromCorro<'a, 'b, const N: usize, T, U: Clone> { + //~^ ERROR: rustc_dump_generics: DefId(0:22 ~ dump_generics[c1f6]::LookItsFromCorro) + dear_pesky_engineers: &'a T, + the_rustaceans_and_i: &'b [U; N] +} + +#[rustc_dump_generics] +enum HaveTakenOver<'a: 'a, 'b, const N: usize, T, U: Clone> { + //~^ ERROR: rustc_dump_generics: DefId(0:31 ~ dump_generics[c1f6]::HaveTakenOver) + The(&'a T), + CratesIo(&'b U), + Kingdom([(); N]), +} + +#[rustc_dump_generics] +union TheFoundation<'a: 'a, 'b, const N: usize, T, U: Clone> { + //~^ ERROR: rustc_dump_generics: DefId(0:47 ~ dump_generics[c1f6]::TheFoundation) + is_now_a_permanent_guest: &'a T, + at_one_of_my_seven_pull_requests: &'b [U; N], +} + +#[rustc_dump_generics] +const fn i_dare_you<'a: 'a, 'b, const N: usize, T, U>(you_can: &'a bool, _: &'b [(T, U); N]) { + //~^ ERROR: rustc_dump_generics: DefId(0:56 ~ dump_generics[c1f6]::i_dare_you) + let _to_find_it = if *you_can { 1 } else { 2 }; + + let we_got_to_find_the_foundation = + #[rustc_dump_generics] + || {}; + // and you gotta help us! +} + +#[rustc_dump_generics] +trait IfYouNeed<'_a: '_a, '_b, const N: usize, T, U: Clone> {} +//~^ ERROR: rustc_dump_generics: DefId(0:64 ~ dump_generics[c1f6]::IfYouNeed) + +#[rustc_dump_generics] +type Instructions<'a: 'a, 'b, const N: usize, T, U: Clone> = dyn IfYouNeed<'a, 'b, N, T, U>; +//~^ ERROR: rustc_dump_generics: DefId(0:70 ~ dump_generics[c1f6]::Instructions) + +#[rustc_dump_generics] +const ON_HOW_TO_GET: usize = <() as NiceOfTheFoundation::<'static, 'static, 7, (), ()>>::OVER_FOR; +//~^ ERROR: rustc_dump_generics: DefId(0:76 ~ dump_generics[c1f6]::ON_HOW_TO_GET) + + +// FIXME: make sure we have tests for these targets. +// Allow(Target::Impl { of_trait: false }), +// Allow(Target::Impl { of_trait: true }), +// Allow(Target::Method(MethodKind::Inherent)), +// Allow(Target::Method(MethodKind::Trait { body: false })), +// Allow(Target::Method(MethodKind::Trait { body: true })), +// Allow(Target::Method(MethodKind::TraitImpl)), +// Allow(Target::Delegation { mac: false }), +// Allow(Target::Delegation { mac: true }), + +impl<'_a: '_a, '_b, const N: usize, T, U: Clone> NiceOfTheFoundation<'_a, '_b, N, T, U> for () { + type ToInviteUs<V: PartialEq> = usize; + + const OVER_FOR: usize = 7; +} + +fn main() {}
diff --git a/tests/ui/attributes/dump_generics.stderr b/tests/ui/attributes/dump_generics.stderr new file mode 100644 index 0000000..5a212e0 --- /dev/null +++ b/tests/ui/attributes/dump_generics.stderr
@@ -0,0 +1,830 @@ +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:8:1 + | +LL | trait NiceOfTheFoundation<'_a: '_a, '_b, const N: usize, T, U: Clone> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Generics { + parent: None, + parent_count: 0, + own_params: [ + GenericParamDef { + name: "Self", + def_id: DefId(..), + index: 0, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + GenericParamDef { + name: "'_a", + def_id: DefId(..), + index: 1, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "'_b", + def_id: DefId(..), + index: 2, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "N", + def_id: DefId(..), + index: 3, + pure_wrt_drop: false, + kind: Const { + has_default: false, + }, + }, + GenericParamDef { + name: "T", + def_id: DefId(..), + index: 4, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + GenericParamDef { + name: "U", + def_id: DefId(..), + index: 5, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + ], + param_def_id_to_index: [ + ( + DefId(..), + 0, + ), + ( + DefId(..), + 1, + ), + ( + DefId(..), + 2, + ), + ( + DefId(..), + 3, + ), + ( + DefId(..), + 4, + ), + ( + DefId(..), + 5, + ), + ], + has_self: true, + has_late_bound_regions: None, + } + --> $DIR/dump_generics.rs:8:1 + | +LL | trait NiceOfTheFoundation<'_a: '_a, '_b, const N: usize, T, U: Clone> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:28:1 + | +LL | pub trait IHopeItMadeLotsOfCode<'a, 'b, const N: usize, T, U: Clone> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Generics { + parent: None, + parent_count: 0, + own_params: [ + GenericParamDef { + name: "Self", + def_id: DefId(..), + index: 0, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + GenericParamDef { + name: "'a", + def_id: DefId(..), + index: 1, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "'b", + def_id: DefId(..), + index: 2, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "N", + def_id: DefId(..), + index: 3, + pure_wrt_drop: false, + kind: Const { + has_default: false, + }, + }, + GenericParamDef { + name: "T", + def_id: DefId(..), + index: 4, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + GenericParamDef { + name: "U", + def_id: DefId(..), + index: 5, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + ], + param_def_id_to_index: [ + ( + DefId(..), + 0, + ), + ( + DefId(..), + 1, + ), + ( + DefId(..), + 2, + ), + ( + DefId(..), + 3, + ), + ( + DefId(..), + 4, + ), + ( + DefId(..), + 5, + ), + ], + has_self: true, + has_late_bound_regions: None, + } + --> $DIR/dump_generics.rs:28:1 + | +LL | pub trait IHopeItMadeLotsOfCode<'a, 'b, const N: usize, T, U: Clone> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:33:1 + | +LL | struct LookItsFromCorro<'a, 'b, const N: usize, T, U: Clone> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Generics { + parent: None, + parent_count: 0, + own_params: [ + GenericParamDef { + name: "'a", + def_id: DefId(..), + index: 0, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "'b", + def_id: DefId(..), + index: 1, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "N", + def_id: DefId(..), + index: 2, + pure_wrt_drop: false, + kind: Const { + has_default: false, + }, + }, + GenericParamDef { + name: "T", + def_id: DefId(..), + index: 3, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + GenericParamDef { + name: "U", + def_id: DefId(..), + index: 4, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + ], + param_def_id_to_index: [ + ( + DefId(..), + 0, + ), + ( + DefId(..), + 1, + ), + ( + DefId(..), + 2, + ), + ( + DefId(..), + 3, + ), + ( + DefId(..), + 4, + ), + ], + has_self: false, + has_late_bound_regions: None, + } + --> $DIR/dump_generics.rs:33:1 + | +LL | struct LookItsFromCorro<'a, 'b, const N: usize, T, U: Clone> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:40:1 + | +LL | enum HaveTakenOver<'a: 'a, 'b, const N: usize, T, U: Clone> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Generics { + parent: None, + parent_count: 0, + own_params: [ + GenericParamDef { + name: "'a", + def_id: DefId(..), + index: 0, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "'b", + def_id: DefId(..), + index: 1, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "N", + def_id: DefId(..), + index: 2, + pure_wrt_drop: false, + kind: Const { + has_default: false, + }, + }, + GenericParamDef { + name: "T", + def_id: DefId(..), + index: 3, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + GenericParamDef { + name: "U", + def_id: DefId(..), + index: 4, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + ], + param_def_id_to_index: [ + ( + DefId(..), + 0, + ), + ( + DefId(..), + 1, + ), + ( + DefId(..), + 2, + ), + ( + DefId(..), + 3, + ), + ( + DefId(..), + 4, + ), + ], + has_self: false, + has_late_bound_regions: None, + } + --> $DIR/dump_generics.rs:40:1 + | +LL | enum HaveTakenOver<'a: 'a, 'b, const N: usize, T, U: Clone> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:48:1 + | +LL | union TheFoundation<'a: 'a, 'b, const N: usize, T, U: Clone> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Generics { + parent: None, + parent_count: 0, + own_params: [ + GenericParamDef { + name: "'a", + def_id: DefId(..), + index: 0, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "'b", + def_id: DefId(..), + index: 1, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "N", + def_id: DefId(..), + index: 2, + pure_wrt_drop: false, + kind: Const { + has_default: false, + }, + }, + GenericParamDef { + name: "T", + def_id: DefId(..), + index: 3, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + GenericParamDef { + name: "U", + def_id: DefId(..), + index: 4, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + ], + param_def_id_to_index: [ + ( + DefId(..), + 0, + ), + ( + DefId(..), + 1, + ), + ( + DefId(..), + 2, + ), + ( + DefId(..), + 3, + ), + ( + DefId(..), + 4, + ), + ], + has_self: false, + has_late_bound_regions: None, + } + --> $DIR/dump_generics.rs:48:1 + | +LL | union TheFoundation<'a: 'a, 'b, const N: usize, T, U: Clone> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:55:1 + | +LL | const fn i_dare_you<'a: 'a, 'b, const N: usize, T, U>(you_can: &'a bool, _: &'b [(T, U); N]) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Generics { + parent: None, + parent_count: 0, + own_params: [ + GenericParamDef { + name: "'a", + def_id: DefId(..), + index: 0, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "N", + def_id: DefId(..), + index: 1, + pure_wrt_drop: false, + kind: Const { + has_default: false, + }, + }, + GenericParamDef { + name: "T", + def_id: DefId(..), + index: 2, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + GenericParamDef { + name: "U", + def_id: DefId(..), + index: 3, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + ], + param_def_id_to_index: [ + ( + DefId(..), + 0, + ), + ( + DefId(..), + 1, + ), + ( + DefId(..), + 2, + ), + ( + DefId(..), + 3, + ), + ], + has_self: false, + has_late_bound_regions: Some( + $DIR/dump_generics.rs:55:29: 55:31 (#0), + ), + } + --> $DIR/dump_generics.rs:55:1 + | +LL | const fn i_dare_you<'a: 'a, 'b, const N: usize, T, U>(you_can: &'a bool, _: &'b [(T, U); N]) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:66:1 + | +LL | trait IfYouNeed<'_a: '_a, '_b, const N: usize, T, U: Clone> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Generics { + parent: None, + parent_count: 0, + own_params: [ + GenericParamDef { + name: "Self", + def_id: DefId(..), + index: 0, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + GenericParamDef { + name: "'_a", + def_id: DefId(..), + index: 1, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "'_b", + def_id: DefId(..), + index: 2, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "N", + def_id: DefId(..), + index: 3, + pure_wrt_drop: false, + kind: Const { + has_default: false, + }, + }, + GenericParamDef { + name: "T", + def_id: DefId(..), + index: 4, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + GenericParamDef { + name: "U", + def_id: DefId(..), + index: 5, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + ], + param_def_id_to_index: [ + ( + DefId(..), + 0, + ), + ( + DefId(..), + 1, + ), + ( + DefId(..), + 2, + ), + ( + DefId(..), + 3, + ), + ( + DefId(..), + 4, + ), + ( + DefId(..), + 5, + ), + ], + has_self: true, + has_late_bound_regions: None, + } + --> $DIR/dump_generics.rs:66:1 + | +LL | trait IfYouNeed<'_a: '_a, '_b, const N: usize, T, U: Clone> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:70:1 + | +LL | type Instructions<'a: 'a, 'b, const N: usize, T, U: Clone> = dyn IfYouNeed<'a, 'b, N, T, U>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Generics { + parent: None, + parent_count: 0, + own_params: [ + GenericParamDef { + name: "'a", + def_id: DefId(..), + index: 0, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "'b", + def_id: DefId(..), + index: 1, + pure_wrt_drop: false, + kind: Lifetime, + }, + GenericParamDef { + name: "N", + def_id: DefId(..), + index: 2, + pure_wrt_drop: false, + kind: Const { + has_default: false, + }, + }, + GenericParamDef { + name: "T", + def_id: DefId(..), + index: 3, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + GenericParamDef { + name: "U", + def_id: DefId(..), + index: 4, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + ], + param_def_id_to_index: [ + ( + DefId(..), + 0, + ), + ( + DefId(..), + 1, + ), + ( + DefId(..), + 2, + ), + ( + DefId(..), + 3, + ), + ( + DefId(..), + 4, + ), + ], + has_self: false, + has_late_bound_regions: None, + } + --> $DIR/dump_generics.rs:70:1 + | +LL | type Instructions<'a: 'a, 'b, const N: usize, T, U: Clone> = dyn IfYouNeed<'a, 'b, N, T, U>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:74:1 + | +LL | const ON_HOW_TO_GET: usize = <() as NiceOfTheFoundation::<'static, 'static, 7, (), ()>>::OVER_FOR; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Generics { + parent: None, + parent_count: 0, + own_params: [], + param_def_id_to_index: [], + has_self: false, + has_late_bound_regions: None, + } + --> $DIR/dump_generics.rs:74:1 + | +LL | const ON_HOW_TO_GET: usize = <() as NiceOfTheFoundation::<'static, 'static, 7, (), ()>>::OVER_FOR; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:12:5 + | +LL | type ToInviteUs<V: PartialEq>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Generics { + parent: Some( + DefId(..), + ), + parent_count: 6, + own_params: [ + GenericParamDef { + name: "V", + def_id: DefId(..), + index: 6, + pure_wrt_drop: false, + kind: Type { + has_default: false, + synthetic: false, + }, + }, + ], + param_def_id_to_index: [ + ( + DefId(..), + 6, + ), + ], + has_self: true, + has_late_bound_regions: None, + } + --> $DIR/dump_generics.rs:12:5 + | +LL | type ToInviteUs<V: PartialEq>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:16:5 + | +LL | const OVER_FOR: usize; + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: Generics { + parent: Some( + DefId(..), + ), + parent_count: 6, + own_params: [], + param_def_id_to_index: [], + has_self: true, + has_late_bound_regions: None, + } + --> $DIR/dump_generics.rs:16:5 + | +LL | const OVER_FOR: usize; + | ^^^^^^^^^^^^^^^^^^^^^ + +error: rustc_dump_generics: DefId(..) + --> $DIR/dump_generics.rs:20:5 + | +LL | / fn a_picnic<const NN: usize>( +LL | | &self, +LL | | eh: [u8; N], +LL | | ferris: [u32; NN] +LL | | ) { } + | |_____^ + | +note: Generics { + parent: Some( + DefId(..), + ), + parent_count: 6, + own_params: [ + GenericParamDef { + name: "NN", + def_id: DefId(..), + index: 6, + pure_wrt_drop: false, + kind: Const { + has_default: false, + }, + }, + ], + param_def_id_to_index: [ + ( + DefId(..), + 6, + ), + ], + has_self: true, + has_late_bound_regions: Some( + $DIR/dump_generics.rs:21:9: 21:10 (#0), + ), + } + --> $DIR/dump_generics.rs:20:5 + | +LL | / fn a_picnic<const NN: usize>( +LL | | &self, +LL | | eh: [u8; N], +LL | | ferris: [u32; NN] +LL | | ) { } + | |_____^ + +error: aborting due to 12 previous errors +
diff --git a/tests/ui/const-generics/const_trait_fn-issue-88433.rs b/tests/ui/const-generics/const_trait_fn-issue-88433.rs index 51c4fef..3e775f5 100644 --- a/tests/ui/const-generics/const_trait_fn-issue-88433.rs +++ b/tests/ui/const-generics/const_trait_fn-issue-88433.rs
@@ -11,7 +11,7 @@ const trait Func<T> { struct Closure; -impl const Func<&usize> for Closure { +const impl Func<&usize> for Closure { type Output = usize; fn call_once(self, arg: &usize) -> Self::Output {
diff --git a/tests/ui/const-generics/issues/issue-88119.rs b/tests/ui/const-generics/issues/issue-88119.rs index fb279dd..01791c2 100644 --- a/tests/ui/const-generics/issues/issue-88119.rs +++ b/tests/ui/const-generics/issues/issue-88119.rs
@@ -6,7 +6,7 @@ const trait ConstName { const NAME_BYTES: &'static [u8]; } -impl const ConstName for u8 { +const impl ConstName for u8 { const NAME_BYTES: &'static [u8] = b"u8"; } @@ -14,14 +14,14 @@ const fn name_len<T: ?Sized + ConstName>() -> usize { T::NAME_BYTES.len() } -impl<T: ?Sized + ConstName> const ConstName for &T +const impl<T: ?Sized + ConstName> ConstName for &T where [(); name_len::<T>()]:, { const NAME_BYTES: &'static [u8] = b"&T"; } -impl<T: ?Sized + ConstName> const ConstName for &mut T +const impl<T: ?Sized + ConstName> ConstName for &mut T where [(); name_len::<T>()]:, {
diff --git a/tests/ui/const-generics/issues/issue-98629.rs b/tests/ui/const-generics/issues/issue-98629.rs index 4d65ce8..372c781 100644 --- a/tests/ui/const-generics/issues/issue-98629.rs +++ b/tests/ui/const-generics/issues/issue-98629.rs
@@ -4,12 +4,13 @@ const trait Trait { const N: usize; } -impl const Trait for i32 {} +const impl Trait for i32 {} //~^ ERROR not all trait items implemented, missing: `N` fn f() where [(); <i32 as Trait>::N]:, -{} +{ +} fn main() {}
diff --git a/tests/ui/const-generics/issues/issue-98629.stderr b/tests/ui/const-generics/issues/issue-98629.stderr index 3e92935..4921806 100644 --- a/tests/ui/const-generics/issues/issue-98629.stderr +++ b/tests/ui/const-generics/issues/issue-98629.stderr
@@ -4,7 +4,7 @@ LL | const N: usize; | -------------- `N` from trait ... -LL | impl const Trait for i32 {} +LL | const impl Trait for i32 {} | ^^^^^^^^^^^^^^^^^^^^^^^^ missing `N` in implementation error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-closure-in-trait-impl.rs b/tests/ui/consts/const-closure-in-trait-impl.rs index 29722dd..6d13cef 100644 --- a/tests/ui/consts/const-closure-in-trait-impl.rs +++ b/tests/ui/consts/const-closure-in-trait-impl.rs
@@ -12,7 +12,7 @@ const trait T { struct S; -impl const T for S { +const impl T for S { fn a(&mut self, f: impl [const] Fn() + [const] Destruct) { f() }
diff --git a/tests/ui/consts/const-try.rs b/tests/ui/consts/const-try.rs index 46ed3cd..b6dc001 100644 --- a/tests/ui/consts/const-try.rs +++ b/tests/ui/consts/const-try.rs
@@ -15,13 +15,13 @@ struct TryMe; struct Error; -impl const FromResidual<Error> for TryMe { +const impl FromResidual<Error> for TryMe { fn from_residual(residual: Error) -> Self { TryMe } } -impl const Try for TryMe { +const impl Try for TryMe { type Output = (); type Residual = Error; fn from_output(output: Self::Output) -> Self {
diff --git a/tests/ui/consts/drop-impl-nonconst-drop-field.rs b/tests/ui/consts/drop-impl-nonconst-drop-field.rs index 9715724007..33f9310 100644 --- a/tests/ui/consts/drop-impl-nonconst-drop-field.rs +++ b/tests/ui/consts/drop-impl-nonconst-drop-field.rs
@@ -12,20 +12,20 @@ fn drop(&mut self) {} struct ConstDrop(NotConstDrop); //~^ ERROR: `NotConstDrop` does not implement `[const] Destruct` -impl const Drop for ConstDrop { +const impl Drop for ConstDrop { fn drop(&mut self) {} } struct ConstDrop2<T>(T); //~^ ERROR: `T` does not implement `[const] Destruct` -impl<T> const Drop for ConstDrop2<T> { +const impl<T> Drop for ConstDrop2<T> { fn drop(&mut self) {} } struct ConstDrop3<T>(T); -impl<T: [const] Destruct> const Drop for ConstDrop3<T> { +const impl<T: [const] Destruct> Drop for ConstDrop3<T> { fn drop(&mut self) {} }
diff --git a/tests/ui/consts/drop-impl-nonconst-drop-field.stderr b/tests/ui/consts/drop-impl-nonconst-drop-field.stderr index 5a81044..edb01ec 100644 --- a/tests/ui/consts/drop-impl-nonconst-drop-field.stderr +++ b/tests/ui/consts/drop-impl-nonconst-drop-field.stderr
@@ -7,7 +7,7 @@ note: required for this `Drop` impl --> $DIR/drop-impl-nonconst-drop-field.rs:15:1 | -LL | impl const Drop for ConstDrop { +LL | const impl Drop for ConstDrop { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0367]: `T` does not implement `[const] Destruct` @@ -19,12 +19,12 @@ note: required for this `Drop` impl --> $DIR/drop-impl-nonconst-drop-field.rs:22:1 | -LL | impl<T> const Drop for ConstDrop2<T> { +LL | const impl<T> Drop for ConstDrop2<T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider restricting type parameter `T` with unstable trait `Destruct` | -LL | impl<T: [const] Destruct> const Drop for ConstDrop2<T> { - | ++++++++++++++++++ +LL | const impl<T: [const] Destruct> Drop for ConstDrop2<T> { + | ++++++++++++++++++ error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/promoted-const-drop.rs b/tests/ui/consts/promoted-const-drop.rs index 1d1897e..a77f154 100644 --- a/tests/ui/consts/promoted-const-drop.rs +++ b/tests/ui/consts/promoted-const-drop.rs
@@ -2,7 +2,7 @@ struct A(); -impl const Drop for A { +const impl Drop for A { fn drop(&mut self) {} }
diff --git a/tests/ui/consts/promoted_const_call.rs b/tests/ui/consts/promoted_const_call.rs index 79cb2ea..1be3f43 100644 --- a/tests/ui/consts/promoted_const_call.rs +++ b/tests/ui/consts/promoted_const_call.rs
@@ -1,9 +1,15 @@ #![feature(const_trait_impl, const_destruct)] struct Panic; -impl const Drop for Panic { fn drop(&mut self) { panic!(); } } +const impl Drop for Panic { + fn drop(&mut self) { + panic!(); + } +} -pub const fn id<T>(x: T) -> T { x } +pub const fn id<T>(x: T) -> T { + x +} pub const C: () = { let _: &'static _ = &id(&Panic); //~^ ERROR: temporary value dropped while borrowed
diff --git a/tests/ui/consts/promoted_const_call.stderr b/tests/ui/consts/promoted_const_call.stderr index 7a9cdd6..cc6f52e 100644 --- a/tests/ui/consts/promoted_const_call.stderr +++ b/tests/ui/consts/promoted_const_call.stderr
@@ -1,24 +1,4 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:8:26 - | -LL | let _: &'static _ = &id(&Panic); - | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | }; - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:8:30 - | -LL | let _: &'static _ = &id(&Panic); - | ---------- ^^^^^ - temporary value is freed at the end of this statement - | | | - | | creates a temporary value which is freed while still in use - | type annotation requires that borrow lasts for `'static` - -error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_const_call.rs:14:26 | LL | let _: &'static _ = &id(&Panic); @@ -26,7 +6,7 @@ | | | type annotation requires that borrow lasts for `'static` ... -LL | } +LL | }; | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed @@ -39,7 +19,27 @@ | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:17:26 + --> $DIR/promoted_const_call.rs:20:26 + | +LL | let _: &'static _ = &id(&Panic); + | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_const_call.rs:20:30 + | +LL | let _: &'static _ = &id(&Panic); + | ---------- ^^^^^ - temporary value is freed at the end of this statement + | | | + | | creates a temporary value which is freed while still in use + | type annotation requires that borrow lasts for `'static` + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_const_call.rs:23:26 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -50,7 +50,7 @@ | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:17:27 + --> $DIR/promoted_const_call.rs:23:27 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
diff --git a/tests/ui/consts/trait_alias.rs b/tests/ui/consts/trait_alias.rs index 3d9a60c..7bda53c 100644 --- a/tests/ui/consts/trait_alias.rs +++ b/tests/ui/consts/trait_alias.rs
@@ -12,8 +12,8 @@ const trait Baz { fn baz(&self) {} } -impl const Bar for () {} -impl const Baz for () {} +const impl Bar for () {} +const impl Baz for () {} const trait Foo = [const] Bar + Baz;
diff --git a/tests/ui/consts/trait_alias_method_call.rs b/tests/ui/consts/trait_alias_method_call.rs index 75c51f8..9e6234f 100644 --- a/tests/ui/consts/trait_alias_method_call.rs +++ b/tests/ui/consts/trait_alias_method_call.rs
@@ -11,15 +11,14 @@ pub const trait Baz { fn baz(&self) {} } - impl const Bar for () {} - impl const Baz for () {} + const impl Bar for () {} + const impl Baz for () {} pub const trait Foo = [const] Bar + Baz; } use foo::Foo as _; - const _: () = { // Ok via `[const] Bar` on `Foo` ().bar();
diff --git a/tests/ui/diagnostic_namespace/on_const/misplaced_attr.rs b/tests/ui/diagnostic_namespace/on_const/misplaced_attr.rs index a580f54..940d462 100644 --- a/tests/ui/diagnostic_namespace/on_const/misplaced_attr.rs +++ b/tests/ui/diagnostic_namespace/on_const/misplaced_attr.rs
@@ -7,7 +7,7 @@ #[diagnostic::on_const(message = "tadaa", note = "boing")] //~^ ERROR: `#[diagnostic::on_const]` can only be applied to non-const trait implementations -impl const PartialEq for Foo { +const impl PartialEq for Foo { fn eq(&self, _other: &Foo) -> bool { true }
diff --git a/tests/ui/diagnostic_namespace/on_const/misplaced_attr.stderr b/tests/ui/diagnostic_namespace/on_const/misplaced_attr.stderr index 0efead6..b585451 100644 --- a/tests/ui/diagnostic_namespace/on_const/misplaced_attr.stderr +++ b/tests/ui/diagnostic_namespace/on_const/misplaced_attr.stderr
@@ -4,7 +4,7 @@ LL | #[diagnostic::on_const(message = "tadaa", note = "boing")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | -LL | impl const PartialEq for Foo { +LL | const impl PartialEq for Foo { | ---------------------------- this is a const trait implementation | note: the lint level is defined here
diff --git a/tests/ui/diagnostic_namespace/on_unknown/auxiliary/module.rs b/tests/ui/diagnostic_namespace/on_unknown/auxiliary/module.rs new file mode 100644 index 0000000..8b1a393 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/auxiliary/module.rs
@@ -0,0 +1 @@ +// empty
diff --git a/tests/ui/diagnostic_namespace/on_unknown/auxiliary/other.rs b/tests/ui/diagnostic_namespace/on_unknown/auxiliary/other.rs new file mode 100644 index 0000000..616c214 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/auxiliary/other.rs
@@ -0,0 +1,5 @@ +#![crate_type = "lib"] +#![feature(diagnostic_on_unknown)] + +#[diagnostic::on_unknown(message = "you silly, this module is empty")] +pub mod empty {}
diff --git a/tests/ui/diagnostic_namespace/on_unknown/auxiliary/other_crate_level.rs b/tests/ui/diagnostic_namespace/on_unknown/auxiliary/other_crate_level.rs new file mode 100644 index 0000000..0dd96c7 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/auxiliary/other_crate_level.rs
@@ -0,0 +1,5 @@ +#![feature(custom_inner_attributes)] +#![feature(diagnostic_on_unknown)] +#![crate_type = "lib"] + +#![diagnostic::on_unknown(message = "you silly, the crate `{This}` is empty")]
diff --git a/tests/ui/diagnostic_namespace/on_unknown/combined_use_and_module.rs b/tests/ui/diagnostic_namespace/on_unknown/combined_use_and_module.rs new file mode 100644 index 0000000..bb5584a --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/combined_use_and_module.rs
@@ -0,0 +1,29 @@ +#![crate_type = "lib"] +#![feature(diagnostic_on_unknown)] + +#[diagnostic::on_unknown( + message = "THIS MUST NEVER BE SHOWN", + label = "THIS MUST NEVER BE SHOWN", + note = "module note 1", + note = "module note 2" +)] +pub mod constants { + pub const ONE: usize = 1; + pub const TWO: usize = 3; + pub const FOUR: usize = 4; +} + +#[diagnostic::on_unknown( + message = "the message", + label = "the label", + note = "use note 1", + note = "use note 2" +)] +pub use constants::THREE; +//~^ ERROR the message +//~| NOTE the label +//~| NOTE unresolved import `constants::THREE` +//~| NOTE use note 1 +//~| NOTE use note 2 +//~| NOTE module note 1 +//~| NOTE module note 2
diff --git a/tests/ui/diagnostic_namespace/on_unknown/combined_use_and_module.stderr b/tests/ui/diagnostic_namespace/on_unknown/combined_use_and_module.stderr new file mode 100644 index 0000000..f123dc2 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/combined_use_and_module.stderr
@@ -0,0 +1,17 @@ +error[E0432]: the message + --> $DIR/combined_use_and_module.rs:22:9 + | +LL | pub use constants::THREE; + | ^^^^^^^^^^^----- + | | + | the label + | + = note: unresolved import `constants::THREE` + = note: use note 1 + = note: use note 2 + = note: module note 1 + = note: module note 2 + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`.
diff --git a/tests/ui/diagnostic_namespace/on_unknown/crate_level.rs b/tests/ui/diagnostic_namespace/on_unknown/crate_level.rs new file mode 100644 index 0000000..3b0a5ef --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/crate_level.rs
@@ -0,0 +1,27 @@ +//@ compile-flags: --crate-name crate_level_test +//@ edition: 2018.. +// See https://doc.rust-lang.org/nightly/reference/items/use-declarations.html#r-items.use.path.edition2018 + +#![feature(custom_inner_attributes)] +#![feature(diagnostic_on_unknown)] +#![crate_type = "lib"] + +// Only applies to the root, not everything in the entire crate +#![diagnostic::on_unknown(message = "crate_level `{This}`")] + +mod module{} + +pub use crate::foo; +//~^ ERROR crate_level `crate_level_test` + +pub use ::bar; +//~^ ERROR unresolved import `bar` + +pub use baz; +//~^ ERROR unresolved import `baz` + +pub use crate::module::waz; +//~^ ERROR unresolved import `crate::module::waz` + +pub use module::bluz; +//~^ ERROR unresolved import `module::bluz`
diff --git a/tests/ui/diagnostic_namespace/on_unknown/crate_level.stderr b/tests/ui/diagnostic_namespace/on_unknown/crate_level.stderr new file mode 100644 index 0000000..c8fd1e9 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/crate_level.stderr
@@ -0,0 +1,43 @@ +error[E0432]: crate_level `crate_level_test` + --> $DIR/crate_level.rs:14:9 + | +LL | pub use crate::foo; + | ^^^^^^^--- + | | + | no `foo` in the root + | + = note: unresolved import `crate::foo` + +error[E0432]: unresolved import `bar` + --> $DIR/crate_level.rs:17:9 + | +LL | pub use ::bar; + | ^^--- + | | + | no external crate `bar` + +error[E0432]: unresolved import `baz` + --> $DIR/crate_level.rs:20:9 + | +LL | pub use baz; + | ^^^ no external crate `baz` + +error[E0432]: unresolved import `crate::module::waz` + --> $DIR/crate_level.rs:23:9 + | +LL | pub use crate::module::waz; + | ^^^^^^^^^^^^^^^--- + | | + | no `waz` in `module` + +error[E0432]: unresolved import `module::bluz` + --> $DIR/crate_level.rs:26:9 + | +LL | pub use module::bluz; + | ^^^^^^^^---- + | | + | no `bluz` in `module` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0432`.
diff --git a/tests/ui/diagnostic_namespace/on_unknown/downstream_crate.rs b/tests/ui/diagnostic_namespace/on_unknown/downstream_crate.rs new file mode 100644 index 0000000..f50cdff --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/downstream_crate.rs
@@ -0,0 +1,9 @@ +//@ aux-crate:other=other.rs + +#![crate_type = "lib"] +extern crate other; + +pub use ::other::empty::something; +//~^ ERROR you silly, this module is empty +//~| NOTE unresolved import `other::empty::something` +//~| NOTE no `something` in `empty`
diff --git a/tests/ui/diagnostic_namespace/on_unknown/downstream_crate.stderr b/tests/ui/diagnostic_namespace/on_unknown/downstream_crate.stderr new file mode 100644 index 0000000..8812919 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/downstream_crate.stderr
@@ -0,0 +1,13 @@ +error[E0432]: you silly, this module is empty + --> $DIR/downstream_crate.rs:6:9 + | +LL | pub use ::other::empty::something; + | ^^^^^^^^^^^^^^^^--------- + | | + | no `something` in `empty` + | + = note: unresolved import `other::empty::something` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`.
diff --git a/tests/ui/diagnostic_namespace/on_unknown/incorrect-locations.rs b/tests/ui/diagnostic_namespace/on_unknown/incorrect_locations.rs similarity index 77% rename from tests/ui/diagnostic_namespace/on_unknown/incorrect-locations.rs rename to tests/ui/diagnostic_namespace/on_unknown/incorrect_locations.rs index b8852e7..ec32bf5 100644 --- a/tests/ui/diagnostic_namespace/on_unknown/incorrect-locations.rs +++ b/tests/ui/diagnostic_namespace/on_unknown/incorrect_locations.rs
@@ -1,52 +1,53 @@ -//@ run-pass +//@ check-pass #![allow(dead_code, unused_imports)] #![feature(diagnostic_on_unknown)] #[diagnostic::on_unknown(message = "foo")] -//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements +//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations extern crate std as other_std; #[diagnostic::on_unknown(message = "foo")] -//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements +//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations const CONST: () = (); #[diagnostic::on_unknown(message = "foo")] -//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements +//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations static STATIC: () = (); #[diagnostic::on_unknown(message = "foo")] -//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements +//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations type Type = (); #[diagnostic::on_unknown(message = "foo")] -//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements +//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations enum Enum {} #[diagnostic::on_unknown(message = "foo")] -//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements +//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations impl Enum {} #[diagnostic::on_unknown(message = "foo")] -//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements +//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations extern "C" {} #[diagnostic::on_unknown(message = "foo")] -//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements +//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations fn fun() {} #[diagnostic::on_unknown(message = "foo")] -//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements +//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations struct Struct {} #[diagnostic::on_unknown(message = "foo")] -//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements +//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations trait Trait {} #[diagnostic::on_unknown(message = "foo")] -//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements +//~^WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations impl Trait for i32 {} #[diagnostic::on_unknown(message = "foo")] use std::str::FromStr; -fn main() {} +fn main() { +}
diff --git a/tests/ui/diagnostic_namespace/on_unknown/incorrect-locations.stderr b/tests/ui/diagnostic_namespace/on_unknown/incorrect_locations.stderr similarity index 63% rename from tests/ui/diagnostic_namespace/on_unknown/incorrect-locations.stderr rename to tests/ui/diagnostic_namespace/on_unknown/incorrect_locations.stderr index c763621..c812e99 100644 --- a/tests/ui/diagnostic_namespace/on_unknown/incorrect-locations.stderr +++ b/tests/ui/diagnostic_namespace/on_unknown/incorrect_locations.stderr
@@ -1,103 +1,103 @@ -warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements - --> $DIR/incorrect-locations.rs:5:1 +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_locations.rs:5:1 | LL | #[diagnostic::on_unknown(message = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | extern crate std as other_std; - | ------------------------------ not an import + | ------------------------------ not an import or module | = note: `#[warn(misplaced_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default -warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements - --> $DIR/incorrect-locations.rs:9:1 +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_locations.rs:9:1 | LL | #[diagnostic::on_unknown(message = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | const CONST: () = (); - | --------------------- not an import + | --------------------- not an import or module -warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements - --> $DIR/incorrect-locations.rs:13:1 +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_locations.rs:13:1 | LL | #[diagnostic::on_unknown(message = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | static STATIC: () = (); - | ----------------------- not an import + | ----------------------- not an import or module -warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements - --> $DIR/incorrect-locations.rs:17:1 +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_locations.rs:17:1 | LL | #[diagnostic::on_unknown(message = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | type Type = (); - | --------------- not an import + | --------------- not an import or module -warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements - --> $DIR/incorrect-locations.rs:21:1 +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_locations.rs:21:1 | LL | #[diagnostic::on_unknown(message = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | enum Enum {} - | ------------ not an import + | ------------ not an import or module -warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements - --> $DIR/incorrect-locations.rs:25:1 +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_locations.rs:25:1 | LL | #[diagnostic::on_unknown(message = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | impl Enum {} - | ------------ not an import + | ------------ not an import or module -warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements - --> $DIR/incorrect-locations.rs:29:1 +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_locations.rs:29:1 | LL | #[diagnostic::on_unknown(message = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | extern "C" {} - | ------------- not an import + | ------------- not an import or module -warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements - --> $DIR/incorrect-locations.rs:33:1 +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_locations.rs:33:1 | LL | #[diagnostic::on_unknown(message = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | fn fun() {} - | ----------- not an import + | ----------- not an import or module -warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements - --> $DIR/incorrect-locations.rs:37:1 +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_locations.rs:37:1 | LL | #[diagnostic::on_unknown(message = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | struct Struct {} - | ---------------- not an import + | ---------------- not an import or module -warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements - --> $DIR/incorrect-locations.rs:41:1 +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_locations.rs:41:1 | LL | #[diagnostic::on_unknown(message = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | trait Trait {} - | -------------- not an import + | -------------- not an import or module -warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements - --> $DIR/incorrect-locations.rs:45:1 +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_locations.rs:45:1 | LL | #[diagnostic::on_unknown(message = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | impl Trait for i32 {} - | --------------------- not an import + | --------------------- not an import or module warning: 11 warnings emitted
diff --git a/tests/ui/diagnostic_namespace/on_unknown/incorrect_unstable_positions.rs b/tests/ui/diagnostic_namespace/on_unknown/incorrect_unstable_positions.rs new file mode 100644 index 0000000..7795d34 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/incorrect_unstable_positions.rs
@@ -0,0 +1,11 @@ +//@ check-pass + +#![feature(custom_inner_attributes)] +#![feature(diagnostic_on_unknown)] +#![feature(stmt_expr_attributes)] + +fn main() { + #[diagnostic::on_unknown(message = "anonymous block")] + //~^ WARN `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + {} +}
diff --git a/tests/ui/diagnostic_namespace/on_unknown/incorrect_unstable_positions.stderr b/tests/ui/diagnostic_namespace/on_unknown/incorrect_unstable_positions.stderr new file mode 100644 index 0000000..daa6688 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/incorrect_unstable_positions.stderr
@@ -0,0 +1,13 @@ +warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations + --> $DIR/incorrect_unstable_positions.rs:8:5 + | +LL | #[diagnostic::on_unknown(message = "anonymous block")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | {} + | -- not an import or module + | + = note: `#[warn(misplaced_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default + +warning: 1 warning emitted +
diff --git a/tests/ui/diagnostic_namespace/on_unknown/multiple.rs b/tests/ui/diagnostic_namespace/on_unknown/multiple.rs new file mode 100644 index 0000000..89e2974 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/multiple.rs
@@ -0,0 +1,42 @@ +#![crate_type = "lib"] +#![feature(diagnostic_on_unknown)] + +#[diagnostic::on_unknown( + message = "NEVER SHOWN", + label = "label different", + note = "note different" +)] +pub mod different {} + +#[diagnostic::on_unknown(message = "the same message", label = "label x", note = "note x")] +pub mod x {} + +#[diagnostic::on_unknown(label = "label y", note = "note y")] +pub mod y {} + +#[diagnostic::on_unknown(message = "the same message", note = "note z")] +pub mod z {} + +pub use { + x::Bar, + //~^ ERROR the same message + //~| NOTE note x + //~| NOTE note y + //~| NOTE note z + //~| NOTE unresolved imports `x::Bar`, `y::Foo`, `z::Baz` + //~| NOTE label x + y::Foo, + //~^ NOTE label y + z::Baz, + //~^ NOTE no `Baz` in `z` +}; + +pub use { + different::nothing, + //~^ ERROR unresolved imports `different::nothing`, `x::Buz` + //~| NOTE note x + //~| NOTE note different + //~| NOTE label different + x::Buz, + //~^ NOTE label x +};
diff --git a/tests/ui/diagnostic_namespace/on_unknown/multiple.stderr b/tests/ui/diagnostic_namespace/on_unknown/multiple.stderr new file mode 100644 index 0000000..e9e54a6 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/multiple.stderr
@@ -0,0 +1,42 @@ +error[E0432]: the same message + --> $DIR/multiple.rs:21:5 + | +LL | x::Bar, + | ^^^--- + | | + | label x +... +LL | y::Foo, + | ^^^--- + | | + | label y +LL | +LL | z::Baz, + | ^^^--- + | | + | no `Baz` in `z` + | + = note: unresolved imports `x::Bar`, `y::Foo`, `z::Baz` + = note: note x + = note: note y + = note: note z + +error[E0432]: unresolved imports `different::nothing`, `x::Buz` + --> $DIR/multiple.rs:35:5 + | +LL | different::nothing, + | ^^^^^^^^^^^------- + | | + | label different +... +LL | x::Buz, + | ^^^--- + | | + | label x + | + = note: note different + = note: note x + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0432`.
diff --git a/tests/ui/diagnostic_namespace/on_unknown/on_module.rs b/tests/ui/diagnostic_namespace/on_unknown/on_module.rs new file mode 100644 index 0000000..50977ff --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/on_module.rs
@@ -0,0 +1,10 @@ +#![crate_type = "lib"] +#![feature(diagnostic_on_unknown)] + +#[diagnostic::on_unknown(message = "oh no, `{Unresolved}` is not in module `{This}`")] +pub mod x { + pub struct Foo; +} + +pub use x::Bar; +//~^ ERROR oh no, `Bar` is not in module `x`
diff --git a/tests/ui/diagnostic_namespace/on_unknown/on_module.stderr b/tests/ui/diagnostic_namespace/on_unknown/on_module.stderr new file mode 100644 index 0000000..37a38f8 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/on_module.stderr
@@ -0,0 +1,13 @@ +error[E0432]: oh no, `Bar` is not in module `x` + --> $DIR/on_module.rs:9:9 + | +LL | pub use x::Bar; + | ^^^--- + | | + | no `Bar` in `x` + | + = note: unresolved import `x::Bar` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`.
diff --git a/tests/ui/diagnostic_namespace/on_unknown/on_module_inner.rs b/tests/ui/diagnostic_namespace/on_unknown/on_module_inner.rs new file mode 100644 index 0000000..44d5dcc --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/on_module_inner.rs
@@ -0,0 +1,11 @@ +#![crate_type = "lib"] +#![feature(diagnostic_on_unknown)] +#![feature(custom_inner_attributes)] + +pub mod x { + #![diagnostic::on_unknown(message = "oh no, `{Unresolved}` is not in module `{This}`")] + pub struct Foo; +} + +pub use x::Bar; +//~^ ERROR oh no, `Bar` is not in module `x`
diff --git a/tests/ui/diagnostic_namespace/on_unknown/on_module_inner.stderr b/tests/ui/diagnostic_namespace/on_unknown/on_module_inner.stderr new file mode 100644 index 0000000..0d5673b --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/on_module_inner.stderr
@@ -0,0 +1,13 @@ +error[E0432]: oh no, `Bar` is not in module `x` + --> $DIR/on_module_inner.rs:10:9 + | +LL | pub use x::Bar; + | ^^^--- + | | + | no `Bar` in `x` + | + = note: unresolved import `x::Bar` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`.
diff --git a/tests/ui/diagnostic_namespace/on_unknown/on_module_no_body.rs b/tests/ui/diagnostic_namespace/on_unknown/on_module_no_body.rs new file mode 100644 index 0000000..c37908b --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/on_module_no_body.rs
@@ -0,0 +1,9 @@ +#![crate_type = "lib"] +#![feature(diagnostic_on_unknown)] + +#[diagnostic::on_unknown(message = "oh no, that is not in aux module `{This}`")] +#[path = "auxiliary/module.rs"] +pub mod x; + +pub use x::Bar; +//~^ ERROR oh no, that is not in aux module `x`
diff --git a/tests/ui/diagnostic_namespace/on_unknown/on_module_no_body.stderr b/tests/ui/diagnostic_namespace/on_unknown/on_module_no_body.stderr new file mode 100644 index 0000000..3f729e7 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/on_module_no_body.stderr
@@ -0,0 +1,13 @@ +error[E0432]: oh no, that is not in aux module `x` + --> $DIR/on_module_no_body.rs:8:9 + | +LL | pub use x::Bar; + | ^^^--- + | | + | no `Bar` in `x` + | + = note: unresolved import `x::Bar` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`.
diff --git a/tests/ui/diagnostic_namespace/on_unknown/other_crate_with_crate_level_attr.rs b/tests/ui/diagnostic_namespace/on_unknown/other_crate_with_crate_level_attr.rs new file mode 100644 index 0000000..488ec69 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/other_crate_with_crate_level_attr.rs
@@ -0,0 +1,9 @@ +//@ aux-crate:other=other_crate_level.rs + +#![crate_type = "lib"] +extern crate other; + +pub use ::other::nothing; +//~^ ERROR you silly, the crate `other_crate_level` is empty +//~| NOTE unresolved import `other::nothing` +//~| NOTE no `nothing` in the root
diff --git a/tests/ui/diagnostic_namespace/on_unknown/other_crate_with_crate_level_attr.stderr b/tests/ui/diagnostic_namespace/on_unknown/other_crate_with_crate_level_attr.stderr new file mode 100644 index 0000000..e7c4f94 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unknown/other_crate_with_crate_level_attr.stderr
@@ -0,0 +1,13 @@ +error[E0432]: you silly, the crate `other_crate_level` is empty + --> $DIR/other_crate_with_crate_level_attr.rs:6:9 + | +LL | pub use ::other::nothing; + | ^^^^^^^^^------- + | | + | no `nothing` in the root + | + = note: unresolved import `other::nothing` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`.
diff --git a/tests/ui/generic-const-items/const-trait-impl.rs b/tests/ui/generic-const-items/const-trait-impl.rs index 197c97e..f77be95 100644 --- a/tests/ui/generic-const-items/const-trait-impl.rs +++ b/tests/ui/generic-const-items/const-trait-impl.rs
@@ -15,13 +15,14 @@ const trait Create { fn create() -> Self; } -impl const Create for i32 { +const impl Create for i32 { fn create() -> i32 { 4096 } } -trait Mod { // doesn't need to be a const trait +// doesn't need to be a const trait +trait Mod { const CREATE<T: const Create>: T; }
diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index fde68f8..1a65ef7 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs
@@ -491,7 +491,7 @@ trait Trait<'a>: Sized c1!(item, [ pub impl Struct {} ], "pub impl Struct {}"); c1!(item, [ impl<T> Struct<T> {} ], "impl<T> Struct<T> {}"); c1!(item, [ pub impl Trait for Struct {} ], "pub impl Trait for Struct {}"); - c1!(item, [ impl<T> const Trait for T {} ], "impl<T> const Trait for T {}"); + c1!(item, [ const impl<T> Trait for T {} ], "const impl<T> Trait for T {}"); // ItemKind::MacCall c1!(item, [ mac!(); ], "mac!();");
diff --git a/tests/ui/parser/const-recover-semi-issue-151149.fixed b/tests/ui/parser/const-recover-semi-issue-151149.fixed index 79a3c7b..4b1cc44 100644 --- a/tests/ui/parser/const-recover-semi-issue-151149.fixed +++ b/tests/ui/parser/const-recover-semi-issue-151149.fixed
@@ -7,7 +7,7 @@ fn const_default() -> Self; } -impl const ConstDefault for u8 { +const impl ConstDefault for u8 { fn const_default() -> Self { 0 } }
diff --git a/tests/ui/parser/const-recover-semi-issue-151149.rs b/tests/ui/parser/const-recover-semi-issue-151149.rs index affd81f..ab1933c 100644 --- a/tests/ui/parser/const-recover-semi-issue-151149.rs +++ b/tests/ui/parser/const-recover-semi-issue-151149.rs
@@ -7,7 +7,7 @@ const trait ConstDefault { fn const_default() -> Self; } -impl const ConstDefault for u8 { +const impl ConstDefault for u8 { fn const_default() -> Self { 0 } }
diff --git a/tests/ui/parser/impls-nested-within-fns-semantic-1.rs b/tests/ui/parser/impls-nested-within-fns-semantic-1.rs index be8a7dd..4a960e9 100644 --- a/tests/ui/parser/impls-nested-within-fns-semantic-1.rs +++ b/tests/ui/parser/impls-nested-within-fns-semantic-1.rs
@@ -8,7 +8,7 @@ const trait Trait { fn required(); } -impl const Trait for () { +const impl Trait for () { fn required() { pub struct Type;
diff --git a/tests/ui/reborrow/generic-reborrow-expr-use-visitor-closure.rs b/tests/ui/reborrow/generic-reborrow-expr-use-visitor-closure.rs new file mode 100644 index 0000000..c28cb1e --- /dev/null +++ b/tests/ui/reborrow/generic-reborrow-expr-use-visitor-closure.rs
@@ -0,0 +1,34 @@ +//@ check-pass + +#![feature(reborrow)] + +use std::marker::{CoerceShared, Reborrow}; + +#[allow(unused)] +struct CustomMut<'a, T>(&'a mut T); +impl<'a, T> Reborrow for CustomMut<'a, T> {} +impl<'a, T> CoerceShared<CustomRef<'a, T>> for CustomMut<'a, T> {} + +#[allow(unused)] +struct CustomRef<'a, T>(&'a T); +impl<'a, T> Clone for CustomRef<'a, T> { + fn clone(&self) -> Self { + Self(self.0) + } +} +impl<'a, T> Copy for CustomRef<'a, T> {} + +fn takes_mut(_: CustomMut<'_, ()>) {} +fn takes_shared(_: CustomRef<'_, ()>) {} + +fn main() { + let a = CustomMut(&mut ()); + + let mut f = || { + takes_mut(a); + takes_shared(a); + }; + + f(); + f(); +}
diff --git a/tests/ui/reborrow/generic-reborrow-expr-use-visitor.rs b/tests/ui/reborrow/generic-reborrow-expr-use-visitor.rs new file mode 100644 index 0000000..d513577 --- /dev/null +++ b/tests/ui/reborrow/generic-reborrow-expr-use-visitor.rs
@@ -0,0 +1,32 @@ +//@ check-pass + +#![feature(reborrow)] + +use std::marker::{CoerceShared, Reborrow}; + +#[allow(unused)] +struct CustomMut<'a, T>(&'a mut T); +impl<'a, T> Reborrow for CustomMut<'a, T> {} +impl<'a, T> CoerceShared<CustomRef<'a, T>> for CustomMut<'a, T> {} + +#[allow(unused)] +struct CustomRef<'a, T>(&'a T); +impl<'a, T> Clone for CustomRef<'a, T> { + fn clone(&self) -> Self { + Self(self.0) + } +} +impl<'a, T> Copy for CustomRef<'a, T> {} + +fn takes_mut(_: CustomMut<'_, ()>) {} +fn takes_shared(_: CustomRef<'_, ()>) {} + +fn main() { + let a = CustomMut(&mut ()); + + takes_mut(a); + takes_mut(a); + + takes_shared(a); + takes_shared(a); +}
diff --git a/tests/ui/reborrow/reborrow-source-unsafety.rs b/tests/ui/reborrow/reborrow-source-unsafety.rs new file mode 100644 index 0000000..e6f3540 --- /dev/null +++ b/tests/ui/reborrow/reborrow-source-unsafety.rs
@@ -0,0 +1,28 @@ +// Regression test for rust-lang/rust#158033. + +#![feature(reborrow)] +#![allow(dead_code)] +#![deny(unsafe_code)] + +use std::marker::Reborrow; + +struct Thing<'a> { + field: &'a mut usize, +} + +impl<'a> Reborrow for Thing<'a> {} + +fn takes(_: Thing<'_>) {} + +fn main() { + let mut x = 0; + let thing = Thing { field: &mut x }; + let y = 123usize; + + takes({ + let p: *const usize = &y; + std::hint::black_box(std::ptr::read(p)); + //~^ ERROR call to unsafe function `std::ptr::read` is unsafe + thing + }); +}
diff --git a/tests/ui/reborrow/reborrow-source-unsafety.stderr b/tests/ui/reborrow/reborrow-source-unsafety.stderr new file mode 100644 index 0000000..431893a --- /dev/null +++ b/tests/ui/reborrow/reborrow-source-unsafety.stderr
@@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function `std::ptr::read` is unsafe and requires unsafe function or block + --> $DIR/reborrow-source-unsafety.rs:24:30 + | +LL | std::hint::black_box(std::ptr::read(p)); + | ^^^^^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0133`.
diff --git a/tests/ui/resolve/suggest-import-before-outer-attrs-issue-69733.fixed b/tests/ui/resolve/suggest-import-before-outer-attrs-issue-69733.fixed new file mode 100644 index 0000000..73bc24a --- /dev/null +++ b/tests/ui/resolve/suggest-import-before-outer-attrs-issue-69733.fixed
@@ -0,0 +1,13 @@ +//@ edition:2015 +//@ run-rustfix +//@ compile-flags: -Adead_code + +use std::path::Path; + +#[derive(Debug)] +struct Symbol; + +type Ident = Path; +//~^ ERROR cannot find type `Path` in this scope + +fn main() {}
diff --git a/tests/ui/resolve/suggest-import-before-outer-attrs-issue-69733.rs b/tests/ui/resolve/suggest-import-before-outer-attrs-issue-69733.rs new file mode 100644 index 0000000..eb9a3d4 --- /dev/null +++ b/tests/ui/resolve/suggest-import-before-outer-attrs-issue-69733.rs
@@ -0,0 +1,11 @@ +//@ edition:2015 +//@ run-rustfix +//@ compile-flags: -Adead_code + +#[derive(Debug)] +struct Symbol; + +type Ident = Path; +//~^ ERROR cannot find type `Path` in this scope + +fn main() {}
diff --git a/tests/ui/resolve/suggest-import-before-outer-attrs-issue-69733.stderr b/tests/ui/resolve/suggest-import-before-outer-attrs-issue-69733.stderr new file mode 100644 index 0000000..f8faea4 --- /dev/null +++ b/tests/ui/resolve/suggest-import-before-outer-attrs-issue-69733.stderr
@@ -0,0 +1,14 @@ +error[E0425]: cannot find type `Path` in this scope + --> $DIR/suggest-import-before-outer-attrs-issue-69733.rs:8:14 + | +LL | type Ident = Path; + | ^^^^ not found in this scope + | +help: consider importing this struct + | +LL + use std::path::Path; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/scalable-vectors/debuginfo-no-opt-llvm-ice.rs b/tests/ui/scalable-vectors/debuginfo-no-opt-llvm-ice.rs new file mode 100644 index 0000000..02d541c --- /dev/null +++ b/tests/ui/scalable-vectors/debuginfo-no-opt-llvm-ice.rs
@@ -0,0 +1,40 @@ +//@ only-aarch64 +//@ build-pass +//@ compile-flags: -Ctarget-feature=+sve,+sve2 -Copt-level=0 -g +//@ edition:2021 +#![feature(stdarch_aarch64_sve)] + +use std::arch::aarch64::*; + +static I8_275: [i8; 275] = [ + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, + 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, + 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, + 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, + 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, + 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, + 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, + 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, -0x80, + -0x7f, -0x7e, -0x7d, -0x7c, -0x7b, -0x7a, -0x79, -0x78, -0x77, -0x76, -0x75, -0x74, -0x73, + -0x72, -0x71, -0x70, -0x6f, -0x6e, -0x6d, -0x6c, -0x6b, -0x6a, -0x69, -0x68, -0x67, -0x66, + -0x65, -0x64, -0x63, -0x62, -0x61, -0x60, -0x5f, -0x5e, -0x5d, -0x5c, -0x5b, -0x5a, -0x59, + -0x58, -0x57, -0x56, -0x55, -0x54, -0x53, -0x52, -0x51, -0x50, -0x4f, -0x4e, -0x4d, -0x4c, + -0x4b, -0x4a, -0x49, -0x48, -0x47, -0x46, -0x45, -0x44, -0x43, -0x42, -0x41, -0x40, -0x3f, + -0x3e, -0x3d, -0x3c, -0x3b, -0x3a, -0x39, -0x38, -0x37, -0x36, -0x35, -0x34, -0x33, -0x32, + -0x31, -0x30, -0x2f, -0x2e, -0x2d, -0x2c, -0x2b, -0x2a, -0x29, -0x28, -0x27, -0x26, -0x25, + -0x24, -0x23, -0x22, -0x21, -0x20, -0x1f, -0x1e, -0x1d, -0x1c, -0x1b, -0x1a, -0x19, -0x18, + -0x17, -0x16, -0x15, -0x14, -0x13, -0x12, -0x11, -0x10, -0xf, -0xe, -0xd, -0xc, -0xb, -0xa, + -0x9, -0x8, -0x7, -0x6, -0x5, -0x4, -0x3, -0x2, -0x1, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, + 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, +]; + +fn main() { + unsafe { + let __pred = svptrue_b8(); + let op1_val = svld1_s8(__pred, I8_275.as_ptr().add(0) as _); + + let mut __c_return_value = std::mem::MaybeUninit::uninit(); + std::ptr::write(__c_return_value.as_mut_ptr(), svext_s8::<0>(op1_val, op1_val)); + let __c_return_value = __c_return_value.assume_init(); + } +}
diff --git a/tests/ui/stability-attribute/missing-const-stability.rs b/tests/ui/stability-attribute/missing-const-stability.rs index 8a37f19..5a1cfef 100644 --- a/tests/ui/stability-attribute/missing-const-stability.rs +++ b/tests/ui/stability-attribute/missing-const-stability.rs
@@ -26,7 +26,7 @@ pub const trait Bar { fn fun(); } #[stable(feature = "stable", since = "1.0.0")] -impl const Bar for Foo { +const impl Bar for Foo { // ok because all users must enable `const_trait_impl` fn fun() {} }
diff --git a/tests/ui/structs/default-field-values/support.rs b/tests/ui/structs/default-field-values/support.rs index 670557e..5fb4408 100644 --- a/tests/ui/structs/default-field-values/support.rs +++ b/tests/ui/structs/default-field-values/support.rs
@@ -31,7 +31,7 @@ pub const trait ConstDefault { fn value() -> Self; } -impl const ConstDefault for i32 { +const impl ConstDefault for i32 { fn value() -> i32 { 101 } @@ -63,7 +63,7 @@ const fn foo() -> i32 { 42 } -fn main () { +fn main() { let x = Foo { .. }; let y = Foo::default(); let z = Foo { baz: 1, .. }; @@ -81,6 +81,7 @@ fn main () { assert!(matches!(Bar::Foo { bar: S, baz: 1 }, z)); let x = Qux::<i32, 4, i32> { .. }; + #[rustfmt::skip] assert!(matches!( Qux::<i32, 4, i32> { bar: S,
diff --git a/tests/ui/traits/const-traits/assoc-type.rs b/tests/ui/traits/const-traits/assoc-type.rs index 3fb6f67..f01c009 100644 --- a/tests/ui/traits/const-traits/assoc-type.rs +++ b/tests/ui/traits/const-traits/assoc-type.rs
@@ -9,7 +9,7 @@ const trait Add<Rhs = Self> { fn add(self, other: Rhs) -> Self::Output; } -impl const Add for i32 { +const impl Add for i32 { type Output = Self; fn add(self, other: Self) -> Self::Output { @@ -31,7 +31,7 @@ const trait Foo { type Bar: [const] Add; } -impl const Foo for NonConstAdd { +const impl Foo for NonConstAdd { type Bar = NonConstAdd; //~^ ERROR the trait bound `NonConstAdd: [const] Add` is not satisfied } @@ -40,7 +40,7 @@ const trait Baz { type Qux: Add; } -impl const Baz for NonConstAdd { +const impl Baz for NonConstAdd { type Qux = NonConstAdd; // OK }
diff --git a/tests/ui/traits/const-traits/auxiliary/cross-crate.rs b/tests/ui/traits/const-traits/auxiliary/cross-crate.rs index 7d464d5..d3460eb 100644 --- a/tests/ui/traits/const-traits/auxiliary/cross-crate.rs +++ b/tests/ui/traits/const-traits/auxiliary/cross-crate.rs
@@ -9,15 +9,11 @@ fn defaulted_func(&self) {} pub struct NonConst; impl MyTrait for NonConst { - fn func(self) { - - } + fn func(self) {} } pub struct Const; -impl const MyTrait for Const { - fn func(self) { - - } +const impl MyTrait for Const { + fn func(self) {} }
diff --git a/tests/ui/traits/const-traits/auxiliary/minicore.rs b/tests/ui/traits/const-traits/auxiliary/minicore.rs index 2e5df13..e1d1135 100644 --- a/tests/ui/traits/const-traits/auxiliary/minicore.rs +++ b/tests/ui/traits/const-traits/auxiliary/minicore.rs
@@ -12,7 +12,7 @@ fundamental, marker_trait_attr, const_trait_impl, - const_destruct, + const_destruct )] #![allow(internal_features, incomplete_features)] #![no_std] @@ -41,7 +41,7 @@ pub const trait Add<Rhs = Self> { fn add(self, rhs: Rhs) -> Self::Output; } -impl const Add for i32 { +const impl Add for i32 { type Output = i32; fn add(self, rhs: i32) -> i32 { loop {} @@ -170,7 +170,7 @@ pub const trait Index<Idx: PointeeSized> { fn index(self, slice: &T) -> &Self::Output; } -impl<T, I> const Index<I> for [T] +const impl<T, I> Index<I> for [T] where I: [const] SliceIndex<[T]>, { @@ -182,7 +182,7 @@ fn index(&self, index: I) -> &I::Output { } } -impl<T, I, const N: usize> const Index<I> for [T; N] +const impl<T, I, const N: usize> Index<I> for [T; N] where [T]: [const] Index<I>, { @@ -210,7 +210,7 @@ pub const trait Deref { fn deref(&self) -> &Self::Target; } -impl<T: MetaSized> const Deref for &T { +const impl<T: MetaSized> Deref for &T { type Target = T; fn deref(&self) -> &T { @@ -218,7 +218,7 @@ fn deref(&self) -> &T { } } -impl<T: MetaSized> const Deref for &mut T { +const impl<T: MetaSized> Deref for &mut T { type Target = T; fn deref(&self) -> &T { @@ -269,7 +269,7 @@ pub const trait From<T>: Sized { fn from(value: T) -> Self; } -impl<T, U> const Into<U> for T +const impl<T, U> Into<U> for T where U: [const] From<T>, { @@ -278,7 +278,7 @@ fn into(self) -> U { } } -impl<T> const From<T> for T { +const impl<T> From<T> for T { fn from(t: T) -> T { t } @@ -306,7 +306,7 @@ fn ne(&self, other: &Rhs) -> bool { } } -impl<A: PointeeSized, B: PointeeSized> const PartialEq<&B> for &A +const impl<A: PointeeSized, B: PointeeSized> PartialEq<&B> for &A where A: [const] PartialEq<B>, { @@ -327,7 +327,7 @@ pub const trait Not { fn not(self) -> Self::Output; } -impl const Not for bool { +const impl Not for bool { type Output = bool; fn not(self) -> bool { !self @@ -387,14 +387,14 @@ const fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut T>> { } } -impl<P: [const] Deref> const Deref for Pin<P> { +const impl<P: [const] Deref> Deref for Pin<P> { type Target = P::Target; fn deref(&self) -> &P::Target { Pin::get_ref(Pin::as_ref(self)) } } -impl<T> const Deref for Option<T> { +const impl<T> Deref for Option<T> { type Target = T; fn deref(&self) -> &T { loop {}
diff --git a/tests/ui/traits/const-traits/auxiliary/staged-api.rs b/tests/ui/traits/const-traits/auxiliary/staged-api.rs index 65e7586..7859b9f 100644 --- a/tests/ui/traits/const-traits/auxiliary/staged-api.rs +++ b/tests/ui/traits/const-traits/auxiliary/staged-api.rs
@@ -14,7 +14,7 @@ pub const trait MyTrait { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "unstable", issue = "none")] -impl const MyTrait for Unstable { +const impl MyTrait for Unstable { fn func() {} } @@ -31,6 +31,6 @@ pub fn inherent_func() {} #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "unstable2", issue = "none")] -impl const MyTrait for Unstable2 { +const impl MyTrait for Unstable2 { fn func() {} }
diff --git a/tests/ui/traits/const-traits/call-const-trait-method-fail.rs b/tests/ui/traits/const-traits/call-const-trait-method-fail.rs index bb481d0..dd8e3df 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-fail.rs +++ b/tests/ui/traits/const-traits/call-const-trait-method-fail.rs
@@ -5,7 +5,7 @@ pub const trait Plus { fn plus(self, rhs: Self) -> Self; } -impl const Plus for i32 { +const impl Plus for i32 { fn plus(self, rhs: Self) -> Self { self + rhs }
diff --git a/tests/ui/traits/const-traits/call-const-trait-method-pass.rs b/tests/ui/traits/const-traits/call-const-trait-method-pass.rs index b12e7e8..c48879d 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-pass.rs +++ b/tests/ui/traits/const-traits/call-const-trait-method-pass.rs
@@ -3,7 +3,7 @@ struct Int(i32); -impl const std::ops::Add for Int { +const impl std::ops::Add for Int { type Output = Int; fn add(self, rhs: Self) -> Self { @@ -11,7 +11,7 @@ fn add(self, rhs: Self) -> Self { } } -impl const PartialEq for Int { +const impl PartialEq for Int { fn eq(&self, rhs: &Self) -> bool { self.0 == rhs.0 } @@ -24,7 +24,7 @@ pub const trait Plus { fn plus(self, rhs: Self) -> Self; } -impl const Plus for i32 { +const impl Plus for i32 { fn plus(self, rhs: Self) -> Self { self + rhs }
diff --git a/tests/ui/traits/const-traits/call-generic-in-impl.rs b/tests/ui/traits/const-traits/call-generic-in-impl.rs index 4ed937e..cf45aa9 100644 --- a/tests/ui/traits/const-traits/call-generic-in-impl.rs +++ b/tests/ui/traits/const-traits/call-generic-in-impl.rs
@@ -5,7 +5,7 @@ const trait MyPartialEq { fn eq(&self, other: &Self) -> bool; } -impl<T: [const] PartialEq> const MyPartialEq for T { +const impl<T: [const] PartialEq> MyPartialEq for T { fn eq(&self, other: &Self) -> bool { PartialEq::eq(self, other) }
diff --git a/tests/ui/traits/const-traits/call-generic-method-chain.rs b/tests/ui/traits/const-traits/call-generic-method-chain.rs index db053b4..616fd28 100644 --- a/tests/ui/traits/const-traits/call-generic-method-chain.rs +++ b/tests/ui/traits/const-traits/call-generic-method-chain.rs
@@ -7,7 +7,7 @@ struct S; -impl const PartialEq for S { +const impl PartialEq for S { fn eq(&self, _: &S) -> bool { true }
diff --git a/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs b/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs index 5913cbf..7090447 100644 --- a/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs +++ b/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs
@@ -5,7 +5,7 @@ struct S; -impl const PartialEq for S { +const impl PartialEq for S { fn eq(&self, _: &S) -> bool { true }
diff --git a/tests/ui/traits/const-traits/call-generic-method-pass.rs b/tests/ui/traits/const-traits/call-generic-method-pass.rs index 01c5860..d4f8f49 100644 --- a/tests/ui/traits/const-traits/call-generic-method-pass.rs +++ b/tests/ui/traits/const-traits/call-generic-method-pass.rs
@@ -7,7 +7,7 @@ struct S; -impl const PartialEq for S { +const impl PartialEq for S { fn eq(&self, _: &S) -> bool { true }
diff --git a/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs b/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs index 2241f70..ba0f154 100644 --- a/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs +++ b/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs
@@ -16,7 +16,7 @@ const trait Add42 { fn add(a: usize) -> usize; } -impl const Add42 for () { +const impl Add42 for () { fn add(a: usize) -> usize { a + 42 }
diff --git a/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs b/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs index 11ff1dd..e8b4737 100644 --- a/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs +++ b/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs
@@ -7,7 +7,7 @@ const trait Main { fn compute<T: [const] Aux>() -> u32; } -impl const Main for () { +const impl Main for () { fn compute<T: [const] Aux>() -> u32 { T::generate() } @@ -17,7 +17,7 @@ const trait Aux { fn generate() -> u32; } -impl const Aux for () { +const impl Aux for () { fn generate() -> u32 { 1024 } }
diff --git a/tests/ui/traits/const-traits/conditionally-const-in-anon-const.rs b/tests/ui/traits/const-traits/conditionally-const-in-anon-const.rs index 21419be..25abfe1 100644 --- a/tests/ui/traits/const-traits/conditionally-const-in-anon-const.rs +++ b/tests/ui/traits/const-traits/conditionally-const-in-anon-const.rs
@@ -3,7 +3,7 @@ struct S; const trait Trait<const N: u32> {} -impl const Trait<0> for () {} +const impl Trait<0> for () {} const fn f< T: Trait< @@ -19,7 +19,9 @@ const fn g<U: [const] Trait<0>>() {} 0 }, >, ->(x: &T) { +>( + x: &T, +) { // Should be allowed here let y: &impl [const] Trait<0> = x; }
diff --git a/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs b/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs index dfb8286..41acbc8 100644 --- a/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs +++ b/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs
@@ -6,7 +6,7 @@ const trait Trait { type Assoc<T: [const] Bound>; } -impl const Trait for () { +const impl Trait for () { type Assoc<T: [const] Bound> = T; }
diff --git a/tests/ui/traits/const-traits/const-and-non-const-impl.rs b/tests/ui/traits/const-traits/const-and-non-const-impl.rs index 560b740..4fb0370 100644 --- a/tests/ui/traits/const-traits/const-and-non-const-impl.rs +++ b/tests/ui/traits/const-traits/const-and-non-const-impl.rs
@@ -2,7 +2,7 @@ pub struct Int(i32); -impl const std::ops::Add for i32 { +const impl std::ops::Add for i32 { //~^ ERROR only traits defined in the current crate can be implemented for primitive types type Output = Self; @@ -19,7 +19,7 @@ fn add(self, rhs: Self) -> Self { } } -impl const std::ops::Add for Int { +const impl std::ops::Add for Int { //~^ ERROR conflicting implementations of trait type Output = Self;
diff --git a/tests/ui/traits/const-traits/const-and-non-const-impl.stderr b/tests/ui/traits/const-traits/const-and-non-const-impl.stderr index 26ed7d0..71bcad0 100644 --- a/tests/ui/traits/const-traits/const-and-non-const-impl.stderr +++ b/tests/ui/traits/const-traits/const-and-non-const-impl.stderr
@@ -4,13 +4,13 @@ LL | impl std::ops::Add for Int { | -------------------------- first implementation here ... -LL | impl const std::ops::Add for Int { +LL | const impl std::ops::Add for Int { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Int` error[E0117]: only traits defined in the current crate can be implemented for primitive types --> $DIR/const-and-non-const-impl.rs:5:1 | -LL | impl const std::ops::Add for i32 { +LL | const impl std::ops::Add for i32 { | ^^^^^^^^^^^-------------^^^^^--- | | | | | `i32` is not defined in the current crate
diff --git a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs index 9b2e93f..dc10c6f 100644 --- a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs +++ b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs
@@ -13,7 +13,7 @@ trait OtherTrait { struct MyStruct<T>(T); -impl const MyTrait for u32 { +const impl MyTrait for u32 { fn do_something(&self) {} }
diff --git a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs index f80e379..8086b38 100644 --- a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs +++ b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs
@@ -9,9 +9,11 @@ const trait T { fn non_const() {} -impl const T for S { - fn foo() { non_const() } - //~^ ERROR cannot call non-const function +const impl T for S { + fn foo() { + non_const() + //~^ ERROR cannot call non-const function + } } fn main() {}
diff --git a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr index 04da8f7..7c33fb6 100644 --- a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr +++ b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr
@@ -1,8 +1,8 @@ error[E0015]: cannot call non-const function `non_const` in constant functions - --> $DIR/const-check-fns-in-const-impl.rs:13:16 + --> $DIR/const-check-fns-in-const-impl.rs:14:9 | -LL | fn foo() { non_const() } - | ^^^^^^^^^^^ +LL | non_const() + | ^^^^^^^^^^^ | note: function `non_const` is not const --> $DIR/const-check-fns-in-const-impl.rs:10:1
diff --git a/tests/ui/traits/const-traits/const-closure-trait-method.rs b/tests/ui/traits/const-traits/const-closure-trait-method.rs index 62de7c5..1817337 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method.rs +++ b/tests/ui/traits/const-traits/const-closure-trait-method.rs
@@ -7,8 +7,10 @@ const trait Tr { fn a(self) -> i32; } -impl const Tr for () { - fn a(self) -> i32 { 42 } +const impl Tr for () { + fn a(self) -> i32 { + 42 + } } const fn need_const_closure<T: [const] FnOnce(()) -> i32>(x: T) -> i32 {
diff --git a/tests/ui/traits/const-traits/const-cond-for-rpitit.rs b/tests/ui/traits/const-traits/const-cond-for-rpitit.rs index 0d010fe..3cbf399 100644 --- a/tests/ui/traits/const-traits/const-cond-for-rpitit.rs +++ b/tests/ui/traits/const-traits/const-cond-for-rpitit.rs
@@ -11,7 +11,10 @@ pub const trait Foo { pub const trait Bar {} struct A<T>(T); -impl<T> const Foo for A<T> where A<T>: [const] Bar { +const impl<T> Foo for A<T> +where + A<T>: [const] Bar, +{ fn method(self) -> impl [const] Bar { self }
diff --git a/tests/ui/traits/const-traits/const-default-method-bodies.rs b/tests/ui/traits/const-traits/const-default-method-bodies.rs index b2ddf1b..ccd4642 100644 --- a/tests/ui/traits/const-traits/const-default-method-bodies.rs +++ b/tests/ui/traits/const-traits/const-default-method-bodies.rs
@@ -16,7 +16,7 @@ impl ConstDefaultFn for NonConstImpl { fn b(self) {} } -impl const ConstDefaultFn for ConstImpl { +const impl ConstDefaultFn for ConstImpl { fn b(self) {} }
diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr b/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr index b4603f4..c6d71bd 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr
@@ -7,10 +7,10 @@ note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `const Drop` --> $DIR/const-drop-fail-2.rs:24:26 | -LL | impl<T: [const] A> const Drop for ConstDropImplWithBounds<T> { - | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | unsatisfied trait bound introduced here +LL | const impl<T: [const] A> Drop for ConstDropImplWithBounds<T> { + | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here note: required by a bound in `check` --> $DIR/const-drop-fail-2.rs:20:19 |
diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.rs b/tests/ui/traits/const-traits/const-drop-fail-2.rs index f5e5793..d75d8a3 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.rs +++ b/tests/ui/traits/const-traits/const-drop-fail-2.rs
@@ -21,7 +21,7 @@ const fn check<T: [const] Destruct>(_: T) {} struct ConstDropImplWithBounds<T: A>(PhantomData<T>); -impl<T: [const] A> const Drop for ConstDropImplWithBounds<T> { +const impl<T: [const] A> Drop for ConstDropImplWithBounds<T> { fn drop(&mut self) { T::a(); } @@ -34,7 +34,7 @@ fn drop(&mut self) { struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); -impl<T: [const] A> const Drop for ConstDropImplWithNonConstBounds<T> { +const impl<T: [const] A> Drop for ConstDropImplWithNonConstBounds<T> { fn drop(&mut self) { T::a(); }
diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr b/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr index b4603f4..c6d71bd 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr
@@ -7,10 +7,10 @@ note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `const Drop` --> $DIR/const-drop-fail-2.rs:24:26 | -LL | impl<T: [const] A> const Drop for ConstDropImplWithBounds<T> { - | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | unsatisfied trait bound introduced here +LL | const impl<T: [const] A> Drop for ConstDropImplWithBounds<T> { + | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here note: required by a bound in `check` --> $DIR/const-drop-fail-2.rs:20:19 |
diff --git a/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr b/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr index db4df30..33289d9 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr
@@ -7,7 +7,7 @@ note: required for this `Drop` impl --> $DIR/const-drop-fail.rs:22:1 | -LL | impl const Drop for ConstImplWithDropGlue { +LL | const impl Drop for ConstImplWithDropGlue { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
diff --git a/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr b/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr index db4df30..33289d9 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr
@@ -7,7 +7,7 @@ note: required for this `Drop` impl --> $DIR/const-drop-fail.rs:22:1 | -LL | impl const Drop for ConstImplWithDropGlue { +LL | const impl Drop for ConstImplWithDropGlue { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
diff --git a/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr b/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr index db4df30..33289d9 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr
@@ -7,7 +7,7 @@ note: required for this `Drop` impl --> $DIR/const-drop-fail.rs:22:1 | -LL | impl const Drop for ConstImplWithDropGlue { +LL | const impl Drop for ConstImplWithDropGlue { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
diff --git a/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr b/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr index db4df30..33289d9 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr
@@ -7,7 +7,7 @@ note: required for this `Drop` impl --> $DIR/const-drop-fail.rs:22:1 | -LL | impl const Drop for ConstImplWithDropGlue { +LL | const impl Drop for ConstImplWithDropGlue { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
diff --git a/tests/ui/traits/const-traits/const-drop-fail.rs b/tests/ui/traits/const-traits/const-drop-fail.rs index 7e12043..d85c942 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.rs +++ b/tests/ui/traits/const-traits/const-drop-fail.rs
@@ -19,7 +19,7 @@ fn drop(&mut self) { struct ConstImplWithDropGlue(NonTrivialDrop); //~^ ERROR: `NonTrivialDrop` does not implement `[const] Destruct` -impl const Drop for ConstImplWithDropGlue { +const impl Drop for ConstImplWithDropGlue { fn drop(&mut self) {} }
diff --git a/tests/ui/traits/const-traits/const-drop.rs b/tests/ui/traits/const-traits/const-drop.rs index f7c3ec9..00f7aff 100644 --- a/tests/ui/traits/const-traits/const-drop.rs +++ b/tests/ui/traits/const-traits/const-drop.rs
@@ -10,7 +10,7 @@ struct S<'a>(&'a mut u8); -impl<'a> const Drop for S<'a> { +const impl<'a> Drop for S<'a> { fn drop(&mut self) { *self.0 += 1; } @@ -42,7 +42,7 @@ pub enum Bar { A } pub fn foo() {} pub struct ConstDrop; - impl const Drop for ConstDrop { + const impl Drop for ConstDrop { fn drop(&mut self) {} } @@ -52,7 +52,7 @@ fn drop(&mut self) {} pub const trait SomeTrait { fn foo(); } - impl const SomeTrait for () { + const impl SomeTrait for () { fn foo() {} } // non-const impl @@ -62,7 +62,7 @@ fn foo() {} pub struct ConstDropWithBound<T: const SomeTrait>(pub core::marker::PhantomData<T>); - impl<T: const SomeTrait> const Drop for ConstDropWithBound<T> { + const impl<T: const SomeTrait> Drop for ConstDropWithBound<T> { fn drop(&mut self) { T::foo(); } @@ -70,7 +70,7 @@ fn drop(&mut self) { pub struct ConstDropWithNonconstBound<T: SomeTrait>(pub core::marker::PhantomData<T>); - impl<T: SomeTrait> const Drop for ConstDropWithNonconstBound<T> { + const impl<T: SomeTrait> Drop for ConstDropWithNonconstBound<T> { fn drop(&mut self) { // Note: we DON'T use the `T: SomeTrait` bound }
diff --git a/tests/ui/traits/const-traits/const-impl-requires-const-trait.rs b/tests/ui/traits/const-traits/const-impl-requires-const-trait.rs index 176ae09..fd3a4de 100644 --- a/tests/ui/traits/const-traits/const-impl-requires-const-trait.rs +++ b/tests/ui/traits/const-traits/const-impl-requires-const-trait.rs
@@ -3,7 +3,7 @@ pub trait A {} -impl const A for () {} +const impl A for () {} //~^ ERROR: const `impl` for trait `A` which is not `const` fn main() {}
diff --git a/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr b/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr index 705ade3..0ddf30d 100644 --- a/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr +++ b/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr
@@ -1,7 +1,7 @@ error: const `impl` for trait `A` which is not `const` --> $DIR/const-impl-requires-const-trait.rs:6:12 | -LL | impl const A for () {} +LL | const impl A for () {} | ^ this trait is not `const` | = note: marking a trait with `const` ensures all default method bodies are `const`
diff --git a/tests/ui/traits/const-traits/const-impl-trait.rs b/tests/ui/traits/const-traits/const-impl-trait.rs index e3fcf54..0c7b073 100644 --- a/tests/ui/traits/const-traits/const-impl-trait.rs +++ b/tests/ui/traits/const-traits/const-impl-trait.rs
@@ -20,7 +20,7 @@ const trait Foo { fn huh() -> impl [const] PartialEq + [const] Destruct + Copy; } -impl const Foo for () { +const impl Foo for () { fn huh() -> impl [const] PartialEq + [const] Destruct + Copy { 123 } @@ -37,7 +37,7 @@ fn huh() -> impl [const] PartialEq + [const] Destruct + Copy { const trait T {} struct S; -impl const T for S {} +const impl T for S {} const fn rpit() -> impl [const] T { S
diff --git a/tests/ui/traits/const-traits/const-opaque.rs b/tests/ui/traits/const-traits/const-opaque.rs index 9b24cfa..bc4643e 100644 --- a/tests/ui/traits/const-traits/const-opaque.rs +++ b/tests/ui/traits/const-traits/const-opaque.rs
@@ -8,12 +8,12 @@ const trait Foo { fn method(&self); } -impl<T: [const] Foo> const Foo for (T,) { +const impl<T: [const] Foo> Foo for (T,) { fn method(&self) {} } #[cfg(yes)] -impl const Foo for () { +const impl Foo for () { fn method(&self) {} }
diff --git a/tests/ui/traits/const-traits/const-trait-async-assoc-fn.rs b/tests/ui/traits/const-traits/const-trait-async-assoc-fn.rs index 00fdccc..caadd79 100644 --- a/tests/ui/traits/const-traits/const-trait-async-assoc-fn.rs +++ b/tests/ui/traits/const-traits/const-trait-async-assoc-fn.rs
@@ -3,16 +3,16 @@ const trait Tr { async fn ft1() {} -//~^ ERROR async functions are not allowed in `const` traits + //~^ ERROR async functions are not allowed in `const` traits } const trait Tr2 { fn f() -> impl std::future::Future<Output = ()>; } -impl const Tr2 for () { +const impl Tr2 for () { async fn f() {} -//~^ ERROR async functions are not allowed in `const` trait impls + //~^ ERROR async functions are not allowed in `const` trait impls } fn main() {}
diff --git a/tests/ui/traits/const-traits/const-trait-async-assoc-fn.stderr b/tests/ui/traits/const-traits/const-trait-async-assoc-fn.stderr index 09ba096..7afb7f2 100644 --- a/tests/ui/traits/const-traits/const-trait-async-assoc-fn.stderr +++ b/tests/ui/traits/const-traits/const-trait-async-assoc-fn.stderr
@@ -9,8 +9,8 @@ error: async functions are not allowed in `const` trait impls --> $DIR/const-trait-async-assoc-fn.rs:14:5 | -LL | impl const Tr2 for () { - | ----- associated functions of `const` cannot be declared `async` +LL | const impl Tr2 for () { + | ----- associated functions of `const` cannot be declared `async` LL | async fn f() {} | ^^^^^
diff --git a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs index fcc23fb..0eb3435 100644 --- a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs +++ b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs
@@ -14,7 +14,7 @@ const trait Main { fn compute<T: [const] Aux>() -> u32; } -impl const Main for () { +const impl Main for () { fn compute<'x>() -> u32 { //~^ ERROR associated function `compute` has 0 type parameters but its trait declaration has 1 type parameter 0 @@ -23,7 +23,7 @@ fn compute<'x>() -> u32 { const trait Aux {} -impl const Aux for () {} +const impl Aux for () {} fn main() { const _: u32 = <()>::compute::<()>();
diff --git a/tests/ui/traits/const-traits/const-traits-alloc.rs b/tests/ui/traits/const-traits/const-traits-alloc.rs index 4dfec2f..fe882dc 100644 --- a/tests/ui/traits/const-traits/const-traits-alloc.rs +++ b/tests/ui/traits/const-traits/const-traits-alloc.rs
@@ -5,5 +5,8 @@ const STRING: String = Default::default(); // alloc::vec const VEC: Vec<()> = Default::default(); +// alloc::collections::btree::map::BTreeMap +use std::collections::BTreeMap; +const BTREE: BTreeMap<(), ()> = Default::default(); fn main() {}
diff --git a/tests/ui/traits/const-traits/const_derives/derive-const-use.rs b/tests/ui/traits/const-traits/const_derives/derive-const-use.rs index 78c25cc..8dc49bd 100644 --- a/tests/ui/traits/const-traits/const_derives/derive-const-use.rs +++ b/tests/ui/traits/const-traits/const_derives/derive-const-use.rs
@@ -3,12 +3,16 @@ pub struct A; -impl const Default for A { - fn default() -> A { A } +const impl Default for A { + fn default() -> A { + A + } } -impl const PartialEq for A { - fn eq(&self, _: &A) -> bool { true } +const impl PartialEq for A { + fn eq(&self, _: &A) -> bool { + true + } } #[derive_const(Default, PartialEq)]
diff --git a/tests/ui/traits/const-traits/do-not-const-check-override.rs b/tests/ui/traits/const-traits/do-not-const-check-override.rs index caa3e19..93af74d 100644 --- a/tests/ui/traits/const-traits/do-not-const-check-override.rs +++ b/tests/ui/traits/const-traits/do-not-const-check-override.rs
@@ -5,11 +5,12 @@ const trait Foo { #[rustc_do_not_const_check] - fn into_iter(&self) { println!("FEAR ME!") } + fn into_iter(&self) { + println!("FEAR ME!") + } } - -impl const Foo for () { +const impl Foo for () { fn into_iter(&self) { // ^_^ }
diff --git a/tests/ui/traits/const-traits/dont-observe-host.rs b/tests/ui/traits/const-traits/dont-observe-host.rs index f8477a3..2ef6e09 100644 --- a/tests/ui/traits/const-traits/dont-observe-host.rs +++ b/tests/ui/traits/const-traits/dont-observe-host.rs
@@ -7,7 +7,7 @@ const trait Trait { fn method() {} } -impl const Trait for () {} +const impl Trait for () {} fn main() { let mut x = const {
diff --git a/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs b/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs index f45265c..cbf3a22 100644 --- a/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs +++ b/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs
@@ -4,7 +4,7 @@ const trait Foo {} -impl<T> const Foo for (T,) where T: [const] Foo {} +const impl<T> Foo for (T,) where T: [const] Foo {} const fn needs_const_foo(_: impl [const] Foo + Copy) {}
diff --git a/tests/ui/traits/const-traits/drop-manually-drop.rs b/tests/ui/traits/const-traits/drop-manually-drop.rs index 62e8a81..23f1770 100644 --- a/tests/ui/traits/const-traits/drop-manually-drop.rs +++ b/tests/ui/traits/const-traits/drop-manually-drop.rs
@@ -15,7 +15,7 @@ fn drop(&mut self) {} struct ConstDropper<T>(ManuallyDrop<T>); -impl<T> const Drop for ConstDropper<T> { +const impl<T> Drop for ConstDropper<T> { fn drop(&mut self) {} }
diff --git a/tests/ui/traits/const-traits/effect-param-infer.rs b/tests/ui/traits/const-traits/effect-param-infer.rs index 4ff2406..44144e0 100644 --- a/tests/ui/traits/const-traits/effect-param-infer.rs +++ b/tests/ui/traits/const-traits/effect-param-infer.rs
@@ -9,6 +9,6 @@ pub const trait Foo<Rhs: ?Sized = Self> { /* stuff */ } -impl const Foo for () {} +const impl Foo for () {} fn main() {}
diff --git a/tests/ui/traits/const-traits/enforce-deref-on-adjust.rs b/tests/ui/traits/const-traits/enforce-deref-on-adjust.rs index cba207f..4bf4499 100644 --- a/tests/ui/traits/const-traits/enforce-deref-on-adjust.rs +++ b/tests/ui/traits/const-traits/enforce-deref-on-adjust.rs
@@ -12,7 +12,7 @@ impl Foo { const fn call(&self) {} } -impl<T> const Deref for Wrap<T> { +const impl<T> Deref for Wrap<T> { type Target = T; fn deref(&self) -> &Self::Target {
diff --git a/tests/ui/traits/const-traits/eval-bad-signature.rs b/tests/ui/traits/const-traits/eval-bad-signature.rs index 02afdb9..3d205e9 100644 --- a/tests/ui/traits/const-traits/eval-bad-signature.rs +++ b/tests/ui/traits/const-traits/eval-bad-signature.rs
@@ -12,7 +12,7 @@ const fn get_value<T: [const] Value>() -> u32 { struct FortyTwo; -impl const Value for FortyTwo { +const impl Value for FortyTwo { fn value() -> i64 { //~^ ERROR method `value` has an incompatible type for trait 42
diff --git a/tests/ui/traits/const-traits/feature-gate.rs b/tests/ui/traits/const-traits/feature-gate.rs index 46f0e92..ac0e1cd 100644 --- a/tests/ui/traits/const-traits/feature-gate.rs +++ b/tests/ui/traits/const-traits/feature-gate.rs
@@ -6,7 +6,7 @@ struct S; const trait T {} //[stock]~ ERROR const trait impls are experimental -impl const T for S {} +const impl T for S {} //[stock]~^ ERROR const trait impls are experimental const fn f<A: [const] T>() {} //[stock]~ ERROR const trait impls are experimental
diff --git a/tests/ui/traits/const-traits/feature-gate.stock.stderr b/tests/ui/traits/const-traits/feature-gate.stock.stderr index b5e0310..3b019eb 100644 --- a/tests/ui/traits/const-traits/feature-gate.stock.stderr +++ b/tests/ui/traits/const-traits/feature-gate.stock.stderr
@@ -9,10 +9,10 @@ = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:9:6 + --> $DIR/feature-gate.rs:9:1 | -LL | impl const T for S {} - | ^^^^^ +LL | const impl T for S {} + | ^^^^^ | = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
diff --git a/tests/ui/traits/const-traits/generic-bound.rs b/tests/ui/traits/const-traits/generic-bound.rs index 99de214..0438bf9 100644 --- a/tests/ui/traits/const-traits/generic-bound.rs +++ b/tests/ui/traits/const-traits/generic-bound.rs
@@ -13,7 +13,7 @@ fn clone(&self) -> Self { } } -impl<T> const std::ops::Add for S<T> { +const impl<T> std::ops::Add for S<T> { type Output = Self; fn add(self, _: Self) -> Self {
diff --git a/tests/ui/traits/const-traits/hir-const-check.rs b/tests/ui/traits/const-traits/hir-const-check.rs index 5473cdd..66cd9ff 100644 --- a/tests/ui/traits/const-traits/hir-const-check.rs +++ b/tests/ui/traits/const-traits/hir-const-check.rs
@@ -10,7 +10,7 @@ pub const trait MyTrait { fn method(&self) -> Option<()>; } -impl const MyTrait for () { +const impl MyTrait for () { fn method(&self) -> Option<()> { Some(())?; None
diff --git a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs index 8a6efda..ce43506 100644 --- a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs +++ b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs
@@ -3,7 +3,7 @@ use std::ops::FromResidual; -impl<T> const FromResidual for T { +const impl<T> FromResidual for T { //~^ ERROR type parameter `T` must be used as an argument to some local type fn from_residual(t: T) -> _ { //~^ ERROR the placeholder `_` is not allowed
diff --git a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr index 1d1805a..6096786 100644 --- a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr +++ b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr
@@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct<T>`) - --> $DIR/ice-119717-constant-lifetime.rs:6:6 + --> $DIR/ice-119717-constant-lifetime.rs:6:12 | -LL | impl<T> const FromResidual for T { - | ^ uncovered type parameter +LL | const impl<T> FromResidual for T { + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter
diff --git a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs index 617c28c..ba503be 100644 --- a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs +++ b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs
@@ -4,9 +4,9 @@ const trait Foo {} -impl const Foo for i32 {} +const impl Foo for i32 {} -impl<T> const Foo for T where T: [const] Foo {} +const impl<T> Foo for T where T: [const] Foo {} //~^ ERROR conflicting implementations of trait `Foo` for type `i32` fn main() {}
diff --git a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr index 082e7a1..97fdb4b 100644 --- a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr +++ b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr
@@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `Foo` for type `i32` --> $DIR/ice-124857-combine-effect-const-infer-vars.rs:9:1 | -LL | impl const Foo for i32 {} +LL | const impl Foo for i32 {} | ---------------------- first implementation here LL | -LL | impl<T> const Foo for T where T: [const] Foo {} +LL | const impl<T> Foo for T where T: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` error: aborting due to 1 previous error
diff --git a/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.rs b/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.rs index e02710e..11ebe4e 100644 --- a/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.rs +++ b/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.rs
@@ -5,16 +5,16 @@ struct TryMe; struct Error; -impl const FromResidual<Error> for TryMe {} +const impl FromResidual<Error> for TryMe {} //~^ ERROR not all trait items implemented -impl const Try for TryMe { +const impl Try for TryMe { //~^ ERROR not all trait items implemented type Output = (); type Residual = Error; } -impl const Residual<()> for Error { +const impl Residual<()> for Error { type TryType = TryMe; }
diff --git a/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr b/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr index 183203a..77b715a 100644 --- a/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr +++ b/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr
@@ -1,7 +1,7 @@ error[E0046]: not all trait items implemented, missing: `from_residual` --> $DIR/ice-126148-failed-to-normalize.rs:8:1 | -LL | impl const FromResidual<Error> for TryMe {} +LL | const impl FromResidual<Error> for TryMe {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_residual` in implementation | = help: implement the missing item: `fn from_residual(_: Error) -> Self { todo!() }` @@ -9,7 +9,7 @@ error[E0046]: not all trait items implemented, missing: `from_output`, `branch` --> $DIR/ice-126148-failed-to-normalize.rs:11:1 | -LL | impl const Try for TryMe { +LL | const impl Try for TryMe { | ^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_output`, `branch` in implementation | = help: implement the missing item: `fn from_output(_: <Self as Try>::Output) -> Self { todo!() }`
diff --git a/tests/ui/traits/const-traits/impl-with-default-fn-fail.rs b/tests/ui/traits/const-traits/impl-with-default-fn-fail.rs index 7becb01..18066d8 100644 --- a/tests/ui/traits/const-traits/impl-with-default-fn-fail.rs +++ b/tests/ui/traits/const-traits/impl-with-default-fn-fail.rs
@@ -8,9 +8,8 @@ fn default() {} struct S; -impl const Tr for u16 { +const impl Tr for u16 { fn default() {} } //~^^ ERROR not all trait items implemented - fn main() {}
diff --git a/tests/ui/traits/const-traits/impl-with-default-fn-fail.stderr b/tests/ui/traits/const-traits/impl-with-default-fn-fail.stderr index 61f9898..33df023 100644 --- a/tests/ui/traits/const-traits/impl-with-default-fn-fail.stderr +++ b/tests/ui/traits/const-traits/impl-with-default-fn-fail.stderr
@@ -4,7 +4,7 @@ LL | fn req(&self); | -------------- `req` from trait ... -LL | impl const Tr for u16 { +LL | const impl Tr for u16 { | ^^^^^^^^^^^^^^^^^^^^^ missing `req` in implementation error: aborting due to 1 previous error
diff --git a/tests/ui/traits/const-traits/impl-with-default-fn-pass.rs b/tests/ui/traits/const-traits/impl-with-default-fn-pass.rs index f6888f5..7e54f85 100644 --- a/tests/ui/traits/const-traits/impl-with-default-fn-pass.rs +++ b/tests/ui/traits/const-traits/impl-with-default-fn-pass.rs
@@ -8,16 +8,16 @@ const trait Tr { fn default() {} } -impl const Tr for u8 { +const impl Tr for u8 { fn req(&self) {} } macro_rules! impl_tr { ($ty: ty) => { - impl const Tr for $ty { + const impl Tr for $ty { fn req(&self) {} } - } + }; } impl_tr!(u64);
diff --git a/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs b/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs index 6770146..aa8d98a 100644 --- a/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs +++ b/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs
@@ -6,12 +6,14 @@ const trait A {} const trait B {} -impl const A for S {} -impl const B for S {} +const impl A for S {} +const impl B for S {} impl S { - const fn a<T: [const] A>() where T: [const] B { - + const fn a<T: [const] A>() + where + T: [const] B, + { } }
diff --git a/tests/ui/traits/const-traits/inherent-impl.rs b/tests/ui/traits/const-traits/inherent-impl.rs index 886cfb0..62398ab 100644 --- a/tests/ui/traits/const-traits/inherent-impl.rs +++ b/tests/ui/traits/const-traits/inherent-impl.rs
@@ -6,8 +6,8 @@ struct S; trait T {} -impl const S {} +const impl S {} -impl const dyn T {} +const impl dyn T {} fn main() {}
diff --git a/tests/ui/traits/const-traits/issue-100222.rs b/tests/ui/traits/const-traits/issue-100222.rs index aebcb62..45bc5e9 100644 --- a/tests/ui/traits/const-traits/issue-100222.rs +++ b/tests/ui/traits/const-traits/issue-100222.rs
@@ -5,8 +5,14 @@ #![allow(incomplete_features)] #![feature(const_trait_impl, associated_type_defaults)] -#[cfg(any(yn, yy))] pub const trait Index { type Output; } -#[cfg(not(any(yn, yy)))] pub trait Index { type Output; } +#[cfg(any(yn, yy))] +pub const trait Index { + type Output; +} +#[cfg(not(any(yn, yy)))] +pub trait Index { + type Output; +} #[cfg(any(ny, yy))] pub const trait IndexMut @@ -33,7 +39,7 @@ impl Index for () { } #[cfg(not(any(nn, yn)))] -impl const IndexMut for <() as Index>::Output { +const impl IndexMut for <() as Index>::Output { const C: <Self as Index>::Output = (); type Assoc = <Self as Index>::Output; fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output
diff --git a/tests/ui/traits/const-traits/issue-102156.rs b/tests/ui/traits/const-traits/issue-102156.rs index bd9fdff..506fdaa 100644 --- a/tests/ui/traits/const-traits/issue-102156.rs +++ b/tests/ui/traits/const-traits/issue-102156.rs
@@ -8,7 +8,7 @@ use std::pin::Pin; use std::alloc::Allocator; -impl<T: ?Sized, A: Allocator> const From<Box<T, A>> for Pin<Box<T, A>> +const impl<T: ?Sized, A: Allocator> From<Box<T, A>> for Pin<Box<T, A>> where A: 'static, {}
diff --git a/tests/ui/traits/const-traits/issue-79450.rs b/tests/ui/traits/const-traits/issue-79450.rs index c6234f8..7c217f9 100644 --- a/tests/ui/traits/const-traits/issue-79450.rs +++ b/tests/ui/traits/const-traits/issue-79450.rs
@@ -12,7 +12,7 @@ fn prov(&self) { struct S; -impl const Tr for S { +const impl Tr for S { fn req(&self) {} }
diff --git a/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs b/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs index 0663e23..66262ba 100644 --- a/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs +++ b/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs
@@ -8,7 +8,7 @@ pub const trait Super {} pub const trait Sub: Super {} -impl<A> const Super for &A where A: [const] Super {} -impl<A> const Sub for &A where A: [const] Sub {} +const impl<A> Super for &A where A: [const] Super {} +const impl<A> Sub for &A where A: [const] Sub {} fn main() {}
diff --git a/tests/ui/traits/const-traits/item-bound-entailment-fails.rs b/tests/ui/traits/const-traits/item-bound-entailment-fails.rs index 047da4c..17b35f7 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment-fails.rs +++ b/tests/ui/traits/const-traits/item-bound-entailment-fails.rs
@@ -11,16 +11,16 @@ const trait Bar {} struct N<T>(T); impl<T> Bar for N<T> where T: Bar {} struct C<T>(T); -impl<T> const Bar for C<T> where T: [const] Bar {} +const impl<T> Bar for C<T> where T: [const] Bar {} -impl const Foo for u32 { +const impl Foo for u32 { type Assoc<T> = N<T> //~^ ERROR the trait bound `N<T>: [const] Bar` is not satisfied where T: [const] Bar; } -impl const Foo for i32 { +const impl Foo for i32 { type Assoc<T> = C<T> //~^ ERROR the trait bound `T: [const] Bar` is not satisfied where
diff --git a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr index 3c150c7..ffa9679 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr +++ b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr
@@ -23,7 +23,7 @@ note: required for `C<T>` to implement `[const] Bar` --> $DIR/item-bound-entailment-fails.rs:14:15 | -LL | impl<T> const Bar for C<T> where T: [const] Bar {} +LL | const impl<T> Bar for C<T> where T: [const] Bar {} | ^^^ ^^^^ ----------- unsatisfied trait bound introduced here note: required by a bound in `Foo::Assoc` --> $DIR/item-bound-entailment-fails.rs:5:20
diff --git a/tests/ui/traits/const-traits/item-bound-entailment.rs b/tests/ui/traits/const-traits/item-bound-entailment.rs index facd222..ae00b91 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment.rs +++ b/tests/ui/traits/const-traits/item-bound-entailment.rs
@@ -13,7 +13,7 @@ const trait Bar {} struct N<T>(T); impl<T> Bar for N<T> where T: Bar {} struct C<T>(T); -impl<T> const Bar for C<T> where T: [const] Bar {} +const impl<T> Bar for C<T> where T: [const] Bar {} impl Foo for u32 { type Assoc<T> = N<T> @@ -21,7 +21,7 @@ impl Foo for u32 { T: Bar; } -impl const Foo for i32 { +const impl Foo for i32 { type Assoc<T> = C<T> where T: [const] Bar;
diff --git a/tests/ui/traits/const-traits/minicore-drop-fail.rs b/tests/ui/traits/const-traits/minicore-drop-fail.rs index f17a88d..7cfd9ae 100644 --- a/tests/ui/traits/const-traits/minicore-drop-fail.rs +++ b/tests/ui/traits/const-traits/minicore-drop-fail.rs
@@ -19,7 +19,7 @@ const trait Foo {} impl Foo for () {} struct Conditional<T: Foo>(T); -impl<T> const Drop for Conditional<T> where T: [const] Foo + [const] Destruct { +const impl<T> Drop for Conditional<T> where T: [const] Foo + [const] Destruct { fn drop(&mut self) {} }
diff --git a/tests/ui/traits/const-traits/minicore-drop-without-feature-gate.rs b/tests/ui/traits/const-traits/minicore-drop-without-feature-gate.rs index e75bf3d..3524aca 100644 --- a/tests/ui/traits/const-traits/minicore-drop-without-feature-gate.rs +++ b/tests/ui/traits/const-traits/minicore-drop-without-feature-gate.rs
@@ -13,7 +13,7 @@ use minicore::*; struct ConstDrop; -impl const Drop for ConstDrop { +const impl Drop for ConstDrop { fn drop(&mut self) {} }
diff --git a/tests/ui/traits/const-traits/minicore-works.rs b/tests/ui/traits/const-traits/minicore-works.rs index ef08e84..a3c86a4 100644 --- a/tests/ui/traits/const-traits/minicore-works.rs +++ b/tests/ui/traits/const-traits/minicore-works.rs
@@ -11,7 +11,7 @@ use minicore::*; struct Custom; -impl const Add for Custom { +const impl Add for Custom { type Output = (); fn add(self, _other: Self) {} }
diff --git a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs index c0051c6..80d70ac 100644 --- a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs +++ b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs
@@ -6,7 +6,10 @@ const trait Convert<T> { fn to(self) -> T; } -impl<A, B> const Convert<B> for A where B: [const] From<A> { +const impl<A, B> Convert<B> for A +where + B: [const] From<A>, +{ fn to(self) -> B { B::from(self) }
diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr b/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr index 57bb556..e80ad41 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr
@@ -1,7 +1,7 @@ error[E0119]: conflicting implementations of trait `Foo` for type `(_,)` --> $DIR/overlap-const-with-nonconst.rs:20:1 | -LL | / impl<T> const Foo for T +LL | / const impl<T> Foo for T LL | | where LL | | T: [const] Bar, | |___________________- first implementation here
diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs b/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs index 0e21d31..4de3eb8 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs
@@ -5,12 +5,12 @@ #![cfg_attr(min_spec, feature(min_specialization))] const trait Bar {} -impl<T> const Bar for T {} +const impl<T> Bar for T {} const trait Foo { fn method(&self); } -impl<T> const Foo for T +const impl<T> Foo for T where T: [const] Bar, { @@ -18,7 +18,7 @@ impl<T> const Foo for T } // specializing impl: impl<T> Foo for (T,) { -//~^ ERROR conflicting implementations + //~^ ERROR conflicting implementations fn method(&self) { println!("hi"); }
diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr b/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr index 57bb556..e80ad41 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr
@@ -1,7 +1,7 @@ error[E0119]: conflicting implementations of trait `Foo` for type `(_,)` --> $DIR/overlap-const-with-nonconst.rs:20:1 | -LL | / impl<T> const Foo for T +LL | / const impl<T> Foo for T LL | | where LL | | T: [const] Bar, | |___________________- first implementation here
diff --git a/tests/ui/traits/const-traits/partial/no-const-callers.rs b/tests/ui/traits/const-traits/partial/no-const-callers.rs index 7c198f4..a6e81f4 100644 --- a/tests/ui/traits/const-traits/partial/no-const-callers.rs +++ b/tests/ui/traits/const-traits/partial/no-const-callers.rs
@@ -6,17 +6,17 @@ const trait A { fn b() { println!("hi"); } } -impl const A for () { +const impl A for () { fn a() {} } -impl const A for u8 { +const impl A for u8 { fn a() {} fn b() { println!("hello"); } //~^ ERROR: cannot call non-const function } -impl const A for i8 { +const impl A for i8 { fn a() {} fn b() {} }
diff --git a/tests/ui/traits/const-traits/predicate-entailment-fails.rs b/tests/ui/traits/const-traits/predicate-entailment-fails.rs index d1a8c35..602b739 100644 --- a/tests/ui/traits/const-traits/predicate-entailment-fails.rs +++ b/tests/ui/traits/const-traits/predicate-entailment-fails.rs
@@ -2,7 +2,7 @@ #![feature(const_trait_impl)] const trait Bar {} -impl const Bar for () {} +const impl Bar for () {} const trait TildeConst { @@ -31,7 +31,7 @@ impl NeverConst for i32 { fn foo<T>() where T: const Bar {} //~^ ERROR impl has stricter requirements than trait } -impl const NeverConst for u32 { +const impl NeverConst for u32 { type Bar<T> = () where T: [const] Bar; //~^ ERROR impl has stricter requirements than trait
diff --git a/tests/ui/traits/const-traits/predicate-entailment-passes.rs b/tests/ui/traits/const-traits/predicate-entailment-passes.rs index c2bac51..a7f3325 100644 --- a/tests/ui/traits/const-traits/predicate-entailment-passes.rs +++ b/tests/ui/traits/const-traits/predicate-entailment-passes.rs
@@ -4,7 +4,7 @@ #![feature(const_trait_impl)] const trait Bar {} -impl const Bar for () {} +const impl Bar for () {} const trait TildeConst { fn foo<T>() where T: [const] Bar; @@ -20,7 +20,7 @@ const trait AlwaysConst { impl AlwaysConst for i32 { fn foo<T>() where T: Bar {} } -impl const AlwaysConst for u32 { +const impl AlwaysConst for u32 { fn foo<T>() where T: [const] Bar {} }
diff --git a/tests/ui/traits/const-traits/rustc-impl-const-stability.rs b/tests/ui/traits/const-traits/rustc-impl-const-stability.rs index 7d30342..e1131a5 100644 --- a/tests/ui/traits/const-traits/rustc-impl-const-stability.rs +++ b/tests/ui/traits/const-traits/rustc-impl-const-stability.rs
@@ -11,7 +11,7 @@ pub struct Data { #[stable(feature = "potato", since = "1.27.0")] #[rustc_const_unstable(feature = "data_foo", issue = "none")] -impl const Default for Data { +const impl Default for Data { fn default() -> Data { Data { _data: 0xbeef } }
diff --git a/tests/ui/traits/const-traits/self-receiver-type-mismatch.rs b/tests/ui/traits/const-traits/self-receiver-type-mismatch.rs index 61f0dbe..96c8ed4 100644 --- a/tests/ui/traits/const-traits/self-receiver-type-mismatch.rs +++ b/tests/ui/traits/const-traits/self-receiver-type-mismatch.rs
@@ -10,7 +10,7 @@ const trait Func { struct Cls; -impl const Func for Cls { +const impl Func for Cls { fn trigger(&self, a: usize) -> usize { //~^ ERROR method `trigger` has 2 parameters but the declaration in trait `Func::trigger` has 1 0
diff --git a/tests/ui/traits/const-traits/span-bug-issue-121418.rs b/tests/ui/traits/const-traits/span-bug-issue-121418.rs index 97d9c69..4086d9c 100644 --- a/tests/ui/traits/const-traits/span-bug-issue-121418.rs +++ b/tests/ui/traits/const-traits/span-bug-issue-121418.rs
@@ -3,7 +3,7 @@ struct S; trait T {} -impl const dyn T { +const impl dyn T { pub const fn new() -> std::sync::Mutex<dyn T> {} //~^ ERROR mismatched types //~| ERROR cannot be known at compilation time
diff --git a/tests/ui/traits/const-traits/span-bug-issue-121418.stderr b/tests/ui/traits/const-traits/span-bug-issue-121418.stderr index 88776f2..3beb92d 100644 --- a/tests/ui/traits/const-traits/span-bug-issue-121418.stderr +++ b/tests/ui/traits/const-traits/span-bug-issue-121418.stderr
@@ -1,8 +1,8 @@ error: redundant `const` fn marker in const impl --> $DIR/span-bug-issue-121418.rs:7:9 | -LL | impl const dyn T { - | ----- this declares all associated functions implicitly const +LL | const impl dyn T { + | ----- this declares all associated functions implicitly const LL | pub const fn new() -> std::sync::Mutex<dyn T> {} | ^^^^^^ help: remove the `const`
diff --git a/tests/ui/traits/const-traits/spec-effectvar-ice.rs b/tests/ui/traits/const-traits/spec-effectvar-ice.rs index 46f71b1..d7a286b 100644 --- a/tests/ui/traits/const-traits/spec-effectvar-ice.rs +++ b/tests/ui/traits/const-traits/spec-effectvar-ice.rs
@@ -7,10 +7,10 @@ trait Specialize {} trait Foo {} -impl<T> const Foo for T {} +const impl<T> Foo for T {} //~^ error: const `impl` for trait `Foo` which is not `const` -impl<T> const Foo for T where T: const Specialize {} +const impl<T> Foo for T where T: const Specialize {} //~^ error: const `impl` for trait `Foo` which is not `const` //~| error: `const` can only be applied to `const` traits //~| error: specialization impl does not specialize any associated items
diff --git a/tests/ui/traits/const-traits/spec-effectvar-ice.stderr b/tests/ui/traits/const-traits/spec-effectvar-ice.stderr index 8dbbd30..14b4561 100644 --- a/tests/ui/traits/const-traits/spec-effectvar-ice.stderr +++ b/tests/ui/traits/const-traits/spec-effectvar-ice.stderr
@@ -1,7 +1,7 @@ error: const `impl` for trait `Foo` which is not `const` --> $DIR/spec-effectvar-ice.rs:10:15 | -LL | impl<T> const Foo for T {} +LL | const impl<T> Foo for T {} | ^^^ this trait is not `const` | = note: marking a trait with `const` ensures all default method bodies are `const` @@ -14,7 +14,7 @@ error: const `impl` for trait `Foo` which is not `const` --> $DIR/spec-effectvar-ice.rs:13:15 | -LL | impl<T> const Foo for T where T: const Specialize {} +LL | const impl<T> Foo for T where T: const Specialize {} | ^^^ this trait is not `const` | = note: marking a trait with `const` ensures all default method bodies are `const` @@ -27,7 +27,7 @@ error: `const` can only be applied to `const` traits --> $DIR/spec-effectvar-ice.rs:13:34 | -LL | impl<T> const Foo for T where T: const Specialize {} +LL | const impl<T> Foo for T where T: const Specialize {} | ^^^^^ can't be applied to `Specialize` | help: mark `Specialize` as `const` to allow it to have `const` implementations @@ -38,19 +38,19 @@ error: specialization impl does not specialize any associated items --> $DIR/spec-effectvar-ice.rs:13:1 | -LL | impl<T> const Foo for T where T: const Specialize {} +LL | const impl<T> Foo for T where T: const Specialize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: impl is a specialization of this impl --> $DIR/spec-effectvar-ice.rs:10:1 | -LL | impl<T> const Foo for T {} +LL | const impl<T> Foo for T {} | ^^^^^^^^^^^^^^^^^^^^^^^ error: cannot specialize on trait `Specialize` --> $DIR/spec-effectvar-ice.rs:13:34 | -LL | impl<T> const Foo for T where T: const Specialize {} +LL | const impl<T> Foo for T where T: const Specialize {} | ^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors
diff --git a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs index f771107..ddd9737 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs +++ b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs
@@ -14,7 +14,7 @@ const trait Bar { fn bar(); } -impl<T> const Bar for T +const impl<T> Bar for T where T: [const] Foo, { @@ -33,14 +33,14 @@ const trait Baz { fn baz(); } -impl<T> const Baz for T +const impl<T> Baz for T where T: [const] Foo, { default fn baz() {} } -impl<T> const Baz for T //~ ERROR conflicting implementations of trait `Baz` +const impl<T> Baz for T //~ ERROR conflicting implementations of trait `Baz` where T: Foo, T: Specialize,
diff --git a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr index ff27559..ae44a43 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr +++ b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr
@@ -1,7 +1,7 @@ error[E0119]: conflicting implementations of trait `Bar` --> $DIR/const-default-bound-non-const-specialized-bound.rs:24:1 | -LL | / impl<T> const Bar for T +LL | / const impl<T> Bar for T LL | | where LL | | T: [const] Foo, | |___________________- first implementation here @@ -15,12 +15,12 @@ error[E0119]: conflicting implementations of trait `Baz` --> $DIR/const-default-bound-non-const-specialized-bound.rs:43:1 | -LL | / impl<T> const Baz for T +LL | / const impl<T> Baz for T LL | | where LL | | T: [const] Foo, | |___________________- first implementation here ... -LL | / impl<T> const Baz for T +LL | / const impl<T> Baz for T LL | | where LL | | T: Foo, LL | | T: Specialize,
diff --git a/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs b/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs index 3be2ff4..872f5be 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs +++ b/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs
@@ -14,7 +14,7 @@ const fn get_value<T: [const] Value>() -> u32 { T::value() } -impl<T> const Value for T { +const impl<T> Value for T { default fn value() -> u32 { 0 } @@ -22,7 +22,7 @@ impl<T> const Value for T { struct FortyTwo; -impl const Value for FortyTwo { +const impl Value for FortyTwo { fn value() -> u32 { 42 }
diff --git a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.min_spec.stderr b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.min_spec.stderr index ad3c177..197495f 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.min_spec.stderr +++ b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.min_spec.stderr
@@ -1,7 +1,7 @@ error[E0119]: conflicting implementations of trait `Value` for type `FortyTwo` --> $DIR/const-default-impl-non-const-specialized-impl.rs:20:1 | -LL | impl<T> const Value for T { +LL | const impl<T> Value for T { | ------------------------- first implementation here ... LL | impl Value for FortyTwo {
diff --git a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.rs b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.rs index b26e655..c742592 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.rs +++ b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.rs
@@ -9,7 +9,7 @@ const trait Value { fn value() -> u32; } -impl<T> const Value for T { +const impl<T> Value for T { default fn value() -> u32 { 0 }
diff --git a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.spec.stderr b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.spec.stderr index ad3c177..197495f 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.spec.stderr +++ b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.spec.stderr
@@ -1,7 +1,7 @@ error[E0119]: conflicting implementations of trait `Value` for type `FortyTwo` --> $DIR/const-default-impl-non-const-specialized-impl.rs:20:1 | -LL | impl<T> const Value for T { +LL | const impl<T> Value for T { | ------------------------- first implementation here ... LL | impl Value for FortyTwo {
diff --git a/tests/ui/traits/const-traits/specialization/default-keyword.rs b/tests/ui/traits/const-traits/specialization/default-keyword.rs index 5b07401..0eadec0 100644 --- a/tests/ui/traits/const-traits/specialization/default-keyword.rs +++ b/tests/ui/traits/const-traits/specialization/default-keyword.rs
@@ -7,7 +7,7 @@ const trait Foo { fn foo(); } -impl const Foo for u32 { +const impl Foo for u32 { default fn foo() {} }
diff --git a/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs b/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs index dbdbf59..a2175de 100644 --- a/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs +++ b/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs
@@ -24,7 +24,7 @@ impl<T> Bar for T default fn bar() {} } -impl<T> const Bar for T +const impl<T> Bar for T where T: [const] Foo, T: Specialize, @@ -36,14 +36,14 @@ const trait Baz { fn baz(); } -impl<T> const Baz for T +const impl<T> Baz for T where T: Foo, { default fn baz() {} } -impl<T> const Baz for T +const impl<T> Baz for T where T: [const] Foo, T: Specialize,
diff --git a/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs b/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs index c68f80d..61f97a7 100644 --- a/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs +++ b/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs
@@ -23,7 +23,7 @@ impl<T> Value for T { struct FortyTwo; -impl const Value for FortyTwo { +const impl Value for FortyTwo { fn value() -> u32 { 42 }
diff --git a/tests/ui/traits/const-traits/specialization/pass.rs b/tests/ui/traits/const-traits/specialization/pass.rs index 0ba4e40..60c7bd6 100644 --- a/tests/ui/traits/const-traits/specialization/pass.rs +++ b/tests/ui/traits/const-traits/specialization/pass.rs
@@ -10,37 +10,37 @@ #[rustc_specialization_trait] pub const unsafe trait Sub: [const] Sup {} -unsafe impl const Sup for u8 { +const unsafe impl Sup for u8 { default fn foo() -> u32 { 1 } } -unsafe impl const Sup for () { +const unsafe impl Sup for () { fn foo() -> u32 { 42 } } -unsafe impl const Sub for () {} +const unsafe impl Sub for () {} pub const trait A { fn a() -> u32; } -impl<T: [const] Default> const A for T { +const impl<T: [const] Default> A for T { default fn a() -> u32 { 2 } } -impl<T: [const] Default + [const] Sup> const A for T { +const impl<T: [const] Default + [const] Sup> A for T { default fn a() -> u32 { 3 } } -impl<T: [const] Default + [const] Sub> const A for T { +const impl<T: [const] Default + [const] Sub> A for T { fn a() -> u32 { T::foo() }
diff --git a/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs b/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs index a0630d1..9122b1a 100644 --- a/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs +++ b/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs
@@ -14,11 +14,11 @@ const trait Foo { fn foo(); } -impl<T> const Foo for T { +const impl<T> Foo for T { default fn foo() {} } -impl<T> const Foo for T +const impl<T> Foo for T where T: [const] Specialize, { @@ -29,14 +29,14 @@ const trait Bar { fn bar() {} } -impl<T> const Bar for T +const impl<T> Bar for T where T: [const] Foo, { default fn bar() {} } -impl<T> const Bar for T +const impl<T> Bar for T where T: [const] Foo, T: [const] Specialize,
diff --git a/tests/ui/traits/const-traits/specialization/specializing-constness-2.rs b/tests/ui/traits/const-traits/specialization/specializing-constness-2.rs index 78cfbe3..bbfe35d 100644 --- a/tests/ui/traits/const-traits/specialization/specializing-constness-2.rs +++ b/tests/ui/traits/const-traits/specialization/specializing-constness-2.rs
@@ -4,7 +4,7 @@ #[rustc_specialization_trait] pub const trait Sup {} -impl const Sup for () {} +const impl Sup for () {} pub const trait A { fn a() -> u32; @@ -16,7 +16,7 @@ impl<T: Default> A for T { } } -impl<T: Default + [const] Sup> const A for T { +const impl<T: Default + [const] Sup> A for T { fn a() -> u32 { 3 }
diff --git a/tests/ui/traits/const-traits/specialization/specializing-constness.rs b/tests/ui/traits/const-traits/specialization/specializing-constness.rs index 6e9931e..1ece1b6 100644 --- a/tests/ui/traits/const-traits/specialization/specializing-constness.rs +++ b/tests/ui/traits/const-traits/specialization/specializing-constness.rs
@@ -3,7 +3,7 @@ #[rustc_specialization_trait] pub const trait Sup {} -impl const Sup for () {} +const impl Sup for () {} pub const trait A { fn a() -> u32; @@ -11,7 +11,7 @@ pub const trait A { pub const trait Spec {} -impl<T: [const] Spec> const A for T { +const impl<T: [const] Spec> A for T { default fn a() -> u32 { 2 }
diff --git a/tests/ui/traits/const-traits/specialization/specializing-constness.stderr b/tests/ui/traits/const-traits/specialization/specializing-constness.stderr index e55b24f..e67f34f 100644 --- a/tests/ui/traits/const-traits/specialization/specializing-constness.stderr +++ b/tests/ui/traits/const-traits/specialization/specializing-constness.stderr
@@ -1,7 +1,7 @@ error[E0119]: conflicting implementations of trait `A` --> $DIR/specializing-constness.rs:20:1 | -LL | impl<T: [const] Spec> const A for T { +LL | const impl<T: [const] Spec> A for T { | ----------------------------------- first implementation here ... LL | impl<T: Spec + Sup> A for T {
diff --git a/tests/ui/traits/const-traits/staged-api.rs b/tests/ui/traits/const-traits/staged-api.rs index cd74bb4..055a405 100644 --- a/tests/ui/traits/const-traits/staged-api.rs +++ b/tests/ui/traits/const-traits/staged-api.rs
@@ -18,7 +18,7 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "local_feature", issue = "none")] -impl const MyTrait for Foo { +const impl MyTrait for Foo { fn func() {} } @@ -93,26 +93,26 @@ const trait U {} const trait S {} // implied stable -impl const U for u8 {} +const impl U for u8 {} //~^ ERROR const stability on the impl does not match the const stability on the trait #[rustc_const_stable(since = "0.0.0", feature = "beef2")] -impl const U for u16 {} +const impl U for u16 {} //~^ ERROR const stability on the impl does not match the const stability on the trait //~| ERROR trait implementations cannot be const stable yet #[rustc_const_unstable(feature = "beef", issue = "none")] -impl const U for u32 {} +const impl U for u32 {} // implied stable -impl const S for u8 {} +const impl S for u8 {} #[rustc_const_stable(since = "0.0.0", feature = "beef2")] -impl const S for u16 {} +const impl S for u16 {} //~^ ERROR trait implementations cannot be const stable yet #[rustc_const_unstable(feature = "beef", issue = "none")] -impl const S for u32 {} +const impl S for u32 {} //~^ ERROR const stability on the impl does not match the const stability on the trait fn main() {}
diff --git a/tests/ui/traits/const-traits/staged-api.stderr b/tests/ui/traits/const-traits/staged-api.stderr index 15328ae..6f43418 100644 --- a/tests/ui/traits/const-traits/staged-api.stderr +++ b/tests/ui/traits/const-traits/staged-api.stderr
@@ -1,13 +1,13 @@ error: const stability on the impl does not match the const stability on the trait --> $DIR/staged-api.rs:96:1 | -LL | impl const U for u8 {} +LL | const impl U for u8 {} | ^^^^^^^^^^^^^^^^^^^^^^ | note: this impl is (implicitly) stable... --> $DIR/staged-api.rs:96:1 | -LL | impl const U for u8 {} +LL | const impl U for u8 {} | ^^^^^^^^^^^^^^^^^^^^^^ note: ...but the trait is unstable --> $DIR/staged-api.rs:90:13 @@ -18,7 +18,7 @@ error: trait implementations cannot be const stable yet --> $DIR/staged-api.rs:100:1 | -LL | impl const U for u16 {} +LL | const impl U for u16 {} | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information @@ -26,13 +26,13 @@ error: const stability on the impl does not match the const stability on the trait --> $DIR/staged-api.rs:100:1 | -LL | impl const U for u16 {} +LL | const impl U for u16 {} | ^^^^^^^^^^^^^^^^^^^^^^^ | note: this impl is (implicitly) stable... --> $DIR/staged-api.rs:100:1 | -LL | impl const U for u16 {} +LL | const impl U for u16 {} | ^^^^^^^^^^^^^^^^^^^^^^^ note: ...but the trait is unstable --> $DIR/staged-api.rs:90:13 @@ -43,7 +43,7 @@ error: trait implementations cannot be const stable yet --> $DIR/staged-api.rs:111:1 | -LL | impl const S for u16 {} +LL | const impl S for u16 {} | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information @@ -51,13 +51,13 @@ error: const stability on the impl does not match the const stability on the trait --> $DIR/staged-api.rs:115:1 | -LL | impl const S for u32 {} +LL | const impl S for u32 {} | ^^^^^^^^^^^^^^^^^^^^^^^ | note: this impl is unstable... --> $DIR/staged-api.rs:115:1 | -LL | impl const S for u32 {} +LL | const impl S for u32 {} | ^^^^^^^^^^^^^^^^^^^^^^^ note: ...but the trait is stable --> $DIR/staged-api.rs:93:13
diff --git a/tests/ui/traits/const-traits/super-traits-fail.rs b/tests/ui/traits/const-traits/super-traits-fail.rs index 4f835fd..6686efc 100644 --- a/tests/ui/traits/const-traits/super-traits-fail.rs +++ b/tests/ui/traits/const-traits/super-traits-fail.rs
@@ -12,7 +12,7 @@ impl Foo for S { fn a(&self) {} } -impl const Bar for S {} +const impl Bar for S {} //~^ ERROR the trait bound fn main() {}
diff --git a/tests/ui/traits/const-traits/super-traits-fail.stderr b/tests/ui/traits/const-traits/super-traits-fail.stderr index 37ce058..bb3bc51 100644 --- a/tests/ui/traits/const-traits/super-traits-fail.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail.stderr
@@ -1,7 +1,7 @@ error[E0277]: the trait bound `S: [const] Foo` is not satisfied --> $DIR/super-traits-fail.rs:15:20 | -LL | impl const Bar for S {} +LL | const impl Bar for S {} | ^ | help: make the `impl` of trait `Foo` `const`
diff --git a/tests/ui/traits/const-traits/super-traits.rs b/tests/ui/traits/const-traits/super-traits.rs index 1696271..2653832 100644 --- a/tests/ui/traits/const-traits/super-traits.rs +++ b/tests/ui/traits/const-traits/super-traits.rs
@@ -9,11 +9,11 @@ const trait Foo { const trait Bar: [const] Foo {} struct S; -impl const Foo for S { +const impl Foo for S { fn a(&self) {} } -impl const Bar for S {} +const impl Bar for S {} const fn foo<T: [const] Bar>(t: &T) { t.a();
diff --git a/tests/ui/traits/const-traits/syntactical-unstable.rs b/tests/ui/traits/const-traits/syntactical-unstable.rs index 6518dd0..42fd5bd 100644 --- a/tests/ui/traits/const-traits/syntactical-unstable.rs +++ b/tests/ui/traits/const-traits/syntactical-unstable.rs
@@ -25,7 +25,7 @@ const fn rpit() -> impl [const] MyTrait { Local } //~^ ERROR use of unstable const library feature `unstable` struct Local; -impl const MyTrait for Local { +const impl MyTrait for Local { //~^ ERROR use of unstable const library feature `unstable` fn func() {} }
diff --git a/tests/ui/traits/const-traits/syntactical-unstable.stderr b/tests/ui/traits/const-traits/syntactical-unstable.stderr index e2a65c7..3318a7b 100644 --- a/tests/ui/traits/const-traits/syntactical-unstable.stderr +++ b/tests/ui/traits/const-traits/syntactical-unstable.stderr
@@ -45,7 +45,7 @@ error[E0658]: use of unstable const library feature `unstable` --> $DIR/syntactical-unstable.rs:28:12 | -LL | impl const MyTrait for Local { +LL | const impl MyTrait for Local { | ^^^^^^^ trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable
diff --git a/tests/ui/traits/const-traits/trait-default-body-stability.rs b/tests/ui/traits/const-traits/trait-default-body-stability.rs index 4a2bcbe..a8936b1 100644 --- a/tests/ui/traits/const-traits/trait-default-body-stability.rs +++ b/tests/ui/traits/const-traits/trait-default-body-stability.rs
@@ -17,7 +17,7 @@ #[stable(feature = "foo", since = "1.0")] #[rustc_const_unstable(feature = "const_t_try", issue = "none")] -impl const Try for T { +const impl Try for T { type Output = T; type Residual = T; @@ -32,13 +32,13 @@ fn branch(self) -> ControlFlow<T, T> { #[stable(feature = "foo", since = "1.0")] #[rustc_const_unstable(feature = "const_t_try", issue = "none")] -impl const Residual<T> for T { +const impl Residual<T> for T { type TryType = T; } #[stable(feature = "foo", since = "1.0")] #[rustc_const_unstable(feature = "const_t_try", issue = "none")] -impl const FromResidual for T { +const impl FromResidual for T { fn from_residual(t: T) -> T { t }
diff --git a/tests/ui/traits/const-traits/trait-fn-const.rs b/tests/ui/traits/const-traits/trait-fn-const.rs index b8ad7b8..8f1941d 100644 --- a/tests/ui/traits/const-traits/trait-fn-const.rs +++ b/tests/ui/traits/const-traits/trait-fn-const.rs
@@ -5,7 +5,7 @@ const trait Trait { const fn fun(); //~ ERROR functions in traits cannot be declared const } -impl const Trait for () { +const impl Trait for () { const fn fun() {} //~ ERROR functions in trait impls cannot be declared const }
diff --git a/tests/ui/traits/const-traits/trait-fn-const.stderr b/tests/ui/traits/const-traits/trait-fn-const.stderr index 78cfc72..1ff1d50 100644 --- a/tests/ui/traits/const-traits/trait-fn-const.stderr +++ b/tests/ui/traits/const-traits/trait-fn-const.stderr
@@ -12,8 +12,8 @@ error[E0379]: functions in trait impls cannot be declared const --> $DIR/trait-fn-const.rs:9:5 | -LL | impl const Trait for () { - | ----- this declares all associated functions implicitly const +LL | const impl Trait for () { + | ----- this declares all associated functions implicitly const LL | const fn fun() {} | ^^^^^- | |
diff --git a/tests/ui/traits/const-traits/trait-where-clause-run.rs b/tests/ui/traits/const-traits/trait-where-clause-run.rs index d24a2ab..c32db85 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-run.rs +++ b/tests/ui/traits/const-traits/trait-where-clause-run.rs
@@ -24,13 +24,13 @@ fn bar() -> u8 { impl Foo for NonConst {} -impl const Bar for Const { +const impl Bar for Const { fn bar() -> u8 { 4 } } -impl const Foo for Const {} +const impl Foo for Const {} fn main() { const ANS1: u8 = Const::foo();
diff --git a/tests/ui/traits/const-traits/variance.rs b/tests/ui/traits/const-traits/variance.rs index 711b810..312ff6c 100644 --- a/tests/ui/traits/const-traits/variance.rs +++ b/tests/ui/traits/const-traits/variance.rs
@@ -4,7 +4,7 @@ const trait Foo {} -impl const Foo for () {} +const impl Foo for () {} fn foo<'a: 'a>() -> impl const Foo {} //~^ ERROR ['a: *]
diff --git a/tests/ui/traits/next-solver/canonical/effect-var.rs b/tests/ui/traits/next-solver/canonical/effect-var.rs index 872a704..7440507 100644 --- a/tests/ui/traits/next-solver/canonical/effect-var.rs +++ b/tests/ui/traits/next-solver/canonical/effect-var.rs
@@ -9,11 +9,14 @@ const trait Foo { trait Bar {} -impl const Foo for i32 { +const impl Foo for i32 { fn foo() {} } -impl<T> const Foo for T where T: Bar { +const impl<T> Foo for T +where + T: Bar, +{ fn foo() {} }
diff --git a/tests/ui/unpretty/exhaustive.rs b/tests/ui/unpretty/exhaustive.rs index 0bbc878..462429e 100644 --- a/tests/ui/unpretty/exhaustive.rs +++ b/tests/ui/unpretty/exhaustive.rs
@@ -543,7 +543,7 @@ mod item_impl { impl () {} impl<T> () {} impl Default for () {} - impl<T> const Default for () {} + const impl<T> Default for () {} } /// ItemKind::MacCall