Skip to content

Commit d678b81

Browse files
committed
Auto merge of rust-lang#129999 - matthiaskrgr:rollup-pzr9c8p, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang#128919 (Add an internal lint that warns when accessing untracked data) - rust-lang#129472 (fix ICE when `asm_const` and `const_refs_to_static` are combined) - rust-lang#129653 (clarify that addr_of creates read-only pointers) - rust-lang#129775 (bootstrap: Try to track down why `initial_libdir` sometimes fails) - rust-lang#129939 (explain why Rvalue::Len still exists) - rust-lang#129942 (copy rustc rustlib artifacts from ci-rustc) - rust-lang#129943 (use the bootstrapped compiler for `test-float-parse` test) - rust-lang#129944 (Add compat note for trait solver change) - rust-lang#129947 (Add digit separators in `Duration` examples) - rust-lang#129955 (Temporarily remove fmease from the review rotation) - rust-lang#129957 (forward linker option to lint-docs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 54fdef7 + d34ad5d commit d678b81

File tree

32 files changed

+241
-70
lines changed

32 files changed

+241
-70
lines changed

RELEASES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ Compatibility Notes
100100
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()`.
101101

102102
* 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.
103+
* [In very rare cases, a change in the internal evaluation order of the trait
104+
solver may result in new fatal overflow errors.](https://github.com/rust-lang/rust/pull/126128)
105+
103106

104107
<a id="1.81.0-Internal-Changes"></a>
105108

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2522,7 +2522,7 @@ mod diags {
25222522
}
25232523

25242524
pub(crate) fn emit_errors(&mut self) -> Option<ErrorGuaranteed> {
2525-
let mut res = None;
2525+
let mut res = self.infcx.tainted_by_errors();
25262526

25272527
// Buffer any move errors that we collected and de-duplicated.
25282528
for (_, (_, diag)) in std::mem::take(&mut self.diags.buffered_move_errors) {

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ use rustc_macros::extension;
2929
use rustc_middle::ty::fold::TypeFoldable;
3030
use rustc_middle::ty::print::with_no_trimmed_paths;
3131
use rustc_middle::ty::{
32-
self, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty, TyCtxt,
32+
self, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty,
33+
TyCtxt, TypeVisitableExt,
3334
};
3435
use rustc_middle::{bug, span_bug};
3536
use rustc_span::symbol::{kw, sym};
@@ -688,7 +689,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
688689
defining_ty: DefiningTy<'tcx>,
689690
) -> ty::Binder<'tcx, &'tcx ty::List<Ty<'tcx>>> {
690691
let tcx = self.infcx.tcx;
691-
match defining_ty {
692+
693+
let inputs_and_output = match defining_ty {
692694
DefiningTy::Closure(def_id, args) => {
693695
assert_eq!(self.mir_def.to_def_id(), def_id);
694696
let closure_sig = args.as_closure().sig();
@@ -798,6 +800,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
798800
// "output" (the type of the constant).
799801
assert_eq!(self.mir_def.to_def_id(), def_id);
800802
let ty = tcx.type_of(self.mir_def).instantiate_identity();
803+
801804
let ty = indices.fold_to_region_vids(tcx, ty);
802805
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
803806
}
@@ -807,7 +810,14 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
807810
let ty = args.as_inline_const().ty();
808811
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
809812
}
813+
};
814+
815+
// FIXME(#129952): We probably want a more principled approach here.
816+
if let Err(terr) = inputs_and_output.skip_binder().error_reported() {
817+
self.infcx.set_tainted_by_errors(terr);
810818
}
819+
820+
inputs_and_output
811821
}
812822
}
813823

compiler/rustc_data_structures/src/steal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ impl<T> Steal<T> {
5757
///
5858
/// This should not be used within rustc as it leaks information not tracked
5959
/// by the query system, breaking incremental compilation.
60+
#[cfg_attr(not(bootstrap), rustc_lint_untracked_query_information)]
6061
pub fn is_stolen(&self) -> bool {
6162
self.value.borrow().is_none()
6263
}

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,12 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
793793
rustc_lint_query_instability, Normal, template!(Word),
794794
WarnFollowing, EncodeCrossCrate::Yes, INTERNAL_UNSTABLE
795795
),
796+
// Used by the `rustc::untracked_query_information` lint to warn methods which
797+
// might not be stable during incremental compilation.
798+
rustc_attr!(
799+
rustc_lint_untracked_query_information, Normal, template!(Word),
800+
WarnFollowing, EncodeCrossCrate::Yes, INTERNAL_UNSTABLE
801+
),
796802
// Used by the `rustc::diagnostic_outside_of_impl` lints to assist in changes to diagnostic
797803
// APIs. Any function with this attribute will be checked by that lint.
798804
rustc_attr!(

compiler/rustc_lint/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,9 @@ lint_ptr_null_checks_ref = references are not nullable, so checking them for nul
699699
lint_query_instability = using `{$query}` can result in unstable query results
700700
.note = if you believe this case to be fine, allow this lint and add a comment explaining your rationale
701701
702+
lint_query_untracked = `{$method}` accesses information that is not tracked by the query system
703+
.note = if you believe this case to be fine, allow this lint and add a comment explaining your rationale
704+
702705
lint_range_endpoint_out_of_range = range endpoint is out of range for `{$ty}`
703706
704707
lint_range_use_inclusive_range = use an inclusive range instead

compiler/rustc_lint/src/internal.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use tracing::debug;
1717

1818
use crate::lints::{
1919
BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword,
20-
NonGlobImportTypeIrInherent, QueryInstability, SpanUseEqCtxtDiag, TyQualified, TykindDiag,
21-
TykindKind, TypeIrInherentUsage, UntranslatableDiag,
20+
NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, SpanUseEqCtxtDiag, TyQualified,
21+
TykindDiag, TykindKind, TypeIrInherentUsage, UntranslatableDiag,
2222
};
2323
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
2424

@@ -88,7 +88,18 @@ declare_tool_lint! {
8888
report_in_external_macro: true
8989
}
9090

91-
declare_lint_pass!(QueryStability => [POTENTIAL_QUERY_INSTABILITY]);
91+
declare_tool_lint! {
92+
/// The `untracked_query_information` lint detects use of methods which leak information not
93+
/// tracked by the query system, such as whether a `Steal<T>` value has already been stolen. In
94+
/// order not to break incremental compilation, such methods must be used very carefully or not
95+
/// at all.
96+
pub rustc::UNTRACKED_QUERY_INFORMATION,
97+
Allow,
98+
"require explicit opt-in when accessing information not tracked by the query system",
99+
report_in_external_macro: true
100+
}
101+
102+
declare_lint_pass!(QueryStability => [POTENTIAL_QUERY_INSTABILITY, UNTRACKED_QUERY_INFORMATION]);
92103

93104
impl LateLintPass<'_> for QueryStability {
94105
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
@@ -102,6 +113,13 @@ impl LateLintPass<'_> for QueryStability {
102113
QueryInstability { query: cx.tcx.item_name(def_id) },
103114
);
104115
}
116+
if cx.tcx.has_attr(def_id, sym::rustc_lint_untracked_query_information) {
117+
cx.emit_span_lint(
118+
UNTRACKED_QUERY_INFORMATION,
119+
span,
120+
QueryUntracked { method: cx.tcx.item_name(def_id) },
121+
);
122+
}
105123
}
106124
}
107125
}

compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ fn register_internals(store: &mut LintStore) {
610610
vec![
611611
LintId::of(DEFAULT_HASH_TYPES),
612612
LintId::of(POTENTIAL_QUERY_INSTABILITY),
613+
LintId::of(UNTRACKED_QUERY_INFORMATION),
613614
LintId::of(USAGE_OF_TY_TYKIND),
614615
LintId::of(PASS_BY_VALUE),
615616
LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),

compiler/rustc_lint/src/lints.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,13 @@ pub(crate) struct QueryInstability {
894894
pub query: Symbol,
895895
}
896896

897+
#[derive(LintDiagnostic)]
898+
#[diag(lint_query_untracked)]
899+
#[note]
900+
pub(crate) struct QueryUntracked {
901+
pub method: Symbol,
902+
}
903+
897904
#[derive(LintDiagnostic)]
898905
#[diag(lint_span_use_eq_ctxt)]
899906
pub(crate) struct SpanUseEqCtxtDiag;

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,9 @@ pub enum Rvalue<'tcx> {
13071307
/// If the type of the place is an array, this is the array length. For slices (`[T]`, not
13081308
/// `&[T]`) this accesses the place's metadata to determine the length. This rvalue is
13091309
/// ill-formed for places of other types.
1310+
///
1311+
/// This cannot be a `UnOp(PtrMetadata, _)` because that expects a value, and we only
1312+
/// have a place, and `UnOp(PtrMetadata, RawPtr(place))` is not a thing.
13101313
Len(Place<'tcx>),
13111314

13121315
/// Performs essentially all of the casts that can be performed via `as`.

0 commit comments

Comments
 (0)