Skip to content

Commit 2efb0cd

Browse files
committed
Auto merge of #103954 - matthiaskrgr:rollup-tskpxnj, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #103825 (Remove let_underscore_must_use from list of uplifted lints) - #103884 (Add visit_fn_ret_ty to hir intravisit) - #103892 (Properly render asyncness for trait fns without default body) - #103905 (rustdoc: remove redundant mobile CSS `.sidebar-elems { background }`) - #103912 (Add howto for adding new targets) - #103915 (Improve use of ErrorGuaranteed and code cleanup) - #103930 (Move some tests from `src/test/ui` to more reasonable places) - #103931 (Add note to RELEASES.md regarding issue 102754.) - #103938 (rustdoc: clean up hardcoded CSS border color on search results) - #103940 (rustdoc: remove no-op CSS `#main-content > .item-info { margin-top: 0 }`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 15d7556 + 923d907 commit 2efb0cd

File tree

34 files changed

+125
-83
lines changed

34 files changed

+125
-83
lines changed

RELEASES.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Language
66
- [Error on `as` casts of enums with `#[non_exhaustive]` variants](https://github.com/rust-lang/rust/pull/92744/)
77
- [Stabilize `let else`](https://github.com/rust-lang/rust/pull/93628/)
88
- [Stabilize generic associated types (GATs)](https://github.com/rust-lang/rust/pull/96709/)
9-
- [Add lints `let_underscore_drop`, `let_underscore_lock`, and `let_underscore_must_use` from Clippy](https://github.com/rust-lang/rust/pull/97739/)
9+
- [Add lints `let_underscore_drop` and `let_underscore_lock` from Clippy](https://github.com/rust-lang/rust/pull/97739/)
1010
- [Stabilize `break`ing from arbitrary labeled blocks ("label-break-value")](https://github.com/rust-lang/rust/pull/99332/)
1111
- [Uninitialized integers, floats, and raw pointers are now considered immediate UB](https://github.com/rust-lang/rust/pull/98919/).
1212
Usage of `MaybeUninit` is the correct way to work with uninitialized memory.
@@ -87,6 +87,9 @@ Compatibility Notes
8787
This strengthens the forward compatibility lint deprecated_cfg_attr_crate_type_name to deny.
8888
- [`llvm-has-rust-patches` allows setting the build system to treat the LLVM as having Rust-specific patches](https://github.com/rust-lang/rust/pull/101072)
8989
This option may need to be set for distributions that are building Rust with a patched LLVM via `llvm-config`, not the built-in LLVM.
90+
- Combining three or more languages (e.g. Objective C, C++ and Rust) into one binary may hit linker limitations when using `lld`. For more information, see [issue 102754][102754].
91+
92+
[102754]: https://github.com/rust-lang/rust/issues/102754
9093

9194
Internal Changes
9295
----------------

compiler/rustc_const_eval/src/interpret/operand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use rustc_hir::def::Namespace;
55
use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout};
66
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter};
7-
use rustc_middle::ty::{ConstInt, DelaySpanBugEmitted, Ty};
7+
use rustc_middle::ty::{ConstInt, Ty};
88
use rustc_middle::{mir, ty};
99
use rustc_target::abi::{self, Abi, Align, HasDataLayout, Size, TagEncoding};
1010
use rustc_target::abi::{VariantIdx, Variants};
@@ -567,7 +567,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
567567
ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(..) => {
568568
throw_inval!(TooGeneric)
569569
}
570-
ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => {
570+
ty::ConstKind::Error(reported) => {
571571
throw_inval!(AlreadyReported(reported))
572572
}
573573
ty::ConstKind::Unevaluated(uv) => {

compiler/rustc_const_eval/src/transform/promote_consts.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ impl<'tcx> MirPass<'tcx> for PromoteTemps<'tcx> {
4545
// There's not really any point in promoting errorful MIR.
4646
//
4747
// This does not include MIR that failed const-checking, which we still try to promote.
48-
if body.return_ty().references_error() {
49-
tcx.sess.delay_span_bug(body.span, "PromoteTemps: MIR had errors");
48+
if let Err(_) = body.return_ty().error_reported() {
49+
debug!("PromoteTemps: MIR had errors");
5050
return;
5151
}
52-
5352
if body.source.promoted.is_some() {
5453
return;
5554
}

compiler/rustc_hir/src/intravisit.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ pub trait Visitor<'v>: Sized {
358358
fn visit_where_predicate(&mut self, predicate: &'v WherePredicate<'v>) {
359359
walk_where_predicate(self, predicate)
360360
}
361+
fn visit_fn_ret_ty(&mut self, ret_ty: &'v FnRetTy<'v>) {
362+
walk_fn_ret_ty(self, ret_ty)
363+
}
361364
fn visit_fn_decl(&mut self, fd: &'v FnDecl<'v>) {
362365
walk_fn_decl(self, fd)
363366
}
@@ -903,7 +906,7 @@ pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &
903906
for ty in function_declaration.inputs {
904907
visitor.visit_ty(ty)
905908
}
906-
walk_fn_ret_ty(visitor, &function_declaration.output)
909+
visitor.visit_fn_ret_ty(&function_declaration.output)
907910
}
908911

909912
pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FnRetTy<'v>) {

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
19791979
}
19801980

19811981
err.emit()
1982-
} else if let Some(reported) = qself_ty.error_reported() {
1982+
} else if let Err(reported) = qself_ty.error_reported() {
19831983
reported
19841984
} else {
19851985
// Don't print `TyErr` to the user.

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ pub(crate) fn orphan_check_impl(
2323
impl_def_id: LocalDefId,
2424
) -> Result<(), ErrorGuaranteed> {
2525
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
26-
if let Some(err) = trait_ref.error_reported() {
27-
return Err(err);
28-
}
26+
trait_ref.error_reported()?;
2927

3028
let ret = do_orphan_check_impl(tcx, trait_ref, impl_def_id);
3129
if tcx.trait_is_auto(trait_ref.def_id) {

compiler/rustc_hir_typeck/src/cast.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9494
debug!("pointer_kind({:?}, {:?})", t, span);
9595

9696
let t = self.resolve_vars_if_possible(t);
97-
98-
if let Some(reported) = t.error_reported() {
99-
return Err(reported);
100-
}
97+
t.error_reported()?;
10198

10299
if self.type_is_sized_modulo_regions(self.param_env, t, span) {
103100
return Ok(Some(PointerKind::Thin));
@@ -222,8 +219,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
222219
// inference is more completely known.
223220
match cast_ty.kind() {
224221
ty::Dynamic(_, _, ty::Dyn) | ty::Slice(..) => {
225-
let reported = check.report_cast_to_unsized_type(fcx);
226-
Err(reported)
222+
Err(check.report_cast_to_unsized_type(fcx))
227223
}
228224
_ => Ok(check),
229225
}
@@ -614,10 +610,11 @@ impl<'a, 'tcx> CastCheck<'tcx> {
614610
}
615611

616612
fn report_cast_to_unsized_type(&self, fcx: &FnCtxt<'a, 'tcx>) -> ErrorGuaranteed {
617-
if let Some(reported) =
618-
self.cast_ty.error_reported().or_else(|| self.expr_ty.error_reported())
619-
{
620-
return reported;
613+
if let Err(err) = self.cast_ty.error_reported() {
614+
return err;
615+
}
616+
if let Err(err) = self.expr_ty.error_reported() {
617+
return err;
621618
}
622619

623620
let tstr = fcx.ty_to_string(self.cast_ty);

compiler/rustc_middle/src/traits/specialization_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ pub fn ancestors<'tcx>(
262262

263263
if let Some(reported) = specialization_graph.has_errored {
264264
Err(reported)
265-
} else if let Some(reported) = tcx.type_of(start_from_impl).error_reported() {
265+
} else if let Err(reported) = tcx.type_of(start_from_impl).error_reported() {
266266
Err(reported)
267267
} else {
268268
Ok(Ancestors {

compiler/rustc_middle/src/ty/abstract_const.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! A subset of a mir body used for const evaluatability checking.
22
use crate::mir;
33
use crate::ty::visit::TypeVisitable;
4-
use crate::ty::{self, DelaySpanBugEmitted, EarlyBinder, SubstsRef, Ty, TyCtxt};
4+
use crate::ty::{self, EarlyBinder, SubstsRef, Ty, TyCtxt};
55
use rustc_errors::ErrorGuaranteed;
66
use rustc_hir::def_id::DefId;
77
use std::cmp;
@@ -43,7 +43,7 @@ impl<'tcx> AbstractConst<'tcx> {
4343
) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> {
4444
match ct.kind() {
4545
ty::ConstKind::Unevaluated(uv) => AbstractConst::new(tcx, uv),
46-
ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => Err(reported),
46+
ty::ConstKind::Error(reported) => Err(reported),
4747
_ => Ok(None),
4848
}
4949
}

compiler/rustc_middle/src/ty/consts/kind.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub enum ConstKind<'tcx> {
6969

7070
/// A placeholder for a const which could not be computed; this is
7171
/// propagated to avoid useless error messages.
72-
Error(ty::DelaySpanBugEmitted),
72+
Error(ErrorGuaranteed),
7373
}
7474

7575
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]

compiler/rustc_middle/src/ty/context.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
117117
type BoundTy = ty::BoundTy;
118118
type PlaceholderType = ty::PlaceholderType;
119119
type InferTy = InferTy;
120-
type DelaySpanBugEmitted = DelaySpanBugEmitted;
120+
type ErrorGuaranteed = ErrorGuaranteed;
121121
type PredicateKind = ty::PredicateKind<'tcx>;
122122
type AllocId = crate::mir::interpret::AllocId;
123123

@@ -128,15 +128,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
128128
type PlaceholderRegion = ty::PlaceholderRegion;
129129
}
130130

131-
/// A type that is not publicly constructable. This prevents people from making [`TyKind::Error`]s
132-
/// except through the error-reporting functions on a [`tcx`][TyCtxt].
133-
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
134-
#[derive(TyEncodable, TyDecodable, HashStable)]
135-
pub struct DelaySpanBugEmitted {
136-
pub reported: ErrorGuaranteed,
137-
_priv: (),
138-
}
139-
140131
type InternedSet<'tcx, T> = ShardedHashMap<InternedInSet<'tcx, T>, ()>;
141132

142133
pub struct CtxtInterners<'tcx> {
@@ -1303,7 +1294,7 @@ impl<'tcx> TyCtxt<'tcx> {
13031294
#[track_caller]
13041295
pub fn ty_error_with_message<S: Into<MultiSpan>>(self, span: S, msg: &str) -> Ty<'tcx> {
13051296
let reported = self.sess.delay_span_bug(span, msg);
1306-
self.mk_ty(Error(DelaySpanBugEmitted { reported, _priv: () }))
1297+
self.mk_ty(Error(reported))
13071298
}
13081299

13091300
/// Like [TyCtxt::ty_error] but for constants.
@@ -1325,10 +1316,7 @@ impl<'tcx> TyCtxt<'tcx> {
13251316
msg: &str,
13261317
) -> Const<'tcx> {
13271318
let reported = self.sess.delay_span_bug(span, msg);
1328-
self.mk_const(ty::ConstS {
1329-
kind: ty::ConstKind::Error(DelaySpanBugEmitted { reported, _priv: () }),
1330-
ty,
1331-
})
1319+
self.mk_const(ty::ConstS { kind: ty::ConstKind::Error(reported), ty })
13321320
}
13331321

13341322
pub fn consider_optimizing<T: Fn() -> String>(self, msg: T) -> bool {

compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub use self::consts::{
8080
};
8181
pub use self::context::{
8282
tls, CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations,
83-
CtxtInterners, DeducedParamAttrs, DelaySpanBugEmitted, FreeRegionInfo, GeneratorDiagnosticData,
83+
CtxtInterners, DeducedParamAttrs, FreeRegionInfo, GeneratorDiagnosticData,
8484
GeneratorInteriorTypeCause, GlobalCtxt, Lift, OnDiskCache, TyCtxt, TypeckResults, UserType,
8585
UserTypeAnnotationIndex,
8686
};

compiler/rustc_middle/src/ty/structural_impls.rs

-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ TrivialTypeTraversalAndLiftImpls! {
240240
Field,
241241
interpret::Scalar,
242242
rustc_target::abi::Size,
243-
ty::DelaySpanBugEmitted,
244243
rustc_type_ir::DebruijnIndex,
245244
ty::BoundVar,
246245
ty::Placeholder<ty::BoundVar>,

compiler/rustc_middle/src/ty/visit.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ pub trait TypeVisitable<'tcx>: fmt::Debug + Clone {
9595
fn references_error(&self) -> bool {
9696
self.has_type_flags(TypeFlags::HAS_ERROR)
9797
}
98-
fn error_reported(&self) -> Option<ErrorGuaranteed> {
98+
fn error_reported(&self) -> Result<(), ErrorGuaranteed> {
9999
if self.references_error() {
100-
Some(ErrorGuaranteed::unchecked_claim_error_was_emitted())
100+
Err(ErrorGuaranteed::unchecked_claim_error_was_emitted())
101101
} else {
102-
None
102+
Ok(())
103103
}
104104
}
105105
fn has_non_region_param(&self) -> bool {

compiler/rustc_transmute/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ mod rustc {
122122

123123
let c = c.eval(tcx, param_env);
124124

125-
if let Some(err) = c.error_reported() {
125+
if let Err(err) = c.error_reported() {
126126
return Some(Self {
127127
alignment: true,
128128
lifetimes: true,

compiler/rustc_ty_utils/src/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Ty<'_>> {
413413
/// Check if a function is async.
414414
fn asyncness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::IsAsync {
415415
let node = tcx.hir().get_by_def_id(def_id.expect_local());
416-
if let Some(fn_kind) = node.fn_kind() { fn_kind.asyncness() } else { hir::IsAsync::NotAsync }
416+
node.fn_sig().map_or(hir::IsAsync::NotAsync, |sig| sig.header.asyncness)
417417
}
418418

419419
/// Don't call this directly: use ``tcx.conservative_is_privately_uninhabited`` instead.

compiler/rustc_type_ir/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub trait Interner {
4545
type BoundTy: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
4646
type PlaceholderType: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
4747
type InferTy: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
48-
type DelaySpanBugEmitted: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
48+
type ErrorGuaranteed: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
4949
type PredicateKind: Clone + Debug + Hash + PartialEq + Eq;
5050
type AllocId: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
5151

compiler/rustc_type_ir/src/sty.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub enum TyKind<I: Interner> {
217217

218218
/// A placeholder for a type which could not be computed; this is
219219
/// propagated to avoid useless error messages.
220-
Error(I::DelaySpanBugEmitted),
220+
Error(I::ErrorGuaranteed),
221221
}
222222

223223
impl<I: Interner> TyKind<I> {
@@ -626,7 +626,7 @@ impl<I: Interner> fmt::Debug for TyKind<I> {
626626
// This is manually implemented because a derive would require `I: Encodable`
627627
impl<I: Interner, E: TyEncoder> Encodable<E> for TyKind<I>
628628
where
629-
I::DelaySpanBugEmitted: Encodable<E>,
629+
I::ErrorGuaranteed: Encodable<E>,
630630
I::AdtDef: Encodable<E>,
631631
I::SubstsRef: Encodable<E>,
632632
I::DefId: Encodable<E>,
@@ -645,7 +645,6 @@ where
645645
I::BoundTy: Encodable<E>,
646646
I::PlaceholderType: Encodable<E>,
647647
I::InferTy: Encodable<E>,
648-
I::DelaySpanBugEmitted: Encodable<E>,
649648
I::PredicateKind: Encodable<E>,
650649
I::AllocId: Encodable<E>,
651650
{
@@ -744,7 +743,7 @@ where
744743
// This is manually implemented because a derive would require `I: Decodable`
745744
impl<I: Interner, D: TyDecoder<I = I>> Decodable<D> for TyKind<I>
746745
where
747-
I::DelaySpanBugEmitted: Decodable<D>,
746+
I::ErrorGuaranteed: Decodable<D>,
748747
I::AdtDef: Decodable<D>,
749748
I::SubstsRef: Decodable<D>,
750749
I::DefId: Decodable<D>,
@@ -763,7 +762,6 @@ where
763762
I::BoundTy: Decodable<D>,
764763
I::PlaceholderType: Decodable<D>,
765764
I::InferTy: Decodable<D>,
766-
I::DelaySpanBugEmitted: Decodable<D>,
767765
I::PredicateKind: Decodable<D>,
768766
I::AllocId: Decodable<D>,
769767
{
@@ -829,7 +827,7 @@ where
829827
I::ParamTy: HashStable<CTX>,
830828
I::PlaceholderType: HashStable<CTX>,
831829
I::InferTy: HashStable<CTX>,
832-
I::DelaySpanBugEmitted: HashStable<CTX>,
830+
I::ErrorGuaranteed: HashStable<CTX>,
833831
{
834832
#[inline]
835833
fn hash_stable(

src/doc/rustc/src/target-tier-policy.md

+25
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Table of Contents
44

55
* [General](#general)
6+
* [Adding a new target](#adding-a-new-target)
67
* [Tier 3 target policy](#tier-3-target-policy)
78
* [Tier 2 target policy](#tier-2-target-policy)
89
* [Tier 2 with host tools](#tier-2-with-host-tools)
@@ -104,6 +105,30 @@ indicates something entirely optional, and does not indicate guidance or
104105
recommendations. This language is based on [IETF RFC
105106
2119](https://tools.ietf.org/html/rfc2119).
106107

108+
## Adding a new target
109+
110+
New targets typically start as Tier 3 and then can be promoted later.
111+
To propose addition of a new target, open a pull request on [`rust-lang/rust`]:
112+
113+
- Copy the [Tier 3 target policy](#tier-3-target-policy) to the description
114+
and fill it out, see [example][tier3example].
115+
- Add a new description for the target in `src/doc/rustc/src/platform-support`
116+
using the [template][platform_template].
117+
- Add the target to the [SUMMARY.md][summary] (allows wildcards) and
118+
[platform-support.md][platformsupport] (must name all targets verbatim).
119+
Link to the created description page.
120+
- Ensure the pull request is assigned to a member of the [Rust compiler team][rust_compiler_team] by commenting:
121+
```text
122+
r? compiler-team
123+
```
124+
125+
[tier3example]: https://github.com/rust-lang/rust/pull/94872
126+
[platform_template]: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/TEMPLATE.md
127+
[summary]: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/SUMMARY.md
128+
[platformsupport]: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support.md
129+
[rust_compiler_team]: https://www.rust-lang.org/governance/teams/compiler
130+
[`rust-lang/rust`]: https://github.com/rust-lang/rust
131+
107132
## Tier 3 target policy
108133

109134
At this tier, the Rust project provides no official support for a target, so we

0 commit comments

Comments
 (0)