diff --git a/compiler/rustc_lint/src/diagnostics.rs b/compiler/rustc_lint/src/diagnostics.rs index 3565df367aa89..a3663ca96af6c 100644 --- a/compiler/rustc_lint/src/diagnostics.rs +++ b/compiler/rustc_lint/src/diagnostics.rs @@ -1101,7 +1101,7 @@ pub(crate) struct ConstItemInteriorMutationsDiag<'tcx> { pub method_name: Ident, pub const_name: Ident, pub const_ty: Ty<'tcx>, - #[label("`{$const_name}` is a interior mutable `const` item of type `{$const_ty}`")] + #[label("`{$const_name}` is an interior mutable `const` item of type `{$const_ty}`")] pub receiver_span: Span, #[subdiagnostic] pub sugg_static: Option, diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 6fc40b4c25c2e..b8661462d20e9 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -722,6 +722,99 @@ impl Duration { self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos.as_inner() as u128 } + /// Returns the number of _whole_ weeks contained by this `Duration`. + /// + /// The returned value does not include any fractional component + /// corresponding to units less than a week of the duration. + /// + /// For this method, one week is defined as 7 days, or 604,800 seconds. + /// + /// # Examples + /// + /// ``` + /// #![feature(duration_extractors)] + /// #![feature(duration_constructors)] + /// use std::time::Duration; + /// + /// let duration = Duration::from_days(40); + /// assert_eq!(duration.as_weeks(), 5); + /// ``` + #[unstable(feature = "duration_extractors", issue = "165786")] + #[must_use] + #[inline] + pub const fn as_weeks(&self) -> u64 { + self.as_secs() / (SECS_PER_MINUTE * MINS_PER_HOUR * HOURS_PER_DAY * DAYS_PER_WEEK) + } + + /// Returns the number of _whole_ days contained by this `Duration`. + /// + /// The returned value does not include any fractional component + /// corresponding to units less than a day of the duration. + /// + /// For this method, one day is defined as 24 hours, or 86,400 seconds. + /// + /// # Examples + /// + /// ``` + /// #![feature(duration_extractors)] + /// use std::time::Duration; + /// + /// let duration = Duration::from_hours(130); + /// assert_eq!(duration.as_days(), 5); + /// ``` + #[unstable(feature = "duration_extractors", issue = "165786")] + #[must_use] + #[inline] + pub const fn as_days(&self) -> u64 { + self.as_secs() / (SECS_PER_MINUTE * MINS_PER_HOUR * HOURS_PER_DAY) + } + + /// Returns the number of _whole_ hours contained by this `Duration`. + /// + /// The returned value does not include any fractional component + /// corresponding to units less than an hour of the duration. + /// + /// For this method, one hour is defined as 60 minutes, or 3,600 seconds. + /// + /// # Examples + /// + /// ``` + /// #![feature(duration_extractors_lite)] + /// use std::time::Duration; + /// + /// let duration = Duration::from_mins(320); + /// assert_eq!(duration.as_hours(), 5); + /// ``` + #[unstable(feature = "duration_extractors_lite", issue = "165784")] + #[must_use] + #[inline] + pub const fn as_hours(&self) -> u64 { + self.as_secs() / (SECS_PER_MINUTE * MINS_PER_HOUR) + } + + /// Returns the number of _whole_ minutes contained by this `Duration`. + /// + /// The returned value does not include any fractional component + /// corresponding to units less than a minute of the duration. + /// + /// For this method, one minute is defined as 60 seconds. + /// + /// # Examples + /// + /// ``` + /// #![feature(duration_extractors_lite)] + /// use std::time::Duration; + /// + /// let duration = Duration::from_secs(320); + /// assert_eq!(duration.as_mins(), 5); + /// ``` + #[unstable(feature = "duration_extractors_lite", issue = "165784")] + #[must_use] + #[inline] + pub const fn as_mins(&self) -> u64 { + self.as_secs() / SECS_PER_MINUTE + } + /// Computes the absolute difference between `self` and `other`. /// /// # Examples diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index f3ef2e79b5927..690d8569ec70c 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -56,6 +56,8 @@ #![feature(duration_constants)] #![feature(duration_constructors)] #![feature(duration_display_seconds)] +#![feature(duration_extractors)] +#![feature(duration_extractors_lite)] #![feature(exact_div)] #![feature(exact_size_is_empty)] #![feature(extend_one)] diff --git a/library/coretests/tests/time.rs b/library/coretests/tests/time.rs index c5ad53346f8ae..1fa905e50ca3e 100644 --- a/library/coretests/tests/time.rs +++ b/library/coretests/tests/time.rs @@ -641,6 +641,30 @@ fn duration_const() { const FROM_NANOS_U128: Duration = Duration::from_nanos_u128(NANOS); assert_eq!(FROM_NANOS_U128, Duration::SECOND); + const WEEKS: u64 = Duration::WEEK.as_weeks(); + assert_eq!(WEEKS, 1); + + const FROM_WEEKS: Duration = Duration::from_weeks(1); + assert_eq!(FROM_WEEKS, 604_800 * Duration::SECOND); + + const DAYS: u64 = Duration::DAY.as_days(); + assert_eq!(DAYS, 1); + + const FROM_DAYS: Duration = Duration::from_days(1); + assert_eq!(FROM_DAYS, 86400 * Duration::SECOND); + + const HOURS: u64 = Duration::HOUR.as_hours(); + assert_eq!(HOURS, 1); + + const FROM_HOURS: Duration = Duration::from_hours(1); + assert_eq!(FROM_HOURS, 3600 * Duration::SECOND); + + const MINUTES: u64 = Duration::MINUTE.as_mins(); + assert_eq!(MINUTES, 1); + + const FROM_MINUTES: Duration = Duration::from_mins(1); + assert_eq!(FROM_MINUTES, 60 * Duration::SECOND); + const MAX: Duration = Duration::new(u64::MAX, 999_999_999); const CHECKED_ADD: Option = MAX.checked_add(Duration::SECOND); diff --git a/library/std/src/sys/process/unix/unix.rs b/library/std/src/sys/process/unix/unix.rs index d1262ba3e2e6e..40c907d864ca3 100644 --- a/library/std/src/sys/process/unix/unix.rs +++ b/library/std/src/sys/process/unix/unix.rs @@ -1020,7 +1020,10 @@ impl Process { pub(crate) fn send_process_group_signal(&self, signal: i32) -> io::Result<()> { // See note in `send_signal` regarding recycled PIDs. if self.status.is_some() { - return Ok(()); + return Err(io::Error::new( + io::ErrorKind::Other, + "process group leader has already been awaited", + )); } #[cfg(target_os = "linux")] if let Some(pid_fd) = self.pidfd.as_ref() { diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 5841fc7196773..27249a76bd952 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1071,12 +1071,17 @@ pub struct IntrinsicTest { host: TargetSelection, } +impl IntrinsicTest { + const ALIAS: &'static str = "stdarch-intrinsic-test"; +} + impl CommandLineStep for IntrinsicTest { type Output = (); const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.alias("intrinsic-test") + // Not using a path since we don't want this to be part of `./x test library`. + run.alias(Self::ALIAS) } fn is_default_step(_builder: &Builder<'_>) -> bool { @@ -1087,12 +1092,12 @@ impl CommandLineStep for IntrinsicTest { let target = run.target; let builder = run.builder; - let is_explicit = - builder.config.paths.iter().any(|p| p.to_string_lossy() == "intrinsic-test"); + let is_explicit = builder.config.paths.iter().any(|p| p.to_string_lossy() == Self::ALIAS); if target.contains("x86_64-unknown-linux") && builder.config.sde.is_none() && is_explicit { panic!( - "SDE is required to run intrinsic-test. Please configure `build.sde` in config.toml." + "SDE is required to run {}. Please configure `build.sde` in config.toml.", + Self::ALIAS ); } diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap index b01ccfcba50b5..6ce5a96dfe5b8 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -228,4 +228,4 @@ expression: test - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap index 0a4ccdbd86e3d..f7c447b2d6ae4 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -225,4 +225,4 @@ expression: test --skip=coverage - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap index 89f26ad80b322..e4e77171cfbe6 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap @@ -228,4 +228,4 @@ expression: test --skip=coverage-map - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap index b0b5ba9c3e116..30b0495b0499b 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap @@ -228,4 +228,4 @@ expression: test --skip=coverage-run - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap index 95472f161268e..29c900f1bc258 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -168,4 +168,4 @@ expression: test --skip=tests - Set({compiler-builtins}) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap index 8c9faca01e50c..598e41393f740 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap @@ -225,4 +225,4 @@ expression: test --skip=tests/coverage - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap index 9c276798d948e..25899cf1d214f 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap @@ -148,4 +148,4 @@ expression: test --skip=tests --skip=library --skip=tidyselftest - Set({compiler-builtins}) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/doc/rustc-dev-guide/josh-sync.toml b/src/doc/rustc-dev-guide/josh-sync.toml index 7882051e23390..b3f154de71af7 100644 --- a/src/doc/rustc-dev-guide/josh-sync.toml +++ b/src/doc/rustc-dev-guide/josh-sync.toml @@ -1,3 +1,5 @@ org = "rust-lang" repo = "rustc-dev-guide" path = "src/doc/rustc-dev-guide" +push-pr.suffix = "r? @ghost" +pull-pr.suffix = "r? @ghost" diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version index 7fe96b0a30f39..1d6089214b36e 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -c55b900aa3e4d23bb5628a00718304b31077d619 +5debe6a1244452beced762385f88a51857a915fc diff --git a/src/doc/rustc-dev-guide/src/appendix/code-index.md b/src/doc/rustc-dev-guide/src/appendix/code-index.md index 351be5e39f921..fd822ab641486 100644 --- a/src/doc/rustc-dev-guide/src/appendix/code-index.md +++ b/src/doc/rustc-dev-guide/src/appendix/code-index.md @@ -11,7 +11,7 @@ Item | Kind | Short description | Chapter | `ast::Crate` | struct | A syntax-level representation of a parsed crate | [The parser] | [compiler/rustc_ast/src/ast.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/ast/struct.Crate.html) `hir::Crate` | struct | A more abstract, compiler-friendly form of a crate's AST | [The Hir] | [compiler/rustc_middle/src/hir/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/struct.Crate.html) `DefId` | struct | One of four types of HIR node identifiers | [Identifiers in the HIR] | [compiler/rustc_hir/src/def_id.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.DefId.html) -`Diag` | struct | A struct for a compiler diagnostic, such as an error or lint | [Emitting Diagnostics] | [compiler/rustc_errors/src/diagnostic.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Diag.html) +`Diag` | struct | A struct for a compiler diagnostic, such as an error or lint | [Emitting Diagnostics] | [compiler/rustc_errors/src/diagnostic.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/diagnostic/struct.Diag.html) `DocContext` | struct | A state container used by rustdoc when crawling through a crate to gather its documentation | [Rustdoc] | [src/librustdoc/core.rs](https://github.com/rust-lang/rust/blob/HEAD/src/librustdoc/core.rs) `HirId` | struct | One of four types of HIR node identifiers | [Identifiers in the HIR] | [compiler/rustc_hir_id/src/lib.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.HirId.html) `Lexer` | struct | This is the lexer used during parsing. It consumes characters from the raw source code being compiled and produces a series of tokens for use by the rest of the parser | [The parser] | [compiler/rustc_parse/src/lexer/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/lexer/struct.Lexer.html) @@ -27,7 +27,7 @@ Item | Kind | Short description | Chapter | `TraitDef` | struct | This struct contains a trait's definition with type information | [The `ty` modules] | [compiler/rustc_middle/src/ty/trait_def.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/trait_def/struct.TraitDef.html) `TraitRef` | struct | The combination of a trait and its input types (e.g. `P0: Trait`) | [Trait Solving: Goals and Clauses] | [compiler/rustc_middle/src/ty/sty.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/type.TraitRef.html) `Ty<'tcx>` | struct | This is the internal representation of a type used for type checking | [Type checking] | [compiler/rustc_middle/src/ty/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.html) -`TyCtxt<'tcx>` | struct | The "typing context". This is the central data structure in the compiler. It is the context that you use to perform all manner of queries | [The `ty` modules] | [compiler/rustc_middle/src/ty/context.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html) +`TyCtxt<'tcx>` | struct | The "typing context". This is the central data structure in the compiler. It is the context that you use to perform all manner of queries | [The `ty` modules] | [compiler/rustc_middle/src/ty/context.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html) [The HIR]: ../hir.md [Identifiers in the HIR]: ../hir.md#hir-id diff --git a/src/doc/rustc-dev-guide/src/backend/implicit-caller-location.md b/src/doc/rustc-dev-guide/src/backend/implicit-caller-location.md index 909c00ea40cff..bfb2973bdd743 100644 --- a/src/doc/rustc-dev-guide/src/backend/implicit-caller-location.md +++ b/src/doc/rustc-dev-guide/src/backend/implicit-caller-location.md @@ -284,7 +284,7 @@ to the author and reviewers. [requires-location]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/instance/enum.InstanceKind.html#method.requires_caller_location [alloc-location]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_const_eval/interpret/struct.InterpCx.html#method.alloc_caller_location [fcx-location]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/mir/struct.FunctionCx.html#structfield.caller_location -[const-location-query]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.const_caller_location +[const-location-query]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.const_caller_location [location-memory-kind]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_const_eval/interpret/enum.MemoryKind.html#variant.CallerLocation [const-frame]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_const_eval/interpret/struct.Frame.html [const-stack]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_const_eval/interpret/struct.InterpCx.html#structfield.stack diff --git a/src/doc/rustc-dev-guide/src/const-generics.md b/src/doc/rustc-dev-guide/src/const-generics.md index 2738782db9e48..579b12f55ac62 100644 --- a/src/doc/rustc-dev-guide/src/const-generics.md +++ b/src/doc/rustc-dev-guide/src/const-generics.md @@ -248,9 +248,9 @@ Looking at the above example, this corresponds to `[u8; ANON]` being a well form [`ConstKind::Value`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/consts/type.ConstKind.html#variant.Value [const_arg_has_type]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/type.ClauseKind.html#variant.ConstArgHasType [`ParamEnv`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.ParamEnv.html -[`generics_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#impl-TyCtxt%3C'tcx%3E/method.generics_of -[`type_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.type_of +[`generics_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.generics_of +[`type_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.type_of [`DefKind::AnonConst`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def/enum.DefKind.html#variant.AnonConst [`hir::Node::AnonConst`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.Node.html#variant.AnonConst# [cec_fcw]: https://github.com/rust-lang/rust/issues/76200 -[`const_eval_resolve_for_typeck`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.const_eval_resolve_for_typeck +[`const_eval_resolve_for_typeck`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.const_eval_resolve_for_typeck diff --git a/src/doc/rustc-dev-guide/src/diagnostics.md b/src/doc/rustc-dev-guide/src/diagnostics.md index bdb3f8c9f22ae..23d40dff79341 100644 --- a/src/doc/rustc-dev-guide/src/diagnostics.md +++ b/src/doc/rustc-dev-guide/src/diagnostics.md @@ -352,8 +352,8 @@ before emitting it by calling the [`emit`] method. [spanerr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.DiagCtxt.html#method.span_err [strspanerr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.DiagCtxt.html#method.struct_span_err -[`emit`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Diag.html#method.emit -[cancel]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Diag.html#method.cancel +[`emit`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/diagnostic/struct.Diag.html#method.emit +[cancel]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/diagnostic/struct.Diag.html#method.cancel ```rust,ignore // Get a `Diag`. This does _not_ emit an error yet. @@ -412,7 +412,7 @@ some heuristics for verbosity are met) suggestion is obvious from the text, but we still want to let tools to apply them) - not shown (used for _very_ obvious cases, but we still want to allow tools to apply them) -[span_suggestion]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Diag.html#method.span_suggestion +[span_suggestion]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/diagnostic/struct.Diag.html#method.span_suggestion For example, to make our `qux` suggestion machine-applicable, we would do: @@ -860,7 +860,7 @@ The JSON emitter defines [its own `Diagnostic` struct](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/json/struct.Diagnostic.html) (and sub-structs) for the JSON serialization. Don't confuse this with -[`errors::Diag`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Diag.html)! +[`errors::Diag`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/diagnostic/struct.Diag.html)! ## Diagnostic attributes @@ -879,4 +879,4 @@ If possible, consider improving or implementing such an attribute rather than ad reporting code. [`rustc_on_unimplemented`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_ir/attribute.rustc_on_unimplemented.html -[diag]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Diag.html +[diag]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/diagnostic/struct.Diag.html diff --git a/src/doc/rustc-dev-guide/src/effects.md b/src/doc/rustc-dev-guide/src/effects.md index f6a11b435ad32..0a06ba3202c3f 100644 --- a/src/doc/rustc-dev-guide/src/effects.md +++ b/src/doc/rustc-dev-guide/src/effects.md @@ -19,8 +19,8 @@ therefore they will result in `HostEffect(T: Tr, const)` being added to `clauses and not `const_conditions`. [`HostEffectPredicate`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_type_ir/predicate/struct.HostEffectPredicate.html -[`clauses_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.clauses_of -[`const_conditions`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.const_conditions +[`clauses_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.clauses_of +[`const_conditions`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.const_conditions ## The `const_conditions` query @@ -137,7 +137,7 @@ These bounds are checked in [`compare_impl_item::check_type_bounds`] for HIR typ [`evaluate_host_effect_from_item_bounds`] in the old solver and [`consider_additional_alias_assumptions`] in the new solver. -[`explicit_item_bounds`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.explicit_item_bounds +[`explicit_item_bounds`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.explicit_item_bounds [`compare_impl_item::check_type_bounds`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/check/compare_impl_item/fn.check_type_bounds.html [`evaluate_host_effect_from_item_bounds`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/effects/fn.evaluate_host_effect_from_item_bounds.html [`consider_additional_alias_assumptions`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_next_trait_solver/solve/assembly/trait.GoalKind.html#tymethod.consider_additional_alias_assumptions diff --git a/src/doc/rustc-dev-guide/src/external-repos.md b/src/doc/rustc-dev-guide/src/external-repos.md index 28a7cc667f066..4bef36c799ae9 100644 --- a/src/doc/rustc-dev-guide/src/external-repos.md +++ b/src/doc/rustc-dev-guide/src/external-repos.md @@ -17,6 +17,7 @@ As a general rule: The following external projects are managed using a Josh `subtree`: * [clippy](https://github.com/rust-lang/rust-clippy) +* [hashbrown](https://github.com/rust-lang/hashbrown) * [miri](https://github.com/rust-lang/miri) * [portable-simd](https://github.com/rust-lang/portable-simd) * [rustfmt](https://github.com/rust-lang/rustfmt) diff --git a/src/doc/rustc-dev-guide/src/git.md b/src/doc/rustc-dev-guide/src/git.md index 5974e0e92cad6..3e70c05d1c07e 100644 --- a/src/doc/rustc-dev-guide/src/git.md +++ b/src/doc/rustc-dev-guide/src/git.md @@ -687,4 +687,4 @@ easily figure out *why* a commit is ignored. [Git submodules]: https://git-scm.com/book/en/v2/Git-Tools-Submodules [`rust-lang/llvm-project`]: https://github.com/rust-lang/llvm-project -[llvm-update]: https://github.com/rust-lang/rust/pull/99464/files +[llvm-update]: https://github.com/rust-lang/rust/pull/99464/changes diff --git a/src/doc/rustc-dev-guide/src/hir.md b/src/doc/rustc-dev-guide/src/hir.md index c2e227dc936ce..ff33b0d908605 100644 --- a/src/doc/rustc-dev-guide/src/hir.md +++ b/src/doc/rustc-dev-guide/src/hir.md @@ -1,14 +1,12 @@ # The HIR -The HIR – "High-Level Intermediate Representation" – is the primary IR used -in most of rustc. +The HIR – "High-Level Intermediate Representation" – is the primary IR used in most of rustc. It is a compiler-friendly representation of the abstract -syntax tree (AST) that is generated after parsing, macro expansion, and name -resolution (see [Lowering](./hir/lowering.md) for how the HIR is created). -Many parts of HIR resemble Rust surface syntax quite closely, with -the exception that some of Rust's expression forms have been desugared away. -For example, `for` loops are converted into a `loop` and do not appear in -the HIR. +syntax tree (AST) that is generated after parsing, macro expansion, +and name resolution (see [Lowering](./hir/lowering.md) for how the HIR is created). +Many parts of HIR resemble Rust surface syntax quite closely, +with the exception that some of Rust's expression forms have been desugared away. +For example, `for` loops are converted into a `loop` and do not appear in the HIR. This makes HIR more amenable to analysis than a normal AST. This chapter covers the main concepts of the HIR. @@ -30,19 +28,17 @@ cargo rustc -- -Z unpretty=hir ## Out-of-band storage and the `Crate` type -The top-level data-structure in the HIR is the [`Crate`], which stores -the contents of the crate currently being compiled (we only ever +The top-level data-structure in the HIR is the [`Crate`], +which stores the contents of the crate currently being compiled (we only ever construct HIR for the current crate). -Whereas in the AST the crate -data structure basically just contains the root module, the HIR -`Crate` structure contains a number of maps and other things that +Whereas in the AST the crate data structure basically just contains the root module, +the HIR `Crate` structure contains a number of maps and other things that serve to organize the content of the crate for easier access. [`Crate`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/struct.Crate.html For example, the contents of individual items (e.g. modules, -functions, traits, impls, etc) in the HIR are not immediately -accessible in the parents. +functions, traits, impls, etc) in the HIR are not immediately accessible in the parents. So, for example, if there is a module item `foo` containing a function `bar()`: ```rust @@ -53,8 +49,7 @@ mod foo { then in the HIR the representation of module `foo` (the [`Mod`] struct) would only have the **`ItemId`** `I` of `bar()`. -To get the details of the function `bar()`, we would lookup `I` in the -`items` map. +To get the details of the function `bar()`, we would lookup `I` in the `items` map. [`Mod`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Mod.html @@ -69,11 +64,10 @@ integration with incremental compilation. This way, if you gain access to an [`&rustc_hir::Item`] (e.g. for the mod `foo`), you do not immediately gain access to the contents of the function `bar()`. -Instead, you only -gain access to the **id** for `bar()`, and you must invoke some -function to lookup the contents of `bar()` given its id; this gives -the compiler a chance to observe that you accessed the data for -`bar()`, and then record the dependency. +Instead, you only gain access to the **id** for `bar()`, +and you must invoke some function to lookup the contents of `bar()` given its id; this gives +the compiler a chance to observe that you accessed the data for `bar()`, +and then record the dependency. [`&rustc_hir::Item`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Item.html @@ -83,31 +77,29 @@ the compiler a chance to observe that you accessed the data for The HIR uses a bunch of different identifiers that coexist and serve different purposes. -- A [`DefId`], as the name suggests, identifies a particular definition, or top-level - item, in a given crate. +- A [`DefId`], as the name suggests, identifies a particular definition, or top-level item, + in a given crate. It is composed of two parts: a [`CrateNum`] which identifies - the crate the definition comes from, and a [`DefIndex`] which identifies the definition - within the crate. - Unlike [`HirId`]s, there isn't a [`DefId`] for every expression, which - makes them more stable across compilations. + the crate the definition comes from, + and a [`DefIndex`] which identifies the definition within the crate. + Unlike [`HirId`]s, there isn't a [`DefId`] for every expression, + which makes them more stable across compilations. - A [`LocalDefId`] is basically a [`DefId`] that is known to come from the current crate. This allows us to drop the [`CrateNum`] part, and use the type system to ensure that only local definitions are passed to functions that expect a local definition. - A [`HirId`] uniquely identifies a node in the HIR of the current crate. - It is composed of two parts: - an `owner` and a `local_id` that is unique within the `owner`. + It is composed of two parts: an `owner` and a `local_id` that is unique within the `owner`. This combination makes for more stable values which are helpful for incremental compilation. Unlike [`DefId`]s, a [`HirId`] can refer to [fine-grained entities][Node] like expressions, but stays local to the current crate. - A [`BodyId`] identifies a HIR [`Body`] in the current crate. It is currently only a wrapper around a [`HirId`]. - For more info about HIR bodies, please refer to the - [HIR chapter][hir-bodies]. + For more info about HIR bodies, please refer to the [HIR chapter][hir-bodies]. -These identifiers can be converted into one another through the `TyCtxt`. +These identifiers can be converted into one another through the [`TyCtxt`]. [`DefId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.DefId.html [`LocalDefId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.LocalDefId.html @@ -121,51 +113,50 @@ These identifiers can be converted into one another through the `TyCtxt`. ## HIR Operations -Most of the time when you are working with the HIR, you will do so via `TyCtxt`. -It contains a number of methods, defined in the `hir::map` module and -mostly prefixed with `hir_`, to convert between IDs of various kinds and to -lookup data associated with a HIR node. +Most of the time when you are working with the HIR, you will do so via [`TyCtxt`]. +It contains a number of methods, defined in the `hir::map` module and mostly prefixed with `hir_`, +to convert between IDs of various kinds and to lookup data associated with a HIR node. -[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html +[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html -For example, if you have a [`LocalDefId`], and you would like to convert it -to a [`HirId`], you can use [`tcx.local_def_id_to_hir_id(def_id)`][local_def_id_to_hir_id]. +For example, if you have a [`LocalDefId`], and you would like to convert it to a [`HirId`], +you can use [`tcx.local_def_id_to_hir_id(def_id)`][local_def_id_to_hir_id]. You need a `LocalDefId`, rather than a `DefId`, since only local items have HIR nodes. -[local_def_id_to_hir_id]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.local_def_id_to_hir_id +[local_def_id_to_hir_id]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.local_def_id_to_hir_id -Similarly, you can use [`tcx.hir_node(n)`][hir_node] to lookup the node for a -[`HirId`]. -This returns a `Option>`, where [`Node`] is an enum -defined in the map. -By matching on this, you can find out what sort of -node the `HirId` referred to and also get a pointer to the data -itself. Often, you know what sort of node `n` is – e.g. if you know -that `n` must be some HIR expression, you can do -[`tcx.hir_expect_expr(n)`][expect_expr], which will extract and return the -[`&hir::Expr`][Expr], panicking if `n` is not in fact an expression. +Similarly, you can use [`tcx.hir_node(n)`][hir_node] to lookup the node for a [`HirId`]. +This returns a `Option>`, where [`Node`] is an enum defined in the map. +By matching on this, +you can find out what sort of node the `HirId` referred to and also get a pointer to the data +itself. +Often, you know what sort of node `n` is – e.g. if you know +that `n` must be some HIR expression, you can do [`tcx.hir_expect_expr(n)`][expect_expr], +which will extract and return the [`&hir::Expr`][Expr], +panicking if `n` is not in fact an expression. -[hir_node]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.hir_node +[hir_node]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.hir_node [`Node`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.Node.html -[expect_expr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.expect_expr +[expect_expr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.expect_expr [Expr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Expr.html -Finally, you can find the parents of nodes, via -calls like [`tcx.parent_hir_node(n)`][parent_hir_node]. +Finally, you can find the parents of nodes, +via calls like [`tcx.parent_hir_node(n)`][parent_hir_node]. -[parent_hir_node]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.parent_hir_node +[parent_hir_node]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.parent_hir_node ## HIR Bodies -A [`rustc_hir::Body`] represents some kind of executable code, such as the body -of a function/closure or the definition of a constant. -Bodies are associated with an **owner**, which is typically some kind of item -(e.g. an `fn()` or `const`), but could also be a closure expression -(e.g. `|x, y| x + y`). You can use the `TyCtxt` to find the body +A [`rustc_hir::Body`] represents some kind of executable code, +such as the body of a function/closure, or the definition of a constant. +Bodies are associated with an **owner**, +which is typically some kind of item (e.g. an `fn()` or `const`), +but could also be a closure expression (e.g. `|x, y| x + y`). +You can use the [`TyCtxt`] to find the body associated with a given def-id ([`hir_maybe_body_owned_by`]) or to find the owner of a body ([`hir_body_owner_def_id`]). [`rustc_hir::Body`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Body.html -[`hir_maybe_body_owned_by`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.hir_maybe_body_owned_by -[`hir_body_owner_def_id`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.hir_body_owner_def_id +[`hir_maybe_body_owned_by`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.hir_maybe_body_owned_by +[`hir_body_owner_def_id`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.hir_body_owner_def_id diff --git a/src/doc/rustc-dev-guide/src/hir/lowering.md b/src/doc/rustc-dev-guide/src/hir/lowering.md index d555e0e7b3a85..fdbe782f70163 100644 --- a/src/doc/rustc-dev-guide/src/hir/lowering.md +++ b/src/doc/rustc-dev-guide/src/hir/lowering.md @@ -30,39 +30,41 @@ split across multiple files in the [`rustc_ast_lowering`] crate such as `item.rs `expr.rs`, `pat.rs`, `path.rs`, and others, but they all share the same [`LoweringContext`] state and ID‑lowering machinery. -Each owner is lowered in its own [`with_hir_id_owner`] scope. -This is why the -`HirId` invariants below matter: `lower_node_id` maps AST `NodeId`s into the -current owner, while `next_id` creates fresh HIR-only nodes introduced during -desugaring. +Each owner is lowered in its own [`LoweringContext`] context. +Each Lowering owner gets a new lowering context inside `lower_to_hir`, +specifically `with_lctx` helper function. +This is why the `HirId` invariants below matter: `lower_node_id` allocates a new `HirId` for +the given `NodeId`, while `next_id` creates fresh `HirId` introduced during desugaring. Lowering needs to uphold several invariants in order to not trigger the sanity checks in [`compiler/rustc_passes/src/hir_id_validator.rs`][hir_id_validator]: -1. A `HirId` must be used if created. - So, if you use the `lower_node_id`, - you *must* use the resulting `NodeId` or `HirId` (either is fine, since - any `NodeId`s in the `HIR` are checked for existing `HirId`s). +1. A `HirId` must be used if created, + therefore the `ItemLocalId`s set of local IDs associated with the owner’s nodes + form a dense range of integers starting at zero as IDs are allocated + consecutively starting at one, zero is reserved for the owner. + 2. Lowering a `HirId` must be done in the scope of the *owning* item. - This means you need to use `with_hir_id_owner` if you are creating parts - of an item other than the one being currently lowered. - This happens, for example, during the lowering of existential `impl Trait`. -3. A `NodeId` that will be placed into a HIR structure must be lowered, - even if its `HirId` is unused. - Calling `let _ = self.lower_node_id(node_id);` is perfectly legitimate. -4. If you are creating new nodes that didn't exist in the `AST`, you *must* - create new ids for them. - This is done by calling the `next_id` method, - which produces both a new `NodeId` as well as automatically lowering it - for you so you also get the `HirId`. + And this is done by creating a new `LoweringContext` for each owner. + +3. When lowering an AST node, + the compiler can create HIR nodes that don't exist in the AST tree during desugaring + such as the loop instead of the for loop. + These HIR nodes must have a `HirId` and this is done by `next_id`. + +4. There's always at least one entry for the owning item itself. + The owner node has local ID zero, so the owner’s collection is nonempty. + +5. When traversing an item with a nested item, + the owner part of the nested item's definition parent `HirId` must match + the enclosing HIR owner currently being traversed. [`rustc_ast_lowering`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast_lowering/index.html [`lower_to_hir`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast_lowering/fn.lower_to_hir.html -[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html +[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html [`hir::Crate`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/struct.Crate.html [`ItemLowerer::lower_node`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast_lowering/item/struct.ItemLowerer.html [`LoweringContext`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast_lowering/struct.LoweringContext.html -[`with_hir_id_owner`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast_lowering/struct.LoweringContext.html#method.with_hir_id_owner [hir_id_validator]: https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_passes/src/hir_id_validator.rs If you are creating new `DefId`s, since each `DefId` needs to have a diff --git a/src/doc/rustc-dev-guide/src/implementing-new-features.md b/src/doc/rustc-dev-guide/src/implementing-new-features.md index 947dd9d36d0e5..e892d15466719 100644 --- a/src/doc/rustc-dev-guide/src/implementing-new-features.md +++ b/src/doc/rustc-dev-guide/src/implementing-new-features.md @@ -222,7 +222,7 @@ The below steps needs to be followed in order to implement a new unstable featur If the feature gate is not set, you should either maintain the pre-feature behavior or raise an error, depending on what makes sense. - Errors should generally use [`rustc_session::errors::feature_err`]. + Errors should generally use [`rustc_session::diagnostics::feature_err`]. For an example of adding an error, see [#81015]. For features introducing new syntax, pre-expansion gating should be used instead. @@ -252,7 +252,7 @@ The below steps needs to be followed in order to implement a new unstable featur [`GatedSpans`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/parse/struct.GatedSpans.html [#81015]: https://github.com/rust-lang/rust/pull/81015 -[`rustc_session::errors::feature_err`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/errors/fn.feature_err.html +[`rustc_session::diagnostics::feature_err`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/diagnostics/fn.feature_err.html [`rustc_ast_passes::feature_gate::check_crate`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast_passes/feature_gate/fn.check_crate.html [value the stability of Rust]: https://github.com/rust-lang/rfcs/blob/master/text/1122-language-semver.md [stability in code]: #stability-in-code diff --git a/src/doc/rustc-dev-guide/src/lang-items.md b/src/doc/rustc-dev-guide/src/lang-items.md index e3859f46a3651..737bbe2897bd2 100644 --- a/src/doc/rustc-dev-guide/src/lang-items.md +++ b/src/doc/rustc-dev-guide/src/lang-items.md @@ -55,7 +55,7 @@ You can either: - Proceed with limited functionality, by just omitting whatever you were going to do with the `DefId`. -[`tcx.lang_items()`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.lang_items +[`tcx.lang_items()`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.lang_items ## List of all language items diff --git a/src/doc/rustc-dev-guide/src/memory.md b/src/doc/rustc-dev-guide/src/memory.md index 14601e47b81c9..dc961afb73bba 100644 --- a/src/doc/rustc-dev-guide/src/memory.md +++ b/src/doc/rustc-dev-guide/src/memory.md @@ -85,7 +85,7 @@ As you can see, the `TyCtxt` type takes a lifetime parameter. When you see a reference with a lifetime like `'tcx`, you know that it refers to arena-allocated data (or data that lives as long as the arenas, anyhow). -[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html +[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html ### A Note On Lifetimes diff --git a/src/doc/rustc-dev-guide/src/normalization.md b/src/doc/rustc-dev-guide/src/normalization.md index cefd92999d9e5..f0acf9afd047c 100644 --- a/src/doc/rustc-dev-guide/src/normalization.md +++ b/src/doc/rustc-dev-guide/src/normalization.md @@ -286,7 +286,7 @@ Lints and codegen make heavy use of this entry point as they typically are worki (or at least, are not responsible for erroring on). [`infcx.query_normalize`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/infer/at/struct.At.html#method.query_normalize -[`normalize_erasing_regions`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.normalize_erasing_regions +[`normalize_erasing_regions`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.normalize_erasing_regions [`normalize`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/infer/at/struct.At.html#method.normalize [`deeply_normalize`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/normalize/trait.NormalizeExt.html#tymethoz [structurally_normalize]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/trait.StructurallyNormalizeExt.html#tymethod.structurally_normalize_ty diff --git a/src/doc/rustc-dev-guide/src/overview.md b/src/doc/rustc-dev-guide/src/overview.md index 374a3c5bfa406..006ed2d3c97aa 100644 --- a/src/doc/rustc-dev-guide/src/overview.md +++ b/src/doc/rustc-dev-guide/src/overview.md @@ -138,7 +138,7 @@ The different libraries/binaries are then linked together to produce the final b [`bump`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html#method.bump [`check`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html#method.check [`Crate`]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_ast/ast/struct.Crate.html -[`diag`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Diag.html +[`diag`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/diagnostic/struct.Diag.html [`eat`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html#method.eat [`expect`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html#method.expect [`Expr`]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_ast/ast/struct.Expr.html @@ -330,7 +330,7 @@ You will also see lifetimes with the name `'tcx`, which means that something is tied to the lifetime of the [`TyCtxt`] (usually it is stored or interned there). -[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html +[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html For more information about queries in the compiler, see [the queries chapter][queries]. @@ -433,7 +433,7 @@ For more details on bootstrapping, see [the bootstrapping section of the guide][ - Guide: [Type Inference](type-inference.md) - Guide: [The ty Module: Representing Types](ty.md) (semantics) - Main entry point (type inference): [`InferCtxtBuilder::enter`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxtBuilder.html#method.enter) - - Main entry point (type checking bodies): [the `typeck` query](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.typeck) + - Main entry point (type checking bodies): [the `typeck` query](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.typeck) - These two functions can't be decoupled. - The Mid Level Intermediate Representation (MIR) - Guide: [The `MIR` (Mid level IR)](mir/index.md) diff --git a/src/doc/rustc-dev-guide/src/parallel-rustc.md b/src/doc/rustc-dev-guide/src/parallel-rustc.md index 4a530518c8696..98f831e1c985f 100644 --- a/src/doc/rustc-dev-guide/src/parallel-rustc.md +++ b/src/doc/rustc-dev-guide/src/parallel-rustc.md @@ -12,14 +12,13 @@ As of November 2024, most of the rust compiler is now parallelized. - The codegen part is executed concurrently by default. - You can use the `-C - codegen-units=n` option to control the number of concurrent tasks. -- The parts after HIR lowering to codegen such as type checking, borrowing - checking, and mir optimization are parallelized in the nightly version. - Currently, they are executed in serial by default, and parallelization is - manually enabled by the user using the `-Z threads = n` option. -- Other parts, such as lexical parsing, HIR lowering, and macro expansion, are - still executed in serial mode. + You can use the `-C codegen-units=n` option to control the number of concurrent tasks. +- The parts after HIR lowering to codegen, such as type checking, borrow-checking, + and mir optimization are parallelized in the nightly version. + Currently, they are executed serially by default, + and parallelization is manually enabled by the user using the `-Z threads = n` option. +- Other parts, such as lexical parsing, HIR lowering, and macro expansion, + are still executed in serial mode.
The following sections are kept for now but are quite outdated. @@ -34,8 +33,7 @@ The following sections are kept for now but are quite outdated. During monomorphization the compiler splits up all the code to be generated into smaller chunks called _codegen units_. These are then generated by independent instances of LLVM running in parallel. -At the end, the linker -is run to combine all the codegen units together into one binary. +At the end, the linker is run to combine all the codegen units together into one binary. This process occurs in the [`rustc_codegen_ssa::base`] module. [`rustc_codegen_ssa::base`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/base/index.html @@ -44,8 +42,7 @@ This process occurs in the [`rustc_codegen_ssa::base`] module. The underlying thread-safe data-structures used in the parallel compiler can be found in the [`rustc_data_structures::sync`] module. -These data structures -are implemented differently depending on whether `parallel-compiler` is true. +These data structures are implemented differently, depending on whether `parallel-compiler` is true. | data structure | parallel | non-parallel | | -------------------------------- | --------------------------------------------------- | ------------ | @@ -61,8 +58,8 @@ are implemented differently depending on whether `parallel-compiler` is true. can cause lock contention resulting in degraded performance as the number of threads increases beyond 4. So we audit the use of these data structures which leads to either a refactoring so as to reduce the use of shared state, - or the authoring of persistent documentation covering the specific of the - invariants, the atomicity, and the lock orderings. + or the authoring of persistent documentation covering the specific of the invariants, + the atomicity, and the lock orderings. - On the other hand, we still need to figure out what other invariants during compilation might not hold in parallel compilation. @@ -73,31 +70,27 @@ are implemented differently depending on whether `parallel-compiler` is true. [`WorkerLocal`] is a special data structure implemented for parallel compilers. It holds worker-locals values for each thread in a thread pool. -You can only -access the worker local value through the `Deref` `impl` on the thread pool it +You can only access the worker local value through the `Deref` `impl` on the thread pool it was constructed on. It panics otherwise. -`WorkerLocal` is used to implement the `Arena` allocator in the parallel -environment, which is critical in parallel queries. -Its implementation is -located in the [`rustc_data_structures::sync::worker_local`] module. +`WorkerLocal` is used to implement the `Arena` allocator in the parallel environment, +which is critical in parallel queries. +Its implementation is located in the [`rustc_data_structures::sync::worker_local`] module. However, -in the non-parallel compiler, it is implemented as `(OneThread)`, whose `T` -can be accessed directly through `Deref::deref`. +in the non-parallel compiler, it is implemented as `(OneThread)`, +whose `T` can be accessed directly through `Deref::deref`. [`rustc_data_structures::sync::worker_local`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/sync/worker_local/index.html [`WorkerLocal`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/sync/worker_local/struct.WorkerLocal.html ## Parallel iterator -The parallel iterators provided by the [`rayon`] crate are easy ways to -implement parallelism. +The parallel iterators provided by the [`rayon`] crate are easy ways to implement parallelism. In the current implementation of the parallel compiler, we use [a custom fork of `rayon`][rustc-rayon] to run tasks in parallel. -Some iterator functions are implemented to run loops in parallel -when `parallel-compiler` is true. +Some iterator functions are implemented to run loops in parallel when `parallel-compiler` is true. | Function(Omit `Send` and `Sync`) | Introduction | Owning Module | | ------------------------------------------------------------ | ------------------------------------------------------------ | -------------------------- | @@ -136,30 +129,26 @@ There are still many loops that have the potential to use parallel iterators. The query model has some properties that make it actually feasible to evaluate multiple queries in parallel without too much effort: -- All data a query provider can access is via the query context, so - the query context can take care of synchronizing access. +- All data a query provider can access is via the query context, + so the query context can take care of synchronizing access. - Query results are required to be immutable so they can safely be used by different threads concurrently. When a query `foo` is evaluated, the cache table for `foo` is locked. -- If there already is a result, we can clone it, release the lock and - we are done. -- If there is no cache entry and no other active query invocation computing the - same result, we mark the key as being "in progress", release the lock and - start evaluating. -- If there *is* another query invocation for the same key in progress, we - release the lock, and just block the thread until the other invocation has - computed the result we are waiting for. +- If there already is a result, we can clone it, release the lock, and we are done. +- If there is no cache entry and no other active query invocation computing the same result, + we mark the key as being "in progress", release the lock, and start evaluating. +- If there *is* another query invocation for the same key in progress, we release the lock, + and just block the thread until the other invocation has computed the result we are waiting for. **Cycle error detection** in the parallel compiler requires more complex logic than in single-threaded mode. - When - worker threads in parallel queries stop making progress due to interdependence, - the compiler uses an extra thread *(named deadlock handler)* to detect, remove and - report the cycle error. + When worker threads in parallel queries stop making progress due to interdependence, + the compiler uses an extra thread *(named deadlock handler)* to detect, + remove, and report the cycle error. -The parallel query feature still has implementation to do, most of which is -related to the previous `Data Structures` and `Parallel Iterators`. +The parallel query feature still has implementation to do, +most of which is related to the previous `Data Structures` and `Parallel Iterators`. See [this open feature tracking issue][tracking]. ## Rustdoc diff --git a/src/doc/rustc-dev-guide/src/query.md b/src/doc/rustc-dev-guide/src/query.md index a4b9eef02f13a..af2528831cff8 100644 --- a/src/doc/rustc-dev-guide/src/query.md +++ b/src/doc/rustc-dev-guide/src/query.md @@ -60,7 +60,7 @@ For example, to invoke the `type_of` query, you would just do this: let ty = tcx.type_of(some_def_id); ``` -[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html +[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html ## How the compiler executes a query diff --git a/src/doc/rustc-dev-guide/src/serialization.md b/src/doc/rustc-dev-guide/src/serialization.md index 891ff913c144f..0f5b53d346593 100644 --- a/src/doc/rustc-dev-guide/src/serialization.md +++ b/src/doc/rustc-dev-guide/src/serialization.md @@ -108,7 +108,7 @@ like [`ty::Predicate`] and manually implementing `Encodable` and `Decodable` may [`RefDecodable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/codec/trait.RefDecodable.html [`rustc_middle`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/index.html [`ty::Predicate`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/predicate/struct.Predicate.html -[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html +[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html [`TyDecodable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_macros/derive.TyDecodable.html [`TyDecoder`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/codec/trait.TyDecoder.html [`TyEncodable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_macros/derive.TyEncodable.html diff --git a/src/doc/rustc-dev-guide/src/tests/compiletest.md b/src/doc/rustc-dev-guide/src/tests/compiletest.md index 037b5b2929afb..800266b3feaa0 100644 --- a/src/doc/rustc-dev-guide/src/tests/compiletest.md +++ b/src/doc/rustc-dev-guide/src/tests/compiletest.md @@ -808,8 +808,10 @@ pub fn identity(ts: TokenStream) -> TokenStream { > force-host` and `//@ no-prefer-dynamic` headers in the proc-macro. ### Auxiliary lint + -By using an `aux-lint` directive in a `ui-fulldeps` test, you can build a 'lint library' file which will be loaded into rustc's lints when running your test. +By using an `aux-lint` directive in a `ui-fulldeps` test, +you can build a 'lint library' file which will be loaded into rustc's lints when running your test. ```rs // tests/ui-fulldeps/lint_test.rs diff --git a/src/doc/rustc-dev-guide/src/tests/running.md b/src/doc/rustc-dev-guide/src/tests/running.md index 112c9af455628..4aa538f894f8b 100644 --- a/src/doc/rustc-dev-guide/src/tests/running.md +++ b/src/doc/rustc-dev-guide/src/tests/running.md @@ -373,7 +373,7 @@ export TEST_DEVICE_ADDR="127.0.0.1:12345" # FIXME(madsmtm): Allow debuginfo tests to work (maybe needs `.dSYM` folder to be copied to the target?). ``` -[armhf-gnu]: https://github.com/rust-lang/rust/tree/HEAD/src/ci/docker/host-x86_64/armhf-gnu/Dockerfile +[armhf-gnu]: https://github.com/rust-lang/rust/tree/HEAD/src/ci/docker/host-x86_64/test-armhf-gnu/Dockerfile [QEMU]: https://www.qemu.org/ [remote-test-client]: https://github.com/rust-lang/rust/tree/HEAD/src/tools/remote-test-client [remote-test-server]: https://github.com/rust-lang/rust/tree/HEAD/src/tools/remote-test-server diff --git a/src/doc/rustc-dev-guide/src/tests/ui.md b/src/doc/rustc-dev-guide/src/tests/ui.md index 1ec6e84d30502..56c0b46d7b862 100644 --- a/src/doc/rustc-dev-guide/src/tests/ui.md +++ b/src/doc/rustc-dev-guide/src/tests/ui.md @@ -177,10 +177,10 @@ The corresponding reference file will use the normalized output to test both ... ``` -Please see [`ui/transmute/main.rs`][mrs] and [`main.stderr`] for a concrete usage example. +Please see [`ui/transmute/main.rs`][mrs] and [`main.current.stderr`] for a concrete usage example. [mrs]: https://github.com/rust-lang/rust/blob/HEAD/tests/ui/transmute/main.rs -[`main.stderr`]: https://github.com/rust-lang/rust/blob/HEAD/tests/ui/transmute/main.stderr +[`main.current.stderr`]: https://github.com/rust-lang/rust/blob/HEAD/tests/ui/transmute/main.current.stderr ## Error annotations diff --git a/src/doc/rustc-dev-guide/src/tests/x86_64-gnu-parallel-frontend.md b/src/doc/rustc-dev-guide/src/tests/x86_64-gnu-parallel-frontend.md index bfabce1dc2b69..b897b1d4d44b3 100644 --- a/src/doc/rustc-dev-guide/src/tests/x86_64-gnu-parallel-frontend.md +++ b/src/doc/rustc-dev-guide/src/tests/x86_64-gnu-parallel-frontend.md @@ -1,8 +1,8 @@ # Parallel frontend testing on CI -If you see any test failures in `tests/ui` from the CI job `test-x86_64-gnu-parallel-frontend`, please -add `//@ ignore-parallel-frontend triage` to the failing test, even if your PR is otherwise -entirely unrelated to parallel compiler or its testing. +If you see any test failures in `tests/ui` from the CI job `test-x86_64-gnu-parallel-frontend`, +please add `//@ ignore-parallel-frontend triage` to the failing test, +even if your PR is otherwise entirely unrelated to parallel compiler or its testing. In some time people from the parallel rustc working group will triage the failing test, make a tracking issue for it, and try to debug the problem. diff --git a/src/doc/rustc-dev-guide/src/ty-module/generic-arguments.md b/src/doc/rustc-dev-guide/src/ty-module/generic-arguments.md index 295b654e0ce4b..b7d032ce9b51c 100644 --- a/src/doc/rustc-dev-guide/src/ty-module/generic-arguments.md +++ b/src/doc/rustc-dev-guide/src/ty-module/generic-arguments.md @@ -51,7 +51,7 @@ There is essentially a one-to-one relationship between `AdtDef` and `DefId`. You can get the `AdtDef` for a `DefId` with the [`tcx.adt_def(def_id)` query][adtdefq]. `AdtDef`s are all interned, as shown by the `'tcx` lifetime. -[adtdefq]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.adt_def +[adtdefq]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.adt_def ## Question: Why not substitute “inside” the `AdtDef`? @@ -166,5 +166,5 @@ The general theme of how it works is outermost to innermost (`T` before `T2` in Check out [`ty::Generics`] for exact specifics on how the flattening works. [`ty::Generics`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Generics.html -[`generics_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.generics_of +[`generics_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.generics_of [late-bound generics]: ../early-late-parameters.md diff --git a/tests/ui/asm/x86_64/issue-96797.rs b/tests/ui/asm/x86_64/issue-96797.rs index 3f1f71be021b6..6e9451c2a8874 100644 --- a/tests/ui/asm/x86_64/issue-96797.rs +++ b/tests/ui/asm/x86_64/issue-96797.rs @@ -1,15 +1,15 @@ -//@ add-minicore //@ build-pass -//@ compile-flags: --target x86_64-unknown-linux-gnu -O -//@ needs-llvm-components: x86 -#![crate_type = "lib"] -#![feature(no_core)] -#![no_core] - -extern crate minicore; -use minicore::*; +//@ compile-flags: -O +//@ needs-asm-support +//@ only-x86_64 +//@ only-linux // regression test for #96797 +// +// Note that this test needs to link. It's checking that we did not +// merge `foobar` into `my_func`, which would cause linking to fail. + +use std::arch::global_asm; #[no_mangle] fn my_func() {} diff --git a/tests/ui/autodiff/autodiff_illegal.rs b/tests/ui/autodiff/autodiff_illegal.rs index 5143d26406d5b..5f398933f2d45 100644 --- a/tests/ui/autodiff/autodiff_illegal.rs +++ b/tests/ui/autodiff/autodiff_illegal.rs @@ -1,9 +1,4 @@ -//@ needs-enzyme - #![feature(autodiff)] -//@ pretty-mode:expanded -//@ pretty-compare-only -//@ pp-exact:autodiff_illegal.pp // Test that invalid ad macros give nice errors and don't ICE. diff --git a/tests/ui/autodiff/autodiff_illegal.stderr b/tests/ui/autodiff/autodiff_illegal.stderr index f9f31c3b90a08..54b0e91cb3c17 100644 --- a/tests/ui/autodiff/autodiff_illegal.stderr +++ b/tests/ui/autodiff/autodiff_illegal.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/autodiff_illegal.rs:54:5 + --> $DIR/autodiff_illegal.rs:49:5 | LL | #[autodiff_forward(df7, Dual)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,43 +9,43 @@ LL | #[autodiff_forward(df7, Dual)] = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: Duplicated can not be used for this type - --> $DIR/autodiff_illegal.rs:14:14 + --> $DIR/autodiff_illegal.rs:9:14 | LL | pub fn f1(x: f64) { | ^^^ error: expected 1 activities, but found 2 - --> $DIR/autodiff_illegal.rs:20:1 + --> $DIR/autodiff_illegal.rs:15:1 | LL | #[autodiff_reverse(df3, Duplicated, Const)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected 1 activities, but found 0 - --> $DIR/autodiff_illegal.rs:27:1 + --> $DIR/autodiff_illegal.rs:22:1 | LL | #[autodiff_reverse(df4)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: Dual can not be used in Reverse Mode - --> $DIR/autodiff_illegal.rs:34:1 + --> $DIR/autodiff_illegal.rs:29:1 | LL | #[autodiff_reverse(df5, Dual)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated can not be used in Forward Mode - --> $DIR/autodiff_illegal.rs:41:1 + --> $DIR/autodiff_illegal.rs:36:1 | LL | #[autodiff_forward(df6, Duplicated)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated can not be used for this type - --> $DIR/autodiff_illegal.rs:42:14 + --> $DIR/autodiff_illegal.rs:37:14 | LL | pub fn f6(x: f64) { | ^^^ error[E0658]: macro attributes on statements are unstable - --> $DIR/autodiff_illegal.rs:49:5 + --> $DIR/autodiff_illegal.rs:44:5 | LL | #[autodiff_forward(df7, Dual)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -55,13 +55,13 @@ LL | #[autodiff_forward(df7, Dual)] = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: autodiff must be applied to function - --> $DIR/autodiff_illegal.rs:51:5 + --> $DIR/autodiff_illegal.rs:46:5 | LL | let mut x = 5; | ^^^^^^^^^^^^^^ error[E0658]: macro attributes on expressions are unstable - --> $DIR/autodiff_illegal.rs:54:5 + --> $DIR/autodiff_illegal.rs:49:5 | LL | #[autodiff_forward(df7, Dual)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -71,13 +71,13 @@ LL | #[autodiff_forward(df7, Dual)] = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: autodiff must be applied to function - --> $DIR/autodiff_illegal.rs:55:5 + --> $DIR/autodiff_illegal.rs:50:5 | LL | x = x + 3; | ^ error[E0658]: macro attributes on statements are unstable - --> $DIR/autodiff_illegal.rs:60:5 + --> $DIR/autodiff_illegal.rs:55:5 | LL | #[autodiff_forward(df7, Dual)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -87,13 +87,13 @@ LL | #[autodiff_forward(df7, Dual)] = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: autodiff must be applied to function - --> $DIR/autodiff_illegal.rs:62:5 + --> $DIR/autodiff_illegal.rs:57:5 | LL | let add_one_v2 = |x: u32| -> u32 { x + 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: autodiff requires at least a name and mode - --> $DIR/autodiff_illegal.rs:68:1 + --> $DIR/autodiff_illegal.rs:63:1 | LL | / pub fn f7(x: f64) { LL | | @@ -102,7 +102,7 @@ LL | | } | |_^ error: autodiff requires at least a name and mode - --> $DIR/autodiff_illegal.rs:75:1 + --> $DIR/autodiff_illegal.rs:70:1 | LL | / pub fn f8(x: f64) { LL | | @@ -111,7 +111,7 @@ LL | | } | |_^ error: autodiff requires at least a name and mode - --> $DIR/autodiff_illegal.rs:82:1 + --> $DIR/autodiff_illegal.rs:77:1 | LL | / pub fn f9(x: f64) { LL | | @@ -120,7 +120,7 @@ LL | | } | |_^ error[E0428]: the name `fn_exists` is defined multiple times - --> $DIR/autodiff_illegal.rs:90:1 + --> $DIR/autodiff_illegal.rs:85:1 | LL | fn fn_exists() {} | -------------- previous definition of the value `fn_exists` here @@ -131,25 +131,25 @@ LL | #[autodiff_reverse(fn_exists, Active)] = note: `fn_exists` must be defined only once in the value namespace of this module error: did not recognize Activity: `Reverse` - --> $DIR/autodiff_illegal.rs:98:26 + --> $DIR/autodiff_illegal.rs:93:26 | LL | #[autodiff_reverse(df13, Reverse)] | ^^^^^^^ error: invalid return activity Active in Forward Mode - --> $DIR/autodiff_illegal.rs:134:1 + --> $DIR/autodiff_illegal.rs:129:1 | LL | #[autodiff_forward(df19, Dual, Active)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid return activity Dual in Reverse Mode - --> $DIR/autodiff_illegal.rs:140:1 + --> $DIR/autodiff_illegal.rs:135:1 | LL | #[autodiff_reverse(df20, Active, Dual)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid return activity Duplicated in Reverse Mode - --> $DIR/autodiff_illegal.rs:147:1 + --> $DIR/autodiff_illegal.rs:142:1 | LL | #[autodiff_reverse(df21, Active, Duplicated)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lifetimes/where-bound-with-lifetime-53156.current.stderr b/tests/ui/lifetimes/where-bound-with-lifetime-53156.current.stderr new file mode 100644 index 0000000000000..b9d50d4f5354d --- /dev/null +++ b/tests/ui/lifetimes/where-bound-with-lifetime-53156.current.stderr @@ -0,0 +1,26 @@ +error: lifetime may not live long enough + --> $DIR/where-bound-with-lifetime-53156.rs:35:9 + | +LL | impl<'a, B> OwnedWrap + | -- lifetime `'a` defined here +... +LL | pub fn to_arc_aac(&self) -> Arc { + | - let's call the lifetime of this reference `'1` +LL | let OwnedWrap(ref owned) = *self; +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'a` + +error[E0621]: explicit lifetime required in the type of `wrap` + --> $DIR/where-bound-with-lifetime-53156.rs:135:5 + | +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required + | +help: add explicit lifetime `'a` to the type of `wrap` + | +LL | fn to_arc_aac<'a, B>(wrap: &'a OwnedWrap) -> Arc + | ++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/lifetimes/where-bound-with-lifetime-53156.next.stderr b/tests/ui/lifetimes/where-bound-with-lifetime-53156.next.stderr new file mode 100644 index 0000000000000..b9d50d4f5354d --- /dev/null +++ b/tests/ui/lifetimes/where-bound-with-lifetime-53156.next.stderr @@ -0,0 +1,26 @@ +error: lifetime may not live long enough + --> $DIR/where-bound-with-lifetime-53156.rs:35:9 + | +LL | impl<'a, B> OwnedWrap + | -- lifetime `'a` defined here +... +LL | pub fn to_arc_aac(&self) -> Arc { + | - let's call the lifetime of this reference `'1` +LL | let OwnedWrap(ref owned) = *self; +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'a` + +error[E0621]: explicit lifetime required in the type of `wrap` + --> $DIR/where-bound-with-lifetime-53156.rs:135:5 + | +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required + | +help: add explicit lifetime `'a` to the type of `wrap` + | +LL | fn to_arc_aac<'a, B>(wrap: &'a OwnedWrap) -> Arc + | ++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/lifetimes/where-bound-with-lifetime-53156.rs b/tests/ui/lifetimes/where-bound-with-lifetime-53156.rs new file mode 100644 index 0000000000000..10663bdb5f578 --- /dev/null +++ b/tests/ui/lifetimes/where-bound-with-lifetime-53156.rs @@ -0,0 +1,235 @@ +//! Regression test for . +//! Second where bound was causing incorrect rejection of acceptable lifetime. + +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +use std::borrow::Borrow; +use std::sync::Arc; + +struct OwnedWrap(::Owned); + +impl<'a, B> OwnedWrap +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + // 1a-2a-3a + pub fn to_arc_aaa(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2a-3b + pub fn to_arc_aab(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2a-3c + pub fn to_arc_aac(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + //~^ ERROR lifetime may not live long enough + } + + // 1a-2b-3a + pub fn to_arc_aba(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2b-3b + pub fn to_arc_abb(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2b-3c + pub fn to_arc_abc(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + } +} + +impl<'a, B> OwnedWrap +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + // 1b-2a-3a + pub fn to_arc_baa(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2a-3b + pub fn to_arc_bab(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2a-3c + pub fn to_arc_bac(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + } + + // 1b-2b-3a + pub fn to_arc_bba(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2b-3b + pub fn to_arc_bbb(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2b-3c + pub fn to_arc_bbc(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + } +} + +// 1a-2a-3a +fn to_arc_aaa<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2a-3b +fn to_arc_aab<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2a-3c +fn to_arc_aac<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() + //~^ ERROR explicit lifetime required in the type of `wrap` +} + +// 1a-2b-3a +fn to_arc_aba<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2b-3b +fn to_arc_abb<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2b-3c +fn to_arc_abc<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() +} + +// 1b-2a-3a +fn to_arc_baa<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2a-3b +fn to_arc_bab<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2a-3c +fn to_arc_bac<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() +} + +// 1b-2b-3a +fn to_arc_bba<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2b-3b +fn to_arc_bbb<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2b-3c +fn to_arc_bbc<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() +} + +fn main() {} diff --git a/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr index dd6f561f5b799..d82944bbd88c7 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr +++ b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr @@ -4,7 +4,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -22,7 +22,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -39,7 +39,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(false, true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -56,7 +56,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -73,7 +73,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -90,7 +90,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_and` LL | let _a = A.fetch_and(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -107,7 +107,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_nand` LL | let _a = A.fetch_nand(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -124,7 +124,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -141,7 +141,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -158,7 +158,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_not` LL | let _a = A.fetch_not(Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -175,7 +175,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(true)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -192,7 +192,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(false)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -209,7 +209,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| true); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -226,7 +226,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -243,7 +243,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -260,7 +260,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(std::ptr::null_mut(), std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -275,7 +275,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch --> $DIR/const-item-interior-mutations-const-atomics.rs:64:14 | LL | let _a = A.compare_exchange( - | ^ `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | ^ `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | ______________| | | LL | | @@ -299,7 +299,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch --> $DIR/const-item-interior-mutations-const-atomics.rs:72:14 | LL | let _a = A.compare_exchange_weak( - | ^ `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | ^ `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | ______________| | | LL | | @@ -325,7 +325,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -342,7 +342,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -359,7 +359,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| std::ptr::null_mut()); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -376,7 +376,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_ptr_ad LL | let _a = A.fetch_ptr_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -393,7 +393,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_ptr_su LL | let _a = A.fetch_ptr_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -410,7 +410,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_byte_a LL | let _a = A.fetch_byte_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -427,7 +427,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_byte_s LL | let _a = A.fetch_byte_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -444,7 +444,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_and` LL | let _a = A.fetch_and(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -461,7 +461,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -478,7 +478,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -495,7 +495,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -512,7 +512,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(2, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -529,7 +529,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(2, 3, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -546,7 +546,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange(3, 4, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -563,7 +563,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange_weak(4, 5, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -580,7 +580,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_add` LL | let _a = A.fetch_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -597,7 +597,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_sub` LL | let _a = A.fetch_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -614,7 +614,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_add` LL | let _a = A.fetch_add(2, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -631,7 +631,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_nand` LL | let _a = A.fetch_nand(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -648,7 +648,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -665,7 +665,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -682,7 +682,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(10)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -699,7 +699,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(11)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -716,7 +716,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| 12); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -733,7 +733,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_max` LL | let _a = A.fetch_max(20, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -750,7 +750,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_min` LL | let _a = A.fetch_min(5, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified diff --git a/tests/ui/lint/const-item-interior-mutations-const-cell.stderr b/tests/ui/lint/const-item-interior-mutations-const-cell.stderr index ec3a5f4e38eed..c9b95a64200bc 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-cell.stderr +++ b/tests/ui/lint/const-item-interior-mutations-const-cell.stderr @@ -4,7 +4,7 @@ warning: mutation of an interior mutable `const` item with call to `force` LL | let _ = LazyCell::force(&A); | ^^^^^^^^^^^^^^^^^-^ | | - | `A` is a interior mutable `const` item of type `LazyCell` + | `A` is an interior mutable `const` item of type `LazyCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -22,7 +22,7 @@ warning: mutation of an interior mutable `const` item with call to `set` LL | let _ = A.set(10); | -^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceCell` + | `A` is an interior mutable `const` item of type `OnceCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -39,7 +39,7 @@ warning: mutation of an interior mutable `const` item with call to `try_insert` LL | let _ = A.try_insert(20); | -^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceCell` + | `A` is an interior mutable `const` item of type `OnceCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -56,7 +56,7 @@ warning: mutation of an interior mutable `const` item with call to `get_or_init` LL | let _ = A.get_or_init(|| 30); | -^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceCell` + | `A` is an interior mutable `const` item of type `OnceCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -73,7 +73,7 @@ warning: mutation of an interior mutable `const` item with call to `get_or_try_i LL | let _ = A.get_or_try_init(|| Ok::<_, ()>(40)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceCell` + | `A` is an interior mutable `const` item of type `OnceCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -90,7 +90,7 @@ warning: mutation of an interior mutable `const` item with call to `set` LL | let _ = A.set(1); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Cell` + | `A` is an interior mutable `const` item of type `Cell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -107,7 +107,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _ = A.swap(&A); | -^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Cell` + | `A` is an interior mutable `const` item of type `Cell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -124,7 +124,7 @@ warning: mutation of an interior mutable `const` item with call to `replace` LL | let _ = A.replace(2); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Cell` + | `A` is an interior mutable `const` item of type `Cell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -141,7 +141,7 @@ warning: mutation of an interior mutable `const` item with call to `get` LL | let _ = A.get(); | -^^^^^^ | | - | `A` is a interior mutable `const` item of type `Cell` + | `A` is an interior mutable `const` item of type `Cell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -158,7 +158,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _ = A.update(|x| x + 1); | -^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Cell` + | `A` is an interior mutable `const` item of type `Cell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -175,7 +175,7 @@ warning: mutation of an interior mutable `const` item with call to `replace` LL | let _ = A.replace(1); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -192,7 +192,7 @@ warning: mutation of an interior mutable `const` item with call to `replace_with LL | let _ = A.replace_with(|x| *x + 2); | -^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -209,7 +209,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _ = A.swap(&A); | -^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -226,7 +226,7 @@ warning: mutation of an interior mutable `const` item with call to `borrow` LL | let _ = A.borrow(); | -^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -243,7 +243,7 @@ warning: mutation of an interior mutable `const` item with call to `try_borrow` LL | let _ = A.try_borrow(); | -^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -260,7 +260,7 @@ warning: mutation of an interior mutable `const` item with call to `borrow_mut` LL | let _ = A.borrow_mut(); | -^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -277,7 +277,7 @@ warning: mutation of an interior mutable `const` item with call to `try_borrow_m LL | let _ = A.try_borrow_mut(); | -^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -294,7 +294,7 @@ warning: mutation of an interior mutable `const` item with call to `replace` LL | let _ = unsafe { A.replace(1) }; | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `UnsafeCell` + | `A` is an interior mutable `const` item of type `UnsafeCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -311,7 +311,7 @@ warning: mutation of an interior mutable `const` item with call to `get` LL | let _ = A.get(); | -^^^^^^ | | - | `A` is a interior mutable `const` item of type `UnsafeCell` + | `A` is an interior mutable `const` item of type `UnsafeCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -328,7 +328,7 @@ warning: mutation of an interior mutable `const` item with call to `as_ref_unche LL | let _ = A.as_ref_unchecked(); | -^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `UnsafeCell` + | `A` is an interior mutable `const` item of type `UnsafeCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -345,7 +345,7 @@ warning: mutation of an interior mutable `const` item with call to `as_mut_unche LL | let _ = A.as_mut_unchecked(); | -^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `UnsafeCell` + | `A` is an interior mutable `const` item of type `UnsafeCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -362,7 +362,7 @@ warning: mutation of an interior mutable `const` item with call to `get` LL | let _ = A.get(); | -^^^^^^ | | - | `A` is a interior mutable `const` item of type `SyncUnsafeCell` + | `A` is an interior mutable `const` item of type `SyncUnsafeCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified diff --git a/tests/ui/lint/const-item-interior-mutations-const.stderr b/tests/ui/lint/const-item-interior-mutations-const.stderr index 2fe8f190dbed8..f615f6ecabf93 100644 --- a/tests/ui/lint/const-item-interior-mutations-const.stderr +++ b/tests/ui/lint/const-item-interior-mutations-const.stderr @@ -4,7 +4,7 @@ warning: mutation of an interior mutable `const` item with call to `set` LL | let _a = A.set(1); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | `A` is an interior mutable `const` item of type `std::sync::Mutex` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -22,7 +22,7 @@ warning: mutation of an interior mutable `const` item with call to `replace` LL | let _a = A.replace(2); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | `A` is an interior mutable `const` item of type `std::sync::Mutex` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -39,7 +39,7 @@ warning: mutation of an interior mutable `const` item with call to `lock` LL | drop(A.lock()); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | `A` is an interior mutable `const` item of type `std::sync::Mutex` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -56,7 +56,7 @@ warning: mutation of an interior mutable `const` item with call to `try_lock` LL | drop(A.try_lock()); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | `A` is an interior mutable `const` item of type `std::sync::Mutex` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -73,7 +73,7 @@ warning: mutation of an interior mutable `const` item with call to `clear_poison LL | let _a = A.clear_poison(); | -^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | `A` is an interior mutable `const` item of type `std::sync::Mutex` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -90,7 +90,7 @@ warning: mutation of an interior mutable `const` item with call to `call_once` LL | let _a = A.call_once(|| {}); | -^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Once` + | `A` is an interior mutable `const` item of type `std::sync::Once` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -107,7 +107,7 @@ warning: mutation of an interior mutable `const` item with call to `call_once_fo LL | let _a = A.call_once_force(|_| {}); | -^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Once` + | `A` is an interior mutable `const` item of type `std::sync::Once` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -124,7 +124,7 @@ warning: mutation of an interior mutable `const` item with call to `wait` LL | let _a = A.wait(); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Once` + | `A` is an interior mutable `const` item of type `std::sync::Once` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -141,7 +141,7 @@ warning: mutation of an interior mutable `const` item with call to `wait_force` LL | let _a = A.wait_force(); | -^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Once` + | `A` is an interior mutable `const` item of type `std::sync::Once` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -158,7 +158,7 @@ warning: mutation of an interior mutable `const` item with call to `set` LL | let _a = A.set(1); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -175,7 +175,7 @@ warning: mutation of an interior mutable `const` item with call to `replace` LL | let _a = A.replace(2); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -192,7 +192,7 @@ warning: mutation of an interior mutable `const` item with call to `read` LL | drop(A.read()); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -209,7 +209,7 @@ warning: mutation of an interior mutable `const` item with call to `try_read` LL | drop(A.try_read()); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -226,7 +226,7 @@ warning: mutation of an interior mutable `const` item with call to `write` LL | drop(A.write()); | -^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -243,7 +243,7 @@ warning: mutation of an interior mutable `const` item with call to `try_write` LL | drop(A.try_write()); | -^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -260,7 +260,7 @@ warning: mutation of an interior mutable `const` item with call to `force` LL | let _a = LazyLock::force(&A); | ^^^^^^^^^^^^^^^^^-^ | | - | `A` is a interior mutable `const` item of type `LazyLock` + | `A` is an interior mutable `const` item of type `LazyLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -277,7 +277,7 @@ warning: mutation of an interior mutable `const` item with call to `get` LL | let _a = LazyLock::get(&A); | ^^^^^^^^^^^^^^^-^ | | - | `A` is a interior mutable `const` item of type `LazyLock` + | `A` is an interior mutable `const` item of type `LazyLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -294,7 +294,7 @@ warning: mutation of an interior mutable `const` item with call to `get` LL | let _a = A.get(); | -^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -311,7 +311,7 @@ warning: mutation of an interior mutable `const` item with call to `wait` LL | let _a = A.wait(); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -328,7 +328,7 @@ warning: mutation of an interior mutable `const` item with call to `set` LL | let _a = A.set(10); | -^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -345,7 +345,7 @@ warning: mutation of an interior mutable `const` item with call to `try_insert` LL | let _a = A.try_insert(20); | -^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -362,7 +362,7 @@ warning: mutation of an interior mutable `const` item with call to `get_or_init` LL | let _a = A.get_or_init(|| 30); | -^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -379,7 +379,7 @@ warning: mutation of an interior mutable `const` item with call to `get_or_try_i LL | let _a = A.get_or_try_init(|| Ok::<_, ()>(40)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -396,7 +396,7 @@ warning: mutation of an interior mutable `const` item with call to `wait` LL | let _a = A.wait(guard); | -^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -413,7 +413,7 @@ warning: mutation of an interior mutable `const` item with call to `wait_while` LL | let _a = A.wait_while(guard, |x| *x == 0); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -430,7 +430,7 @@ warning: mutation of an interior mutable `const` item with call to `wait_timeout LL | let _a = A.wait_timeout_ms(guard, 10); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -447,7 +447,7 @@ warning: mutation of an interior mutable `const` item with call to `wait_timeout LL | let _a = A.wait_timeout(guard, Duration::from_millis(10)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -464,7 +464,7 @@ warning: mutation of an interior mutable `const` item with call to `wait_timeout LL | let _a = A.wait_timeout_while(guard, Duration::from_millis(10), |x| *x == 0); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -481,7 +481,7 @@ warning: mutation of an interior mutable `const` item with call to `notify_one` LL | let _a = A.notify_one(); | -^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -498,7 +498,7 @@ warning: mutation of an interior mutable `const` item with call to `notify_all` LL | let _a = A.notify_all(); | -^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified diff --git a/tests/ui/target-feature/target-feature-detection.rs b/tests/ui/target-feature/target-feature-detection.rs index 9a9102bf7d54d..22ff8442e3ed2 100644 --- a/tests/ui/target-feature/target-feature-detection.rs +++ b/tests/ui/target-feature/target-feature-detection.rs @@ -1,5 +1,5 @@ -//! Check that `cfg!(target_feature = "...")` correctly detects available CPU features, -//! specifically `sse2` on x86/x86_64 platforms, and correctly reports absent features. +//! Check that `cfg!(target_feature = "...")` correctly detects available CPU features from the base +//! target, specifically `sse2` on x86/x86_64 platforms, and correctly reports absent features. //@ run-pass //@ ignore-i586 (no SSE2) diff --git a/tests/ui/target-feature/target-feature-flag-sets-cfg.rs b/tests/ui/target-feature/target-feature-flag-sets-cfg.rs new file mode 100644 index 0000000000000..d1d778ce85901 --- /dev/null +++ b/tests/ui/target-feature/target-feature-flag-sets-cfg.rs @@ -0,0 +1,23 @@ +//! Ensure ABI-incompatible features cannot be enabled via `-Ctarget-feature`. +// These are just warnings for now. +//@ check-pass +//@ compile-flags: --crate-type=lib +//@ revisions: x86 riscv +//@[x86] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=+avx512f +//@[x86] needs-llvm-components: x86 +//@[riscv] compile-flags: --target=riscv64im-unknown-none-elf -Ctarget-feature=+d +//@[riscv] needs-llvm-components: riscv +//@ add-minicore + +#![feature(no_core, riscv_target_feature)] +#![no_core] + +extern crate minicore; +use minicore::*; + +// Ensure we can "see" the enabled target feature, and its implications. +#[cfg(not(any( + all(target_arch = "x86_64", target_feature = "avx512f", target_feature = "avx2"), + all(target_arch = "riscv64", target_feature = "d", target_feature = "f") +)))] +compile_error!("target feature has not been set in cfg");