Auto merge of #129999 - matthiaskrgr:rollup-pzr9c8p, r=matthiaskrgr

Rollup of 11 pull requests

Successful merges:

 - #128919 (Add an internal lint that warns when accessing untracked data)
 - #129472 (fix ICE when `asm_const` and `const_refs_to_static` are combined)
 - #129653 (clarify that addr_of creates read-only pointers)
 - #129775 (bootstrap: Try to track down why `initial_libdir` sometimes fails)
 - #129939 (explain why Rvalue::Len still exists)
 - #129942 (copy rustc rustlib artifacts from ci-rustc)
 - #129943 (use the bootstrapped compiler for `test-float-parse` test)
 - #129944 (Add compat note for trait solver change)
 - #129947 (Add digit separators in `Duration` examples)
 - #129955 (Temporarily remove fmease from the review rotation)
 - #129957 (forward linker option to lint-docs)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-09-06 03:06:52 +00:00
commit d678b81485
32 changed files with 241 additions and 70 deletions

View File

@ -100,6 +100,9 @@ Compatibility Notes
The reason is that these types have different roles: `std::panic::PanicHookInfo` is the argument to the [panic hook](https://doc.rust-lang.org/stable/std/panic/fn.set_hook.html) in std context (where panics can have an arbitrary payload), while `core::panic::PanicInfo` is the argument to the [`#[panic_handler]`](https://doc.rust-lang.org/nomicon/panic-handler.html) in no_std context (where panics always carry a formatted *message*). Separating these types allows us to add more useful methods to these types, such as `std::panic::PanicHookInfo::payload_as_str()` and `core::panic::PanicInfo::message()`. The reason is that these types have different roles: `std::panic::PanicHookInfo` is the argument to the [panic hook](https://doc.rust-lang.org/stable/std/panic/fn.set_hook.html) in std context (where panics can have an arbitrary payload), while `core::panic::PanicInfo` is the argument to the [`#[panic_handler]`](https://doc.rust-lang.org/nomicon/panic-handler.html) in no_std context (where panics always carry a formatted *message*). Separating these types allows us to add more useful methods to these types, such as `std::panic::PanicHookInfo::payload_as_str()` and `core::panic::PanicInfo::message()`.
* The new sort implementations may panic if a type's implementation of [`Ord`](https://doc.rust-lang.org/std/cmp/trait.Ord.html) (or the given comparison function) does not implement a [total order](https://en.wikipedia.org/wiki/Total_order) as the trait requires. `Ord`'s supertraits (`PartialOrd`, `Eq`, and `PartialEq`) must also be consistent. The previous implementations would not "notice" any problem, but the new implementations have a good chance of detecting inconsistencies, throwing a panic rather than returning knowingly unsorted data. * The new sort implementations may panic if a type's implementation of [`Ord`](https://doc.rust-lang.org/std/cmp/trait.Ord.html) (or the given comparison function) does not implement a [total order](https://en.wikipedia.org/wiki/Total_order) as the trait requires. `Ord`'s supertraits (`PartialOrd`, `Eq`, and `PartialEq`) must also be consistent. The previous implementations would not "notice" any problem, but the new implementations have a good chance of detecting inconsistencies, throwing a panic rather than returning knowingly unsorted data.
* [In very rare cases, a change in the internal evaluation order of the trait
solver may result in new fatal overflow errors.](https://github.com/rust-lang/rust/pull/126128)
<a id="1.81.0-Internal-Changes"></a> <a id="1.81.0-Internal-Changes"></a>

View File

@ -2522,7 +2522,7 @@ pub(crate) fn buffer_mut_error(&mut self, span: Span, diag: Diag<'infcx>, count:
} }
pub(crate) fn emit_errors(&mut self) -> Option<ErrorGuaranteed> { pub(crate) fn emit_errors(&mut self) -> Option<ErrorGuaranteed> {
let mut res = None; let mut res = self.infcx.tainted_by_errors();
// Buffer any move errors that we collected and de-duplicated. // Buffer any move errors that we collected and de-duplicated.
for (_, (_, diag)) in std::mem::take(&mut self.diags.buffered_move_errors) { for (_, (_, diag)) in std::mem::take(&mut self.diags.buffered_move_errors) {

View File

@ -29,7 +29,8 @@
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty, TyCtxt, self, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty,
TyCtxt, TypeVisitableExt,
}; };
use rustc_middle::{bug, span_bug}; use rustc_middle::{bug, span_bug};
use rustc_span::symbol::{kw, sym}; use rustc_span::symbol::{kw, sym};
@ -688,7 +689,8 @@ fn compute_inputs_and_output(
defining_ty: DefiningTy<'tcx>, defining_ty: DefiningTy<'tcx>,
) -> ty::Binder<'tcx, &'tcx ty::List<Ty<'tcx>>> { ) -> ty::Binder<'tcx, &'tcx ty::List<Ty<'tcx>>> {
let tcx = self.infcx.tcx; let tcx = self.infcx.tcx;
match defining_ty {
let inputs_and_output = match defining_ty {
DefiningTy::Closure(def_id, args) => { DefiningTy::Closure(def_id, args) => {
assert_eq!(self.mir_def.to_def_id(), def_id); assert_eq!(self.mir_def.to_def_id(), def_id);
let closure_sig = args.as_closure().sig(); let closure_sig = args.as_closure().sig();
@ -798,6 +800,7 @@ fn compute_inputs_and_output(
// "output" (the type of the constant). // "output" (the type of the constant).
assert_eq!(self.mir_def.to_def_id(), def_id); assert_eq!(self.mir_def.to_def_id(), def_id);
let ty = tcx.type_of(self.mir_def).instantiate_identity(); let ty = tcx.type_of(self.mir_def).instantiate_identity();
let ty = indices.fold_to_region_vids(tcx, ty); let ty = indices.fold_to_region_vids(tcx, ty);
ty::Binder::dummy(tcx.mk_type_list(&[ty])) ty::Binder::dummy(tcx.mk_type_list(&[ty]))
} }
@ -807,7 +810,14 @@ fn compute_inputs_and_output(
let ty = args.as_inline_const().ty(); let ty = args.as_inline_const().ty();
ty::Binder::dummy(tcx.mk_type_list(&[ty])) ty::Binder::dummy(tcx.mk_type_list(&[ty]))
} }
};
// FIXME(#129952): We probably want a more principled approach here.
if let Err(terr) = inputs_and_output.skip_binder().error_reported() {
self.infcx.set_tainted_by_errors(terr);
} }
inputs_and_output
} }
} }

View File

@ -57,6 +57,7 @@ pub fn steal(&self) -> T {
/// ///
/// This should not be used within rustc as it leaks information not tracked /// This should not be used within rustc as it leaks information not tracked
/// by the query system, breaking incremental compilation. /// by the query system, breaking incremental compilation.
#[cfg_attr(not(bootstrap), rustc_lint_untracked_query_information)]
pub fn is_stolen(&self) -> bool { pub fn is_stolen(&self) -> bool {
self.value.borrow().is_none() self.value.borrow().is_none()
} }

View File

@ -793,6 +793,12 @@ pub struct BuiltinAttribute {
rustc_lint_query_instability, Normal, template!(Word), rustc_lint_query_instability, Normal, template!(Word),
WarnFollowing, EncodeCrossCrate::Yes, INTERNAL_UNSTABLE WarnFollowing, EncodeCrossCrate::Yes, INTERNAL_UNSTABLE
), ),
// Used by the `rustc::untracked_query_information` lint to warn methods which
// might not be stable during incremental compilation.
rustc_attr!(
rustc_lint_untracked_query_information, Normal, template!(Word),
WarnFollowing, EncodeCrossCrate::Yes, INTERNAL_UNSTABLE
),
// Used by the `rustc::diagnostic_outside_of_impl` lints to assist in changes to diagnostic // Used by the `rustc::diagnostic_outside_of_impl` lints to assist in changes to diagnostic
// APIs. Any function with this attribute will be checked by that lint. // APIs. Any function with this attribute will be checked by that lint.
rustc_attr!( rustc_attr!(

View File

@ -699,6 +699,9 @@ lint_ptr_null_checks_ref = references are not nullable, so checking them for nul
lint_query_instability = using `{$query}` can result in unstable query results lint_query_instability = using `{$query}` can result in unstable query results
.note = if you believe this case to be fine, allow this lint and add a comment explaining your rationale .note = if you believe this case to be fine, allow this lint and add a comment explaining your rationale
lint_query_untracked = `{$method}` accesses information that is not tracked by the query system
.note = if you believe this case to be fine, allow this lint and add a comment explaining your rationale
lint_range_endpoint_out_of_range = range endpoint is out of range for `{$ty}` lint_range_endpoint_out_of_range = range endpoint is out of range for `{$ty}`
lint_range_use_inclusive_range = use an inclusive range instead lint_range_use_inclusive_range = use an inclusive range instead

View File

@ -17,8 +17,8 @@
use crate::lints::{ use crate::lints::{
BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword, BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword,
NonGlobImportTypeIrInherent, QueryInstability, SpanUseEqCtxtDiag, TyQualified, TykindDiag, NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, SpanUseEqCtxtDiag, TyQualified,
TykindKind, TypeIrInherentUsage, UntranslatableDiag, TykindDiag, TykindKind, TypeIrInherentUsage, UntranslatableDiag,
}; };
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
@ -88,7 +88,18 @@ fn typeck_results_of_method_fn<'tcx>(
report_in_external_macro: true report_in_external_macro: true
} }
declare_lint_pass!(QueryStability => [POTENTIAL_QUERY_INSTABILITY]); declare_tool_lint! {
/// The `untracked_query_information` lint detects use of methods which leak information not
/// tracked by the query system, such as whether a `Steal<T>` value has already been stolen. In
/// order not to break incremental compilation, such methods must be used very carefully or not
/// at all.
pub rustc::UNTRACKED_QUERY_INFORMATION,
Allow,
"require explicit opt-in when accessing information not tracked by the query system",
report_in_external_macro: true
}
declare_lint_pass!(QueryStability => [POTENTIAL_QUERY_INSTABILITY, UNTRACKED_QUERY_INFORMATION]);
impl LateLintPass<'_> for QueryStability { impl LateLintPass<'_> for QueryStability {
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
@ -102,6 +113,13 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
QueryInstability { query: cx.tcx.item_name(def_id) }, QueryInstability { query: cx.tcx.item_name(def_id) },
); );
} }
if cx.tcx.has_attr(def_id, sym::rustc_lint_untracked_query_information) {
cx.emit_span_lint(
UNTRACKED_QUERY_INFORMATION,
span,
QueryUntracked { method: cx.tcx.item_name(def_id) },
);
}
} }
} }
} }

View File

@ -610,6 +610,7 @@ fn register_internals(store: &mut LintStore) {
vec![ vec![
LintId::of(DEFAULT_HASH_TYPES), LintId::of(DEFAULT_HASH_TYPES),
LintId::of(POTENTIAL_QUERY_INSTABILITY), LintId::of(POTENTIAL_QUERY_INSTABILITY),
LintId::of(UNTRACKED_QUERY_INFORMATION),
LintId::of(USAGE_OF_TY_TYKIND), LintId::of(USAGE_OF_TY_TYKIND),
LintId::of(PASS_BY_VALUE), LintId::of(PASS_BY_VALUE),
LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO), LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),

View File

@ -894,6 +894,13 @@ pub(crate) struct QueryInstability {
pub query: Symbol, pub query: Symbol,
} }
#[derive(LintDiagnostic)]
#[diag(lint_query_untracked)]
#[note]
pub(crate) struct QueryUntracked {
pub method: Symbol,
}
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(lint_span_use_eq_ctxt)] #[diag(lint_span_use_eq_ctxt)]
pub(crate) struct SpanUseEqCtxtDiag; pub(crate) struct SpanUseEqCtxtDiag;

View File

@ -1307,6 +1307,9 @@ pub enum Rvalue<'tcx> {
/// If the type of the place is an array, this is the array length. For slices (`[T]`, not /// If the type of the place is an array, this is the array length. For slices (`[T]`, not
/// `&[T]`) this accesses the place's metadata to determine the length. This rvalue is /// `&[T]`) this accesses the place's metadata to determine the length. This rvalue is
/// ill-formed for places of other types. /// ill-formed for places of other types.
///
/// This cannot be a `UnOp(PtrMetadata, _)` because that expects a value, and we only
/// have a place, and `UnOp(PtrMetadata, RawPtr(place))` is not a thing.
Len(Place<'tcx>), Len(Place<'tcx>),
/// Performs essentially all of the casts that can be performed via `as`. /// Performs essentially all of the casts that can be performed via `as`.

View File

@ -125,7 +125,9 @@ fn check_attributes(
[sym::inline, ..] => self.check_inline(hir_id, attr, span, target), [sym::inline, ..] => self.check_inline(hir_id, attr, span, target),
[sym::coverage, ..] => self.check_coverage(attr, span, target), [sym::coverage, ..] => self.check_coverage(attr, span, target),
[sym::optimize, ..] => self.check_optimize(hir_id, attr, target), [sym::optimize, ..] => self.check_optimize(hir_id, attr, target),
[sym::no_sanitize, ..] => self.check_no_sanitize(hir_id, attr, span, target), [sym::no_sanitize, ..] => {
self.check_applied_to_fn_or_method(hir_id, attr, span, target)
}
[sym::non_exhaustive, ..] => self.check_non_exhaustive(hir_id, attr, span, target), [sym::non_exhaustive, ..] => self.check_non_exhaustive(hir_id, attr, span, target),
[sym::marker, ..] => self.check_marker(hir_id, attr, span, target), [sym::marker, ..] => self.check_marker(hir_id, attr, span, target),
[sym::target_feature, ..] => { [sym::target_feature, ..] => {
@ -166,10 +168,13 @@ fn check_attributes(
self.check_rustc_legacy_const_generics(hir_id, attr, span, target, item) self.check_rustc_legacy_const_generics(hir_id, attr, span, target, item)
} }
[sym::rustc_lint_query_instability, ..] => { [sym::rustc_lint_query_instability, ..] => {
self.check_rustc_lint_query_instability(hir_id, attr, span, target) self.check_applied_to_fn_or_method(hir_id, attr, span, target)
}
[sym::rustc_lint_untracked_query_information, ..] => {
self.check_applied_to_fn_or_method(hir_id, attr, span, target)
} }
[sym::rustc_lint_diagnostics, ..] => { [sym::rustc_lint_diagnostics, ..] => {
self.check_rustc_lint_diagnostics(hir_id, attr, span, target) self.check_applied_to_fn_or_method(hir_id, attr, span, target)
} }
[sym::rustc_lint_opt_ty, ..] => self.check_rustc_lint_opt_ty(attr, span, target), [sym::rustc_lint_opt_ty, ..] => self.check_rustc_lint_opt_ty(attr, span, target),
[sym::rustc_lint_opt_deny_field_access, ..] => { [sym::rustc_lint_opt_deny_field_access, ..] => {
@ -452,11 +457,6 @@ fn check_optimize(&self, hir_id: HirId, attr: &Attribute, target: Target) {
} }
} }
/// Checks that `#[no_sanitize(..)]` is applied to a function or method.
fn check_no_sanitize(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) {
self.check_applied_to_fn_or_method(hir_id, attr, span, target)
}
fn check_generic_attr( fn check_generic_attr(
&self, &self,
hir_id: HirId, hir_id: HirId,
@ -1635,30 +1635,6 @@ fn check_applied_to_fn_or_method(
} }
} }
/// Checks that the `#[rustc_lint_query_instability]` attribute is only applied to a function
/// or method.
fn check_rustc_lint_query_instability(
&self,
hir_id: HirId,
attr: &Attribute,
span: Span,
target: Target,
) {
self.check_applied_to_fn_or_method(hir_id, attr, span, target)
}
/// Checks that the `#[rustc_lint_diagnostics]` attribute is only applied to a function or
/// method.
fn check_rustc_lint_diagnostics(
&self,
hir_id: HirId,
attr: &Attribute,
span: Span,
target: Target,
) {
self.check_applied_to_fn_or_method(hir_id, attr, span, target)
}
/// Checks that the `#[rustc_lint_opt_ty]` attribute is only applied to a struct. /// Checks that the `#[rustc_lint_opt_ty]` attribute is only applied to a struct.
fn check_rustc_lint_opt_ty(&self, attr: &Attribute, span: Span, target: Target) { fn check_rustc_lint_opt_ty(&self, attr: &Attribute, span: Span, target: Target) {
match target { match target {

View File

@ -1654,6 +1654,7 @@
rustc_lint_opt_deny_field_access, rustc_lint_opt_deny_field_access,
rustc_lint_opt_ty, rustc_lint_opt_ty,
rustc_lint_query_instability, rustc_lint_query_instability,
rustc_lint_untracked_query_information,
rustc_macro_transparency, rustc_macro_transparency,
rustc_main, rustc_main,
rustc_mir, rustc_mir,

View File

@ -2277,6 +2277,14 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// `addr_of!(expr)` is equivalent to `&raw const expr`. The macro is *soft-deprecated*; /// `addr_of!(expr)` is equivalent to `&raw const expr`. The macro is *soft-deprecated*;
/// use `&raw const` instead. /// use `&raw const` instead.
/// ///
/// It is still an open question under which conditions writing through an `addr_of!`-created
/// pointer is permitted. If the place `expr` evaluates to is based on a raw pointer, then the
/// result of `addr_of!` inherits all permissions from that raw pointer. However, if the place is
/// based on a reference, local variable, or `static`, then until all details are decided, the same
/// rules as for shared references apply: it is UB to write through a pointer created with this
/// operation, except for bytes located inside an `UnsafeCell`. Use `&raw mut` (or [`addr_of_mut`])
/// to create a raw pointer that definitely permits mutation.
///
/// Creating a reference with `&`/`&mut` is only allowed if the pointer is properly aligned /// Creating a reference with `&`/`&mut` is only allowed if the pointer is properly aligned
/// and points to initialized data. For cases where those requirements do not hold, /// and points to initialized data. For cases where those requirements do not hold,
/// raw pointers should be used instead. However, `&expr as *const _` creates a reference /// raw pointers should be used instead. However, `&expr as *const _` creates a reference

View File

@ -250,7 +250,7 @@ pub const fn from_secs(secs: u64) -> Duration {
/// ``` /// ```
/// use std::time::Duration; /// use std::time::Duration;
/// ///
/// let duration = Duration::from_millis(2569); /// let duration = Duration::from_millis(2_569);
/// ///
/// assert_eq!(2, duration.as_secs()); /// assert_eq!(2, duration.as_secs());
/// assert_eq!(569_000_000, duration.subsec_nanos()); /// assert_eq!(569_000_000, duration.subsec_nanos());
@ -279,7 +279,7 @@ pub const fn from_millis(millis: u64) -> Duration {
/// let duration = Duration::from_micros(1_000_002); /// let duration = Duration::from_micros(1_000_002);
/// ///
/// assert_eq!(1, duration.as_secs()); /// assert_eq!(1, duration.as_secs());
/// assert_eq!(2000, duration.subsec_nanos()); /// assert_eq!(2_000, duration.subsec_nanos());
/// ``` /// ```
#[stable(feature = "duration_from_micros", since = "1.27.0")] #[stable(feature = "duration_from_micros", since = "1.27.0")]
#[must_use] #[must_use]
@ -472,7 +472,7 @@ pub const fn is_zero(&self) -> bool {
/// ``` /// ```
/// use std::time::Duration; /// use std::time::Duration;
/// ///
/// let duration = Duration::new(5, 730023852); /// let duration = Duration::new(5, 730_023_852);
/// assert_eq!(duration.as_secs(), 5); /// assert_eq!(duration.as_secs(), 5);
/// ``` /// ```
/// ///
@ -501,7 +501,7 @@ pub const fn as_secs(&self) -> u64 {
/// ``` /// ```
/// use std::time::Duration; /// use std::time::Duration;
/// ///
/// let duration = Duration::from_millis(5432); /// let duration = Duration::from_millis(5_432);
/// assert_eq!(duration.as_secs(), 5); /// assert_eq!(duration.as_secs(), 5);
/// assert_eq!(duration.subsec_millis(), 432); /// assert_eq!(duration.subsec_millis(), 432);
/// ``` /// ```
@ -547,7 +547,7 @@ pub const fn subsec_micros(&self) -> u32 {
/// ``` /// ```
/// use std::time::Duration; /// use std::time::Duration;
/// ///
/// let duration = Duration::from_millis(5010); /// let duration = Duration::from_millis(5_010);
/// assert_eq!(duration.as_secs(), 5); /// assert_eq!(duration.as_secs(), 5);
/// assert_eq!(duration.subsec_nanos(), 10_000_000); /// assert_eq!(duration.subsec_nanos(), 10_000_000);
/// ``` /// ```
@ -566,8 +566,8 @@ pub const fn subsec_nanos(&self) -> u32 {
/// ``` /// ```
/// use std::time::Duration; /// use std::time::Duration;
/// ///
/// let duration = Duration::new(5, 730023852); /// let duration = Duration::new(5, 730_023_852);
/// assert_eq!(duration.as_millis(), 5730); /// assert_eq!(duration.as_millis(), 5_730);
/// ``` /// ```
#[stable(feature = "duration_as_u128", since = "1.33.0")] #[stable(feature = "duration_as_u128", since = "1.33.0")]
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")] #[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
@ -584,8 +584,8 @@ pub const fn as_millis(&self) -> u128 {
/// ``` /// ```
/// use std::time::Duration; /// use std::time::Duration;
/// ///
/// let duration = Duration::new(5, 730023852); /// let duration = Duration::new(5, 730_023_852);
/// assert_eq!(duration.as_micros(), 5730023); /// assert_eq!(duration.as_micros(), 5_730_023);
/// ``` /// ```
#[stable(feature = "duration_as_u128", since = "1.33.0")] #[stable(feature = "duration_as_u128", since = "1.33.0")]
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")] #[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
@ -602,8 +602,8 @@ pub const fn as_micros(&self) -> u128 {
/// ``` /// ```
/// use std::time::Duration; /// use std::time::Duration;
/// ///
/// let duration = Duration::new(5, 730023852); /// let duration = Duration::new(5, 730_023_852);
/// assert_eq!(duration.as_nanos(), 5730023852); /// assert_eq!(duration.as_nanos(), 5_730_023_852);
/// ``` /// ```
#[stable(feature = "duration_as_u128", since = "1.33.0")] #[stable(feature = "duration_as_u128", since = "1.33.0")]
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")] #[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
@ -879,7 +879,7 @@ pub const fn as_secs_f32(&self) -> f32 {
/// use std::time::Duration; /// use std::time::Duration;
/// ///
/// let dur = Duration::new(2, 345_678_000); /// let dur = Duration::new(2, 345_678_000);
/// assert_eq!(dur.as_millis_f64(), 2345.678); /// assert_eq!(dur.as_millis_f64(), 2_345.678);
/// ``` /// ```
#[unstable(feature = "duration_millis_float", issue = "122451")] #[unstable(feature = "duration_millis_float", issue = "122451")]
#[must_use] #[must_use]
@ -900,7 +900,7 @@ pub const fn as_millis_f64(&self) -> f64 {
/// use std::time::Duration; /// use std::time::Duration;
/// ///
/// let dur = Duration::new(2, 345_678_000); /// let dur = Duration::new(2, 345_678_000);
/// assert_eq!(dur.as_millis_f32(), 2345.678); /// assert_eq!(dur.as_millis_f32(), 2_345.678);
/// ``` /// ```
#[unstable(feature = "duration_millis_float", issue = "122451")] #[unstable(feature = "duration_millis_float", issue = "122451")]
#[must_use] #[must_use]
@ -1017,7 +1017,7 @@ pub fn mul_f64(self, rhs: f64) -> Duration {
/// ///
/// let dur = Duration::new(2, 700_000_000); /// let dur = Duration::new(2, 700_000_000);
/// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_641)); /// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_641));
/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847800, 0)); /// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847_800, 0));
/// ``` /// ```
#[stable(feature = "duration_float", since = "1.38.0")] #[stable(feature = "duration_float", since = "1.38.0")]
#[must_use = "this returns the result of the operation, \ #[must_use = "this returns the result of the operation, \

View File

@ -931,7 +931,12 @@ fn run(self, builder: &Builder<'_>) -> u32 {
// NOTE: the ABI of the beta compiler is different from the ABI of the downloaded compiler, // NOTE: the ABI of the beta compiler is different from the ABI of the downloaded compiler,
// so its artifacts can't be reused. // so its artifacts can't be reused.
if builder.download_rustc() && compiler.stage != 0 { if builder.download_rustc() && compiler.stage != 0 {
builder.ensure(Sysroot { compiler, force_recompile: false }); let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });
cp_rustc_component_to_ci_sysroot(
builder,
&sysroot,
builder.config.ci_rustc_dev_contents(),
);
return compiler.stage; return compiler.stage;
} }

View File

@ -1186,6 +1186,9 @@ fn run(self, builder: &Builder<'_>) {
cmd.arg("--rustc"); cmd.arg("--rustc");
cmd.arg(&rustc); cmd.arg(&rustc);
cmd.arg("--rustc-target").arg(self.target.rustc_target_arg()); cmd.arg("--rustc-target").arg(self.target.rustc_target_arg());
if let Some(target_linker) = builder.linker(self.target) {
cmd.arg("--rustc-linker").arg(target_linker);
}
if builder.is_verbose() { if builder.is_verbose() {
cmd.arg("--verbose"); cmd.arg("--verbose");
} }

View File

@ -3529,11 +3529,13 @@ fn make_run(run: RunConfig<'_>) {
fn run(self, builder: &Builder<'_>) { fn run(self, builder: &Builder<'_>) {
let bootstrap_host = builder.config.build; let bootstrap_host = builder.config.build;
let compiler = builder.compiler(0, bootstrap_host); let compiler = builder.compiler(builder.top_stage, bootstrap_host);
let path = self.path.to_str().unwrap(); let path = self.path.to_str().unwrap();
let crate_name = self.path.components().last().unwrap().as_os_str().to_str().unwrap(); let crate_name = self.path.components().last().unwrap().as_os_str().to_str().unwrap();
builder.ensure(compile::Std::new(compiler, self.host)); if !builder.download_rustc() {
builder.ensure(compile::Std::new(compiler, self.host));
}
// Run any unit tests in the crate // Run any unit tests in the crate
let cargo_test = tool::prepare_tool_cargo( let cargo_test = tool::prepare_tool_cargo(

View File

@ -332,14 +332,20 @@ pub fn new(mut config: Config) -> Build {
.trim() .trim()
.to_string(); .to_string();
let initial_libdir = initial_target_dir // FIXME(Zalathar): Determining this path occasionally fails locally for
.parent() // unknown reasons, so we print some extra context to help track down why.
.unwrap() let find_initial_libdir = || {
.parent() let initial_libdir =
.unwrap() initial_target_dir.parent()?.parent()?.strip_prefix(&initial_sysroot).ok()?;
.strip_prefix(&initial_sysroot) Some(initial_libdir.to_path_buf())
.unwrap() };
.to_path_buf(); let Some(initial_libdir) = find_initial_libdir() else {
panic!(
"couldn't determine `initial_libdir` \
from target dir {initial_target_dir:?} \
and sysroot {initial_sysroot:?}"
)
};
let version = std::fs::read_to_string(src.join("src").join("version")) let version = std::fs::read_to_string(src.join("src").join("version"))
.expect("failed to read src/version"); .expect("failed to read src/version");

View File

@ -56,6 +56,8 @@ pub struct LintExtractor<'a> {
pub rustc_path: &'a Path, pub rustc_path: &'a Path,
/// The target arch to build the docs for. /// The target arch to build the docs for.
pub rustc_target: &'a str, pub rustc_target: &'a str,
/// The target linker overriding `rustc`'s default
pub rustc_linker: Option<&'a str>,
/// Verbose output. /// Verbose output.
pub verbose: bool, pub verbose: bool,
/// Validate the style and the code example. /// Validate the style and the code example.
@ -459,6 +461,9 @@ fn generate_lint_output(
} }
cmd.arg("--error-format=json"); cmd.arg("--error-format=json");
cmd.arg("--target").arg(self.rustc_target); cmd.arg("--target").arg(self.rustc_target);
if let Some(target_linker) = self.rustc_linker {
cmd.arg(format!("-Clinker={target_linker}"));
}
if options.contains(&"test") { if options.contains(&"test") {
cmd.arg("--test"); cmd.arg("--test");
} }

View File

@ -27,6 +27,7 @@ fn doit() -> Result<(), Box<dyn Error>> {
let mut out_path = None; let mut out_path = None;
let mut rustc_path = None; let mut rustc_path = None;
let mut rustc_target = None; let mut rustc_target = None;
let mut rustc_linker = None;
let mut verbose = false; let mut verbose = false;
let mut validate = false; let mut validate = false;
while let Some(arg) = args.next() { while let Some(arg) = args.next() {
@ -55,6 +56,12 @@ fn doit() -> Result<(), Box<dyn Error>> {
None => return Err("--rustc-target requires a value".into()), None => return Err("--rustc-target requires a value".into()),
}; };
} }
"--rustc-linker" => {
rustc_linker = match args.next() {
Some(s) => Some(s),
None => return Err("--rustc-linker requires a value".into()),
};
}
"-v" | "--verbose" => verbose = true, "-v" | "--verbose" => verbose = true,
"--validate" => validate = true, "--validate" => validate = true,
s => return Err(format!("unexpected argument `{}`", s).into()), s => return Err(format!("unexpected argument `{}`", s).into()),
@ -77,6 +84,7 @@ fn doit() -> Result<(), Box<dyn Error>> {
out_path: &out_path.unwrap(), out_path: &out_path.unwrap(),
rustc_path: &rustc_path.unwrap(), rustc_path: &rustc_path.unwrap(),
rustc_target: &rustc_target.unwrap(), rustc_target: &rustc_target.unwrap(),
rustc_linker: rustc_linker.as_deref(),
verbose, verbose,
validate, validate,
}; };

View File

@ -464,6 +464,9 @@ macro_rules! experimental {
// Used by the `rustc::potential_query_instability` lint to warn methods which // Used by the `rustc::potential_query_instability` lint to warn methods which
// might not be stable during incremental compilation. // might not be stable during incremental compilation.
rustc_attr!(rustc_lint_query_instability, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE), rustc_attr!(rustc_lint_query_instability, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
// Used by the `rustc::untracked_query_information` lint to warn methods which
// might break incremental compilation.
rustc_attr!(rustc_lint_untracked_query_information, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
// Used by the `rustc::untranslatable_diagnostic` and `rustc::diagnostic_outside_of_impl` lints // Used by the `rustc::untranslatable_diagnostic` and `rustc::diagnostic_outside_of_impl` lints
// to assist in changes to diagnostic APIs. // to assist in changes to diagnostic APIs.
rustc_attr!(rustc_lint_diagnostics, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE), rustc_attr!(rustc_lint_diagnostics, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),

View File

@ -0,0 +1,16 @@
//@ compile-flags: -Z unstable-options
// #[cfg(bootstrap)]: We can stop ignoring next beta bump; afterward this ALWAYS should run.
//@ ignore-stage1 (requires matching sysroot built with in-tree compiler)
#![feature(rustc_private)]
#![deny(rustc::untracked_query_information)]
extern crate rustc_data_structures;
use rustc_data_structures::steal::Steal;
fn use_steal(x: Steal<()>) {
let _ = x.is_stolen();
//~^ ERROR `is_stolen` accesses information that is not tracked by the query system
}
fn main() {}

View File

@ -0,0 +1,15 @@
error: `is_stolen` accesses information that is not tracked by the query system
--> $DIR/query_completeness.rs:12:15
|
LL | let _ = x.is_stolen();
| ^^^^^^^^^
|
= note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
note: the lint level is defined here
--> $DIR/query_completeness.rs:5:9
|
LL | #![deny(rustc::untracked_query_information)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error

View File

@ -0,0 +1,21 @@
//@ needs-asm-support
//@ ignore-nvptx64
//@ ignore-spirv
#![feature(const_refs_to_static)]
use std::arch::{asm, global_asm};
use std::ptr::addr_of;
static FOO: u8 = 42;
global_asm!("{}", const addr_of!(FOO));
//~^ ERROR invalid type for `const` operand
#[no_mangle]
fn inline() {
unsafe { asm!("{}", const addr_of!(FOO)) };
//~^ ERROR invalid type for `const` operand
}
fn main() {}

View File

@ -0,0 +1,22 @@
error: invalid type for `const` operand
--> $DIR/const-refs-to-static.rs:12:19
|
LL | global_asm!("{}", const addr_of!(FOO));
| ^^^^^^-------------
| |
| is a `*const u8`
|
= help: `const` operands must be of an integer type
error: invalid type for `const` operand
--> $DIR/const-refs-to-static.rs:17:25
|
LL | unsafe { asm!("{}", const addr_of!(FOO)) };
| ^^^^^^-------------
| |
| is a `*const u8`
|
= help: `const` operands must be of an integer type
error: aborting due to 2 previous errors

View File

@ -16,7 +16,7 @@ impl Range for TwoDigits {
const fn digits(x: u8) -> usize { const fn digits(x: u8) -> usize {
match x { match x {
TwoDigits::FIRST..=TwoDigits::LAST => 0, TwoDigits::FIRST..=TwoDigits::LAST => 0, //~ ERROR: could not evaluate constant pattern
0..=9 | 100..=255 => panic!(), 0..=9 | 100..=255 => panic!(),
} }
} }

View File

@ -4,5 +4,11 @@ error: missing type for `const` item
LL | const FIRST: = 10; LL | const FIRST: = 10;
| ^ help: provide a type for the associated constant: `u8` | ^ help: provide a type for the associated constant: `u8`
error: aborting due to 1 previous error error: could not evaluate constant pattern
--> $DIR/missing_assoc_const_type.rs:19:9
|
LL | TwoDigits::FIRST..=TwoDigits::LAST => 0,
| ^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -1,4 +1,5 @@
//@ known-bug: #124164 // reported as #124164
static S_COUNT: = std::sync::atomic::AtomicUsize::new(0); static S_COUNT: = std::sync::atomic::AtomicUsize::new(0);
//~^ ERROR: missing type for `static` item
fn main() {} fn main() {}

View File

@ -0,0 +1,8 @@
error: missing type for `static` item
--> $DIR/missing-type.rs:2:16
|
LL | static S_COUNT: = std::sync::atomic::AtomicUsize::new(0);
| ^ help: provide a type for the static variable: `AtomicUsize`
error: aborting due to 1 previous error

View File

@ -1,6 +1,7 @@
//@ known-bug: rust-lang/rust#126896
//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes //@ compile-flags: -Zvalidate-mir -Zinline-mir=yes
// reported as rust-lang/rust#126896
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
type Two<'a, 'b> = impl std::fmt::Debug; type Two<'a, 'b> = impl std::fmt::Debug;
@ -9,9 +10,8 @@ fn set(x: &mut isize) -> isize {
} }
fn d(x: Two) { fn d(x: Two) {
let c1 = || set(x); let c1 = || set(x); //~ ERROR: expected generic lifetime parameter, found `'_`
c1; c1;
} }
fn main() { fn main() {}
}

View File

@ -0,0 +1,12 @@
error[E0792]: expected generic lifetime parameter, found `'_`
--> $DIR/taint.rs:13:17
|
LL | type Two<'a, 'b> = impl std::fmt::Debug;
| -- this generic parameter must be used with a generic lifetime parameter
...
LL | let c1 = || set(x);
| ^^^^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0792`.

View File

@ -914,6 +914,7 @@ cc = ["@kobzol"]
warn_non_default_branch = true warn_non_default_branch = true
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html" contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
users_on_vacation = [ users_on_vacation = [
"fmease",
"jhpratt", "jhpratt",
"joboet", "joboet",
"jyn514", "jyn514",