Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #103954

Merged
merged 23 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a0c21e4
Remove let_underscore_must_use from list of uplifted lints
Mark-Simulacrum Nov 1, 2022
7df9d81
deprecate DelaySpanBugEmitted and use ErrorGuaranteed directly
chenyukang Nov 2, 2022
59be515
Properly render asyncness for traits without default body
compiler-errors Nov 2, 2022
ab22f55
change error_reported to use Result instead of an option
chenyukang Nov 2, 2022
68e19aa
rustdoc: remove redundant mobile CSS `.sidebar-elems { background }`
notriddle Nov 2, 2022
a21a055
remove 'delay_span_bug' following 'references_error'
chenyukang Nov 3, 2022
c6d23bd
code cleanup
chenyukang Nov 3, 2022
87b2110
Add howto for adding new targets
flba-eb Nov 3, 2022
ba18f16
Add visit_fn_ret_ty to hir intravisit
spastorino Oct 26, 2022
9c79a27
Add note to RELEASES.md regarding issue 102754.
pnkfelix Nov 3, 2022
35b16d0
Move some tests from `src/test/ui` to more reasonable places
fee1-dead Nov 3, 2022
f097940
rustdoc: clean up hardcoded CSS border color on search results
notriddle Nov 3, 2022
c51c07d
rustdoc: remove no-op CSS `#main-content > .item-info { margin-top: 0 }`
notriddle Nov 3, 2022
a5efeb3
Rollup merge of #103825 - Mark-Simulacrum:fix-relnotes, r=pietroalbini
matthiaskrgr Nov 4, 2022
14fdfcb
Rollup merge of #103884 - spastorino:visit-fn-ret-ty-intravisit, r=co…
matthiaskrgr Nov 4, 2022
6e582ca
Rollup merge of #103892 - compiler-errors:afit-rustdoc, r=GuillaumeGomez
matthiaskrgr Nov 4, 2022
a81a531
Rollup merge of #103905 - notriddle:notriddle/sidebar-elems-backgroun…
matthiaskrgr Nov 4, 2022
47bf743
Rollup merge of #103912 - flba-eb:doc_adding_tier3_target, r=davidtwco
matthiaskrgr Nov 4, 2022
61c6cdb
Rollup merge of #103915 - chenyukang:yukang/fix-103874, r=lcnr
matthiaskrgr Nov 4, 2022
e6eaa2f
Rollup merge of #103930 - fee1-dead-contrib:mv-from-root, r=jyn514
matthiaskrgr Nov 4, 2022
9ef3b41
Rollup merge of #103931 - pnkfelix:note-eh-personality-limit-atop-lld…
matthiaskrgr Nov 4, 2022
f35dccb
Rollup merge of #103938 - notriddle:notriddle/search-results-border-b…
matthiaskrgr Nov 4, 2022
923d907
Rollup merge of #103940 - notriddle:notriddle/main-content-item-info-…
matthiaskrgr Nov 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Language
- [Error on `as` casts of enums with `#[non_exhaustive]` variants](https://github.com/rust-lang/rust/pull/92744/)
- [Stabilize `let else`](https://github.com/rust-lang/rust/pull/93628/)
- [Stabilize generic associated types (GATs)](https://github.com/rust-lang/rust/pull/96709/)
- [Add lints `let_underscore_drop`, `let_underscore_lock`, and `let_underscore_must_use` from Clippy](https://github.com/rust-lang/rust/pull/97739/)
- [Add lints `let_underscore_drop` and `let_underscore_lock` from Clippy](https://github.com/rust-lang/rust/pull/97739/)
- [Stabilize `break`ing from arbitrary labeled blocks ("label-break-value")](https://github.com/rust-lang/rust/pull/99332/)
- [Uninitialized integers, floats, and raw pointers are now considered immediate UB](https://github.com/rust-lang/rust/pull/98919/).
Usage of `MaybeUninit` is the correct way to work with uninitialized memory.
Expand Down Expand Up @@ -87,6 +87,9 @@ Compatibility Notes
This strengthens the forward compatibility lint deprecated_cfg_attr_crate_type_name to deny.
- [`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)
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.
- 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].

[102754]: https://github.com/rust-lang/rust/issues/102754

Internal Changes
----------------
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use rustc_hir::def::Namespace;
use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout};
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter};
use rustc_middle::ty::{ConstInt, DelaySpanBugEmitted, Ty};
use rustc_middle::ty::{ConstInt, Ty};
use rustc_middle::{mir, ty};
use rustc_target::abi::{self, Abi, Align, HasDataLayout, Size, TagEncoding};
use rustc_target::abi::{VariantIdx, Variants};
Expand Down Expand Up @@ -567,7 +567,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(..) => {
throw_inval!(TooGeneric)
}
ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => {
ty::ConstKind::Error(reported) => {
throw_inval!(AlreadyReported(reported))
}
ty::ConstKind::Unevaluated(uv) => {
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_const_eval/src/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ impl<'tcx> MirPass<'tcx> for PromoteTemps<'tcx> {
// There's not really any point in promoting errorful MIR.
//
// This does not include MIR that failed const-checking, which we still try to promote.
if body.return_ty().references_error() {
tcx.sess.delay_span_bug(body.span, "PromoteTemps: MIR had errors");
if let Err(_) = body.return_ty().error_reported() {
debug!("PromoteTemps: MIR had errors");
return;
}

if body.source.promoted.is_some() {
return;
}
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ pub trait Visitor<'v>: Sized {
fn visit_where_predicate(&mut self, predicate: &'v WherePredicate<'v>) {
walk_where_predicate(self, predicate)
}
fn visit_fn_ret_ty(&mut self, ret_ty: &'v FnRetTy<'v>) {
walk_fn_ret_ty(self, ret_ty)
}
fn visit_fn_decl(&mut self, fd: &'v FnDecl<'v>) {
walk_fn_decl(self, fd)
}
Expand Down Expand Up @@ -903,7 +906,7 @@ pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &
for ty in function_declaration.inputs {
visitor.visit_ty(ty)
}
walk_fn_ret_ty(visitor, &function_declaration.output)
visitor.visit_fn_ret_ty(&function_declaration.output)
}

pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FnRetTy<'v>) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}

err.emit()
} else if let Some(reported) = qself_ty.error_reported() {
} else if let Err(reported) = qself_ty.error_reported() {
reported
} else {
// Don't print `TyErr` to the user.
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ pub(crate) fn orphan_check_impl(
impl_def_id: LocalDefId,
) -> Result<(), ErrorGuaranteed> {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
if let Some(err) = trait_ref.error_reported() {
return Err(err);
}
trait_ref.error_reported()?;

let ret = do_orphan_check_impl(tcx, trait_ref, impl_def_id);
if tcx.trait_is_auto(trait_ref.def_id) {
Expand Down
17 changes: 7 additions & 10 deletions compiler/rustc_hir_typeck/src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
debug!("pointer_kind({:?}, {:?})", t, span);

let t = self.resolve_vars_if_possible(t);

if let Some(reported) = t.error_reported() {
return Err(reported);
}
t.error_reported()?;

if self.type_is_sized_modulo_regions(self.param_env, t, span) {
return Ok(Some(PointerKind::Thin));
Expand Down Expand Up @@ -222,8 +219,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
// inference is more completely known.
match cast_ty.kind() {
ty::Dynamic(_, _, ty::Dyn) | ty::Slice(..) => {
let reported = check.report_cast_to_unsized_type(fcx);
Err(reported)
Err(check.report_cast_to_unsized_type(fcx))
}
_ => Ok(check),
}
Expand Down Expand Up @@ -614,10 +610,11 @@ impl<'a, 'tcx> CastCheck<'tcx> {
}

fn report_cast_to_unsized_type(&self, fcx: &FnCtxt<'a, 'tcx>) -> ErrorGuaranteed {
if let Some(reported) =
self.cast_ty.error_reported().or_else(|| self.expr_ty.error_reported())
{
return reported;
if let Err(err) = self.cast_ty.error_reported() {
return err;
}
if let Err(err) = self.expr_ty.error_reported() {
return err;
}

let tstr = fcx.ty_to_string(self.cast_ty);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/traits/specialization_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub fn ancestors<'tcx>(

if let Some(reported) = specialization_graph.has_errored {
Err(reported)
} else if let Some(reported) = tcx.type_of(start_from_impl).error_reported() {
} else if let Err(reported) = tcx.type_of(start_from_impl).error_reported() {
Err(reported)
} else {
Ok(Ancestors {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/abstract_const.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! A subset of a mir body used for const evaluatability checking.
use crate::mir;
use crate::ty::visit::TypeVisitable;
use crate::ty::{self, DelaySpanBugEmitted, EarlyBinder, SubstsRef, Ty, TyCtxt};
use crate::ty::{self, EarlyBinder, SubstsRef, Ty, TyCtxt};
use rustc_errors::ErrorGuaranteed;
use rustc_hir::def_id::DefId;
use std::cmp;
Expand Down Expand Up @@ -43,7 +43,7 @@ impl<'tcx> AbstractConst<'tcx> {
) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> {
match ct.kind() {
ty::ConstKind::Unevaluated(uv) => AbstractConst::new(tcx, uv),
ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => Err(reported),
ty::ConstKind::Error(reported) => Err(reported),
_ => Ok(None),
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/consts/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub enum ConstKind<'tcx> {

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

#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
Expand Down
18 changes: 3 additions & 15 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
type BoundTy = ty::BoundTy;
type PlaceholderType = ty::PlaceholderType;
type InferTy = InferTy;
type DelaySpanBugEmitted = DelaySpanBugEmitted;
type ErrorGuaranteed = ErrorGuaranteed;
type PredicateKind = ty::PredicateKind<'tcx>;
type AllocId = crate::mir::interpret::AllocId;

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

/// A type that is not publicly constructable. This prevents people from making [`TyKind::Error`]s
/// except through the error-reporting functions on a [`tcx`][TyCtxt].
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[derive(TyEncodable, TyDecodable, HashStable)]
pub struct DelaySpanBugEmitted {
pub reported: ErrorGuaranteed,
_priv: (),
}

type InternedSet<'tcx, T> = ShardedHashMap<InternedInSet<'tcx, T>, ()>;

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

/// Like [TyCtxt::ty_error] but for constants.
Expand All @@ -1325,10 +1316,7 @@ impl<'tcx> TyCtxt<'tcx> {
msg: &str,
) -> Const<'tcx> {
let reported = self.sess.delay_span_bug(span, msg);
self.mk_const(ty::ConstS {
kind: ty::ConstKind::Error(DelaySpanBugEmitted { reported, _priv: () }),
ty,
})
self.mk_const(ty::ConstS { kind: ty::ConstKind::Error(reported), ty })
}

pub fn consider_optimizing<T: Fn() -> String>(self, msg: T) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub use self::consts::{
};
pub use self::context::{
tls, CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations,
CtxtInterners, DeducedParamAttrs, DelaySpanBugEmitted, FreeRegionInfo, GeneratorDiagnosticData,
CtxtInterners, DeducedParamAttrs, FreeRegionInfo, GeneratorDiagnosticData,
GeneratorInteriorTypeCause, GlobalCtxt, Lift, OnDiskCache, TyCtxt, TypeckResults, UserType,
UserTypeAnnotationIndex,
};
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ TrivialTypeTraversalAndLiftImpls! {
Field,
interpret::Scalar,
rustc_target::abi::Size,
ty::DelaySpanBugEmitted,
rustc_type_ir::DebruijnIndex,
ty::BoundVar,
ty::Placeholder<ty::BoundVar>,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/ty/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ pub trait TypeVisitable<'tcx>: fmt::Debug + Clone {
fn references_error(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_ERROR)
}
fn error_reported(&self) -> Option<ErrorGuaranteed> {
fn error_reported(&self) -> Result<(), ErrorGuaranteed> {
if self.references_error() {
Some(ErrorGuaranteed::unchecked_claim_error_was_emitted())
Err(ErrorGuaranteed::unchecked_claim_error_was_emitted())
} else {
None
Ok(())
}
}
fn has_non_region_param(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_transmute/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ mod rustc {

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

if let Some(err) = c.error_reported() {
if let Err(err) = c.error_reported() {
return Some(Self {
alignment: true,
lifetimes: true,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ty_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Ty<'_>> {
/// Check if a function is async.
fn asyncness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::IsAsync {
let node = tcx.hir().get_by_def_id(def_id.expect_local());
if let Some(fn_kind) = node.fn_kind() { fn_kind.asyncness() } else { hir::IsAsync::NotAsync }
node.fn_sig().map_or(hir::IsAsync::NotAsync, |sig| sig.header.asyncness)
}

/// Don't call this directly: use ``tcx.conservative_is_privately_uninhabited`` instead.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_type_ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub trait Interner {
type BoundTy: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
type PlaceholderType: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
type InferTy: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
type DelaySpanBugEmitted: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
type ErrorGuaranteed: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
type PredicateKind: Clone + Debug + Hash + PartialEq + Eq;
type AllocId: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;

Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_type_ir/src/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub enum TyKind<I: Interner> {

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

impl<I: Interner> TyKind<I> {
Expand Down Expand Up @@ -626,7 +626,7 @@ impl<I: Interner> fmt::Debug for TyKind<I> {
// This is manually implemented because a derive would require `I: Encodable`
impl<I: Interner, E: TyEncoder> Encodable<E> for TyKind<I>
where
I::DelaySpanBugEmitted: Encodable<E>,
I::ErrorGuaranteed: Encodable<E>,
I::AdtDef: Encodable<E>,
I::SubstsRef: Encodable<E>,
I::DefId: Encodable<E>,
Expand All @@ -645,7 +645,6 @@ where
I::BoundTy: Encodable<E>,
I::PlaceholderType: Encodable<E>,
I::InferTy: Encodable<E>,
I::DelaySpanBugEmitted: Encodable<E>,
I::PredicateKind: Encodable<E>,
I::AllocId: Encodable<E>,
{
Expand Down Expand Up @@ -744,7 +743,7 @@ where
// This is manually implemented because a derive would require `I: Decodable`
impl<I: Interner, D: TyDecoder<I = I>> Decodable<D> for TyKind<I>
where
I::DelaySpanBugEmitted: Decodable<D>,
I::ErrorGuaranteed: Decodable<D>,
I::AdtDef: Decodable<D>,
I::SubstsRef: Decodable<D>,
I::DefId: Decodable<D>,
Expand All @@ -763,7 +762,6 @@ where
I::BoundTy: Decodable<D>,
I::PlaceholderType: Decodable<D>,
I::InferTy: Decodable<D>,
I::DelaySpanBugEmitted: Decodable<D>,
I::PredicateKind: Decodable<D>,
I::AllocId: Decodable<D>,
{
Expand Down Expand Up @@ -829,7 +827,7 @@ where
I::ParamTy: HashStable<CTX>,
I::PlaceholderType: HashStable<CTX>,
I::InferTy: HashStable<CTX>,
I::DelaySpanBugEmitted: HashStable<CTX>,
I::ErrorGuaranteed: HashStable<CTX>,
{
#[inline]
fn hash_stable(
Expand Down
25 changes: 25 additions & 0 deletions src/doc/rustc/src/target-tier-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Table of Contents

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

## Adding a new target

New targets typically start as Tier 3 and then can be promoted later.
To propose addition of a new target, open a pull request on [`rust-lang/rust`]:

- Copy the [Tier 3 target policy](#tier-3-target-policy) to the description
and fill it out, see [example][tier3example].
- Add a new description for the target in `src/doc/rustc/src/platform-support`
using the [template][platform_template].
- Add the target to the [SUMMARY.md][summary] (allows wildcards) and
[platform-support.md][platformsupport] (must name all targets verbatim).
Link to the created description page.
- Ensure the pull request is assigned to a member of the [Rust compiler team][rust_compiler_team] by commenting:
```text
r? compiler-team
```

[tier3example]: https://github.com/rust-lang/rust/pull/94872
[platform_template]: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/TEMPLATE.md
[summary]: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/SUMMARY.md
[platformsupport]: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support.md
[rust_compiler_team]: https://www.rust-lang.org/governance/teams/compiler
[`rust-lang/rust`]: https://github.com/rust-lang/rust

## Tier 3 target policy

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