diff --git a/.github/renovate.json5 b/.github/renovate.json5 index d6c7455fe14cb..6d45e9a81b2fe 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/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb449197f78bd..8747d77b46648 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: run_type: ${{ steps.jobs.outputs.run_type }} steps: - name: Checkout the source code - uses: actions/checkout@v5 + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 - name: Test citool # Only test citool on the auto branch, to reduce latency of the calculate matrix job # on PR/try builds. @@ -117,7 +117,7 @@ jobs: run: git config --global core.autocrlf false - name: checkout the source code - uses: actions/checkout@v5 + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 with: fetch-depth: 2 @@ -254,7 +254,7 @@ jobs: df -h - name: upload artifacts to github - uses: actions/upload-artifact@v7 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: # name is set in previous step name: ${{ env.DOC_ARTIFACT_NAME }} @@ -315,7 +315,7 @@ jobs: environment: ${{ (github.repository == 'rust-lang/rust' && 'bors') || '' }} steps: - name: checkout the source code - uses: actions/checkout@v5 + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 with: fetch-depth: 2 # Publish the toolstate if an auto build succeeds (just before push to the default branch) diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 9512e74601784..be0db12b52f3a 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -51,7 +51,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: checkout the source code - uses: actions/checkout@v5 + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 with: submodules: recursive - name: install the bootstrap toolchain @@ -66,7 +66,7 @@ jobs: run: ./src/tools/update-lockfile.sh - name: upload Cargo.lock artifact for use in PR - uses: actions/upload-artifact@v7 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: name: Cargo-lock path: | @@ -75,7 +75,7 @@ jobs: src/tools/rustbook/Cargo.lock retention-days: 1 - name: upload cargo-update log artifact for use in PR - uses: actions/upload-artifact@v7 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: name: cargo-updates path: cargo_update.log @@ -91,14 +91,14 @@ jobs: pull-requests: write steps: - name: checkout the source code - uses: actions/checkout@v5 + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 - name: download Cargo.lock from update job - uses: actions/download-artifact@v8 + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: name: Cargo-lock - name: download cargo-update log from update job - uses: actions/download-artifact@v8 + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: name: cargo-updates diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index ddb3b2ce0dd58..60deb90542607 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -29,7 +29,7 @@ jobs: # Needed to write to the ghcr.io registry packages: write steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 with: persist-credentials: false diff --git a/.github/workflows/post-merge.yml b/.github/workflows/post-merge.yml index c3d9217a645be..cbe92f1b52d9a 100644 --- a/.github/workflows/post-merge.yml +++ b/.github/workflows/post-merge.yml @@ -15,7 +15,7 @@ jobs: permissions: pull-requests: write steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 with: # Make sure that we have enough commits to find the parent merge commit. # Since all merges should be through merge commits, fetching two commits diff --git a/Cargo.lock b/Cargo.lock index 6b17c0d309cba..b6784840c8c2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -784,6 +784,15 @@ dependencies = [ "cc", ] +[[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" @@ -1330,6 +1339,18 @@ dependencies = [ "stable_deref_trait", ] +[[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" @@ -3055,6 +3076,18 @@ dependencies = [ "portable-atomic", ] +[[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" @@ -4978,7 +5011,7 @@ dependencies = [ name = "rustdoc-json-types" version = "0.1.0" dependencies = [ - "bincode", + "postcard", "rkyv", "rustc-hash 2.1.1", "serde", @@ -5554,9 +5587,9 @@ dependencies = [ [[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 97256963118f3..a09c36efe01f6 100644 --- a/compiler/rustc_ast/Cargo.toml +++ b/compiler/rustc_ast/Cargo.toml @@ -15,6 +15,6 @@ rustc_macros = { path = "../rustc_macros" } 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 f9c08de02512f..0fefc0d9220a3 100644 --- a/compiler/rustc_ast_lowering/Cargo.toml +++ b/compiler/rustc_ast_lowering/Cargo.toml @@ -22,6 +22,6 @@ rustc_session = { path = "../rustc_session" } 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 42cbd7b3d3620..da9b4633fdae9 100644 --- a/compiler/rustc_ast_passes/Cargo.toml +++ b/compiler/rustc_ast_passes/Cargo.toml @@ -18,5 +18,5 @@ rustc_macros = { path = "../rustc_macros" } 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 957fc1297c58e..70da6ba0591ce 100644 --- a/compiler/rustc_ast_pretty/Cargo.toml +++ b/compiler/rustc_ast_pretty/Cargo.toml @@ -13,5 +13,5 @@ rustc_span = { path = "../rustc_span" } [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 fccc36a128057..2e8c912609b2e 100644 --- a/compiler/rustc_attr_parsing/Cargo.toml +++ b/compiler/rustc_attr_parsing/Cargo.toml @@ -20,5 +20,5 @@ rustc_parse_format = { path = "../rustc_parse_format" } 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/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 382f0539f7678..e91ab584bcf47 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -22,7 +22,7 @@ use crate::diagnostics::{ use crate::parser::{ArgParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser}; use crate::session_diagnostics::{ DocAliasBadChar, DocAliasEmpty, DocAliasMalformed, DocAliasStartEnd, DocAttrNotCrateLevel, - DocAttributeNotAttribute, DocKeywordNotKeyword, + DocAttributeNotAttribute, DocKeywordNotKeyword, UnusedDuplicate, }; fn check_keyword(cx: &mut AcceptContext<'_, '_>, keyword: Symbol, span: Span) -> bool { @@ -159,11 +159,7 @@ impl DocParser { let unused_span = path.span(); cx.emit_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - rustc_errors::lints::UnusedDuplicate { - this: unused_span, - other: used_span, - warning: true, - }, + UnusedDuplicate { this: unused_span, other: used_span, warning: true }, unused_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 a80a46e90ac0c..acd5b465a80fe 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 @@ impl SingleAttributeParser for RustcDumpDefPathParser { } } +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 fb5ca0375900a..14e443c922711 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -71,7 +71,7 @@ use crate::parser::{ }; use crate::session_diagnostics::{ AttributeParseError, AttributeParseErrorReason, AttributeParseErrorSuggestions, - ParsedDescription, + ParsedDescription, UnusedDuplicate, }; use crate::target_checking::AllowedTargets; use crate::{AttrSuggestionStyle, AttributeParser, AttributeTemplate, EmitAttribute}; @@ -283,6 +283,7 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, Single>, Single>, Single>, @@ -436,11 +437,7 @@ impl<'f, 'sess: 'f> SharedContext<'f, 'sess> { pub(crate) fn warn_unused_duplicate(&mut self, used_span: Span, unused_span: Span) { self.emit_lint( rustc_session::lint::builtin::UNUSED_ATTRIBUTES, - rustc_errors::lints::UnusedDuplicate { - this: unused_span, - other: used_span, - warning: false, - }, + UnusedDuplicate { this: unused_span, other: used_span, warning: false }, unused_span, ) } @@ -452,11 +449,7 @@ impl<'f, 'sess: 'f> SharedContext<'f, 'sess> { ) { self.emit_lint( rustc_session::lint::builtin::UNUSED_ATTRIBUTES, - rustc_errors::lints::UnusedDuplicate { - this: unused_span, - other: used_span, - warning: true, - }, + UnusedDuplicate { this: unused_span, other: used_span, warning: true }, unused_span, ) } diff --git a/compiler/rustc_attr_parsing/src/session_diagnostics.rs b/compiler/rustc_attr_parsing/src/session_diagnostics.rs index 193ffe195fb6c..d1470d870d130 100644 --- a/compiler/rustc_attr_parsing/src/session_diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/session_diagnostics.rs @@ -1045,3 +1045,16 @@ pub(crate) struct AdditionalCommaSuggestion { #[primary_span] pub span: Span, } + +#[derive(Diagnostic)] +#[diag("unused attribute")] +pub(crate) struct UnusedDuplicate { + #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")] + pub this: Span, + #[note("attribute also specified here")] + pub other: Span, + #[warning( + "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" + )] + pub warning: bool, +} diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index 27ee3f6176ee0..e96dc44fab7c4 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::bug; 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 @@ impl LivenessValues { /// 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) { + 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 @@ impl LivenessValues { /// Returns an iterator of all the points where `region` is live. fn live_points(&self, region: RegionVid) -> impl Iterator { - 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 @@ impl<'tcx, N: Idx> RegionValues<'tcx, N> { /// Returns the locations contained within a given region `r`. pub(crate) fn locations_outlived_by(&self, r: N) -> impl Iterator { - 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, ) -> 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 ebf25d68314db..f5dbc4a0d7cbe 100644 --- a/compiler/rustc_builtin_macros/Cargo.toml +++ b/compiler/rustc_builtin_macros/Cargo.toml @@ -29,7 +29,7 @@ rustc_session = { path = "../rustc_session" } 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 c411954f063bd..2a55cbedfb3b8 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::middle::codegen_fn_attrs::CodegenFnAttrFlags; 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 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { 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 . + 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 c428810e54117..6db3a624500a9 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml @@ -30,7 +30,7 @@ smallvec = { version = "1.8.1", features = [ ] } 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 76cdb10f429c7..e9bb6701c38f1 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -79,7 +79,6 @@ mod diagnostic_impls; pub mod emitter; pub mod formatting; pub mod json; -pub mod lints; mod lock; pub mod markdown; pub mod timings; diff --git a/compiler/rustc_errors/src/lints.rs b/compiler/rustc_errors/src/lints.rs deleted file mode 100644 index 9c93a09bf764c..0000000000000 --- a/compiler/rustc_errors/src/lints.rs +++ /dev/null @@ -1,15 +0,0 @@ -use rustc_macros::Diagnostic; -use rustc_span::Span; - -#[derive(Diagnostic)] -#[diag("unused attribute")] -pub struct UnusedDuplicate { - #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")] - pub this: Span, - #[note("attribute also specified here")] - pub other: Span, - #[warning( - "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" - )] - pub warning: bool, -} diff --git a/compiler/rustc_expand/Cargo.toml b/compiler/rustc_expand/Cargo.toml index 0154d05266fd7..068c84da719a3 100644 --- a/compiler/rustc_expand/Cargo.toml +++ b/compiler/rustc_expand/Cargo.toml @@ -30,6 +30,6 @@ rustc_session = { path = "../rustc_session" } 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 2e13b7705c9d9..e081c2989d3c6 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -390,6 +390,7 @@ pub static BUILTIN_ATTRIBUTES: &[Symbol] = &[ 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 c9e54c9bf71d8..5765163af6e41 100644 --- a/compiler/rustc_hir/Cargo.toml +++ b/compiler/rustc_hir/Cargo.toml @@ -23,6 +23,6 @@ rustc_serialize = { path = "../rustc_serialize" } 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 e419c63162f7a..7c125c3a8983e 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/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index fb6d7e4549fae..f5a6eeec07406 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 @@ impl AttributeKind { 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 87769531f1f5a..09ec1084e9055 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::hir::nested_filter; 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 @@ pub(crate) fn def_parents(tcx: TyCtxt<'_>) { 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/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 871aef76704e4..9a1fcd900a782 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2594,6 +2594,43 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { let variant_def = adt_def.variant_with_id(variant_did); let variant_idx = adt_def.variant_index_with_id(variant_did).as_u32(); + for init in inits { + if !variant_def.fields.iter().any(|field_def| field_def.name == init.field.name) { + let mut err = if adt_def.is_enum() { + struct_span_code_err!( + tcx.dcx(), + init.field.span, + E0559, + "variant `{}::{}` has no field named `{}`", + ty, + variant_def.name, + init.field + ) + } else { + struct_span_code_err!( + tcx.dcx(), + init.field.span, + E0560, + "struct `{}` has no field named `{}`", + variant_def.name, + init.field + ) + }; + if adt_def.is_enum() { + err.span_label( + init.field.span, + format!("`{}::{}` does not have this field", ty, variant_def.name), + ); + } else { + err.span_label( + init.field.span, + format!("`{}` does not have this field", variant_def.name), + ); + } + return ty::Const::new_error(tcx, err.emit()); + } + } + let fields = variant_def .fields .iter() diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 14961abfd92c9..c5a6ce75c0e41 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 a924a81f89b0d..7b39b953e3be0 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 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx 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 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx 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 1896ce10faf2f..33f7e2f38f765 100644 --- a/compiler/rustc_infer/Cargo.toml +++ b/compiler/rustc_infer/Cargo.toml @@ -17,6 +17,6 @@ rustc_middle = { path = "../rustc_middle" } 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 0d93e1478c420..df2412f446781 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 b230fe3be68e3..ce99b01637b04 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 @@ impl LintStoreExpand for LintStoreExpandImpl<'_> { items: &[Box], 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 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) { 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/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 2bee8949c384e..383023aa24457 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -606,37 +606,61 @@ impl_lint_pass!(MissingDebugImplementations => [MISSING_DEBUG_IMPLEMENTATIONS]); impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations { fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) { - if !cx.effective_visibilities.is_reachable(item.owner_id.def_id) { + let def_id = item.owner_id.def_id; + if !cx.effective_visibilities.is_reachable(def_id) { return; } - match item.kind { - hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) | hir::ItemKind::Enum(..) => {} + let is_generic = match item.kind { + hir::ItemKind::Struct(_, generics, _) + | hir::ItemKind::Union(_, generics, _) + | hir::ItemKind::Enum(_, generics, _) => !generics.params.is_empty(), _ => return, - } + }; + + let tcx = cx.tcx; // Avoid listing trait impls if the trait is allowed. - if cx.tcx.lint_level_spec_at_node(MISSING_DEBUG_IMPLEMENTATIONS, item.hir_id()).is_allow() { + if tcx.lint_level_spec_at_node(MISSING_DEBUG_IMPLEMENTATIONS, item.hir_id()).is_allow() { return; } - let Some(debug) = cx.tcx.get_diagnostic_item(sym::Debug) else { return }; + let Some(debug) = tcx.get_diagnostic_item(sym::Debug) else { return }; - let has_impl = cx - .tcx - .non_blanket_impls_for_ty( - debug, - cx.tcx.type_of(item.owner_id).instantiate_identity().skip_norm_wip(), - ) + let ty = tcx.type_of(item.owner_id); + if tcx + .non_blanket_impls_for_ty(debug, ty.instantiate_identity().skip_norm_wip()) .next() - .is_some(); - if !has_impl { - cx.emit_span_lint( - MISSING_DEBUG_IMPLEMENTATIONS, - item.span, - BuiltinMissingDebugImpl { tcx: cx.tcx, def_id: debug }, - ); + .is_some() + { + return; + } + + let infcx = tcx.infer_ctxt().build(cx.typing_mode()); + if is_generic { + let args = infcx.fresh_args_for_item(item.span, def_id.to_def_id()); + if infcx + .type_implements_trait_shallow( + debug, + ty.instantiate(tcx, args).skip_norm_wip(), + cx.param_env, + ) + .is_some() + { + return; + } + } else if infcx + .type_implements_trait(debug, [ty.instantiate_identity().skip_norm_wip()], cx.param_env) + .must_apply_modulo_regions() + { + return; } + + cx.emit_span_lint( + MISSING_DEBUG_IMPLEMENTATIONS, + item.span, + BuiltinMissingDebugImpl { tcx: cx.tcx, def_id: debug }, + ); } } @@ -1514,28 +1538,30 @@ impl EarlyLintPass for DoubleNegations { } } -declare_lint_pass!( - /// Does nothing as a lint pass, but registers some `Lint`s - /// which are used by other parts of the compiler. - SoftLints => [ - WHILE_TRUE, - NON_SHORTHAND_FIELD_PATTERNS, - UNSAFE_CODE, - MISSING_DOCS, - MISSING_COPY_IMPLEMENTATIONS, - MISSING_DEBUG_IMPLEMENTATIONS, - ANONYMOUS_PARAMETERS, - UNUSED_DOC_COMMENTS, - NO_MANGLE_CONST_ITEMS, - NO_MANGLE_GENERIC_ITEMS, - MUTABLE_TRANSMUTES, - UNSTABLE_FEATURES, - UNREACHABLE_PUB, - TYPE_ALIAS_BOUNDS, - TRIVIAL_BOUNDS, - DOUBLE_NEGATIONS - ] -); +pub mod soft { + use super::*; + + pub fn lint_vec() -> crate::LintVec { + vec![ + WHILE_TRUE, + NON_SHORTHAND_FIELD_PATTERNS, + UNSAFE_CODE, + MISSING_DOCS, + MISSING_COPY_IMPLEMENTATIONS, + MISSING_DEBUG_IMPLEMENTATIONS, + ANONYMOUS_PARAMETERS, + UNUSED_DOC_COMMENTS, + NO_MANGLE_CONST_ITEMS, + NO_MANGLE_GENERIC_ITEMS, + MUTABLE_TRANSMUTES, + UNSTABLE_FEATURES, + UNREACHABLE_PUB, + TYPE_ALIAS_BOUNDS, + TRIVIAL_BOUNDS, + DOUBLE_NEGATIONS, + ] + } +} declare_lint! { /// The `ellipsis_inclusive_range_patterns` lint detects the [`...` range diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index df6683c14df42..9cc4f348bd418 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 @@ crate::early_lint_methods!(impl_early_lint_pass, []); /// 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]), } -impl<'a> EarlyCheckNode<'a> for (&'a ast::Crate, &'a [ast::Attribute]) { - fn id(self) -> ast::NodeId { - ast::CRATE_NODE_ID - } - fn attrs(self) -> &'a [ast::Attribute] { - self.1 - } - 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]) { - fn id(self) -> ast::NodeId { - self.0 +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>) { - 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, 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/foreign_modules.rs b/compiler/rustc_lint/src/foreign_modules.rs index df12502c7e5a8..53a84d1285298 100644 --- a/compiler/rustc_lint/src/foreign_modules.rs +++ b/compiler/rustc_lint/src/foreign_modules.rs @@ -17,7 +17,7 @@ pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { clashing_extern_declarations, ..*providers }; } -pub(crate) fn get_lints() -> LintVec { +pub(crate) fn lint_vec() -> LintVec { vec![CLASHING_EXTERN_DECLARATIONS] } diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index dc7cb1270f902..e10ee05e01d91 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -369,7 +369,12 @@ declare_tool_lint! { report_in_external_macro: true } -declare_lint_pass!(TypeIr => [DIRECT_USE_OF_RUSTC_TYPE_IR, NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT, USAGE_OF_TYPE_IR_INHERENT, USAGE_OF_TYPE_IR_TRAITS]); +declare_lint_pass!(TypeIr => [ + DIRECT_USE_OF_RUSTC_TYPE_IR, + NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT, + USAGE_OF_TYPE_IR_INHERENT, + USAGE_OF_TYPE_IR_TRAITS +]); impl<'tcx> LateLintPass<'tcx> for TypeIr { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { @@ -561,8 +566,6 @@ fn is_span_ctxt_call(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { declare_tool_lint! { /// The `symbol_intern_string_literal` detects `Symbol::intern` being called on a string literal pub rustc::SYMBOL_INTERN_STRING_LITERAL, - // rustc_driver crates out of the compiler can't/shouldn't add preinterned symbols; - // bootstrap will deny this manually Allow, "Forbid uses of string literals in `Symbol::intern`, suggesting preinterning instead", report_in_external_macro: true diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs index 0a074c6652a1d..19008a771dedd 100644 --- a/compiler/rustc_lint/src/late.rs +++ b/compiler/rustc_lint/src/late.rs @@ -14,7 +14,6 @@ use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::Session; use rustc_session::lint::LintPass; -use rustc_session::lint::builtin::HardwiredLints; use rustc_span::Span; use tracing::debug; @@ -437,7 +436,6 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) { }) .collect(); - filtered_passes.push(Box::new(HardwiredLints)); let pass = RuntimeCombinedLateLintPass { passes: &mut filtered_passes[..] }; let mut cx = LateContextAndPass { context, pass }; diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index aaa0371b4ec3e..ab09c648adcd9 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -132,7 +132,7 @@ use unused::must_use::*; use unused::*; #[rustfmt::skip] -pub use builtin::{MissingDoc, SoftLints}; +pub use builtin::MissingDoc; pub use context::{CheckLintNameResult, EarlyContext, LateContext, LintContext, LintStore}; pub use early::diagnostics::DiagAndSess; pub use early::{EarlyCheckNode, check_ast_node}; @@ -189,6 +189,18 @@ early_lint_methods!( ] ); +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 @@ late_lint_methods!( ] ); +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(); @@ -281,11 +311,11 @@ fn register_builtins(store: &mut LintStore) { ) } - store.register_lints(&BuiltinCombinedPreExpansionLintPass::get_lints()); - store.register_lints(&BuiltinCombinedEarlyLintPass::get_lints()); - store.register_lints(&BuiltinCombinedModuleLateLintPass::get_lints()); - store.register_lints(&foreign_modules::get_lints()); - store.register_lints(&HardwiredLints::lint_vec()); + store.register_lints(&BuiltinCombinedPreExpansionLintPass::lint_vec()); + store.register_lints(&BuiltinCombinedEarlyLintPass::lint_vec()); + store.register_lints(&BuiltinCombinedModuleLateLintPass::lint_vec()); + store.register_lints(&foreign_modules::lint_vec()); + store.register_lints(&hardwired::lint_vec()); add_lint_group!( "nonstandard_style", @@ -663,50 +693,50 @@ fn register_builtins(store: &mut LintStore) { } fn register_internals(store: &mut LintStore) { - store.register_lints(&LintPassImpl::lint_vec()); - store.register_early_pass(|| Box::new(LintPassImpl)); - 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(&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(&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", None, vec![ + // Early pass: LintPassImpl + LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO), + // Early pass: ImplicitSysrootCrateImport + LintId::of(IMPLICIT_SYSROOT_CRATE_IMPORT), + // Early pass: BadUseOfFindAttr + LintId::of(BAD_USE_OF_FIND_ATTR), + // Late pass: DefaultHashTypes LintId::of(DEFAULT_HASH_TYPES), + // Late pass: QueryStability LintId::of(POTENTIAL_QUERY_INSTABILITY), LintId::of(UNTRACKED_QUERY_INFORMATION), + // Late pass: TyTyKind LintId::of(USAGE_OF_TY_TYKIND), - LintId::of(DISALLOWED_PASS_BY_REF), - LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO), LintId::of(USAGE_OF_QUALIFIED_TY), + // Late pass: TypeIr + LintId::of(DIRECT_USE_OF_RUSTC_TYPE_IR), LintId::of(NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT), LintId::of(USAGE_OF_TYPE_IR_INHERENT), LintId::of(USAGE_OF_TYPE_IR_TRAITS), + // Late pass: BadOptAccess LintId::of(BAD_OPT_ACCESS), + // Late pass: DisallowedPassByRef + LintId::of(DISALLOWED_PASS_BY_REF), + // Late pass: SpanUseEqCtxt LintId::of(SPAN_USE_EQ_CTXT), - LintId::of(DIRECT_USE_OF_RUSTC_TYPE_IR), - LintId::of(IMPLICIT_SYSROOT_CRATE_IMPORT), - LintId::of(BAD_USE_OF_FIND_ATTR), + // Late pass: SymbolInternStringLiteral + // Note: this one is not included in rustc::internal because rustc_driver crates + // outside the compiler can't/shouldn't add preinterned symbols. For rustc itself, + // bootstrap enables this lint manually. For rustdoc, + // `warn(symbol_intern_string_literal)` is used. + // LintId::of(SYMBOL_INTERN_STRING_LITERAL), + // + // Late pass: RustcMustMatchExhaustively LintId::of(RUSTC_MUST_MATCH_EXHAUSTIVELY), ], ); diff --git a/compiler/rustc_lint/src/passes.rs b/compiler/rustc_lint/src/passes.rs index ae145543e70dc..66484b01ff7a8 100644 --- a/compiler/rustc_lint/src/passes.rs +++ b/compiler/rustc_lint/src/passes.rs @@ -1,5 +1,4 @@ use rustc_session::lint::LintPass; -use rustc_session::lint::builtin::HardwiredLints; use crate::context::{EarlyContext, LateContext}; @@ -71,8 +70,6 @@ macro_rules! declare_late_lint_pass { // for all the `check_*` methods. late_lint_methods!(declare_late_lint_pass, []); -impl LateLintPass<'_> for HardwiredLints {} - #[macro_export] macro_rules! expand_combined_late_lint_pass_method { ([$($pass:ident),*], $self: ident, $name: ident, $params:tt) => ({ @@ -109,7 +106,7 @@ macro_rules! declare_combined_late_lint_pass { } } - $v fn get_lints() -> $crate::LintVec { + $v fn lint_vec() -> $crate::LintVec { let mut lints = Vec::new(); $(lints.extend_from_slice(&$pass::lint_vec());)* lints @@ -126,7 +123,7 @@ macro_rules! declare_combined_late_lint_pass { stringify!($name) } fn get_lints(&self) -> LintVec { - $name::get_lints() + $name::lint_vec() } } ) @@ -226,7 +223,7 @@ macro_rules! declare_combined_early_lint_pass { } } - $v fn get_lints() -> $crate::LintVec { + $v fn lint_vec() -> $crate::LintVec { let mut lints = Vec::new(); $(lints.extend_from_slice(&$pass::lint_vec());)* lints diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 7f7dc6a1ef105..d38b1cf47bd6f 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -9,151 +9,153 @@ use crate::{declare_lint, declare_lint_pass, fcw}; -declare_lint_pass! { - /// Does nothing as a lint pass, but registers some `Lint`s - /// that are used by other parts of the compiler. - HardwiredLints => [ - // tidy-alphabetical-start - AARCH64_SOFTFLOAT_NEON, - ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, - AMBIGUOUS_ASSOCIATED_ITEMS, - AMBIGUOUS_DERIVE_HELPERS, - AMBIGUOUS_GLOB_IMPORTED_TRAITS, - AMBIGUOUS_GLOB_IMPORTS, - AMBIGUOUS_GLOB_REEXPORTS, - AMBIGUOUS_IMPORT_VISIBILITIES, - AMBIGUOUS_PANIC_IMPORTS, - ARITHMETIC_OVERFLOW, - ASM_SUB_REGISTER, - BAD_ASM_STYLE, - BARE_TRAIT_OBJECTS, - BINDINGS_WITH_VARIANT_NAME, - BREAK_WITH_LABEL_AND_LOOP, - COHERENCE_LEAK_CHECK, - CONFLICTING_REPR_HINTS, - CONST_EVALUATABLE_UNCHECKED, - CONST_ITEM_MUTATION, - DEAD_CODE, - DEAD_CODE_PUB_IN_BINARY, - DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK, - DEPRECATED, - DEPRECATED_IN_FUTURE, - DEPRECATED_LLVM_INTRINSIC, - DEPRECATED_SAFE_2024, - DEPRECATED_WHERE_CLAUSE_LOCATION, - DUPLICATE_FEATURES, - DUPLICATE_MACRO_ATTRIBUTES, - ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT, - ELIDED_LIFETIMES_IN_PATHS, - EXPLICIT_BUILTIN_CFGS_IN_FLAGS, - EXPORTED_PRIVATE_DEPENDENCIES, - FFI_UNWIND_CALLS, - FLOAT_LITERAL_F32_FALLBACK, - FORBIDDEN_LINT_GROUPS, - FUNCTION_ITEM_REFERENCES, - HIDDEN_GLOB_REEXPORTS, - ILL_FORMED_ATTRIBUTE_INPUT, - INCOMPLETE_INCLUDE, - INEFFECTIVE_UNSTABLE_TRAIT_IMPL, - INLINE_NO_SANITIZE, - INVALID_DOC_ATTRIBUTES, - INVALID_MACRO_EXPORT_ARGUMENTS, - INVALID_TYPE_PARAM_DEFAULT, - IRREFUTABLE_LET_PATTERNS, - LARGE_ASSIGNMENTS, - LATE_BOUND_LIFETIME_ARGUMENTS, - LEGACY_DERIVE_HELPERS, - LINKER_INFO, - LINKER_MESSAGES, - LONG_RUNNING_CONST_EVAL, - MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS, - MACRO_USE_EXTERN_CRATE, - MALFORMED_DIAGNOSTIC_ATTRIBUTES, - MALFORMED_DIAGNOSTIC_FORMAT_LITERALS, - META_VARIABLE_MISUSE, - MISPLACED_DIAGNOSTIC_ATTRIBUTES, - MISSING_ABI, - MISSING_UNSAFE_ON_EXTERN, - MUST_NOT_SUSPEND, - NAMED_ARGUMENTS_USED_POSITIONALLY, - NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE, - NON_CONTIGUOUS_RANGE_ENDPOINTS, - NON_EXHAUSTIVE_OMITTED_PATTERNS, - OUT_OF_SCOPE_MACRO_CALLS, - OVERLAPPING_RANGE_ENDPOINTS, - PATTERNS_IN_FNS_WITHOUT_BODY, - PRIVATE_BOUNDS, - PRIVATE_INTERFACES, - PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, - PUB_USE_OF_PRIVATE_EXTERN_CRATE, - REDUNDANT_IMPORTS, - REDUNDANT_LIFETIMES, - REFINING_IMPL_TRAIT_INTERNAL, - REFINING_IMPL_TRAIT_REACHABLE, - RENAMED_AND_REMOVED_LINTS, - REPR_C_ENUMS_LARGER_THAN_INT, - RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS, - RTSAN_NONBLOCKING_ASYNC, - RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, - RUST_2021_INCOMPATIBLE_OR_PATTERNS, - RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX, - RUST_2021_PRELUDE_COLLISIONS, - RUST_2024_GUARDED_STRING_INCOMPATIBLE_SYNTAX, - RUST_2024_INCOMPATIBLE_PAT, - RUST_2024_PRELUDE_COLLISIONS, - SELF_CONSTRUCTOR_FROM_OUTER_ITEM, - SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, - SHADOWING_SUPERTRAIT_ITEMS, - SINGLE_USE_LIFETIMES, - STABLE_FEATURES, - TAIL_CALL_TRACK_CALLER, - TAIL_EXPR_DROP_ORDER, - TEST_UNSTABLE_LINT, - TEXT_DIRECTION_CODEPOINT_IN_COMMENT, - TEXT_DIRECTION_CODEPOINT_IN_LITERAL, - TRIVIAL_CASTS, - TRIVIAL_NUMERIC_CASTS, - TYVAR_BEHIND_RAW_POINTER, - UNCONDITIONAL_PANIC, - UNCONDITIONAL_RECURSION, - UNCOVERED_PARAM_IN_PROJECTION, - UNEXPECTED_CFGS, - UNFULFILLED_LINT_EXPECTATIONS, - UNINHABITED_STATIC, - UNKNOWN_CRATE_TYPES, - UNKNOWN_DIAGNOSTIC_ATTRIBUTES, - UNKNOWN_LINTS, - UNNAMEABLE_TEST_ITEMS, - UNNAMEABLE_TYPES, - UNREACHABLE_CFG_SELECT_PREDICATES, - UNREACHABLE_CODE, - UNREACHABLE_PATTERNS, - UNSAFE_ATTR_OUTSIDE_UNSAFE, - UNSAFE_OP_IN_UNSAFE_FN, - UNSTABLE_NAME_COLLISIONS, - UNSTABLE_SYNTAX_PRE_EXPANSION, - UNSUPPORTED_CALLING_CONVENTIONS, - UNUSED_ASSIGNMENTS, - UNUSED_ASSOCIATED_TYPE_BOUNDS, - UNUSED_ATTRIBUTES, - UNUSED_CRATE_DEPENDENCIES, - UNUSED_EXTERN_CRATES, - UNUSED_FEATURES, - UNUSED_IMPORTS, - UNUSED_LABELS, - UNUSED_LIFETIMES, - UNUSED_MACROS, - UNUSED_MACRO_RULES, - UNUSED_MUT, - UNUSED_QUALIFICATIONS, - UNUSED_UNSAFE, - UNUSED_VARIABLES, - UNUSED_VISIBILITIES, - USELESS_DEPRECATED, - VARARGS_WITHOUT_PATTERN, - WARNINGS, - // tidy-alphabetical-end - ] +pub mod hardwired { + use super::*; + + pub fn lint_vec() -> crate::LintVec { + vec![ + // tidy-alphabetical-start + AARCH64_SOFTFLOAT_NEON, + ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, + AMBIGUOUS_ASSOCIATED_ITEMS, + AMBIGUOUS_DERIVE_HELPERS, + AMBIGUOUS_GLOB_IMPORTED_TRAITS, + AMBIGUOUS_GLOB_IMPORTS, + AMBIGUOUS_GLOB_REEXPORTS, + AMBIGUOUS_IMPORT_VISIBILITIES, + AMBIGUOUS_PANIC_IMPORTS, + ARITHMETIC_OVERFLOW, + ASM_SUB_REGISTER, + BAD_ASM_STYLE, + BARE_TRAIT_OBJECTS, + BINDINGS_WITH_VARIANT_NAME, + BREAK_WITH_LABEL_AND_LOOP, + COHERENCE_LEAK_CHECK, + CONFLICTING_REPR_HINTS, + CONST_EVALUATABLE_UNCHECKED, + CONST_ITEM_MUTATION, + DEAD_CODE, + DEAD_CODE_PUB_IN_BINARY, + DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK, + DEPRECATED, + DEPRECATED_IN_FUTURE, + DEPRECATED_LLVM_INTRINSIC, + DEPRECATED_SAFE_2024, + DEPRECATED_WHERE_CLAUSE_LOCATION, + DUPLICATE_FEATURES, + DUPLICATE_MACRO_ATTRIBUTES, + ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT, + ELIDED_LIFETIMES_IN_PATHS, + EXPLICIT_BUILTIN_CFGS_IN_FLAGS, + EXPORTED_PRIVATE_DEPENDENCIES, + FFI_UNWIND_CALLS, + FLOAT_LITERAL_F32_FALLBACK, + FORBIDDEN_LINT_GROUPS, + FUNCTION_ITEM_REFERENCES, + HIDDEN_GLOB_REEXPORTS, + ILL_FORMED_ATTRIBUTE_INPUT, + INCOMPLETE_INCLUDE, + INEFFECTIVE_UNSTABLE_TRAIT_IMPL, + INLINE_NO_SANITIZE, + INVALID_DOC_ATTRIBUTES, + INVALID_MACRO_EXPORT_ARGUMENTS, + INVALID_TYPE_PARAM_DEFAULT, + IRREFUTABLE_LET_PATTERNS, + LARGE_ASSIGNMENTS, + LATE_BOUND_LIFETIME_ARGUMENTS, + LEGACY_DERIVE_HELPERS, + LINKER_INFO, + LINKER_MESSAGES, + LONG_RUNNING_CONST_EVAL, + MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS, + MACRO_USE_EXTERN_CRATE, + MALFORMED_DIAGNOSTIC_ATTRIBUTES, + MALFORMED_DIAGNOSTIC_FORMAT_LITERALS, + META_VARIABLE_MISUSE, + MISPLACED_DIAGNOSTIC_ATTRIBUTES, + MISSING_ABI, + MISSING_UNSAFE_ON_EXTERN, + MUST_NOT_SUSPEND, + NAMED_ARGUMENTS_USED_POSITIONALLY, + NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE, + NON_CONTIGUOUS_RANGE_ENDPOINTS, + NON_EXHAUSTIVE_OMITTED_PATTERNS, + OUT_OF_SCOPE_MACRO_CALLS, + OVERLAPPING_RANGE_ENDPOINTS, + PATTERNS_IN_FNS_WITHOUT_BODY, + PRIVATE_BOUNDS, + PRIVATE_INTERFACES, + PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, + PUB_USE_OF_PRIVATE_EXTERN_CRATE, + REDUNDANT_IMPORTS, + REDUNDANT_LIFETIMES, + REFINING_IMPL_TRAIT_INTERNAL, + REFINING_IMPL_TRAIT_REACHABLE, + RENAMED_AND_REMOVED_LINTS, + REPR_C_ENUMS_LARGER_THAN_INT, + RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS, + RTSAN_NONBLOCKING_ASYNC, + RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, + RUST_2021_INCOMPATIBLE_OR_PATTERNS, + RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX, + RUST_2021_PRELUDE_COLLISIONS, + RUST_2024_GUARDED_STRING_INCOMPATIBLE_SYNTAX, + RUST_2024_INCOMPATIBLE_PAT, + RUST_2024_PRELUDE_COLLISIONS, + SELF_CONSTRUCTOR_FROM_OUTER_ITEM, + SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, + SHADOWING_SUPERTRAIT_ITEMS, + SINGLE_USE_LIFETIMES, + STABLE_FEATURES, + TAIL_CALL_TRACK_CALLER, + TAIL_EXPR_DROP_ORDER, + TEST_UNSTABLE_LINT, + TEXT_DIRECTION_CODEPOINT_IN_COMMENT, + TEXT_DIRECTION_CODEPOINT_IN_LITERAL, + TRIVIAL_CASTS, + TRIVIAL_NUMERIC_CASTS, + TYVAR_BEHIND_RAW_POINTER, + UNCONDITIONAL_PANIC, + UNCONDITIONAL_RECURSION, + UNCOVERED_PARAM_IN_PROJECTION, + UNEXPECTED_CFGS, + UNFULFILLED_LINT_EXPECTATIONS, + UNINHABITED_STATIC, + UNKNOWN_CRATE_TYPES, + UNKNOWN_DIAGNOSTIC_ATTRIBUTES, + UNKNOWN_LINTS, + UNNAMEABLE_TEST_ITEMS, + UNNAMEABLE_TYPES, + UNREACHABLE_CFG_SELECT_PREDICATES, + UNREACHABLE_CODE, + UNREACHABLE_PATTERNS, + UNSAFE_ATTR_OUTSIDE_UNSAFE, + UNSAFE_OP_IN_UNSAFE_FN, + UNSTABLE_NAME_COLLISIONS, + UNSTABLE_SYNTAX_PRE_EXPANSION, + UNSUPPORTED_CALLING_CONVENTIONS, + UNUSED_ASSIGNMENTS, + UNUSED_ASSOCIATED_TYPE_BOUNDS, + UNUSED_ATTRIBUTES, + UNUSED_CRATE_DEPENDENCIES, + UNUSED_EXTERN_CRATES, + UNUSED_FEATURES, + UNUSED_IMPORTS, + UNUSED_LABELS, + UNUSED_LIFETIMES, + UNUSED_MACROS, + UNUSED_MACRO_RULES, + UNUSED_MUT, + UNUSED_QUALIFICATIONS, + UNUSED_UNSAFE, + UNUSED_VARIABLES, + UNUSED_VISIBILITIES, + USELESS_DEPRECATED, + VARARGS_WITHOUT_PATTERN, + WARNINGS, + // tidy-alphabetical-end + ] + } } declare_lint! { diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index 51c56d777a751..e782414c62a0a 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -1,6 +1,7 @@ // tidy-alphabetical-start #![allow(internal_features)] #![cfg_attr(bootstrap, feature(result_option_map_or_default))] +#![cfg_attr(bootstrap, feature(strip_circumfix))] #![feature(error_iter)] #![feature(file_buffered)] #![feature(gen_blocks)] @@ -8,7 +9,6 @@ #![feature(min_specialization)] #![feature(never_type)] #![feature(proc_macro_internals)] -#![feature(strip_circumfix)] #![feature(trusted_len)] // tidy-alphabetical-end diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 1cc789f6bcaa3..bd3b2445759e7 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1274,6 +1274,10 @@ impl CrateMetadata { /// 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 { gen move { if let Some(data) = &self.root.proc_macro_data { @@ -1287,7 +1291,9 @@ impl CrateMetadata { } 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 f0e47e0075ff6..6ead1c5ea46a3 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -33,7 +33,7 @@ rustc_target = { path = "../rustc_target" } 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 c01ff3d5d0561..d4817888468fa 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs @@ -2161,6 +2161,15 @@ rustc_queries! { 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 a96f4e9457cb0..24aa4ac513d45 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 84e0b37a7f7d0..6eb5e83005975 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, pub parent_count: usize, @@ -128,6 +128,23 @@ pub struct Generics { pub has_late_bound_regions: Option, } +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::>(); + 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> for &'tcx Generics { fn count(&self) -> usize { self.parent_count + self.own_params.len() diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index f85355330d6b8..8734d2cde8152 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -310,7 +310,9 @@ impl<'tcx> InstanceKind<'tcx> { pub fn requires_caller_location(&self, tcx: TyCtxt<'_>) -> bool { match *self { - InstanceKind::Item(def_id) | InstanceKind::Virtual(def_id, _) => { + InstanceKind::Item(def_id) + | InstanceKind::Virtual(def_id, _) + | InstanceKind::VTableShim(def_id) => { tcx.body_codegen_attrs(def_id).flags.contains(CodegenFnAttrFlags::TRACK_CALLER) } InstanceKind::ClosureOnceShim { call_once: _, closure: _, track_caller } => { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 3d8ab41b37a31..10a5f380d4c80 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -118,7 +118,7 @@ pub use self::typeck_results::{ 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 @@ impl<'tcx> TyCtxt<'tcx> { /// 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 @@ impl<'tcx> TyCtxt<'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_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index ee6aaf9cb6e17..317367d5950de 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -366,6 +366,11 @@ impl<'tcx> TyCtxt<'tcx> { } } + (&ty::Pat(a_inner, _), &ty::Pat(b_inner, _)) => { + a = a_inner; + b = b_inner; + } + _ => break, } } diff --git a/compiler/rustc_mir_dataflow/src/points.rs b/compiler/rustc_mir_dataflow/src/points.rs index e3d1e04a319ba..8568f325f1306 100644 --- a/compiler/rustc_mir_dataflow/src/points.rs +++ b/compiler/rustc_mir_dataflow/src/points.rs @@ -31,7 +31,8 @@ impl DenseLocationMap { 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 @@ impl DenseLocationMap { } /// 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 50782c578f09f..6d9b8feea05f4 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 97aaf076a9d9a..6273506b8adc7 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 @@ where )); } + self.evaluate_goal_cold(source, goal) + } + + #[cold] + #[inline(never)] + pub(super) fn evaluate_goal_cold( + &mut self, + source: GoalSource, + goal: Goal, + ) -> Result<(NestedNormalizationGoals, GoalEvaluation), 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 53727efb46501..22ec84231af49 100644 --- a/compiler/rustc_parse/Cargo.toml +++ b/compiler/rustc_parse/Cargo.toml @@ -17,7 +17,7 @@ rustc_lexer = { path = "../rustc_lexer" } 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/errors.rs b/compiler/rustc_parse/src/errors.rs index 3a726cbce8182..0c850b69ca7f1 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -689,7 +689,7 @@ pub(crate) struct MissingInInForLoop { #[primary_span] pub span: Span, #[subdiagnostic] - pub sub: MissingInInForLoopSub, + pub sub: Option, } #[derive(Subdiagnostic)] diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index e414e10e84169..c81b3dd6ab5c0 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -3086,18 +3086,41 @@ impl<'a> Parser<'a> { } fn error_missing_in_for_loop(&mut self) { - let (span, sub): (_, fn(_) -> _) = if self.token.is_ident_named(sym::of) { + let (span, sub) = if self.token.is_ident_named(sym::of) { // Possibly using JS syntax (#75311). let span = self.token.span; self.bump(); - (span, errors::MissingInInForLoopSub::InNotOf) + (span, Some(errors::MissingInInForLoopSub::InNotOf(span))) } else if self.eat(exp!(Eq)) { - (self.prev_token.span, errors::MissingInInForLoopSub::InNotEq) + let span = self.prev_token.span; + (span, Some(errors::MissingInInForLoopSub::InNotEq(span))) } else { - (self.prev_token.span.between(self.token.span), errors::MissingInInForLoopSub::AddIn) + let span = self.prev_token.span.between(self.token.span); + let sub = (!self.for_loop_head_has_in()) + .then_some(errors::MissingInInForLoopSub::AddIn(span)); + (span, sub) }; - self.dcx().emit_err(errors::MissingInInForLoop { span, sub: sub(span) }); + self.dcx().emit_err(errors::MissingInInForLoop { span, sub }); + } + + /// Whether the `for` loop header already contains an `in` before its body. + /// If it does, the binding is malformed (e.g. `for i i in 0..10`) rather + /// than missing `in`, so suggesting another `in` would just be invalid too. + fn for_loop_head_has_in(&self) -> bool { + let mut dist = 0; + loop { + let (is_in, is_end) = self.look_ahead(dist, |t| { + (t.is_keyword(kw::In), matches!(t.kind, token::OpenBrace | token::Eof)) + }); + if is_in { + return true; + } + if is_end { + return false; + } + dist += 1; + } } /// Parses a `while` or `while let` expression (`while` token already eaten). diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index d6104c705bdd2..16fed9c6c273b 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -659,7 +659,7 @@ impl<'a> Parser<'a> { 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 @@ impl<'a> Parser<'a> { 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 01c31d6acb9dd..dd950cce42103 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -345,6 +345,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { AttributeKind::RustcDummy => (), AttributeKind::RustcDumpDefParents => (), AttributeKind::RustcDumpDefPath(..) => (), + AttributeKind::RustcDumpGenerics => (), AttributeKind::RustcDumpHiddenTypeOfOpaques => (), AttributeKind::RustcDumpInferredOutlives => (), AttributeKind::RustcDumpItemBounds => (), diff --git a/compiler/rustc_public/README.md b/compiler/rustc_public/README.md index ab2546e377ae6..e0bf562d00614 100644 --- a/compiler/rustc_public/README.md +++ b/compiler/rustc_public/README.md @@ -4,7 +4,7 @@ Our goal is to start publishing `stable_mir` into crates.io. Until then, users will use this as any other rustc crate, by installing the rustup component `rustc-dev`, and declaring `stable-mir` as an external crate. -See the StableMIR ["Getting Started"](https://rust-lang.github.io/project-stable-mir/getting-started.html) +See the StableMIR ["Getting Started"](https://rust-lang.github.io/rustc_public/getting-started.html) guide for more information. ## Stable MIR Design diff --git a/compiler/rustc_public/src/lib.rs b/compiler/rustc_public/src/lib.rs index be4886b8cceeb..5b7e1580532a8 100644 --- a/compiler/rustc_public/src/lib.rs +++ b/compiler/rustc_public/src/lib.rs @@ -1,6 +1,6 @@ //! The WIP public interface to rustc internals. //! -//! For more information see +//! For more information see //! //! # Note //! diff --git a/compiler/rustc_public/src/rustc_internal/pretty.rs b/compiler/rustc_public/src/rustc_internal/pretty.rs index 83522e5197783..99357429b4a3b 100644 --- a/compiler/rustc_public/src/rustc_internal/pretty.rs +++ b/compiler/rustc_public/src/rustc_internal/pretty.rs @@ -11,7 +11,7 @@ pub fn write_smir_pretty<'tcx, W: io::Write>(tcx: TyCtxt<'tcx>, w: &mut W) -> io )?; writeln!( w, - "// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir." + "// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/rustc_public." )?; let _ = run(tcx, || { let items = crate::all_local_items(); diff --git a/compiler/rustc_public_bridge/src/lib.rs b/compiler/rustc_public_bridge/src/lib.rs index dd5a3601b3232..d598f88a00d27 100644 --- a/compiler/rustc_public_bridge/src/lib.rs +++ b/compiler/rustc_public_bridge/src/lib.rs @@ -5,7 +5,7 @@ //! This crate is not intended to be invoked directly by users. //! This crate is the public API of rustc that will be invoked by the `rustc_public` crate. //! -//! For more information see +//! For more information see //! //! # Note //! diff --git a/compiler/rustc_resolve/Cargo.toml b/compiler/rustc_resolve/Cargo.toml index 2fc251e2b525e..cb52c21c87ae9 100644 --- a/compiler/rustc_resolve/Cargo.toml +++ b/compiler/rustc_resolve/Cargo.toml @@ -26,6 +26,6 @@ rustc_middle = { path = "../rustc_middle" } 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_serialize/Cargo.toml b/compiler/rustc_serialize/Cargo.toml index 193c89a295980..4e11d8726c84f 100644 --- a/compiler/rustc_serialize/Cargo.toml +++ b/compiler/rustc_serialize/Cargo.toml @@ -8,7 +8,7 @@ edition = "2024" 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 2f9fa09c322bb..73ce5280f6dc8 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -727,7 +727,25 @@ fn build_options( } if let Some(tmod) = *tmod { let v = value.map_or(String::new(), ToOwned::to_owned); - collected_options.target_modifiers.insert(tmod, v); + + // Accumulate all the -Zsanitizer flags into a single target modifier. + match tmod { + OptionsTargetModifiers::UnstableOptions( + UnstableOptionsTargetModifiers::Sanitizer, + ) => { + collected_options + .target_modifiers + .entry(tmod) + .and_modify(|existing| { + existing.push(','); + existing.push_str(&v); + }) + .or_insert(v); + } + _ => { + collected_options.target_modifiers.insert(tmod, v); + } + } } if let Some(mitigation) = mitigation { collected_options.mitigations.reset_mitigation(*mitigation, index); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 72990de7e58aa..c523ae6a990c5 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -878,6 +878,8 @@ symbols! { // to be detected if it accidentally does get used. empty: "", empty_braces: "{}", + empty_brackets: "[]", + empty_parens: "()", enable, end, entry_nops, @@ -1698,6 +1700,7 @@ symbols! { return_address, return_position_impl_trait_in_trait, return_type_notation, + right_arrow: "->", riscv32, riscv64, riscv_target_feature, @@ -1769,6 +1772,7 @@ symbols! { 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/mips64_openwrt_linux_musl.rs b/compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs index 8b02e1235e609..ec91dbeb86ef9 100644 --- a/compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs @@ -2,7 +2,7 @@ use rustc_abi::Endian; -use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -28,6 +28,7 @@ pub(crate) fn target() -> Target { endian: Endian::Big, mcount: "_mcount".into(), llvm_abiname: LlvmAbi::N64, + llvm_args: cvs!["-mno-check-zero-division"], ..base }, } diff --git a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs index 14942885c6b99..bb249d3335cf3 100644 --- a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -23,6 +23,7 @@ pub(crate) fn target() -> Target { max_atomic_width: Some(64), mcount: "_mcount".into(), llvm_abiname: LlvmAbi::N64, + llvm_args: cvs!["-mno-check-zero-division"], ..base::linux_gnu::opts() }, diff --git a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs index c5336fd58fc93..c83d371692e69 100644 --- a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -24,6 +24,7 @@ pub(crate) fn target() -> Target { endian: Endian::Big, mcount: "_mcount".into(), llvm_abiname: LlvmAbi::N64, + llvm_args: cvs!["-mno-check-zero-division"], ..base }, } diff --git a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs index 665cf1d4362d9..f3ab85ecdd2d2 100644 --- a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs @@ -1,4 +1,4 @@ -use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -20,6 +20,7 @@ pub(crate) fn target() -> Target { max_atomic_width: Some(64), mcount: "_mcount".into(), llvm_abiname: LlvmAbi::N64, + llvm_args: cvs!["-mno-check-zero-division"], ..base::linux_gnu::opts() }, diff --git a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs index bd237eaedc667..5685e84f140a4 100644 --- a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs @@ -1,4 +1,4 @@ -use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -21,6 +21,7 @@ pub(crate) fn target() -> Target { cfg_abi: CfgAbi::Abi64, mcount: "_mcount".into(), llvm_abiname: LlvmAbi::N64, + llvm_args: cvs!["-mno-check-zero-division"], ..base }, } diff --git a/compiler/rustc_target/src/spec/targets/mips_mti_none_elf.rs b/compiler/rustc_target/src/spec/targets/mips_mti_none_elf.rs index 32440cdd92e99..b75c3e880cc17 100644 --- a/compiler/rustc_target/src/spec/targets/mips_mti_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/mips_mti_none_elf.rs @@ -2,7 +2,7 @@ use rustc_abi::Endian; use crate::spec::{ Arch, Cc, LinkerFlavor, Lld, LlvmAbi, PanicStrategy, RelocModel, Target, TargetMetadata, - TargetOptions, + TargetOptions, cvs, }; pub(crate) fn target() -> Target { @@ -26,6 +26,7 @@ pub(crate) fn target() -> Target { cpu: "mips32r2".into(), llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], max_atomic_width: Some(32), features: "+mips32r2,+soft-float,+noabicalls".into(), diff --git a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs index 8bfa8ecf60222..a706c4b1cbdc3 100644 --- a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -19,6 +19,7 @@ pub(crate) fn target() -> Target { cpu: "mips32r2".into(), features: "+mips32r2,+fpxx,+nooddspreg".into(), llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], max_atomic_width: Some(32), mcount: "_mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs index 316e59dea88b8..7e3bebc60e9d3 100644 --- a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -21,6 +21,7 @@ pub(crate) fn target() -> Target { options: TargetOptions { endian: Endian::Big, llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], mcount: "_mcount".into(), ..base }, diff --git a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs index b03dec5b5b6e8..d26a8c162e85e 100644 --- a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs +++ b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -19,6 +19,7 @@ pub(crate) fn target() -> Target { cpu: "mips32r2".into(), features: "+mips32r2,+soft-float".into(), llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], max_atomic_width: Some(32), mcount: "_mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsel_mti_none_elf.rs b/compiler/rustc_target/src/spec/targets/mipsel_mti_none_elf.rs index ce50cedef99ff..c702dbc6c8243 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_mti_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_mti_none_elf.rs @@ -2,7 +2,7 @@ use rustc_abi::Endian; use crate::spec::{ Arch, Cc, LinkerFlavor, Lld, LlvmAbi, PanicStrategy, RelocModel, Target, TargetMetadata, - TargetOptions, + TargetOptions, cvs, }; pub(crate) fn target() -> Target { @@ -26,6 +26,7 @@ pub(crate) fn target() -> Target { cpu: "mips32r2".into(), llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], max_atomic_width: Some(32), features: "+mips32r2,+soft-float,+noabicalls".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs index 0541e0e9b2c5d..085f36c70a633 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -17,6 +17,7 @@ pub(crate) fn target() -> Target { cpu: "mips32r2".into(), features: "+mips32r2,+fpxx,+nooddspreg".into(), llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], max_atomic_width: Some(32), mcount: "_mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs index 5d0136a6699a7..c94f2fd87e589 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -16,6 +16,11 @@ pub(crate) fn target() -> Target { pointer_width: 32, data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), arch: Arch::Mips, - options: TargetOptions { llvm_abiname: LlvmAbi::O32, mcount: "_mcount".into(), ..base }, + options: TargetOptions { + llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], + mcount: "_mcount".into(), + ..base + }, } } diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs index 0add21bfc9c65..7b93f0e0ce433 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs @@ -1,4 +1,4 @@ -use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -17,6 +17,7 @@ pub(crate) fn target() -> Target { cpu: "mips32r2".into(), features: "+mips32r2,+soft-float".into(), llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], max_atomic_width: Some(32), mcount: "_mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs index 5395c15ad5813..f765409eb6d9c 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { let mut base = base::netbsd::opts(); @@ -21,6 +21,7 @@ pub(crate) fn target() -> Target { options: TargetOptions { features: "+soft-float".into(), llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], mcount: "__mcount".into(), endian: Endian::Little, ..base diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs index 0e184c8348016..e99092a5c6c27 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs @@ -4,7 +4,7 @@ use crate::spec::{ Arch, Cc, LinkerFlavor, Lld, LlvmAbi, PanicStrategy, RelocModel, Target, TargetMetadata, - TargetOptions, + TargetOptions, cvs, }; pub(crate) fn target() -> Target { @@ -25,6 +25,7 @@ pub(crate) fn target() -> Target { cpu: "mips32r2".into(), features: "+mips32r2,+soft-float,+noabicalls".into(), llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], max_atomic_width: Some(32), linker: Some("rust-lld".into()), panic_strategy: PanicStrategy::Abort, diff --git a/compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs index 80916500a4310..276d25432b6cb 100644 --- a/compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -19,6 +19,7 @@ pub(crate) fn target() -> Target { cpu: "mips32r6".into(), features: "+mips32r6".into(), llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], max_atomic_width: Some(32), mcount: "_mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs index 87db5a2828729..0de12904d9e02 100644 --- a/compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -17,6 +17,7 @@ pub(crate) fn target() -> Target { cpu: "mips32r6".into(), features: "+mips32r6".into(), llvm_abiname: LlvmAbi::O32, + llvm_args: cvs!["-mno-check-zero-division"], max_atomic_width: Some(32), mcount: "_mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs index 8e66407470a25..88e3ab6d9fc39 100644 --- a/compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -23,6 +23,7 @@ pub(crate) fn target() -> Target { max_atomic_width: Some(64), mcount: "_mcount".into(), llvm_abiname: LlvmAbi::N64, + llvm_args: cvs!["-mno-check-zero-division"], ..base::linux_gnu::opts() }, diff --git a/compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs index 5523f4470bd57..01046de7aa14b 100644 --- a/compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs @@ -1,4 +1,4 @@ -use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CfgAbi, LlvmAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -20,6 +20,7 @@ pub(crate) fn target() -> Target { max_atomic_width: Some(64), mcount: "_mcount".into(), llvm_abiname: LlvmAbi::N64, + llvm_args: cvs!["-mno-check-zero-division"], ..base::linux_gnu::opts() }, 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 42f0a6a185e0e..0fa7ae291cf0e 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 802fdda6f0375..3ce76d78e6c8a 100644 --- a/compiler/rustc_trait_selection/Cargo.toml +++ b/compiler/rustc_trait_selection/Cargo.toml @@ -19,6 +19,6 @@ rustc_session = { path = "../rustc_session" } 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_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 9f1bfc018f3a2..8900687036d41 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -11,6 +11,7 @@ //! This API is completely unstable and subject to change. // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(strip_circumfix))] #![feature(associated_type_defaults)] #![feature(default_field_values)] #![feature(deref_patterns)] @@ -18,7 +19,6 @@ #![feature(iter_intersperse)] #![feature(iterator_try_reduce)] #![feature(never_type)] -#![feature(strip_circumfix)] #![feature(try_blocks)] #![feature(unwrap_infallible)] #![feature(yeet_expr)] diff --git a/compiler/rustc_traits/src/normalize_erasing_regions.rs b/compiler/rustc_traits/src/normalize_erasing_regions.rs index d3a2c4d20f95d..1e6089dc37f95 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> + Par goal: PseudoCanonicalInput<'tcx, T>, ) -> Result { 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 7b0b4aa899723..97cddd857af18 100644 --- a/compiler/rustc_type_ir/Cargo.toml +++ b/compiler/rustc_type_ir/Cargo.toml @@ -23,7 +23,7 @@ rustc_type_ir_macros = { path = "../rustc_type_ir_macros" } 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 7d994359ed48b..0a1f7738632c1 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -2594,7 +2594,8 @@ impl Hash for BTreeMap { } #[stable(feature = "rust1", since = "1.0.0")] -impl Default for BTreeMap { +#[rustc_const_unstable(feature = "const_default", issue = "143894")] +const impl Default for BTreeMap { /// Creates an empty `BTreeMap`. fn default() -> BTreeMap { BTreeMap::new() diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 7c6befa95718c..229514803bf6a 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -775,7 +775,6 @@ impl 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 @@ impl 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 { let (chunks, []) = v.as_chunks::<2>() else { return Err(FromUtf16Error { kind: FromUtf16ErrorKind::OddBytes }); @@ -817,7 +816,6 @@ impl String { /// Basic usage: /// /// ``` - /// #![feature(str_from_utf16_endian)] /// // 𝄞music /// let v = &[0x34, 0xD8, 0x1E, 0xDD, 0x6d, 0x00, 0x75, 0x00, /// 0x73, 0x00, 0x1E, 0xDD, 0x69, 0x00, 0x63, 0x00, @@ -827,7 +825,7 @@ impl String { /// 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::() }) { (true, ([], v, [])) => Self::from_utf16_lossy(v), @@ -850,7 +848,6 @@ impl 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 @@ impl 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 { let (chunks, []) = v.as_chunks::<2>() else { return Err(FromUtf16Error { kind: FromUtf16ErrorKind::OddBytes }); @@ -892,7 +889,6 @@ impl String { /// Basic usage: /// /// ``` - /// #![feature(str_from_utf16_endian)] /// // 𝄞music /// let v = &[0xD8, 0x34, 0xDD, 0x1E, 0x00, 0x6d, 0x00, 0x75, /// 0x00, 0x73, 0xDD, 0x1E, 0x00, 0x69, 0x00, 0x63, @@ -902,7 +898,7 @@ impl String { /// 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::() }) { (true, ([], v, [])) => Self::from_utf16_lossy(v), diff --git a/library/alloc/src/task.rs b/library/alloc/src/task.rs index bc668f78bf740..0e36c91f466fd 100644 --- a/library/alloc/src/task.rs +++ b/library/alloc/src/task.rs @@ -37,6 +37,10 @@ use crate::sync::Arc; /// 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 204e5678a69d6..943c9309836d3 100644 --- a/library/alloc/src/vec/partial_eq.rs +++ b/library/alloc/src/vec/partial_eq.rs @@ -6,7 +6,7 @@ use crate::borrow::Cow; macro_rules! __impl_slice_eq1 { ($($const:ident, )? [$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?, $(#[$stability:meta])+ ) => { $(#[$stability])+ - impl $($const)? PartialEq<$rhs> for $lhs + $($const)? impl PartialEq<$rhs> for $lhs where T: $([$const])? PartialEq, $($ty: $bound)? diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs index 590f559e0d524..83b017b7625b9 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 c8c05ee559f74..abd80aef20bd3 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 for $ty { + const impl From 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 898138ed1f36e..a67dc9d87499d 100644 --- a/library/core/src/clone.rs +++ b/library/core/src/clone.rs @@ -710,7 +710,7 @@ mod impls { $( #[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 @@ mod impls { #[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 b699c7a02e477..3371b2cecbd79 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1873,7 +1873,7 @@ mod impls { ($($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 @@ mod impls { ($($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 @@ mod impls { ($($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 { match (*self <= *other, *self >= *other) { @@ -1994,7 +1994,7 @@ mod impls { ($($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 { Some(crate::intrinsics::three_way_compare(*self, *other)) @@ -2005,7 +2005,7 @@ mod impls { #[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 f0f5f656405a9..88b83b5273dbe 100644 --- a/library/core/src/cmp/bytewise.rs +++ b/library/core/src/cmp/bytewise.rs @@ -24,7 +24,7 @@ pub(crate) const unsafe trait BytewiseEq: 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 19398b4680583..1125f437c1538 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 for $int { + const impl From 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 for $float { + const impl From 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> for NonZero<$target> { + const impl TryFrom> 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 { value.try_into().ok() @@ -698,7 +698,7 @@ macro_rules! impl_int_cast { #[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 f90818c7969c9..0d0ff23fe2946 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 @@ macro_rules! forward_ref_unop { 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 @@ macro_rules! forward_ref_binop { } $(#[$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 @@ macro_rules! forward_ref_binop { } $(#[$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 @@ macro_rules! forward_ref_binop { 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 bc415ec977684..a477c2e1a70bd 100644 --- a/library/core/src/intrinsics/fallback.rs +++ b/library/core/src/intrinsics/fallback.rs @@ -21,7 +21,7 @@ pub const trait CarryingMulAdd: Copy + 'static { 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/intrinsics/mir.rs b/library/core/src/intrinsics/mir.rs index 183db46c6405e..dce7bf681a7af 100644 --- a/library/core/src/intrinsics/mir.rs +++ b/library/core/src/intrinsics/mir.rs @@ -4,7 +4,7 @@ //! this feature, turn back. This is *exceptionally* unstable. There is no attempt at all to make //! anything work besides those things which the rustc test suite happened to need. If you make a //! typo you'll probably ICE. Really, this is not the solution to your problems. Consider instead -//! supporting the [stable MIR project group](https://github.com/rust-lang/project-stable-mir). +//! supporting the [rustc public project group](https://github.com/rust-lang/rustc_public). //! //! The documentation for this module describes how to use this feature. If you are interested in //! hacking on the implementation, most of that documentation lives at diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs index 4b19c7ffc00f8..faba1691b6b8c 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs @@ -125,7 +125,6 @@ where } // Zip specialization trait -#[doc(hidden)] trait ZipImpl { type Item; fn new(a: A, b: B) -> Self; @@ -204,7 +203,6 @@ macro_rules! zip_impl_general_defaults { } // General Zip impl -#[doc(hidden)] impl ZipImpl for Zip where A: Iterator, @@ -247,7 +245,6 @@ where } } -#[doc(hidden)] impl ZipImpl for Zip where A: TrustedRandomAccessNoCoerce + Iterator, @@ -288,7 +285,6 @@ where } } -#[doc(hidden)] impl ZipImpl for Zip where A: TrustedRandomAccess + Iterator, diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index 949295a77bca6..273b89159f9c8 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 @@ 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 $i_narrower { + const impl Step for $i_narrower { step_identical_methods!(); step_signed_methods!($u_narrower); @@ -365,7 +365,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_wider { + const impl Step for $u_wider { step_identical_methods!(); step_unsigned_methods!(); @@ -396,7 +396,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 $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 @@ 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<$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 f2d91b9cec649..4e380a93972e7 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 @@ macro_rules! bitop_impls { } $(#[$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 @@ macro_rules! bitop_impls { } $(#[$attr])* - impl const $BitOp<&'_ $ty> for $ty { + const impl $BitOp<&'_ $ty> for $ty { type Output = $ty; #[inline] @@ -2508,7 +2508,7 @@ macro_rules! bitop_impls { } $(#[$attr])* - impl const $BitOp<$ty> for &'_ $ty { + const impl $BitOp<$ty> for &'_ $ty { type Output = $ty; #[inline] @@ -2520,7 +2520,7 @@ macro_rules! bitop_impls { } $(#[$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 59c2b11470f4a..002c56083659c 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 365a82a57e0b9..efe96a9ab7494 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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { /// ``` #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_impl { #[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 @@ macro_rules! saturating_int_impl_signed { #[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 2a5818e9f8d4f..8f5daf2345df9 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 68c5baf15fb9f..1ab95b152629f 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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 @@ macro_rules! wrapping_impl { #[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 afb814dbc6b33..34af7d97acb5a 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 b6daa0f751a31..7c008531c1f5a 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 77fbea510e782..0cf9f10fc8c28 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/index.rs b/library/core/src/slice/index.rs index 914db4bd75c0b..51ab9b5fd1eac 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -27,6 +27,7 @@ where I: [const] SliceIndex<[T]>, { #[inline(always)] + #[rustc_no_writable] fn index_mut(&mut self, index: I) -> &mut I::Output { index.index_mut(self) } @@ -185,6 +186,7 @@ const unsafe impl SliceIndex<[T]> for usize { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut T> { if self < slice.len() { // SAFETY: `self` is checked to be in bounds. @@ -233,6 +235,7 @@ const unsafe impl SliceIndex<[T]> for usize { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut T { // N.B., use intrinsic indexing &mut (*slice)[self] @@ -256,6 +259,7 @@ const unsafe impl SliceIndex<[T]> for ops::IndexRange { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { if self.end() <= slice.len() { // SAFETY: `self` is checked to be valid and in bounds above. @@ -304,6 +308,7 @@ const unsafe impl SliceIndex<[T]> for ops::IndexRange { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut [T] { if self.end() <= slice.len() { // SAFETY: `self` is checked to be valid and in bounds above. @@ -336,6 +341,7 @@ const unsafe impl SliceIndex<[T]> for ops::Range { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { if let Some(new_len) = usize::checked_sub(self.end, self.start) && self.end <= slice.len() @@ -405,6 +411,7 @@ const unsafe impl SliceIndex<[T]> for ops::Range { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut [T] { // Using checked_sub is a safe way to get `SubUnchecked` in MIR if let Some(new_len) = usize::checked_sub(self.end, self.start) @@ -429,6 +436,7 @@ const unsafe impl SliceIndex<[T]> for range::Range { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { ops::Range::from(self).get_mut(slice) } @@ -451,6 +459,7 @@ const unsafe impl SliceIndex<[T]> for range::Range { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut [T] { ops::Range::from(self).index_mut(slice) } @@ -468,6 +477,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeTo { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { (0..self.end).get_mut(slice) } @@ -490,6 +500,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeTo { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut [T] { (0..self.end).index_mut(slice) } @@ -507,6 +518,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeFrom { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { (self.start..slice.len()).get_mut(slice) } @@ -536,6 +548,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeFrom { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut [T] { if self.start > slice.len() { slice_index_fail(self.start, slice.len(), slice.len()) @@ -559,6 +572,7 @@ const unsafe impl SliceIndex<[T]> for range::RangeFrom { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { ops::RangeFrom::from(self).get_mut(slice) } @@ -581,6 +595,7 @@ const unsafe impl SliceIndex<[T]> for range::RangeFrom { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut [T] { ops::RangeFrom::from(self).index_mut(slice) } @@ -597,6 +612,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeFull { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { Some(slice) } @@ -617,6 +633,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeFull { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut [T] { slice } @@ -636,6 +653,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeInclusive { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { if *self.end() >= slice.len() { None } else { self.into_slice_range().get_mut(slice) } } @@ -668,6 +686,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeInclusive { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut [T] { let Self { mut start, mut end, exhausted } = self; let len = slice.len(); @@ -694,6 +713,7 @@ const unsafe impl SliceIndex<[T]> for range::RangeInclusive { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { ops::RangeInclusive::from(self).get_mut(slice) } @@ -716,6 +736,7 @@ const unsafe impl SliceIndex<[T]> for range::RangeInclusive { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut [T] { ops::RangeInclusive::from(self).index_mut(slice) } @@ -733,6 +754,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeToInclusive { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { (0..=self.end).get_mut(slice) } @@ -755,6 +777,7 @@ const unsafe impl SliceIndex<[T]> for ops::RangeToInclusive { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut [T] { (0..=self.end).index_mut(slice) } @@ -772,6 +795,7 @@ const unsafe impl SliceIndex<[T]> for range::RangeToInclusive { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { (0..=self.last).get_mut(slice) } @@ -794,6 +818,7 @@ const unsafe impl SliceIndex<[T]> for range::RangeToInclusive { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut [T] { (0..=self.last).index_mut(slice) } @@ -1007,6 +1032,7 @@ unsafe impl SliceIndex<[T]> for (ops::Bound, ops::Bound) { } #[inline] + #[rustc_no_writable] fn get_mut(self, slice: &mut [T]) -> Option<&mut Self::Output> { try_into_slice_range(slice.len(), self)?.get_mut(slice) } @@ -1029,6 +1055,7 @@ unsafe impl SliceIndex<[T]> for (ops::Bound, ops::Bound) { } #[inline] + #[rustc_no_writable] fn index_mut(self, slice: &mut [T]) -> &mut Self::Output { into_slice_range(slice.len(), self).index_mut(slice) } diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index ae6cc46a22a84..9b077f1f9c1bd 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -2744,8 +2744,6 @@ impl [T] { /// # Examples /// /// ``` - /// #![feature(strip_circumfix)] - /// /// let v = &[10, 50, 40, 30]; /// assert_eq!(v.strip_circumfix(&[10], &[30]), Some(&[50, 40][..])); /// assert_eq!(v.strip_circumfix(&[10], &[40, 30]), Some(&[50][..])); @@ -2756,7 +2754,7 @@ impl [T] { /// assert_eq!(v.strip_circumfix(&[10, 50], &[]), Some(&[40, 30][..])); /// ``` #[must_use = "returns the subslice without modifying the original"] - #[unstable(feature = "strip_circumfix", issue = "147946")] + #[stable(feature = "strip_circumfix", since = "CURRENT_RUSTC_VERSION")] pub fn strip_circumfix(&self, prefix: &P, suffix: &S) -> Option<&[T]> where T: PartialEq, @@ -5300,7 +5298,6 @@ impl [T] { /// # Examples /// Basic usage: /// ``` - /// #![feature(substr_range)] /// use core::range::Range; /// /// let nums = &[0, 5, 10, 0, 0, 5]; @@ -5315,7 +5312,7 @@ impl [T] { /// 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> { 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 9be44cd89de5e..78cb8ca665e1e 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -2510,15 +2510,13 @@ impl str { /// # Examples /// /// ``` - /// #![feature(strip_circumfix)] - /// /// assert_eq!("bar:hello:foo".strip_circumfix("bar:", ":foo"), Some("hello")); /// assert_eq!("bar:foo".strip_circumfix("foo", "foo"), None); /// assert_eq!("foo:bar;".strip_circumfix("foo:", ';'), Some("bar")); /// ``` #[must_use = "this returns the remaining substring as a new slice, \ without modifying the original"] - #[unstable(feature = "strip_circumfix", issue = "147946")] + #[stable(feature = "strip_circumfix", since = "CURRENT_RUSTC_VERSION")] pub fn strip_circumfix(&self, prefix: P, suffix: S) -> Option<&str> where for<'a> S::Searcher<'a>: ReverseSearcher<'a>, @@ -3195,7 +3193,6 @@ impl str { /// /// # Examples /// ``` - /// #![feature(substr_range)] /// use core::range::Range; /// /// let data = "a, b, b, a"; @@ -3207,7 +3204,7 @@ impl str { /// 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> { 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 4f22e019c52be..e8865823deb98 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -2593,7 +2593,7 @@ macro_rules! atomic_int { #[$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 14f0980ff6045..63b7691582a7d 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 adfb027667fac..6dd26d3ed762d 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 @@ macro_rules! tuple_impls { $($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 @@ macro_rules! tuple_impls { $($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 { @@ -108,7 +108,7 @@ macro_rules! tuple_impls { $($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 @@ macro_rules! tuple_impls { $($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 e335fe1c70264..98b00c600f5ef 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -197,6 +197,7 @@ impl fmt::Display for EscapeError { /// 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/attribute_docs.rs b/library/std/src/attribute_docs.rs new file mode 100644 index 0000000000000..1d8dddb7ca54a --- /dev/null +++ b/library/std/src/attribute_docs.rs @@ -0,0 +1,87 @@ +#[doc(attribute = "must_use")] +// +/// Warn when a value is ignored. +/// +/// The `must_use` attribute applies to values where simply creating or returning them is +/// often not enough. If a value marked with `#[must_use]` is produced and then ignored, the +/// compiler warns through the [`unused_must_use`] lint. +/// +/// This is most common on types that represent an important state or outcome. For example, +/// [`Result`] is marked `#[must_use]` because ignoring an error value can hide a failed operation. +/// In the following example, the returned `Result` is the only sign that writing the message +/// might have failed: +/// +/// ```rust +/// # #![allow(unused_must_use)] +/// fn write_message() -> std::io::Result<()> { +/// // Write the message... +/// Ok(()) +/// } +/// +/// write_message(); +/// ``` +/// +/// Ignoring that `Result` triggers this warning: +/// +/// ```text +/// warning: unused `Result` that must be used +/// = note: this `Result` may be an `Err` variant, which should be handled +/// = note: `#[warn(unused_must_use)]` (part of `#[warn(unused)]`) on by default +/// help: use `let _ = ...` to ignore the resulting value +/// ``` +/// +/// Future values are also `#[must_use]`: creating a future does not run it, so ignoring one often +/// means the intended asynchronous work never happens. +/// +/// You can also place `#[must_use]` on a function, method, or trait declaration. On a function or +/// method, the warning is tied to ignoring that call's return value: +/// +/// ```rust +/// # #![allow(unused_must_use)] +/// #[must_use] +/// fn make_token() -> String { +/// String::from("token") +/// } +/// +/// // Ignoring this call's return value triggers `unused_must_use`. +/// make_token(); +/// ``` +/// +/// On a trait, the warning applies when a function returns an opaque type (`impl Trait`) or trait +/// object (`dyn Trait`) whose bounds include that trait. This is how futures warn if you create one +/// but never poll or await it, since an `async fn` returns an opaque type implementing [`Future`]. +/// +/// The attribute can include a message explaining what the caller should do with the value: +/// +/// ```rust +/// # #![allow(dead_code)] +/// #[must_use = "call `.finish()` to complete the operation"] +/// fn start_operation() -> Operation { +/// Operation +/// } +/// +/// struct Operation; +/// ``` +/// +/// If intentionally ignoring the value is correct, bind it to `_` or call [`drop`]: +/// +/// ```rust +/// # #[must_use] +/// # fn make_token() -> String { +/// # String::from("token") +/// # } +/// let _ = make_token(); +/// drop(make_token()); +/// ``` +/// +/// The attribute is a warning tool, not a type-system rule. Code can still explicitly discard a +/// `#[must_use]` value, and the compiler does not require callers to inspect or otherwise act on +/// the value. +/// +/// For more information, see the Reference on [the `must_use` attribute]. +/// +/// [`Result`]: result::Result +/// [`Future`]: future::Future +/// [`unused_must_use`]: ../rustc/lints/listing/warn-by-default.html#unused-must-use +/// [the `must_use` attribute]: ../reference/attributes/diagnostics.html#the-must_use-attribute +mod must_use_attribute {} diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 0c64c16d045e3..c9e884d89c85e 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -787,6 +787,11 @@ include!("../../core/src/primitive_docs.rs"); // because rustdoc only looks for these modules at the crate level. include!("keyword_docs.rs"); +// Include private modules that exist solely to provide rustdoc +// documentation for built-in attributes. Using `include!` because rustdoc +// only looks for these modules at the crate level. +include!("attribute_docs.rs"); + // This is required to avoid an unstable error when `restricted-std` is not // enabled. The use of #![feature(restricted_std)] in rustc-std-workspace-std // is unconditional, so the unstable feature needs to be defined somewhere. diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index 2e8779e05ca76..b673abdff7ba1 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -876,6 +876,29 @@ impl 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 @@ impl TcpListener { /// 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 @@ impl TcpListener { /// 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 cfcaabf80c9c0..2687a12919701 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -3176,7 +3176,9 @@ impl Path { /// 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 @@ impl Path { /// 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>(&self, extension: S) -> PathBuf { diff --git a/library/std/src/sync/once_lock.rs b/library/std/src/sync/once_lock.rs index 8e69e7a22ad8e..c75a974b13522 100644 --- a/library/std/src/sync/once_lock.rs +++ b/library/std/src/sync/once_lock.rs @@ -656,10 +656,10 @@ impl From for OnceLock { /// ``` #[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 eff522fbc7ece..529cdaf72cc6c 100644 --- a/library/std/src/sys/process/unix/unix.rs +++ b/library/std/src/sys/process/unix/unix.rs @@ -881,7 +881,7 @@ impl Command { // 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/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 00aeb70e6e076..955d1f61e7535 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -26,9 +26,10 @@ //! non-zero exit code. //! //! When the main thread of a Rust program terminates, the entire program shuts -//! down, even if other threads are still running. However, this module provides -//! convenient facilities for automatically waiting for the termination of a -//! thread (i.e., join). +//! down, even if other threads are still running, and any destructors on the +//! remaining threads' stacks may not be executed. However, this module +//! provides convenient facilities for automatically waiting for the +//! termination of a thread (i.e., join). //! //! ## Spawning a thread //! diff --git a/library/stdarch/crates/core_arch/src/loongarch64/simd.rs b/library/stdarch/crates/core_arch/src/loongarch64/simd.rs index 2c4a0f84937ec..32f191509be27 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 9a756eee446d2..30c3125f5f8b8 100644 --- a/library/stdarch/crates/core_arch/src/simd.rs +++ b/library/stdarch/crates/core_arch/src/simd.rs @@ -88,7 +88,7 @@ impl Clone for Simd { #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] #[rustfmt::skip] // FIXME: https://github.com/rust-lang/stdarch/pull/2133#issuecomment-4524350350 -impl const crate::cmp::PartialEq for Simd { +const impl crate::cmp::PartialEq for Simd { #[inline] fn eq(&self, other: &Self) -> bool { self.as_array() == other.as_array() @@ -301,7 +301,7 @@ impl Clone for SimdM { #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] #[rustfmt::skip] // FIXME: https://github.com/rust-lang/stdarch/pull/2133#issuecomment-4524350350 -impl const crate::cmp::PartialEq for SimdM { +const impl crate::cmp::PartialEq for SimdM { #[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 fd3e88e1a36f4..2231e0886bbcd 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -2120,9 +2120,11 @@ impl Compiler { } 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/doc/rustc-dev-guide/src/compiler-debugging.md b/src/doc/rustc-dev-guide/src/compiler-debugging.md index dc9d4b9a5cfe1..1750dee1f34ae 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 @@ Here are some notable ones: |----------------|-------------| | `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 cc66b2fdc6dcb..9e8335623b782 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 @@ with native multi threading capabilities. ## Target maintainers [@g0djan](https://github.com/g0djan) -[@abrown](https://github.com/abrown) [@loganek](https://github.com/loganek) ## Requirements diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index f49840a4b21f9..a2ab1d99d9b75 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -323,7 +323,7 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol { warn!( "tried to get argument name from PatKind::Expr, which is silly in function arguments" ); - return Symbol::intern("()"); + return sym::empty_parens; } PatKind::Slice(begin, mid, end) => { fn print_pat(pat: &Pat<'_>, wild: bool) -> impl Display { diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 6ee56cdd5a8a3..6ebd9a5ab9da5 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -1787,7 +1787,7 @@ pub(crate) fn build_index( RenderTypeId::Primitive(PrimitiveType::Array | PrimitiveType::Slice) => { insert_into_map( ItemType::Primitive, - &[Symbol::intern("[]")], + &[sym::empty_brackets], None, false, serialized_index, @@ -1798,7 +1798,7 @@ pub(crate) fn build_index( // typeNameIdOfArrayOrSlice insert_into_map( ItemType::Primitive, - &[Symbol::intern("()")], + &[sym::empty_parens], None, false, serialized_index, @@ -1809,7 +1809,7 @@ pub(crate) fn build_index( RenderTypeId::Primitive(PrimitiveType::Fn) => { insert_into_map( ItemType::Primitive, - &[Symbol::intern("->")], + &[sym::right_arrow], None, false, serialized_index, @@ -1823,7 +1823,7 @@ pub(crate) fn build_index( { insert_into_map( ItemType::Primitive, - &[Symbol::intern("->")], + &[sym::right_arrow], None, false, serialized_index, diff --git a/src/librustdoc/html/span_map.rs b/src/librustdoc/html/span_map.rs index 517b538d1bfd1..6b187a63c679c 100644 --- a/src/librustdoc/html/span_map.rs +++ b/src/librustdoc/html/span_map.rs @@ -144,6 +144,10 @@ impl<'tcx> SpanMapVisitor<'tcx> { 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/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 05bcf50dca0a0..7d691f89015d7 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -117,6 +117,7 @@ function getOrCreateSection(id, classes) { el = document.createElement("section"); el.id = id; el.className = classes; + // MAIN_ID exists, and is not the root // @ts-expect-error insertAfter(el, document.getElementById(MAIN_ID)); } @@ -154,8 +155,7 @@ function switchDisplayedElement(elemToDisplay) { const el = getAlternativeDisplayElem(); if (el.children.length > 0) { - // @ts-expect-error - getNotDisplayedElem().appendChild(el.firstElementChild); + getNotDisplayedElem().appendChild(nonnull(el.firstElementChild)); } if (elemToDisplay === null) { addClass(el, "hidden"); @@ -202,7 +202,7 @@ function preLoadCss(cssUrl) { /** * Run a JavaScript file asynchronously. * @param {string} url - * @param {function(): any} errorCallback + * @param {function(): any} [errorCallback] */ function loadScript(url, errorCallback) { const script = document.createElement("script"); @@ -224,7 +224,6 @@ function preLoadCss(cssUrl) { event.preventDefault(); // Sending request for the CSS and the JS files at the same time so it will // hopefully be loaded when the JS will generate the settings content. - // @ts-expect-error loadScript(getVar("static-root-path") + getVar("settings-js")); // Pre-load all theme CSS files, so that switching feels seamless. // @@ -811,6 +810,7 @@ function preLoadCss(cssUrl) { } const implementors = implementorsElems("implementors-list"); const syntheticImplementors = implementorsElems("synthetic-implementors-list"); + /** @type {Set} */ const inlined_types = new Set(); const TEXT_IDX = 0; @@ -829,17 +829,14 @@ function preLoadCss(cssUrl) { if (!aliases) { return; } - // @ts-expect-error - aliases.split(",").forEach(alias => { + aliases.split(",").forEach(/** @param {string} alias */ alias => { inlined_types.add(alias); }); }); } - // @ts-expect-error - let currentNbImpls = implementors[0].getElementsByClassName("impl").length; - // @ts-expect-error - const traitName = document.querySelector(".main-heading h1 > .trait").textContent; + let currentNbImpls = nonnull(implementors[0]).getElementsByClassName("impl").length; + const traitName = nonnull(document.querySelector(".main-heading h1 > .trait")).textContent; const baseIdName = "impl-" + traitName + "-"; const libs = Object.getOwnPropertyNames(imp); // We don't want to include impls from this JS file, when the HTML already has them. @@ -859,7 +856,8 @@ function preLoadCss(cssUrl) { struct_loop: for (const struct of structs) { - const list = struct[SYNTHETIC_IDX] ? syntheticImplementors : implementors; + const [impList, negImpMarker] = + struct[SYNTHETIC_IDX] ? syntheticImplementors : implementors; // The types list is only used for synthetic impls. // If this changes, `main.js` and `write_shared.rs` both need changed. @@ -898,11 +896,9 @@ function preLoadCss(cssUrl) { // If this is a negative implementor, we put it into the right location (just // before the negative impl marker). if (struct[IS_NEG_IDX]) { - // @ts-expect-error - list[1].before(display); + nonnull(negImpMarker).before(display); } else { - // @ts-expect-error - list[0].appendChild(display); + nonnull(impList).appendChild(display); } currentNbImpls += 1; } @@ -978,8 +974,7 @@ function preLoadCss(cssUrl) { const text = impList[0]; const traitName = impList[1]; const isTrait = typeof traitName === "string"; - // @ts-expect-error - if (types.indexOf(selfPath) === -1) { + if (selfPath === null || types.indexOf(selfPath) === -1) { continue; } let outputList = isTrait ? trait_implementations : implementations; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 24fa74cc84321..a4f8e3e12e510 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -16,6 +16,7 @@ #![feature(variant_count)] #![recursion_limit = "256"] #![warn(rustc::internal)] +#![warn(rustc::symbol_intern_string_literal)] // tidy-alphabetical-end // N.B. these need `extern crate` even in 2018 edition diff --git a/src/librustdoc/lint.rs b/src/librustdoc/lint.rs index b09ea05688595..91f92b799889b 100644 --- a/src/librustdoc/lint.rs +++ b/src/librustdoc/lint.rs @@ -31,9 +31,9 @@ where allowed_lints.extend(lint_opts.iter().map(|(lint, _)| lint).cloned()); let lints = || { - lint::builtin::HardwiredLints::lint_vec() + lint::builtin::hardwired::lint_vec() .into_iter() - .chain(rustc_lint::SoftLints::lint_vec()) + .chain(rustc_lint::builtin::soft::lint_vec()) }; let lint_opts = lints() diff --git a/src/rustdoc-json-types/Cargo.toml b/src/rustdoc-json-types/Cargo.toml index 7e4e53ccaf0de..9e18691a9605a 100644 --- a/src/rustdoc-json-types/Cargo.toml +++ b/src/rustdoc-json-types/Cargo.toml @@ -18,4 +18,4 @@ rkyv = { version = "0.8", optional = true } [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 e878350e43b9b..844dc45ecafa1 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 = bincode::serialize(&s).unwrap(); - let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap(); + // Postcard + let encoded: Vec = 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 = bincode::serialize(&u).unwrap(); - let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap(); + // Postcard + let encoded: Vec = 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/miri/tests/pass/tree_borrows/implicit_writes/unchecked_mut.rs b/src/tools/miri/tests/pass/tree_borrows/slice_get_mut_no_implicit_write.rs similarity index 50% rename from src/tools/miri/tests/pass/tree_borrows/implicit_writes/unchecked_mut.rs rename to src/tools/miri/tests/pass/tree_borrows/slice_get_mut_no_implicit_write.rs index e2785183ff599..789f0a8b88ce6 100644 --- a/src/tools/miri/tests/pass/tree_borrows/implicit_writes/unchecked_mut.rs +++ b/src/tools/miri/tests/pass/tree_borrows/slice_get_mut_no_implicit_write.rs @@ -1,28 +1,48 @@ +//@compile-flags: -Zmiri-tree-borrows -Zmiri-tree-borrows-implicit-writes + // This test reproduces the pattern used by `BorrowedCursor::as_mut`, which appears in `Socket::recv_with_flags` and `std::fs::read`. // Many crates depend on similar patterns. Before https://github.com/rust-lang/rust/pull/157202 this failed under Tree // Borrows with Implicit Writes. With the attribute `#[rustc_no_writable]` added to // `slice::get_unchecked_mut`, both this test and the affected crates work. -//@compile-flags: -Zmiri-tree-borrows -Zmiri-tree-borrows-implicit-writes - -struct BorrowedBuf<'a> { - buf: &'a mut [u8], -} - -impl<'a> BorrowedBuf<'a> { - fn capacity(&self) -> usize { - self.buf.len() +fn borrowed_buf() { + struct BorrowedBuf<'a> { + buf: &'a mut [u8], } - unsafe fn as_mut(&mut self) -> &mut [u8] { - unsafe { self.buf.get_unchecked_mut(..) } + impl<'a> BorrowedBuf<'a> { + fn capacity(&self) -> usize { + self.buf.len() + } + + unsafe fn as_mut(&mut self) -> &mut [u8] { + unsafe { self.buf.get_unchecked_mut(..) } + } } -} -fn main() { let mut arr = [0u8; 4]; let mut buf = BorrowedBuf { buf: &mut arr }; let ptr = unsafe { buf.as_mut() }.as_mut_ptr(); let _ = buf.capacity(); - unsafe { ptr.write(42); } + unsafe { + ptr.write(42); + } +} + +// A variant of the above that uses `index_mut` notation. +fn index_mut() { + fn dostuff(x: &mut [u8]) { + unsafe { + let ptr = (&mut x[..]).as_mut_ptr(); + let _len = x.len(); + ptr.write(99); + } + } + + dostuff(&mut [1, 2, 3, 4]); +} + +fn main() { + borrowed_buf(); + index_mut(); } diff --git a/src/tools/rustfmt/tests/source/impls.rs b/src/tools/rustfmt/tests/source/impls.rs index dcd1f0cd5b09d..8baa704ab5020 100644 --- a/src/tools/rustfmt/tests/source/impls.rs +++ b/src/tools/rustfmt/tests/source/impls.rs @@ -170,7 +170,7 @@ impl<'a, 'b, 'c> SomeThing for (&'a mut SomethingLong, &'b mut Someth 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 09ec22cf8d14c..752cf2e04c47c 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() -> i32 { ::CONST } -impl const T for U {} +const impl T for U {} fn apit(_: impl [ const ] T) {} diff --git a/tests/assembly-llvm/mips-div-no-trap.rs b/tests/assembly-llvm/mips-div-no-trap.rs new file mode 100644 index 0000000000000..d2baff77d3070 --- /dev/null +++ b/tests/assembly-llvm/mips-div-no-trap.rs @@ -0,0 +1,124 @@ +// Test that there's no conditional trap for zero divisor for all mips +// targets by default. Division by zero is defined as panic so the trap is +// redundant. +// +//@ add-minicore +//@ assembly-output: emit-asm +// +// See https://github.com/llvm/llvm-project/pull/204386. +//@ compile-flags: -Copt-level=3 +// +//@ revisions: mips64el-unknown-linux-gnuabi64 +//@[mips64el-unknown-linux-gnuabi64] compile-flags: --target=mips64el-unknown-linux-gnuabi64 +//@[mips64el-unknown-linux-gnuabi64] needs-llvm-components: mips +//@[mips64el-unknown-linux-gnuabi64] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mips64el-unknown-linux-muslabi64 +//@[mips64el-unknown-linux-muslabi64] compile-flags: --target=mips64el-unknown-linux-muslabi64 +//@[mips64el-unknown-linux-muslabi64] needs-llvm-components: mips +//@[mips64el-unknown-linux-muslabi64] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mips64-openwrt-linux-musl +//@[mips64-openwrt-linux-musl] compile-flags: --target=mips64-openwrt-linux-musl +//@[mips64-openwrt-linux-musl] needs-llvm-components: mips +//@[mips64-openwrt-linux-musl] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mips64-unknown-linux-gnuabi64 +//@[mips64-unknown-linux-gnuabi64] compile-flags: --target=mips64-unknown-linux-gnuabi64 +//@[mips64-unknown-linux-gnuabi64] needs-llvm-components: mips +//@[mips64-unknown-linux-gnuabi64] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mips64-unknown-linux-muslabi64 +//@[mips64-unknown-linux-muslabi64] compile-flags: --target=mips64-unknown-linux-muslabi64 +//@[mips64-unknown-linux-muslabi64] needs-llvm-components: mips +//@[mips64-unknown-linux-muslabi64] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsel-mti-none-elf +//@[mipsel-mti-none-elf] compile-flags: --target=mipsel-mti-none-elf +//@[mipsel-mti-none-elf] needs-llvm-components: mips +//@[mipsel-mti-none-elf] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsel-sony-psp +//@[mipsel-sony-psp] compile-flags: --target=mipsel-sony-psp +//@[mipsel-sony-psp] needs-llvm-components: mips +//@[mipsel-sony-psp] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsel-sony-psx +//@[mipsel-sony-psx] compile-flags: --target=mipsel-sony-psx +//@[mipsel-sony-psx] needs-llvm-components: mips +//@[mipsel-sony-psx] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsel-unknown-linux-gnu +//@[mipsel-unknown-linux-gnu] compile-flags: --target=mipsel-unknown-linux-gnu +//@[mipsel-unknown-linux-gnu] needs-llvm-components: mips +//@[mipsel-unknown-linux-gnu] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsel-unknown-linux-musl +//@[mipsel-unknown-linux-musl] compile-flags: --target=mipsel-unknown-linux-musl +//@[mipsel-unknown-linux-musl] needs-llvm-components: mips +//@[mipsel-unknown-linux-musl] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsel-unknown-linux-uclibc +//@[mipsel-unknown-linux-uclibc] compile-flags: --target=mipsel-unknown-linux-uclibc +//@[mipsel-unknown-linux-uclibc] needs-llvm-components: mips +//@[mipsel-unknown-linux-uclibc] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsel-unknown-netbsd +//@[mipsel-unknown-netbsd] compile-flags: --target=mipsel-unknown-netbsd +//@[mipsel-unknown-netbsd] needs-llvm-components: mips +//@[mipsel-unknown-netbsd] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsel-unknown-none +//@[mipsel-unknown-none] compile-flags: --target=mipsel-unknown-none +//@[mipsel-unknown-none] needs-llvm-components: mips +//@[mipsel-unknown-none] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsisa32r6el-unknown-linux-gnu +//@[mipsisa32r6el-unknown-linux-gnu] compile-flags: --target=mipsisa32r6el-unknown-linux-gnu +//@[mipsisa32r6el-unknown-linux-gnu] needs-llvm-components: mips +//@[mipsisa32r6el-unknown-linux-gnu] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsisa32r6-unknown-linux-gnu +//@[mipsisa32r6-unknown-linux-gnu] compile-flags: --target=mipsisa32r6-unknown-linux-gnu +//@[mipsisa32r6-unknown-linux-gnu] needs-llvm-components: mips +//@[mipsisa32r6-unknown-linux-gnu] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsisa64r6el-unknown-linux-gnuabi64 +//@[mipsisa64r6el-unknown-linux-gnuabi64] compile-flags: --target=mipsisa64r6el-unknown-linux-gnuabi64 +//@[mipsisa64r6el-unknown-linux-gnuabi64] needs-llvm-components: mips +//@[mipsisa64r6el-unknown-linux-gnuabi64] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mipsisa64r6-unknown-linux-gnuabi64 +//@[mipsisa64r6-unknown-linux-gnuabi64] compile-flags: --target=mipsisa64r6-unknown-linux-gnuabi64 +//@[mipsisa64r6-unknown-linux-gnuabi64] needs-llvm-components: mips +//@[mipsisa64r6-unknown-linux-gnuabi64] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mips-mti-none-elf +//@[mips-mti-none-elf] compile-flags: --target=mips-mti-none-elf +//@[mips-mti-none-elf] needs-llvm-components: mips +//@[mips-mti-none-elf] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mips-unknown-linux-gnu +//@[mips-unknown-linux-gnu] compile-flags: --target=mips-unknown-linux-gnu +//@[mips-unknown-linux-gnu] needs-llvm-components: mips +//@[mips-unknown-linux-gnu] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mips-unknown-linux-musl +//@[mips-unknown-linux-musl] compile-flags: --target=mips-unknown-linux-musl +//@[mips-unknown-linux-musl] needs-llvm-components: mips +//@[mips-unknown-linux-musl] filecheck-flags: --check-prefix NOTRAP +//@ revisions: mips-unknown-linux-uclibc +//@[mips-unknown-linux-uclibc] compile-flags: --target=mips-unknown-linux-uclibc +//@[mips-unknown-linux-uclibc] needs-llvm-components: mips +//@[mips-unknown-linux-uclibc] filecheck-flags: --check-prefix NOTRAP +// +//@ revisions: TRAP +//@[TRAP] compile-flags: --target=mips64el-unknown-linux-gnuabi64 -C llvm-args=-mno-check-zero-division=0 +//@[TRAP] needs-llvm-components: mips + +#![crate_type = "lib"] +#![feature(no_core, intrinsics)] +#![no_core] + +extern crate minicore; + +#[rustc_intrinsic] +pub unsafe fn unchecked_div(x: T, y: T) -> T; + +#[rustc_intrinsic] +pub fn abort() -> !; + +// NOTRAP-NOT: teq +// TRAP: teq +#[no_mangle] +pub fn div_i32(a: i32, b: i32) -> i32 { + match a { + 0 => abort(), + -1 => match b { + -2147483648 => abort(), + _ => unsafe { unchecked_div(a, b) }, + }, + _ => unsafe { unchecked_div(a, b) }, + } +} 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 acdb69d33fd1e..0000000000000 --- a/tests/assembly-llvm/riscv-redundant-memory-stores.rs +++ /dev/null @@ -1,33 +0,0 @@ -//! Regression test for : - -//@ 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 38e2621698dbf..e6851b5b4deb9 100644 --- a/tests/auxiliary/minisimd.rs +++ b/tests/auxiliary/minisimd.rs @@ -170,20 +170,20 @@ impl PackedSimd { macro_rules! impl_traits { ($($const_:ident)?) => { - impl $($const_)? PartialEq for Simd { + $($const_)? impl PartialEq for Simd { fn eq(&self, other: &Self) -> bool { self.as_array() == other.as_array() } } - impl $($const_)? core::ops::Index for Simd { + $($const_)? impl core::ops::Index for Simd { type Output = T; fn index(&self, i: usize) -> &T { &self.as_array()[i] } } - impl $($const_)? PartialEq for PackedSimd + $($const_)? impl PartialEq for PackedSimd { fn eq(&self, other: &Self) -> bool { self.as_array() == other.as_array() diff --git a/tests/codegen-llvm/issues/issue-118306.rs b/tests/codegen-llvm/issues/issue-118306.rs index ea8b24317ff15..19623e17815d0 100644 --- a/tests/codegen-llvm/issues/issue-118306.rs +++ b/tests/codegen-llvm/issues/issue-118306.rs @@ -1,5 +1,8 @@ //@ compile-flags: -Copt-level=3 //@ only-x86_64 +//@ revisions: LLVM22 LLVM23 +//@ [LLVM22] max-llvm-major-version: 22 +//@ [LLVM23] min-llvm-version: 23 // Test for #118306. // Make sure we don't create `br` or `select` instructions. @@ -11,9 +14,13 @@ pub fn branchy(input: u64) -> u64 { // CHECK-LABEL: @branchy( // CHECK-NEXT: start: // CHECK-NEXT: [[_2:%.*]] = and i64 [[INPUT:%.*]], 3 - // CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds{{( nuw)?}} {{\[4 x i64\]|i64|\[8 x i8\]}}, ptr @switch.table.branchy{{(, i64 0)?}}, i64 [[_2]] - // CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i64, ptr [[SWITCH_GEP]] - // CHECK-NEXT: ret i64 [[SWITCH_LOAD]] + // LLVM22-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds{{( nuw)?}} {{\[4 x i64\]|i64|\[8 x i8\]}}, ptr @switch.table.branchy{{(, i64 0)?}}, i64 [[_2]] + // LLVM22-NEXT: [[SWITCH_LOAD:%.*]] = load i64, ptr [[SWITCH_GEP]] + // LLVM22-NEXT: ret i64 [[SWITCH_LOAD]] + // LLVM23-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds{{( nuw)?}} i8, ptr @switch.table.branchy, i64 [[_2]] + // LLVM23-NEXT: [[SWITCH_LOAD:%.*]] = load i8, ptr [[SWITCH_GEP]], align 1 + // LLVM23-NEXT: [[SWITCH_EXT:%.*]] = zext i8 [[SWITCH_LOAD]] to i64 + // LLVM23-NEXT: ret i64 [[SWITCH_EXT]] match input % 4 { 1 | 2 => 1, 3 => 2, diff --git a/tests/codegen-llvm/pow_known_base.rs b/tests/codegen-llvm/pow_known_base.rs index ea0e40515f9e4..f7e649ef089ea 100644 --- a/tests/codegen-llvm/pow_known_base.rs +++ b/tests/codegen-llvm/pow_known_base.rs @@ -1,4 +1,7 @@ //@ compile-flags: -Copt-level=3 +//@ revisions: LLVM22 LLVM23 +//@ [LLVM22] max-llvm-major-version: 22 +//@ [LLVM23] min-llvm-version: 23 // Test that `pow` can use a faster implementation when `base` is a // known power of two @@ -21,11 +24,16 @@ pub fn pow2(exp: u32) -> u32 { pub fn pow4(exp: u32) -> u32 { // CHECK: %[[ICMP1:.+]] = icmp slt i32 %exp, 0 // CHECK: %[[SHIFT_AMOUNT:.+]] = shl i32 %exp, 1 - // CHECK: %[[ICMP2:.+]] = icmp ult i32 %[[SHIFT_AMOUNT]], 32 - // CHECK: %[[POW:.+]] = shl nuw i32 1, %[[SHIFT_AMOUNT]] - // CHECK: %[[SEL:.+]] = select i1 %[[ICMP2]], i32 %[[POW]], i32 0 - // CHECK: %[[RET:.+]] = select i1 %[[ICMP1]], i32 0, i32 %[[SEL]] - // CHECK: ret i32 %[[RET]] + // LLVM22: %[[ICMP2:.+]] = icmp ult i32 %[[SHIFT_AMOUNT]], 32 + // LLVM22: %[[POW:.+]] = shl nuw i32 1, %[[SHIFT_AMOUNT]] + // LLVM22: %[[SEL:.+]] = select i1 %[[ICMP2]], i32 %[[POW]], i32 0 + // LLVM22: %[[RET:.+]] = select i1 %[[ICMP1]], i32 0, i32 %[[SEL]] + // LLVM22: ret i32 %[[RET]] + // LLVM23: %[[ICMP2:.+]] = icmp ugt i32 %[[SHIFT_AMOUNT]], 31 + // LLVM23: %[[POW:.+]] = shl nuw i32 1, %[[SHIFT_AMOUNT]] + // LLVM23: %[[COND:.+]] = or i1 %[[ICMP1]], %[[ICMP2]] + // LLVM23: %[[RET:.+]] = select i1 %[[COND]], i32 0, i32 %[[POW]] + // LLVM23: ret i32 %[[RET]] 4u32.pow(exp) } @@ -35,11 +43,16 @@ pub fn pow4(exp: u32) -> u32 { pub fn pow16(exp: u32) -> u32 { // CHECK: %[[ICMP1:.+]] = icmp ugt i32 %exp, 1073741823 // CHECK: %[[SHIFT_AMOUNT:.+]] = shl i32 %exp, 2 - // CHECK: %[[ICMP2:.+]] = icmp ult i32 %[[SHIFT_AMOUNT]], 32 - // CHECK: %[[POW:.+]] = shl nuw i32 1, %[[SHIFT_AMOUNT]] - // CHECK: %[[SEL:.+]] = select i1 %[[ICMP2]], i32 %[[POW]], i32 0 - // CHECK: %[[RET:.+]] = select i1 %[[ICMP1]], i32 0, i32 %[[SEL]] - // CHECK: ret i32 %[[RET]] + // LLVM22: %[[ICMP2:.+]] = icmp ult i32 %[[SHIFT_AMOUNT]], 32 + // LLVM22: %[[POW:.+]] = shl nuw i32 1, %[[SHIFT_AMOUNT]] + // LLVM22: %[[SEL:.+]] = select i1 %[[ICMP2]], i32 %[[POW]], i32 0 + // LLVM22: %[[RET:.+]] = select i1 %[[ICMP1]], i32 0, i32 %[[SEL]] + // LLVM22: ret i32 %[[RET]] + // LLVM23: %[[ICMP2:.+]] = icmp ugt i32 %[[SHIFT_AMOUNT]], 31 + // LLVM23: %[[POW:.+]] = shl nuw i32 1, %[[SHIFT_AMOUNT]] + // LLVM23: %[[COND:.+]] = or i1 %[[ICMP1]], %[[ICMP2]] + // LLVM23: %[[RET:.+]] = select i1 %[[COND]], i32 0, i32 %[[POW]] + // LLVM23: ret i32 %[[RET]] 16u32.pow(exp) } diff --git a/tests/codegen-llvm/sanitizer/multiple-sanitizers.rs b/tests/codegen-llvm/sanitizer/multiple-sanitizers.rs new file mode 100644 index 0000000000000..862999e7ac026 --- /dev/null +++ b/tests/codegen-llvm/sanitizer/multiple-sanitizers.rs @@ -0,0 +1,18 @@ +// Verifies that multiple compatible sanitizers (CFI + SafeStack) can be enabled together +// and their target modifiers accumulate instead of overwriting. +// +//@ only-x86_64 +//@ only-linux +//@ needs-sanitizer-cfi +//@ needs-sanitizer-safestack +//@ compile-flags: -Zsanitizer=cfi -Zsanitizer=safestack -Clto -Ccodegen-units=1 -C unsafe-allow-abi-mismatch=sanitizer + +#![crate_type = "lib"] + +// CHECK: ; Function Attrs:{{.*}}safestack +// CHECK: define{{.*}}foo{{.*}}!type +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + f(arg) +} + +// CHECK: attributes #0 = {{.*}}safestack{{.*}} diff --git a/tests/incremental/delegation-ice-155729.rs b/tests/incremental/delegation-ice-155729.rs new file mode 100644 index 0000000000000..5316e7b66cd5b --- /dev/null +++ b/tests/incremental/delegation-ice-155729.rs @@ -0,0 +1,14 @@ +//@ revisions: bpass + +#![feature(fn_delegation)] + +pub mod to_reuse { + pub fn bar() {} +} + +mod a { + use to_reuse; + reuse to_reuse::bar; +} + +fn main() {} diff --git a/tests/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir b/tests/mir-opt/unusual_item_types.Test-X-{constructor#0}.runtime-optimized.after.mir similarity index 73% rename from tests/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir rename to tests/mir-opt/unusual_item_types.Test-X-{constructor#0}.runtime-optimized.after.mir index 1e497b412024c..527089e2b2cf0 100644 --- a/tests/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir +++ b/tests/mir-opt/unusual_item_types.Test-X-{constructor#0}.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 8ec15b4014ae5..e547246bae5f5 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 987a816d465bd..c2ac9d1588034 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 f263410d93afe..c3040802e201d 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 @@ pub const trait Tr { //@ 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 const Tr for T +const impl Tr for T where Option: /* [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 0000000000000..a3e034f973632 --- /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 . + +//@ 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 0000000000000..8456bccc512e7 --- /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; + //~^ 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( //~ 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 = 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 0000000000000..5a212e01e8cbc --- /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; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +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; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +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( +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( +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 51c4fefaf70d5..3e775f502cd78 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 { 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 fb279dd824f81..01791c28a7c50 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() -> usize { T::NAME_BYTES.len() } -impl const ConstName for &T +const impl ConstName for &T where [(); name_len::()]:, { const NAME_BYTES: &'static [u8] = b"&T"; } -impl const ConstName for &mut T +const impl ConstName for &mut T where [(); name_len::()]:, { diff --git a/tests/ui/const-generics/issues/issue-98629.rs b/tests/ui/const-generics/issues/issue-98629.rs index 4d65ce8681958..372c781107d92 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 [(); ::N]:, -{} +{ +} fn main() {} diff --git a/tests/ui/const-generics/issues/issue-98629.stderr b/tests/ui/const-generics/issues/issue-98629.stderr index 3e929356d2cdf..49218065d5b55 100644 --- a/tests/ui/const-generics/issues/issue-98629.stderr +++ b/tests/ui/const-generics/issues/issue-98629.stderr @@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `N` 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/const-generics/mgca/adt_expr_unit_enum_extra_field.rs b/tests/ui/const-generics/mgca/adt_expr_unit_enum_extra_field.rs new file mode 100644 index 0000000000000..6d25e7ef798fa --- /dev/null +++ b/tests/ui/const-generics/mgca/adt_expr_unit_enum_extra_field.rs @@ -0,0 +1,13 @@ +#![feature(min_generic_const_args, adt_const_params)] + +#[derive(Eq, PartialEq, std::marker::ConstParamTy)] +enum E { + S {} +} + +fn foo() {} + +fn main() { + foo::<{E::S { x: const { 1 } }}>(); + //~^ ERROR variant `E::S` has no field named `x` [E0559] +} diff --git a/tests/ui/const-generics/mgca/adt_expr_unit_enum_extra_field.stderr b/tests/ui/const-generics/mgca/adt_expr_unit_enum_extra_field.stderr new file mode 100644 index 0000000000000..7ac3b28cdca5b --- /dev/null +++ b/tests/ui/const-generics/mgca/adt_expr_unit_enum_extra_field.stderr @@ -0,0 +1,9 @@ +error[E0559]: variant `E::S` has no field named `x` + --> $DIR/adt_expr_unit_enum_extra_field.rs:11:19 + | +LL | foo::<{E::S { x: const { 1 } }}>(); + | ^ `E::S` does not have this field + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0559`. diff --git a/tests/ui/const-generics/mgca/adt_expr_unit_struct_extra_field.rs b/tests/ui/const-generics/mgca/adt_expr_unit_struct_extra_field.rs new file mode 100644 index 0000000000000..fbb8db0952f04 --- /dev/null +++ b/tests/ui/const-generics/mgca/adt_expr_unit_struct_extra_field.rs @@ -0,0 +1,11 @@ +#![feature(min_generic_const_args, adt_const_params)] + +#[derive(Eq, PartialEq, std::marker::ConstParamTy)] +struct Foo; + +fn foo() {} + +fn main() { + foo::<{ Foo { field: const { 1 } } }>(); + //~^ ERROR struct `Foo` has no field named `field` [E0560] +} diff --git a/tests/ui/const-generics/mgca/adt_expr_unit_struct_extra_field.stderr b/tests/ui/const-generics/mgca/adt_expr_unit_struct_extra_field.stderr new file mode 100644 index 0000000000000..fb22f8549d35a --- /dev/null +++ b/tests/ui/const-generics/mgca/adt_expr_unit_struct_extra_field.stderr @@ -0,0 +1,9 @@ +error[E0560]: struct `Foo` has no field named `field` + --> $DIR/adt_expr_unit_struct_extra_field.rs:9:19 + | +LL | foo::<{ Foo { field: const { 1 } } }>(); + | ^^^^^ `Foo` does not have this field + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0560`. diff --git a/tests/ui/consts/const-closure-in-trait-impl.rs b/tests/ui/consts/const-closure-in-trait-impl.rs index 29722dd37c1e0..6d13cefaeefdc 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 46ed3cd20d81d..b6dc00140f839 100644 --- a/tests/ui/consts/const-try.rs +++ b/tests/ui/consts/const-try.rs @@ -15,13 +15,13 @@ use std::ops::{ControlFlow, FromResidual, Residual, Try}; struct TryMe; struct Error; -impl const FromResidual for TryMe { +const impl FromResidual 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 9715724007cc4..33f931013a2dd 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 @@ impl Drop for NotConstDrop { 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); //~^ ERROR: `T` does not implement `[const] Destruct` -impl const Drop for ConstDrop2 { +const impl Drop for ConstDrop2 { fn drop(&mut self) {} } struct ConstDrop3(T); -impl const Drop for ConstDrop3 { +const impl Drop for ConstDrop3 { 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 5a81044dfadb7..edb01ecce27ec 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 @@ LL | struct ConstDrop(NotConstDrop); 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 @@ LL | struct ConstDrop2(T); note: required for this `Drop` impl --> $DIR/drop-impl-nonconst-drop-field.rs:22:1 | -LL | impl const Drop for ConstDrop2 { +LL | const impl Drop for ConstDrop2 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider restricting type parameter `T` with unstable trait `Destruct` | -LL | impl const Drop for ConstDrop2 { - | ++++++++++++++++++ +LL | const impl Drop for ConstDrop2 { + | ++++++++++++++++++ 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 1d1897e15d443..a77f154fa7d18 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 79cb2ea2a02a0..1be3f43a6573a 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(x: T) -> T { x } +pub const fn id(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 7a9cdd687048d..cc6f52ea13ef3 100644 --- a/tests/ui/consts/promoted_const_call.stderr +++ b/tests/ui/consts/promoted_const_call.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:8:26 + --> $DIR/promoted_const_call.rs:14:26 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -10,7 +10,7 @@ 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 + --> $DIR/promoted_const_call.rs:14:30 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^ - temporary value is freed at the end of this statement @@ -19,7 +19,7 @@ LL | let _: &'static _ = &id(&Panic); | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:14:26 + --> $DIR/promoted_const_call.rs:20:26 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -30,7 +30,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:14:30 + --> $DIR/promoted_const_call.rs:20:30 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^ - temporary value is freed at the end of this statement @@ -39,7 +39,7 @@ LL | let _: &'static _ = &id(&Panic); | 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:23:26 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -50,7 +50,7 @@ LL | } | - 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 3d9a60cefc7cc..7bda53ca08346 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 75c51f8f031b1..9e6234f89fa54 100644 --- a/tests/ui/consts/trait_alias_method_call.rs +++ b/tests/ui/consts/trait_alias_method_call.rs @@ -11,15 +11,14 @@ mod foo { 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 a580f540a847b..940d4623cba86 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 @@ pub struct Foo; #[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 0efead6720300..b585451cdd859 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 @@ error: `#[diagnostic::on_const]` can only be applied to non-const trait implemen 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/generic-const-items/const-trait-impl.rs b/tests/ui/generic-const-items/const-trait-impl.rs index 197c97ef9fed7..f77be95c196e6 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; } diff --git a/tests/ui/lint/missing-debug-implementations-lint/impl-debug-for-alias-type.rs b/tests/ui/lint/missing-debug-implementations-lint/impl-debug-for-alias-type.rs new file mode 100644 index 0000000000000..5222df24b61a6 --- /dev/null +++ b/tests/ui/lint/missing-debug-implementations-lint/impl-debug-for-alias-type.rs @@ -0,0 +1,22 @@ +//@ check-pass + +#![feature(lazy_type_alias)] +#![deny(missing_debug_implementations)] + +pub struct Local; + +pub type Alias = Local; + +impl std::fmt::Debug for Alias { + fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Ok(()) } +} + +pub struct Generic(T); + +pub type GenericAlias = Generic; + +impl std::fmt::Debug for GenericAlias { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Ok(()) } +} + +fn main() {} diff --git a/tests/ui/lint/missing-debug-implementations-lint/impl-debug-for-project.rs b/tests/ui/lint/missing-debug-implementations-lint/impl-debug-for-project.rs new file mode 100644 index 0000000000000..ecdca8c211382 --- /dev/null +++ b/tests/ui/lint/missing-debug-implementations-lint/impl-debug-for-project.rs @@ -0,0 +1,20 @@ +//@ check-pass + +#![deny(missing_debug_implementations)] + +pub struct Local; + +impl std::fmt::Debug for ::Output { + fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Ok(()) } +} + +pub trait Identity { type Output; } +impl Identity for T { type Output = T; } + +pub struct Generic(T); + +impl std::fmt::Debug for as Identity>::Output { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Ok(()) } +} + +fn main() {} diff --git a/tests/ui/lint/missing-debug-implementations-lint.rs b/tests/ui/lint/missing-debug-implementations-lint/missing-debug-implementations-lint.rs similarity index 100% rename from tests/ui/lint/missing-debug-implementations-lint.rs rename to tests/ui/lint/missing-debug-implementations-lint/missing-debug-implementations-lint.rs diff --git a/tests/ui/lint/missing-debug-implementations-lint.stderr b/tests/ui/lint/missing-debug-implementations-lint/missing-debug-implementations-lint.stderr similarity index 100% rename from tests/ui/lint/missing-debug-implementations-lint.stderr rename to tests/ui/lint/missing-debug-implementations-lint/missing-debug-implementations-lint.stderr diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index fde68f8f760dd..1a65ef7200f52 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -491,7 +491,7 @@ fn test_item() { c1!(item, [ pub impl Struct {} ], "pub impl Struct {}"); c1!(item, [ impl Struct {} ], "impl Struct {}"); c1!(item, [ pub impl Trait for Struct {} ], "pub impl Trait for Struct {}"); - c1!(item, [ impl const Trait for T {} ], "impl const Trait for T {}"); + c1!(item, [ const impl Trait for T {} ], "const impl Trait for T {}"); // ItemKind::MacCall c1!(item, [ mac!(); ], "mac!();"); diff --git a/tests/ui/parallel-rustc/dyn-trait-ice-153366.rs b/tests/ui/parallel-rustc/dyn-trait-ice-153366.rs new file mode 100644 index 0000000000000..9fd53f31a9f61 --- /dev/null +++ b/tests/ui/parallel-rustc/dyn-trait-ice-153366.rs @@ -0,0 +1,25 @@ +// Regression test for ICE from issue #153366. + +#![feature(unboxed_closures)] + +fn iso(a: Fn) -> Option<_> +//~^ ERROR missing generics for trait `Fn` +//~| ERROR the placeholder `_` is not allowed within types on item signatures for return types +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition +where + dyn Fn(A) -> (): Sized, +{ + Box::new(iso_un_option) + //~^ ERROR mismatched types +} +fn iso_un_option() -> Box<_> { +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types + iso(()) + //~^ ERROR the size for values of type `(dyn Fn(_) + 'static)` cannot be known at compilation +} + +fn main() { + iso(()) + //~^ ERROR the size for values of type `(dyn Fn(_) + 'static)` cannot be known at compilation +} diff --git a/tests/ui/parallel-rustc/dyn-trait-ice-153366.stderr b/tests/ui/parallel-rustc/dyn-trait-ice-153366.stderr new file mode 100644 index 0000000000000..ba21ace81c7eb --- /dev/null +++ b/tests/ui/parallel-rustc/dyn-trait-ice-153366.stderr @@ -0,0 +1,93 @@ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/dyn-trait-ice-153366.rs:5:14 + | +LL | fn iso(a: Fn) -> Option<_> + | ^^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see + = note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default +help: if this is a dyn-compatible trait, use `dyn` + | +LL | fn iso(a: dyn Fn) -> Option<_> + | +++ + +error[E0107]: missing generics for trait `Fn` + --> $DIR/dyn-trait-ice-153366.rs:5:14 + | +LL | fn iso(a: Fn) -> Option<_> + | ^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | fn iso(a: Fn) -> Option<_> + | ++++++ + +error[E0277]: the size for values of type `(dyn Fn(_) + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-ice-153366.rs:18:5 + | +LL | iso(()) + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Fn(_) + 'static)` +note: required by a bound in `iso` + --> $DIR/dyn-trait-ice-153366.rs:11:22 + | +LL | fn iso(a: Fn) -> Option<_> + | --- required by a bound in this function +... +LL | dyn Fn(A) -> (): Sized, + | ^^^^^ required by this bound in `iso` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/dyn-trait-ice-153366.rs:16:30 + | +LL | fn iso_un_option() -> Box<_> { + | ^ not allowed in type signatures + +error[E0308]: mismatched types + --> $DIR/dyn-trait-ice-153366.rs:13:5 + | +LL | fn iso(a: Fn) -> Option<_> + | --------- expected `Option<_>` because of return type +... +LL | Box::new(iso_un_option) + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<_>`, found `Box ... {iso_un_option::<_>}>` + | + = note: expected enum `Option<_>` + found struct `Box {type error} {iso_un_option::<_>}>` +help: use parentheses to call this function + | +LL | Box::new(iso_un_option)() + | ++ +help: try wrapping the expression in `Some` + | +LL | Some(Box::new(iso_un_option)) + | +++++ + + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/dyn-trait-ice-153366.rs:5:28 + | +LL | fn iso(a: Fn) -> Option<_> + | ^ not allowed in type signatures + +error[E0277]: the size for values of type `(dyn Fn(_) + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-ice-153366.rs:23:5 + | +LL | iso(()) + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Fn(_) + 'static)` +note: required by a bound in `iso` + --> $DIR/dyn-trait-ice-153366.rs:11:22 + | +LL | fn iso(a: Fn) -> Option<_> + | --- required by a bound in this function +... +LL | dyn Fn(A) -> (): Sized, + | ^^^^^ required by this bound in `iso` + +error: aborting due to 6 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0107, E0121, E0277, E0308. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.rs b/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.rs new file mode 100644 index 0000000000000..752d7b1dafe18 --- /dev/null +++ b/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.rs @@ -0,0 +1,14 @@ +// Regression test for ICE from issue #154056. + +//@ ignore-parallel-frontend query cycle + ICE + +#![feature(min_generic_const_args)] +#![feature(return_type_notation)] + +trait IntFactory { + fn stream(&self) -> impl IntFactory; + //~^ ERROR cycle detected when resolving lifetimes for `IntFactory::stream` +} +trait SendIntFactory: IntFactory + Send {} + +fn main() {} diff --git a/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.stderr b/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.stderr new file mode 100644 index 0000000000000..43f39eca38d97 --- /dev/null +++ b/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.stderr @@ -0,0 +1,19 @@ +error[E0391]: cycle detected when resolving lifetimes for `IntFactory::stream` + --> $DIR/fn-sig-cycle-ice-154560.rs:9:5 + | +LL | fn stream(&self) -> impl IntFactory; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: ...which requires computing function signature of `IntFactory::stream`... + = note: ...which requires looking up late bound vars inside `IntFactory::stream`... + = note: ...which again requires resolving lifetimes for `IntFactory::stream`, completing the cycle +note: cycle used when listing captured lifetimes for opaque `IntFactory::stream::{opaque#0}` + --> $DIR/fn-sig-cycle-ice-154560.rs:9:25 + | +LL | fn stream(&self) -> impl IntFactory; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: for more information, see and + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/parallel-rustc/variances-cycle-ice-154560.rs b/tests/ui/parallel-rustc/variances-cycle-ice-154560.rs new file mode 100644 index 0000000000000..2f0690ab43736 --- /dev/null +++ b/tests/ui/parallel-rustc/variances-cycle-ice-154560.rs @@ -0,0 +1,16 @@ +// Regression test for ICE from issue #154560. +//~^ ERROR cycle detected when computing the variances for items in this crate + +//@ ignore-parallel-frontend query cycle + ICE + +pub struct T<'a>(&'a str); + +pub fn f() -> _ { + T +} + +pub fn g<'a>(val: T<'a>) -> _ { + T +} + +fn main() {} diff --git a/tests/ui/parallel-rustc/variances-cycle-ice-154560.stderr b/tests/ui/parallel-rustc/variances-cycle-ice-154560.stderr new file mode 100644 index 0000000000000..6cfdadf5c5d5c --- /dev/null +++ b/tests/ui/parallel-rustc/variances-cycle-ice-154560.stderr @@ -0,0 +1,24 @@ +error[E0391]: cycle detected when computing the variances for items in this crate + | +note: ...which requires computing function signature of `f`... + --> $DIR/variances-cycle-ice-154560.rs:8:1 + | +LL | pub fn f() -> _ { + | ^^^^^^^^^^^^^^^^^^ + = note: ...which requires type-checking `f`... +note: ...which requires computing the variances of `T`... + --> $DIR/variances-cycle-ice-154560.rs:6:1 + | +LL | pub struct T<'a>(&'a str); + | ^^^^^^^^^^^^^^^^ + = note: ...which again requires computing the variances for items in this crate, completing the cycle +note: cycle used when computing the variances of `T` + --> $DIR/variances-cycle-ice-154560.rs:6:1 + | +LL | pub struct T<'a>(&'a str); + | ^^^^^^^^^^^^^^^^ + = note: for more information, see and + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/parser/const-recover-semi-issue-151149.fixed b/tests/ui/parser/const-recover-semi-issue-151149.fixed index 79a3c7b248db7..4b1cc44720bf2 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 @@ 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/const-recover-semi-issue-151149.rs b/tests/ui/parser/const-recover-semi-issue-151149.rs index affd81fd0b34c..ab1933ca30acf 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 be8a7ddf26693..4a960e9161b2c 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 0000000000000..c28cb1ef4fda4 --- /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> 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 0000000000000..d513577e901a0 --- /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> 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 0000000000000..e6f3540768a44 --- /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 0000000000000..431893a4d0ced --- /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 0000000000000..73bc24a810e02 --- /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 0000000000000..eb9a3d44b9a7c --- /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 0000000000000..f8faea470588b --- /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/rustc_public-ir-print/async-closure.stdout b/tests/ui/rustc_public-ir-print/async-closure.stdout index 8a473d52fff3c..efdc33f1b0579 100644 --- a/tests/ui/rustc_public-ir-print/async-closure.stdout +++ b/tests/ui/rustc_public-ir-print/async-closure.stdout @@ -1,5 +1,5 @@ // WARNING: This is highly experimental output it's intended for rustc_public developers only. -// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir. +// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/rustc_public. fn foo() -> () { let mut _0: (); let _1: i32; diff --git a/tests/ui/rustc_public-ir-print/basic_function.stdout b/tests/ui/rustc_public-ir-print/basic_function.stdout index dc885e009e914..1159b94818d06 100644 --- a/tests/ui/rustc_public-ir-print/basic_function.stdout +++ b/tests/ui/rustc_public-ir-print/basic_function.stdout @@ -1,5 +1,5 @@ // WARNING: This is highly experimental output it's intended for rustc_public developers only. -// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir. +// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/rustc_public. fn foo(_1: i32) -> i32 { let mut _0: i32; let mut _2: i32; diff --git a/tests/ui/rustc_public-ir-print/operands.stdout b/tests/ui/rustc_public-ir-print/operands.stdout index 58f229be2e6e2..c8d31c6339cf2 100644 --- a/tests/ui/rustc_public-ir-print/operands.stdout +++ b/tests/ui/rustc_public-ir-print/operands.stdout @@ -1,5 +1,5 @@ // WARNING: This is highly experimental output it's intended for rustc_public developers only. -// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir. +// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/rustc_public. fn operands(_1: u8) -> () { let mut _0: (); let _2: [u8; 10]; 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 0000000000000..02d541cbee165 --- /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 8a37f19ffb0d8..5a1cfef97ebae 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 670557e12c110..5fb4408dcdc96 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:: { .. }; + #[rustfmt::skip] assert!(matches!( Qux:: { bar: S, diff --git a/tests/ui/suggestions/for-loop-no-spurious-in-suggestion.rs b/tests/ui/suggestions/for-loop-no-spurious-in-suggestion.rs new file mode 100644 index 0000000000000..142f925665881 --- /dev/null +++ b/tests/ui/suggestions/for-loop-no-spurious-in-suggestion.rs @@ -0,0 +1,9 @@ +// Regression test for https://github.com/rust-lang/rust/issues/103561: when the +// `for` loop header already contains an `in`, a missing `in` is not the problem, +// so we must not suggest inserting another one (which would not compile). + +fn main() { + for i i in 0..10 {} + //~^ ERROR missing `in` in `for` loop + //~| ERROR expected `{`, found keyword `in` +} diff --git a/tests/ui/suggestions/for-loop-no-spurious-in-suggestion.stderr b/tests/ui/suggestions/for-loop-no-spurious-in-suggestion.stderr new file mode 100644 index 0000000000000..472ee7d9ddca2 --- /dev/null +++ b/tests/ui/suggestions/for-loop-no-spurious-in-suggestion.stderr @@ -0,0 +1,14 @@ +error: missing `in` in `for` loop + --> $DIR/for-loop-no-spurious-in-suggestion.rs:6:10 + | +LL | for i i in 0..10 {} + | ^ + +error: expected `{`, found keyword `in` + --> $DIR/for-loop-no-spurious-in-suggestion.rs:6:13 + | +LL | for i i in 0..10 {} + | ^^ expected `{` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_both.stderr b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_both.stderr index 440a91c7707f8..44a2c24b2324e 100644 --- a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_both.stderr +++ b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_both.stderr @@ -1,5 +1,5 @@ error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi` - --> $DIR/sanitizers-safestack-and-kcfi.rs:16:1 + --> $DIR/sanitizers-safestack-and-kcfi.rs:18:1 | LL | #![feature(no_core)] | ^ diff --git a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_kcfi.stderr b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_kcfi.stderr index 6cdd7facc3781..e951b36969b78 100644 --- a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_kcfi.stderr +++ b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_kcfi.stderr @@ -1,5 +1,5 @@ error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi` - --> $DIR/sanitizers-safestack-and-kcfi.rs:16:1 + --> $DIR/sanitizers-safestack-and-kcfi.rs:18:1 | LL | #![feature(no_core)] | ^ diff --git a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_safestack.stderr b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_safestack.stderr index ecfbcace39fe5..9fd2738ef45ab 100644 --- a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_safestack.stderr +++ b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_safestack.stderr @@ -1,5 +1,5 @@ error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi` - --> $DIR/sanitizers-safestack-and-kcfi.rs:16:1 + --> $DIR/sanitizers-safestack-and-kcfi.rs:18:1 | LL | #![feature(no_core)] | ^ diff --git a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.rs b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.rs index 6c3ceb7e91008..eb4b4d6194228 100644 --- a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.rs +++ b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.rs @@ -4,14 +4,16 @@ //@ aux-build:safestack-and-kcfi.rs //@ compile-flags: -Cpanic=abort -//@ revisions: good good_reverted missed_safestack missed_kcfi missed_both +//@ revisions: good good_reverted good_multiple missed_safestack missed_kcfi missed_both //@[good] compile-flags: -Zsanitizer=safestack,kcfi //@[good_reverted] compile-flags: -Zsanitizer=kcfi,safestack +//@[good_multiple] compile-flags: -Zsanitizer=safestack -Zsanitizer=kcfi //@[missed_safestack] compile-flags: -Zsanitizer=kcfi //@[missed_kcfi] compile-flags: -Zsanitizer=safestack // [missed_both] no additional compile-flags: //@[good] check-pass //@[good_reverted] check-pass +//@[good_multiple] check-pass #![feature(no_core)] //[missed_safestack]~^ ERROR mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi` diff --git a/tests/ui/traits/const-traits/assoc-type.rs b/tests/ui/traits/const-traits/assoc-type.rs index 3fb6f679a1933..f01c009b86190 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 { 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 7d464d57c3651..d3460eb5229e1 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 @@ pub const trait MyTrait { 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 2e5df13d021d5..e1d1135e6d4ec 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 { 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 unsafe trait SliceIndex { fn index(self, slice: &T) -> &Self::Output; } -impl const Index for [T] +const impl Index for [T] where I: [const] SliceIndex<[T]>, { @@ -182,7 +182,7 @@ where } } -impl const Index for [T; N] +const impl Index for [T; N] where [T]: [const] Index, { @@ -210,7 +210,7 @@ pub const trait Deref { fn deref(&self) -> &Self::Target; } -impl const Deref for &T { +const impl Deref for &T { type Target = T; fn deref(&self) -> &T { @@ -218,7 +218,7 @@ impl const Deref for &T { } } -impl const Deref for &mut T { +const impl Deref for &mut T { type Target = T; fn deref(&self) -> &T { @@ -269,7 +269,7 @@ pub const trait From: Sized { fn from(value: T) -> Self; } -impl const Into for T +const impl Into for T where U: [const] From, { @@ -278,7 +278,7 @@ where } } -impl const From for T { +const impl From for T { fn from(t: T) -> T { t } @@ -306,7 +306,7 @@ pub const trait PartialEq: PointeeSized { } } -impl const PartialEq<&B> for &A +const impl PartialEq<&B> for &A where A: [const] PartialEq, { @@ -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 @@ impl Option { } } -impl const Deref for Pin

{ +const impl Deref for Pin

{ type Target = P::Target; fn deref(&self) -> &P::Target { Pin::get_ref(Pin::as_ref(self)) } } -impl const Deref for Option { +const impl Deref for Option { 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 65e75864ff825..7859b9fe9e5c2 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 struct Unstable; #[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 struct Unstable2; #[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 bb481d0d9ea94..dd8e3dfde4a3d 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 b12e7e82664b7..c48879d69c6a7 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 @@ impl const std::ops::Add for Int { } } -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 4ed937eacaca4..cf45aa98b2fc9 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 const MyPartialEq for T { +const impl 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 db053b4807919..616fd285dbe0f 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 5913cbf8a21d0..7090447bbc089 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 01c5860c8ec5e..d4f8f49c00f4f 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 2241f70cf21e1..ba0f154ef94d8 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 11ff1ddb79535..e8b473728b013 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() -> u32; } -impl const Main for () { +const impl Main for () { fn compute() -> 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 21419be29591f..25abfe186786e 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 {} -impl const Trait<0> for () {} +const impl Trait<0> for () {} const fn f< T: Trait< @@ -19,7 +19,9 @@ const fn f< 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 dfb828623ee68..41acbc846767c 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; } -impl const Trait for () { +const impl Trait for () { type Assoc = 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 560b740dc91c6..4fb0370f18fe6 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 @@ impl std::ops::Add for Int { } } -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 26ed7d05324cc..71bcad0e2bf4d 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 @@ error[E0119]: conflicting implementations of trait `Add` for type `Int` 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 9b2e93fa0dede..dc10c6fc3718e 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); -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 f80e379a13174..8086b38a88831 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 04da8f730e209..7c33fb611d79f 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 62de7c533ffb8..18173371222ea 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 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 0d010fe0de97a..3cbf399138d0f 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); -impl const Foo for A where A: [const] Bar { +const impl Foo for A +where + A: [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 b2ddf1ba541e6..ccd464251d5c1 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 b4603f4882cc9..c6d71bde6a368 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 @@ LL | const _: () = check::>( note: required for `ConstDropImplWithBounds` to implement `const Drop` --> $DIR/const-drop-fail-2.rs:24:26 | -LL | impl const Drop for ConstDropImplWithBounds { - | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | unsatisfied trait bound introduced here +LL | const impl Drop for ConstDropImplWithBounds { + | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | 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 f5e5793b95c1c..d75d8a32cf9e2 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) {} struct ConstDropImplWithBounds(PhantomData); -impl const Drop for ConstDropImplWithBounds { +const impl Drop for ConstDropImplWithBounds { fn drop(&mut self) { T::a(); } @@ -34,7 +34,7 @@ const _: () = check::>( struct ConstDropImplWithNonConstBounds(PhantomData); -impl const Drop for ConstDropImplWithNonConstBounds { +const impl Drop for ConstDropImplWithNonConstBounds { 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 b4603f4882cc9..c6d71bde6a368 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 @@ LL | const _: () = check::>( note: required for `ConstDropImplWithBounds` to implement `const Drop` --> $DIR/const-drop-fail-2.rs:24:26 | -LL | impl const Drop for ConstDropImplWithBounds { - | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | unsatisfied trait bound introduced here +LL | const impl Drop for ConstDropImplWithBounds { + | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | 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 db4df30800b6e..33289d9ed3386 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 @@ LL | struct ConstImplWithDropGlue(NonTrivialDrop); 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 db4df30800b6e..33289d9ed3386 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 @@ LL | struct ConstImplWithDropGlue(NonTrivialDrop); 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 db4df30800b6e..33289d9ed3386 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 @@ LL | struct ConstImplWithDropGlue(NonTrivialDrop); 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 db4df30800b6e..33289d9ed3386 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 @@ LL | struct ConstImplWithDropGlue(NonTrivialDrop); 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 7e12043ce74a7..d85c942bbe6a7 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 @@ impl Drop for NonTrivialDrop { 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 f7c3ec9be331d..00f7affd1851b 100644 --- a/tests/ui/traits/const-traits/const-drop.rs +++ b/tests/ui/traits/const-traits/const-drop.rs @@ -10,7 +10,7 @@ use std::marker::Destruct; 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 @@ mod t { pub fn foo() {} pub struct ConstDrop; - impl const Drop for ConstDrop { + const impl Drop for ConstDrop { fn drop(&mut self) {} } @@ -52,7 +52,7 @@ mod t { pub const trait SomeTrait { fn foo(); } - impl const SomeTrait for () { + const impl SomeTrait for () { fn foo() {} } // non-const impl @@ -62,7 +62,7 @@ mod t { pub struct ConstDropWithBound(pub core::marker::PhantomData); - impl const Drop for ConstDropWithBound { + const impl Drop for ConstDropWithBound { fn drop(&mut self) { T::foo(); } @@ -70,7 +70,7 @@ mod t { pub struct ConstDropWithNonconstBound(pub core::marker::PhantomData); - impl const Drop for ConstDropWithNonconstBound { + const impl Drop for ConstDropWithNonconstBound { 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 176ae091a41a6..fd3a4de72f42e 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 705ade389436b..0ddf30d8b6377 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 e3fcf540643a9..0c7b0736953e8 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 @@ const _: () = { 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 9b24cfa69a863..bc4643e3e7619 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 const Foo for (T,) { +const impl 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 00fdccc2ac8e4..caadd795a7f27 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; } -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 09ba0969dc994..7afb7f29971f2 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 @@ LL | async fn ft1() {} 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 fcc23fbb65104..0eb34358fa74d 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() -> 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 @@ impl const Main for () { 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 4dfec2f77f1ba..fe882dcf59629 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 78c25ccd6e598..8dc49bd5ac017 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 caa3e192e71f3..93af74d67c5de 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 f8477a3e5ea8e..2ef6e09d5f309 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 f45265c2cc758..cbf3a2287adbb 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 const Foo for (T,) where T: [const] Foo {} +const impl 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 62e8a815f1002..23f17701f586e 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 @@ impl Drop for Moose { struct ConstDropper(ManuallyDrop); -impl const Drop for ConstDropper { +const impl Drop for ConstDropper { 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 4ff2406ed15fd..44144e0e157fb 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 { /* 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 cba207f095309..4bf4499c9922c 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 const Deref for Wrap { +const impl Deref for Wrap { 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 02afdb93d2407..3d205e96f1704 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() -> 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 46f0e92021a14..ac0e1cdd2ad40 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() {} //[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 b5e031094600e..3b019eba2a98b 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 @@ LL | const trait T {} = 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 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 99de21471b20c..0438bf9ad14d9 100644 --- a/tests/ui/traits/const-traits/generic-bound.rs +++ b/tests/ui/traits/const-traits/generic-bound.rs @@ -13,7 +13,7 @@ impl Clone for S { } } -impl const std::ops::Add for S { +const impl std::ops::Add for S { 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 5473cdd040754..66cd9ff10e5b5 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 8a6efda6e9b41..ce4350673972f 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 const FromResidual for T { +const impl 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 1d1805a1d1a9f..6096786031364 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`) - --> $DIR/ice-119717-constant-lifetime.rs:6:6 + --> $DIR/ice-119717-constant-lifetime.rs:6:12 | -LL | impl const FromResidual for T { - | ^ uncovered type parameter +LL | const impl 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 617c28cc34016..ba503be2aaff7 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 const Foo for T where T: [const] Foo {} +const impl 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 082e7a1413584..97fdb4b287e8f 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 const Foo for T where T: [const] Foo {} +LL | const impl 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 e02710eef6286..11ebe4e318406 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 @@ use std::ops::{FromResidual, Residual, Try}; struct TryMe; struct Error; -impl const FromResidual for TryMe {} +const impl FromResidual 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 183203aa8ba51..77b715a8f577f 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 for TryMe {} +LL | const impl FromResidual for TryMe {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_residual` in implementation | = help: implement the missing item: `fn from_residual(_: Error) -> Self { todo!() }` @@ -9,7 +9,7 @@ LL | impl const FromResidual for TryMe {} 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(_: ::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 7becb01027d75..18066d8998762 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 @@ const trait Tr { 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 61f989810bf3f..33df0239a1f01 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 @@ error[E0046]: not all trait items implemented, missing: `req` 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 f6888f5e997b7..7e54f85f8f4d3 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 67701461b3892..aa8d98a388819 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 @@ struct S; 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() where T: [const] B { - + const fn 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 886cfb0005f23..62398ab75d200 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 aebcb625cfd7b..45bc5e9ed17f1 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: ::Output = (); type Assoc = ::Output; fn foo(&mut self, x: ::Output) -> ::Output diff --git a/tests/ui/traits/const-traits/issue-102156.rs b/tests/ui/traits/const-traits/issue-102156.rs index bd9fdff3e4271..506fdaa79c6f3 100644 --- a/tests/ui/traits/const-traits/issue-102156.rs +++ b/tests/ui/traits/const-traits/issue-102156.rs @@ -8,7 +8,7 @@ use core::convert::{From, TryFrom}; use std::pin::Pin; use std::alloc::Allocator; -impl const From> for Pin> +const impl From> for Pin> where A: 'static, {} diff --git a/tests/ui/traits/const-traits/issue-79450.rs b/tests/ui/traits/const-traits/issue-79450.rs index c6234f8616d72..7c217f99853c4 100644 --- a/tests/ui/traits/const-traits/issue-79450.rs +++ b/tests/ui/traits/const-traits/issue-79450.rs @@ -12,7 +12,7 @@ const trait Tr { 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 0663e23f51700..66262ba424828 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 const Super for &A where A: [const] Super {} -impl const Sub for &A where A: [const] Sub {} +const impl Super for &A where A: [const] Super {} +const impl 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 047da4cc938da..17b35f765019c 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); impl Bar for N where T: Bar {} struct C(T); -impl const Bar for C where T: [const] Bar {} +const impl Bar for C where T: [const] Bar {} -impl const Foo for u32 { +const impl Foo for u32 { type Assoc = N //~^ ERROR the trait bound `N: [const] Bar` is not satisfied where T: [const] Bar; } -impl const Foo for i32 { +const impl Foo for i32 { type Assoc = C //~^ 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 3c150c77a6916..ffa9679e86ce6 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 @@ LL | type Assoc = C note: required for `C` to implement `[const] Bar` --> $DIR/item-bound-entailment-fails.rs:14:15 | -LL | impl const Bar for C where T: [const] Bar {} +LL | const impl Bar for C 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 facd222e5aafe..ae00b911cd0a3 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); impl Bar for N where T: Bar {} struct C(T); -impl const Bar for C where T: [const] Bar {} +const impl Bar for C where T: [const] Bar {} impl Foo for u32 { type Assoc = N @@ -21,7 +21,7 @@ impl Foo for u32 { T: Bar; } -impl const Foo for i32 { +const impl Foo for i32 { type Assoc = C 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 f17a88dd90211..7cfd9ae5714ea 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); -impl const Drop for Conditional where T: [const] Foo + [const] Destruct { +const impl Drop for Conditional 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 e75bf3db007f0..3524acaa93f36 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 @@ extern crate minicore; 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 ef08e84c02b81..a3c86a4b152f2 100644 --- a/tests/ui/traits/const-traits/minicore-works.rs +++ b/tests/ui/traits/const-traits/minicore-works.rs @@ -11,7 +11,7 @@ extern crate minicore; 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 c0051c62b6d65..80d70ac0f3809 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 { fn to(self) -> T; } -impl const Convert for A where B: [const] From { +const impl Convert for A +where + B: [const] From, +{ 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 57bb5569c8ebb..e80ad41d55a9d 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 const Foo for T +LL | / const impl 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 0e21d31a426ab..4de3eb881189d 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 const Bar for T {} +const impl Bar for T {} const trait Foo { fn method(&self); } -impl const Foo for T +const impl Foo for T where T: [const] Bar, { @@ -18,7 +18,7 @@ where } // specializing impl: impl 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 57bb5569c8ebb..e80ad41d55a9d 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 const Foo for T +LL | / const impl 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 7c198f41ce422..a6e81f4e10e7f 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 d1a8c35442cf2..602b73993a7d1 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() where T: const Bar {} //~^ ERROR impl has stricter requirements than trait } -impl const NeverConst for u32 { +const impl NeverConst for u32 { type Bar = () 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 c2bac51024f39..a7f33257d7475 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() where T: [const] Bar; @@ -20,7 +20,7 @@ const trait AlwaysConst { impl AlwaysConst for i32 { fn foo() where T: Bar {} } -impl const AlwaysConst for u32 { +const impl AlwaysConst for u32 { fn foo() 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 7d30342d11ca4..e1131a5789921 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 61f0dbe3a9751..96c8ed4937d67 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 97d9c69616cf1..4086d9cf934d4 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 {} //~^ 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 88776f28ef6ef..3beb92d967d29 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 {} | ^^^^^^ 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 46f71b114a372..d7a286be97f2a 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 const Foo for T {} +const impl Foo for T {} //~^ error: const `impl` for trait `Foo` which is not `const` -impl const Foo for T where T: const Specialize {} +const impl 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 8dbbd302c655c..14b4561fa59a0 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 const Foo for T {} +LL | const impl 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 @@ LL | const trait Foo {} error: const `impl` for trait `Foo` which is not `const` --> $DIR/spec-effectvar-ice.rs:13:15 | -LL | impl const Foo for T where T: const Specialize {} +LL | const impl 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 @@ LL | const trait Foo {} error: `const` can only be applied to `const` traits --> $DIR/spec-effectvar-ice.rs:13:34 | -LL | impl const Foo for T where T: const Specialize {} +LL | const impl 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 @@ LL | const trait Specialize {} error: specialization impl does not specialize any associated items --> $DIR/spec-effectvar-ice.rs:13:1 | -LL | impl const Foo for T where T: const Specialize {} +LL | const impl Foo for T where T: const Specialize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: impl is a specialization of this impl --> $DIR/spec-effectvar-ice.rs:10:1 | -LL | impl const Foo for T {} +LL | const impl Foo for T {} | ^^^^^^^^^^^^^^^^^^^^^^^ error: cannot specialize on trait `Specialize` --> $DIR/spec-effectvar-ice.rs:13:34 | -LL | impl const Foo for T where T: const Specialize {} +LL | const impl 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 f771107ec068a..ddd97373c3e8b 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 const Bar for T +const impl Bar for T where T: [const] Foo, { @@ -33,14 +33,14 @@ const trait Baz { fn baz(); } -impl const Baz for T +const impl Baz for T where T: [const] Foo, { default fn baz() {} } -impl const Baz for T //~ ERROR conflicting implementations of trait `Baz` +const impl 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 ff27559c8ec6c..ae44a4368e54c 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 const Bar for T +LL | / const impl Bar for T LL | | where LL | | T: [const] Foo, | |___________________- first implementation here @@ -15,12 +15,12 @@ LL | | T: Specialize, error[E0119]: conflicting implementations of trait `Baz` --> $DIR/const-default-bound-non-const-specialized-bound.rs:43:1 | -LL | / impl const Baz for T +LL | / const impl Baz for T LL | | where LL | | T: [const] Foo, | |___________________- first implementation here ... -LL | / impl const Baz for T +LL | / const impl 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 3be2ff4ee6117..872f5bece70c3 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() -> u32 { T::value() } -impl const Value for T { +const impl Value for T { default fn value() -> u32 { 0 } @@ -22,7 +22,7 @@ impl 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 ad3c177862ae7..197495fa1fbcd 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 const Value for T { +LL | const impl 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 b26e655901692..c742592c4ac2d 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 const Value for T { +const impl 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 ad3c177862ae7..197495fa1fbcd 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 const Value for T { +LL | const impl 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 5b074015d1998..0eadec015d835 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 dbdbf5918556f..a2175decc47f7 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 @@ where default fn bar() {} } -impl const Bar for T +const impl Bar for T where T: [const] Foo, T: Specialize, @@ -36,14 +36,14 @@ const trait Baz { fn baz(); } -impl const Baz for T +const impl Baz for T where T: Foo, { default fn baz() {} } -impl const Baz for T +const impl 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 c68f80dfc7286..61f97a7625028 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 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 0ba4e40ee30a0..60c7bd6c3b52d 100644 --- a/tests/ui/traits/const-traits/specialization/pass.rs +++ b/tests/ui/traits/const-traits/specialization/pass.rs @@ -10,37 +10,37 @@ pub const unsafe trait Sup { #[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 const A for T { +const impl A for T { default fn a() -> u32 { 2 } } -impl const A for T { +const impl A for T { default fn a() -> u32 { 3 } } -impl const A for T { +const impl 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 a0630d1a80629..9122b1a9f48cc 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 const Foo for T { +const impl Foo for T { default fn foo() {} } -impl const Foo for T +const impl Foo for T where T: [const] Specialize, { @@ -29,14 +29,14 @@ const trait Bar { fn bar() {} } -impl const Bar for T +const impl Bar for T where T: [const] Foo, { default fn bar() {} } -impl const Bar for T +const impl 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 78cfbe361d911..bbfe35db56312 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 A for T { } } -impl const A for T { +const impl 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 6e9931e8a740a..1ece1b6901484 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 const A for T { +const impl 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 e55b24f6f4fd1..e67f34f6152d3 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 const A for T { +LL | const impl A for T { | ----------------------------------- first implementation here ... LL | impl A for T { diff --git a/tests/ui/traits/const-traits/staged-api.rs b/tests/ui/traits/const-traits/staged-api.rs index cd74bb45f651b..055a405ac4549 100644 --- a/tests/ui/traits/const-traits/staged-api.rs +++ b/tests/ui/traits/const-traits/staged-api.rs @@ -18,7 +18,7 @@ pub struct Foo; #[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 15328ae3b4553..6f43418b2d53a 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 @@ LL | const trait U {} 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 for more information @@ -26,13 +26,13 @@ LL | impl const U for u16 {} 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 @@ LL | const trait U {} 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 for more information @@ -51,13 +51,13 @@ LL | impl const S for u16 {} 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 4f835fd4191ca..6686efc39c696 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 37ce0586deb4e..bb3bc51c44a2c 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 169627149a300..26538328b3d1c 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: &T) { t.a(); diff --git a/tests/ui/traits/const-traits/syntactical-unstable.rs b/tests/ui/traits/const-traits/syntactical-unstable.rs index 6518dd0ac4bb3..42fd5bd3d8d40 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 e2a65c724438b..3318a7bc61344 100644 --- a/tests/ui/traits/const-traits/syntactical-unstable.stderr +++ b/tests/ui/traits/const-traits/syntactical-unstable.stderr @@ -45,7 +45,7 @@ LL | const fn rpit() -> impl [const] MyTrait { Local } 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 4a2bcbe5dc1c6..a8936b139cb46 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 @@ pub struct T; #[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 @@ impl const Try for T { #[stable(feature = "foo", since = "1.0")] #[rustc_const_unstable(feature = "const_t_try", issue = "none")] -impl const Residual for T { +const impl Residual 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 b8ad7b867a5a3..8f1941d3b1017 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 78cfc72c8bf31..1ff1d50423244 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 @@ LL | const fn fun(); 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 d24a2abb17833..c32db85e885fc 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 @@ impl Bar for NonConst { 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 711b810e3716c..312ff6cff1f08 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 872a70417f485..7440507eba5fc 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 const Foo for T where T: Bar { +const impl Foo for T +where + T: Bar, +{ fn foo() {} } diff --git a/tests/ui/type/pattern_types/lockstep-tails.rs b/tests/ui/type/pattern_types/lockstep-tails.rs new file mode 100644 index 0000000000000..b3d76cb45bd1b --- /dev/null +++ b/tests/ui/type/pattern_types/lockstep-tails.rs @@ -0,0 +1,19 @@ +// Regression test for #472: struct_lockstep_tails_raw missing ty::Pat arm. +// Before the fix, the function would not recurse through Pat types when +// walking struct tails, potentially producing wrong coercion results. + +//@ check-pass + +#![feature(pattern_types, pattern_type_macro)] +#![allow(incomplete_features)] + +use std::pat::pattern_type; + +type NonZeroU32 = pattern_type!(u32 is 1..); + +fn accept_nonzero(_: NonZeroU32) {} + +fn main() { + let x: NonZeroU32 = unsafe { std::mem::transmute(1u32) }; + accept_nonzero(x); +} diff --git a/tests/ui/unpretty/exhaustive.rs b/tests/ui/unpretty/exhaustive.rs index 0bbc87845695f..462429ea8e27e 100644 --- a/tests/ui/unpretty/exhaustive.rs +++ b/tests/ui/unpretty/exhaustive.rs @@ -543,7 +543,7 @@ mod items { impl () {} impl () {} impl Default for () {} - impl const Default for () {} + const impl Default for () {} } /// ItemKind::MacCall diff --git a/tests/ui/unsized-locals/track-caller-vtable-shim.rs b/tests/ui/unsized-locals/track-caller-vtable-shim.rs new file mode 100644 index 0000000000000..575f48249e331 --- /dev/null +++ b/tests/ui/unsized-locals/track-caller-vtable-shim.rs @@ -0,0 +1,21 @@ +//@ run-pass + +#![feature(unsized_fn_params)] +#![allow(internal_features)] + +trait TrackedByValue { + #[track_caller] + fn consume(self, expected_line: u32); +} + +impl TrackedByValue for u8 { + fn consume(self, expected_line: u32) { + assert_eq!(self, 7); + assert_eq!(std::panic::Location::caller().line(), expected_line); + } +} + +fn main() { + let obj = Box::new(7_u8) as Box; + obj.consume(line!()); +} diff --git a/triagebot.toml b/triagebot.toml index c8fb0b24b265e..d19e262dfd099 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -1639,14 +1639,14 @@ dep-bumps = [ "/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"] "/compiler/rustc_mir_build/src/builder" = ["compiler", "mir"] "/compiler/rustc_mir_transform" = ["compiler", "mir", "mir-opt"] -"/compiler/rustc_public_bridge" = ["project-stable-mir"] +"/compiler/rustc_public_bridge" = ["project-rustc-public"] "/compiler/rustc_parse" = ["compiler", "parser"] "/compiler/rustc_parse/src/lexer" = ["compiler", "lexer"] "/compiler/rustc_query_impl" = ["compiler", "query-system"] "/compiler/rustc_trait_selection" = ["compiler", "types"] "/compiler/rustc_traits" = ["compiler", "types"] "/compiler/rustc_type_ir" = ["compiler", "types"] -"/compiler/rustc_public" = ["project-stable-mir"] +"/compiler/rustc_public" = ["project-rustc-public"] "/library/alloc" = ["libs"] "/library/alloctests" = ["libs"] "/library/core" = ["libs"]