Skip to content

Rollup of 9 pull requests #89927

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

Closed
wants to merge 20 commits into from
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
433439e
Make std::thread::available_concurrency support process-limited numbe…
joshtriplett Sep 27, 2021
11140ff
Stabilize `unreachable_unchecked` as `const fn`
jhpratt Oct 4, 2021
8007dfa
Remove alloc::prelude
Amanieu Oct 14, 2021
43f4ef5
Moved format-version constant to rustdoc-json-types
Oct 15, 2021
d2dc0f3
emitter: current substitution can be multi-line
davidtwco Oct 15, 2021
c4f9eb1
Emit impl difference error for GenericBoundFailure too
jackh726 Oct 5, 2021
a7c132d
Move push_outlives_components to rustc_infer
jackh726 Oct 9, 2021
d3fa07c
Use LocalDefId directly in more places in wfcheck
jackh726 Oct 14, 2021
2b5b456
Move some outlives bounds things from rustc_trait_selection to rustc_…
jackh726 Oct 15, 2021
a51798a
Add some GATs related regression tests
JohnTitor Oct 15, 2021
d3bddf3
updating docs to reflect current situation
gilescope Oct 15, 2021
5565c66
Rollup merge of #89310 - joshtriplett:available-concurrency-affinity,…
matthiaskrgr Oct 15, 2021
16bdcdb
Rollup merge of #89509 - jhpratt:stabilize-const_unreachable_unchecke…
matthiaskrgr Oct 15, 2021
774ab62
Rollup merge of #89898 - Amanieu:remove_alloc_prelude, r=joshtriplett
matthiaskrgr Oct 15, 2021
d401815
Rollup merge of #89906 - yuvaldolev:move-format-version-to-rustdoc-js…
matthiaskrgr Oct 15, 2021
817c69b
Rollup merge of #89912 - davidtwco:issue-89280-split-lines-multiple-l…
matthiaskrgr Oct 15, 2021
7449115
Rollup merge of #89914 - jackh726:gat_genericboundfailure, r=estebank
matthiaskrgr Oct 15, 2021
4a3b571
Rollup merge of #89915 - jackh726:outlives_cleanup, r=nikomatsakis
matthiaskrgr Oct 15, 2021
fc60d16
Rollup merge of #89918 - JohnTitor:gats-tests, r=jackh726
matthiaskrgr Oct 15, 2021
940609b
Rollup merge of #89925 - gilescope:update-docs-atomic-usage, r=m-ou-se
matthiaskrgr Oct 15, 2021
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
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/example/alloc_example.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![feature(start, core_intrinsics, alloc_prelude, alloc_error_handler, box_syntax)]
#![feature(start, core_intrinsics, alloc_error_handler, box_syntax)]
#![no_std]

extern crate alloc;
extern crate alloc_system;

use alloc::prelude::v1::*;
use alloc::boxed::Box;

use alloc_system::System;

4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/example/alloc_example.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![feature(start, box_syntax, core_intrinsics, alloc_prelude, alloc_error_handler)]
#![feature(start, box_syntax, core_intrinsics, alloc_error_handler)]
#![no_std]

extern crate alloc;
extern crate alloc_system;

use alloc::prelude::v1::*;
use alloc::boxed::Box;

use alloc_system::System;

2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
@@ -341,7 +341,7 @@ impl CodeSuggestion {
});
buf.push_str(&part.snippet);
let cur_hi = sm.lookup_char_pos(part.span.hi());
if prev_hi.line == cur_lo.line {
if prev_hi.line == cur_lo.line && cur_hi.line == cur_lo.line {
// Account for the difference between the width of the current code and the
// snippet being suggested, so that the *later* suggestions are correctly
// aligned on the screen.
Original file line number Diff line number Diff line change
@@ -46,7 +46,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
}
}
}
if let RegionResolutionError::ConcreteFailure(origin, _, _) = error.clone() {
if let RegionResolutionError::ConcreteFailure(origin, _, _)
| RegionResolutionError::GenericBoundFailure(origin, _, _) = error.clone()
{
if let SubregionOrigin::CompareImplTypeObligation {
span,
item_name,
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@
// refers to rules defined in RFC 1214 (`OutlivesFooBar`), so see that
// RFC for reference.

use crate::ty::subst::{GenericArg, GenericArgKind};
use crate::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc_data_structures::sso::SsoHashSet;
use smallvec::SmallVec;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
use smallvec::{smallvec, SmallVec};

#[derive(Debug)]
pub enum Component<'tcx> {
@@ -47,14 +47,16 @@ pub enum Component<'tcx> {
EscapingProjection(Vec<Component<'tcx>>),
}

impl<'tcx> TyCtxt<'tcx> {
/// Push onto `out` all the things that must outlive `'a` for the condition
/// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**.
pub fn push_outlives_components(self, ty0: Ty<'tcx>, out: &mut SmallVec<[Component<'tcx>; 4]>) {
let mut visited = SsoHashSet::new();
compute_components(self, ty0, out, &mut visited);
debug!("components({:?}) = {:?}", ty0, out);
}
/// Push onto `out` all the things that must outlive `'a` for the condition
/// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**.
pub fn push_outlives_components(
tcx: TyCtxt<'tcx>,
ty0: Ty<'tcx>,
out: &mut SmallVec<[Component<'tcx>; 4]>,
) {
let mut visited = SsoHashSet::new();
compute_components(tcx, ty0, out, &mut visited);
debug!("components({:?}) = {:?}", ty0, out);
}

fn compute_components(
1 change: 1 addition & 0 deletions compiler/rustc_infer/src/infer/outlives/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Various code related to computing outlives relations.

pub mod components;
pub mod env;
pub mod obligations;
pub mod verify;
6 changes: 3 additions & 3 deletions compiler/rustc_infer/src/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Code that handles "type-outlives" constraints like `T: 'a`. This
//! is based on the `push_outlives_components` function defined on the tcx,
//! is based on the `push_outlives_components` function defined in rustc_infer,
//! but it adds a bit of heuristics on top, in particular to deal with
//! associated types and projections.
//!
@@ -59,13 +59,13 @@
//! might later infer `?U` to something like `&'b u32`, which would
//! imply that `'b: 'a`.

use crate::infer::outlives::components::{push_outlives_components, Component};
use crate::infer::outlives::env::RegionBoundPairs;
use crate::infer::outlives::verify::VerifyBoundCx;
use crate::infer::{
self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, UndoLog, VerifyBound,
};
use crate::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::outlives::Component;
use rustc_middle::ty::subst::GenericArgKind;
use rustc_middle::ty::{self, Region, Ty, TyCtxt, TypeFoldable};

@@ -271,7 +271,7 @@ where
assert!(!ty.has_escaping_bound_vars());

let mut components = smallvec![];
self.tcx.push_outlives_components(ty, &mut components);
push_outlives_components(self.tcx, ty, &mut components);
self.components_must_outlive(origin, &components, region);
}

4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/traits/util.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use smallvec::smallvec;

use crate::infer::outlives::components::{push_outlives_components, Component};
use crate::traits::{Obligation, ObligationCause, PredicateObligation};
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
use rustc_middle::ty::outlives::Component;
use rustc_middle::ty::{self, ToPredicate, TyCtxt, WithConstness};
use rustc_span::symbol::Ident;

@@ -200,7 +200,7 @@ impl Elaborator<'tcx> {

let visited = &mut self.visited;
let mut components = smallvec![];
tcx.push_outlives_components(ty_max, &mut components);
push_outlives_components(tcx, ty_max, &mut components);
self.stack.extend(
components
.into_iter()
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
@@ -92,7 +92,6 @@ pub mod fold;
pub mod inhabitedness;
pub mod layout;
pub mod normalize_erasing_regions;
pub mod outlives;
pub mod print;
pub mod query;
pub mod relate;
49 changes: 0 additions & 49 deletions compiler/rustc_trait_selection/src/infer.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
use crate::traits::query::outlives_bounds::InferCtxtExt as _;
use crate::traits::{self, TraitEngine, TraitEngineExt};

use rustc_data_structures::stable_set::FxHashSet;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem;
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::traits::ObligationCause;
use rustc_middle::arena::ArenaAllocatable;
use rustc_middle::infer::canonical::{Canonical, CanonicalizedQueryResponse, QueryResponse};
@@ -180,48 +176,3 @@ impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> {
)
}
}

pub trait OutlivesEnvironmentExt<'tcx> {
fn add_implied_bounds(
&mut self,
infcx: &InferCtxt<'a, 'tcx>,
fn_sig_tys: FxHashSet<Ty<'tcx>>,
body_id: hir::HirId,
span: Span,
);
}

impl<'tcx> OutlivesEnvironmentExt<'tcx> for OutlivesEnvironment<'tcx> {
/// This method adds "implied bounds" into the outlives environment.
/// Implied bounds are outlives relationships that we can deduce
/// on the basis that certain types must be well-formed -- these are
/// either the types that appear in the function signature or else
/// the input types to an impl. For example, if you have a function
/// like
///
/// ```
/// fn foo<'a, 'b, T>(x: &'a &'b [T]) { }
/// ```
///
/// we can assume in the caller's body that `'b: 'a` and that `T:
/// 'b` (and hence, transitively, that `T: 'a`). This method would
/// add those assumptions into the outlives-environment.
///
/// Tests: `src/test/ui/regions/regions-free-region-ordering-*.rs`
fn add_implied_bounds(
&mut self,
infcx: &InferCtxt<'a, 'tcx>,
fn_sig_tys: FxHashSet<Ty<'tcx>>,
body_id: hir::HirId,
span: Span,
) {
debug!("add_implied_bounds()");

for ty in fn_sig_tys {
let ty = infcx.resolve_vars_if_possible(ty);
debug!("add_implied_bounds: ty = {}", ty);
let implied_bounds = infcx.implied_outlives_bounds(self.param_env, body_id, ty, span);
self.add_outlives_bounds(Some(infcx), implied_bounds)
}
}
}
1 change: 0 additions & 1 deletion compiler/rustc_trait_selection/src/traits/query/mod.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ pub mod dropck_outlives;
pub mod evaluate_obligation;
pub mod method_autoderef;
pub mod normalize;
pub mod outlives_bounds;
pub mod type_op;

pub use rustc_middle::traits::query::*;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
use crate::traits::query::outlives_bounds::OutlivesBound;
use crate::traits::query::Fallible;
use rustc_infer::traits::query::OutlivesBound;
use rustc_middle::ty::{ParamEnvAnd, Ty, TyCtxt};

#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, Lift)]
6 changes: 3 additions & 3 deletions compiler/rustc_traits/src/implied_outlives_bounds.rs
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@

use rustc_hir as hir;
use rustc_infer::infer::canonical::{self, Canonical};
use rustc_infer::infer::outlives::components::{push_outlives_components, Component};
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::query::OutlivesBound;
use rustc_infer::traits::TraitEngineExt as _;
use rustc_middle::ty::outlives::Component;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc_span::source_map::DUMMY_SP;
use rustc_trait_selection::infer::InferCtxtBuilderExt;
use rustc_trait_selection::traits::query::outlives_bounds::OutlivesBound;
use rustc_trait_selection::traits::query::{CanonicalTyGoal, Fallible, NoSolution};
use rustc_trait_selection::traits::wf;
use rustc_trait_selection::traits::FulfillmentContext;
@@ -118,7 +118,7 @@ fn compute_implied_outlives_bounds<'tcx>(
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_a, r_b)) => {
let ty_a = infcx.resolve_vars_if_possible(ty_a);
let mut components = smallvec![];
tcx.push_outlives_components(ty_a, &mut components);
push_outlives_components(tcx, ty_a, &mut components);
implied_bounds_from_components(r_b, components)
}
},
51 changes: 48 additions & 3 deletions compiler/rustc_typeck/src/check/regionck.rs
Original file line number Diff line number Diff line change
@@ -76,19 +76,19 @@ use crate::check::dropck;
use crate::check::FnCtxt;
use crate::mem_categorization as mc;
use crate::middle::region;
use crate::outlives::outlives_bounds::InferCtxtExt as _;
use rustc_data_structures::stable_set::FxHashSet;
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::PatKind;
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::infer::{self, RegionObligation, RegionckMode};
use rustc_infer::infer::{self, InferCtxt, RegionObligation, RegionckMode};
use rustc_middle::hir::place::{PlaceBase, PlaceWithHirId};
use rustc_middle::ty::adjustment;
use rustc_middle::ty::{self, Ty};
use rustc_span::Span;
use rustc_trait_selection::infer::OutlivesEnvironmentExt;
use rustc_trait_selection::opaque_types::InferCtxtExt;
use rustc_trait_selection::opaque_types::InferCtxtExt as _;
use std::ops::Deref;

// a variation on try that just returns unit
@@ -104,6 +104,51 @@ macro_rules! ignore_err {
};
}

trait OutlivesEnvironmentExt<'tcx> {
fn add_implied_bounds(
&mut self,
infcx: &InferCtxt<'a, 'tcx>,
fn_sig_tys: FxHashSet<Ty<'tcx>>,
body_id: hir::HirId,
span: Span,
);
}

impl<'tcx> OutlivesEnvironmentExt<'tcx> for OutlivesEnvironment<'tcx> {
/// This method adds "implied bounds" into the outlives environment.
/// Implied bounds are outlives relationships that we can deduce
/// on the basis that certain types must be well-formed -- these are
/// either the types that appear in the function signature or else
/// the input types to an impl. For example, if you have a function
/// like
///
/// ```
/// fn foo<'a, 'b, T>(x: &'a &'b [T]) { }
/// ```
///
/// we can assume in the caller's body that `'b: 'a` and that `T:
/// 'b` (and hence, transitively, that `T: 'a`). This method would
/// add those assumptions into the outlives-environment.
///
/// Tests: `src/test/ui/regions/regions-free-region-ordering-*.rs`
fn add_implied_bounds(
&mut self,
infcx: &InferCtxt<'a, 'tcx>,
fn_sig_tys: FxHashSet<Ty<'tcx>>,
body_id: hir::HirId,
span: Span,
) {
debug!("add_implied_bounds()");

for ty in fn_sig_tys {
let ty = infcx.resolve_vars_if_possible(ty);
debug!("add_implied_bounds: ty = {}", ty);
let implied_bounds = infcx.implied_outlives_bounds(self.param_env, body_id, ty, span);
self.add_outlives_bounds(Some(infcx), implied_bounds)
}
}
}

///////////////////////////////////////////////////////////////////////////
// PUBLIC ENTRY POINTS

57 changes: 22 additions & 35 deletions compiler/rustc_typeck/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
@@ -142,23 +142,23 @@ pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
}
}
hir::ItemKind::Fn(ref sig, ..) => {
check_item_fn(tcx, item.hir_id(), item.ident, item.span, sig.decl);
check_item_fn(tcx, item.def_id, item.ident, item.span, sig.decl);
}
hir::ItemKind::Static(ty, ..) => {
check_item_type(tcx, item.hir_id(), ty.span, false);
check_item_type(tcx, item.def_id, ty.span, false);
}
hir::ItemKind::Const(ty, ..) => {
check_item_type(tcx, item.hir_id(), ty.span, false);
check_item_type(tcx, item.def_id, ty.span, false);
}
hir::ItemKind::ForeignMod { items, .. } => {
for it in items.iter() {
let it = tcx.hir().foreign_item(it.id);
match it.kind {
hir::ForeignItemKind::Fn(decl, ..) => {
check_item_fn(tcx, it.hir_id(), it.ident, it.span, decl)
check_item_fn(tcx, it.def_id, it.ident, it.span, decl)
}
hir::ForeignItemKind::Static(ty, ..) => {
check_item_type(tcx, it.hir_id(), ty.span, true)
check_item_type(tcx, it.def_id, ty.span, true)
}
hir::ForeignItemKind::Type => (),
}
@@ -199,7 +199,7 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
_ => (None, trait_item.span),
};
check_object_unsafe_self_trait_by_name(tcx, trait_item);
check_associated_item(tcx, trait_item.hir_id(), span, method_sig);
check_associated_item(tcx, trait_item.def_id, span, method_sig);

let encl_trait_hir_id = tcx.hir().get_parent_item(hir_id);
let encl_trait = tcx.hir().expect_item(encl_trait_hir_id);
@@ -327,7 +327,7 @@ pub fn check_impl_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
_ => (None, impl_item.span),
};

check_associated_item(tcx, impl_item.hir_id(), span, method_sig);
check_associated_item(tcx, impl_item.def_id, span, method_sig);
}

fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
@@ -437,13 +437,13 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
#[tracing::instrument(level = "debug", skip(tcx, span, sig_if_method))]
fn check_associated_item(
tcx: TyCtxt<'_>,
item_id: hir::HirId,
item_id: LocalDefId,
span: Span,
sig_if_method: Option<&hir::FnSig<'_>>,
) {
let code = ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(item_id.expect_owner())));
let code = ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(item_id)));
for_id(tcx, item_id, span).with_fcx(|fcx| {
let item = fcx.tcx.associated_item(fcx.tcx.hir().local_def_id(item_id));
let item = fcx.tcx.associated_item(item_id);

let (mut implied_bounds, self_ty) = match item.container {
ty::TraitContainer(_) => (FxHashSet::default(), fcx.tcx.types.self_param),
@@ -455,11 +455,7 @@ fn check_associated_item(
match item.kind {
ty::AssocKind::Const => {
let ty = fcx.tcx.type_of(item.def_id);
let ty = fcx.normalize_associated_types_in_wf(
span,
ty,
WellFormedLoc::Ty(item_id.expect_owner()),
);
let ty = fcx.normalize_associated_types_in_wf(span, ty, WellFormedLoc::Ty(item_id));
fcx.register_wf_obligation(ty.into(), span, code.clone());
}
ty::AssocKind::Fn => {
@@ -481,11 +477,8 @@ fn check_associated_item(
}
if item.defaultness.has_value() {
let ty = fcx.tcx.type_of(item.def_id);
let ty = fcx.normalize_associated_types_in_wf(
span,
ty,
WellFormedLoc::Ty(item_id.expect_owner()),
);
let ty =
fcx.normalize_associated_types_in_wf(span, ty, WellFormedLoc::Ty(item_id));
fcx.register_wf_obligation(ty.into(), span, code.clone());
}
}
@@ -496,14 +489,13 @@ fn check_associated_item(
}

fn for_item<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item<'_>) -> CheckWfFcxBuilder<'tcx> {
for_id(tcx, item.hir_id(), item.span)
for_id(tcx, item.def_id, item.span)
}

fn for_id(tcx: TyCtxt<'_>, id: hir::HirId, span: Span) -> CheckWfFcxBuilder<'_> {
let def_id = tcx.hir().local_def_id(id);
fn for_id(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) -> CheckWfFcxBuilder<'_> {
CheckWfFcxBuilder {
inherited: Inherited::build(tcx, def_id),
id,
id: hir::HirId::make_owner(def_id),
span,
param_env: tcx.param_env(def_id),
}
@@ -665,30 +657,25 @@ fn check_associated_type_bounds(fcx: &FnCtxt<'_, '_>, item: &ty::AssocItem, span

fn check_item_fn(
tcx: TyCtxt<'_>,
item_id: hir::HirId,
def_id: LocalDefId,
ident: Ident,
span: Span,
decl: &hir::FnDecl<'_>,
) {
for_id(tcx, item_id, span).with_fcx(|fcx| {
let def_id = tcx.hir().local_def_id(item_id);
for_id(tcx, def_id, span).with_fcx(|fcx| {
let sig = tcx.fn_sig(def_id);
let mut implied_bounds = FxHashSet::default();
check_fn_or_method(fcx, ident.span, sig, decl, def_id.to_def_id(), &mut implied_bounds);
implied_bounds
})
}

fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_foreign_ty: bool) {
fn check_item_type(tcx: TyCtxt<'_>, item_id: LocalDefId, ty_span: Span, allow_foreign_ty: bool) {
debug!("check_item_type: {:?}", item_id);

for_id(tcx, item_id, ty_span).with_fcx(|fcx| {
let ty = tcx.type_of(tcx.hir().local_def_id(item_id));
let item_ty = fcx.normalize_associated_types_in_wf(
ty_span,
ty,
WellFormedLoc::Ty(item_id.expect_owner()),
);
let ty = tcx.type_of(item_id);
let item_ty = fcx.normalize_associated_types_in_wf(ty_span, ty, WellFormedLoc::Ty(item_id));

let mut forbid_unsized = true;
if allow_foreign_ty {
@@ -701,7 +688,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_fo
fcx.register_wf_obligation(
item_ty.into(),
ty_span,
ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(item_id.expect_owner()))),
ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(item_id))),
);
if forbid_unsized {
fcx.register_bound(
1 change: 1 addition & 0 deletions compiler/rustc_typeck/src/outlives/mod.rs
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ use rustc_span::Span;

mod explicit;
mod implicit_infer;
crate mod outlives_bounds;
/// Code to write unit test for outlives.
pub mod test;
mod utils;
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::infer::canonical::OriginalQueryValues;
use crate::infer::InferCtxt;
use crate::traits::query::NoSolution;
use crate::traits::{FulfillmentContext, ObligationCause, TraitEngine};
use rustc_hir as hir;
use rustc_infer::traits::TraitEngineExt as _;
use rustc_middle::ty::{self, Ty};
use rustc_span::source_map::Span;
use rustc_trait_selection::infer::canonical::OriginalQueryValues;
use rustc_trait_selection::infer::InferCtxt;
use rustc_trait_selection::traits::query::NoSolution;
use rustc_trait_selection::traits::{FulfillmentContext, ObligationCause, TraitEngine};

pub use rustc_middle::traits::query::OutlivesBound;

4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/outlives/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_middle::ty::outlives::Component;
use rustc_infer::infer::outlives::components::{push_outlives_components, Component};
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
use rustc_middle::ty::{self, Region, RegionKind, Ty, TyCtxt};
use rustc_span::Span;
@@ -35,7 +35,7 @@ pub fn insert_outlives_predicate<'tcx>(
// Or if within `struct Foo<U>` you had `T = Vec<U>`, then
// we would want to add `U: 'outlived_region`
let mut components = smallvec![];
tcx.push_outlives_components(ty, &mut components);
push_outlives_components(tcx, ty, &mut components);
for component in components {
match component {
Component::Region(r) => {
1 change: 0 additions & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -189,7 +189,6 @@ mod boxed {
pub mod borrow;
pub mod collections;
pub mod fmt;
pub mod prelude;
pub mod raw_vec;
pub mod rc;
pub mod slice;
15 changes: 0 additions & 15 deletions library/alloc/src/prelude/mod.rs

This file was deleted.

14 changes: 0 additions & 14 deletions library/alloc/src/prelude/v1.rs

This file was deleted.

2 changes: 1 addition & 1 deletion library/core/src/hint.rs
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ use crate::intrinsics;
/// ```
#[inline]
#[stable(feature = "unreachable", since = "1.27.0")]
#[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")]
#[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")]
pub const unsafe fn unreachable_unchecked() -> ! {
// SAFETY: the safety contract for `intrinsics::unreachable` must
// be upheld by the caller.
2 changes: 1 addition & 1 deletion library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
@@ -735,7 +735,7 @@ extern "rust-intrinsic" {
/// reach code marked with this function.
///
/// The stabilized version of this intrinsic is [`core::hint::unreachable_unchecked`].
#[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")]
#[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")]
pub fn unreachable() -> !;

/// Informs the optimizer that a condition is always true.
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -130,7 +130,6 @@
#![feature(const_trait_impl)]
#![feature(const_type_id)]
#![feature(const_type_name)]
#![feature(const_unreachable_unchecked)]
#![feature(const_default_impls)]
#![feature(duration_consts_2)]
#![feature(ptr_metadata)]
2 changes: 1 addition & 1 deletion library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@
//! some atomic operations. Maximally portable code will want to be careful
//! about which atomic types are used. `AtomicUsize` and `AtomicIsize` are
//! generally the most portable, but even then they're not available everywhere.
//! For reference, the `std` library requires pointer-sized atomics, although
//! For reference, the `std` library requires `AtomicBool`s and pointer-sized atomics, although
//! `core` does not.
//!
//! Currently you'll need to use `#[cfg(target_arch)]` primarily to
8 changes: 8 additions & 0 deletions library/std/src/sys/unix/thread.rs
Original file line number Diff line number Diff line change
@@ -275,6 +275,14 @@ pub fn available_parallelism() -> io::Result<NonZeroUsize> {
target_os = "solaris",
target_os = "illumos",
))] {
#[cfg(any(target_os = "android", target_os = "linux"))]
{
let mut set: libc::cpu_set_t = unsafe { mem::zeroed() };
if unsafe { libc::sched_getaffinity(0, mem::size_of::<libc::cpu_set_t>(), &mut set) } == 0 {
let count = unsafe { libc::CPU_COUNT(&set) };
return Ok(unsafe { NonZeroUsize::new_unchecked(count as usize) });
}
}
match unsafe { libc::sysconf(libc::_SC_NPROCESSORS_ONLN) } {
-1 => Err(io::Error::last_os_error()),
0 => Err(io::Error::new_const(io::ErrorKind::NotFound, &"The number of hardware threads is not known for the target platform")),
2 changes: 1 addition & 1 deletion src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
@@ -255,7 +255,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
)
})
.collect(),
format_version: 9,
format_version: types::FORMAT_VERSION,
};
let mut p = self.out_path.clone();
p.push(output.index.get(&output.root).unwrap().name.clone().unwrap());
3 changes: 3 additions & 0 deletions src/rustdoc-json-types/lib.rs
Original file line number Diff line number Diff line change
@@ -510,5 +510,8 @@ pub struct Static {
pub expr: String,
}

/// rustdoc format-version.
pub const FORMAT_VERSION: u32 = 9;

#[cfg(test)]
mod tests;
4 changes: 1 addition & 3 deletions src/test/ui/consts/const_unsafe_unreachable.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// run-pass

#![feature(const_unreachable_unchecked)]

const unsafe fn foo(x: bool) -> bool {
match x {
true => true,
@@ -12,5 +10,5 @@ const unsafe fn foo(x: bool) -> bool {
const BAR: bool = unsafe { foo(true) };

fn main() {
assert_eq!(BAR, true);
assert_eq!(BAR, true);
}
3 changes: 1 addition & 2 deletions src/test/ui/consts/const_unsafe_unreachable_ub.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// error-pattern: evaluation of constant value failed
#![feature(const_unreachable_unchecked)]

const unsafe fn foo(x: bool) -> bool {
match x {
@@ -11,5 +10,5 @@ const unsafe fn foo(x: bool) -> bool {
const BAR: bool = unsafe { foo(false) };

fn main() {
assert_eq!(BAR, true);
assert_eq!(BAR, true);
}
6 changes: 3 additions & 3 deletions src/test/ui/consts/const_unsafe_unreachable_ub.stderr
Original file line number Diff line number Diff line change
@@ -7,13 +7,13 @@ LL | unsafe { intrinsics::unreachable() }
| entering unreachable code
| inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL
|
::: $DIR/const_unsafe_unreachable_ub.rs:7:18
::: $DIR/const_unsafe_unreachable_ub.rs:6:18
|
LL | false => std::hint::unreachable_unchecked(),
| ---------------------------------- inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:7:18
| ---------------------------------- inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:6:18
...
LL | const BAR: bool = unsafe { foo(false) };
| ---------- inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:11:28
| ---------- inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:10:28

error: aborting due to previous error

10 changes: 10 additions & 0 deletions src/test/ui/errors/issue-89280-emitter-overflow-splice-lines.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// check-pass

trait X {
fn test(x: u32, (
//~^ WARN anonymous parameters are deprecated and will be removed in the next edition
//~^^ WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
)) {}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
warning: anonymous parameters are deprecated and will be removed in the next edition
--> $DIR/issue-89280-emitter-overflow-splice-lines.rs:4:21
|
LL | fn test(x: u32, (
| _____________________^
LL | |
LL | |
LL | | )) {}
| |_____^
|
= note: `#[warn(anonymous_parameters)]` on by default
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
help: try naming the parameter or explicitly ignoring it
|
LL ~ fn test(x: u32, _: (
LL +
LL +
LL ~ )) {}
|

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/impl_bounds.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ struct Fooy<T>(T);

impl<T> Foo for Fooy<T> {
type A<'a> where Self: 'static = (&'a ());
//~^ ERROR the parameter type `T` may not live long enough
//~^ ERROR `impl` associated type
type B<'a, 'b> where 'b: 'a = (&'a(), &'b ());
//~^ ERROR `impl` associated type
//~| ERROR lifetime bound not satisfied
12 changes: 6 additions & 6 deletions src/test/ui/generic-associated-types/impl_bounds.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0310]: the parameter type `T` may not live long enough
error: `impl` associated type signature for `A` doesn't match `trait` associated type signature
--> $DIR/impl_bounds.rs:15:5
|
LL | type A<'a> where Self: 'a;
| -------------------------- expected
...
LL | type A<'a> where Self: 'static = (&'a ());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `T: 'static`...
= note: ...so that the definition in impl matches the definition from the trait
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found

error: `impl` associated type signature for `B` doesn't match `trait` associated type signature
--> $DIR/impl_bounds.rs:17:5
@@ -85,5 +85,5 @@ LL | impl<T: std::marker::Copy> Foo for Fooy<T> {

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0277, E0310, E0478.
Some errors have detailed explanations: E0277, E0478.
For more information about an error, try `rustc --explain E0277`.
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/issue-86787.rs
Original file line number Diff line number Diff line change
@@ -21,8 +21,8 @@ where
{
type T = Either<Left::T, Right::T>;
type TRef<'a>
//~^ the associated type
//~^^ the associated type
//~^ `impl` associated type signature
//~^^ `impl` associated type signature
where
<Left as HasChildrenOf>::T: 'a,
<Right as HasChildrenOf>::T: 'a
17 changes: 10 additions & 7 deletions src/test/ui/generic-associated-types/issue-86787.stderr
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
error[E0309]: the associated type `<Left as HasChildrenOf>::T` may not live long enough
error: `impl` associated type signature for `TRef` doesn't match `trait` associated type signature
--> $DIR/issue-86787.rs:23:5
|
LL | type TRef<'a>;
| -------------- expected
...
LL | / type TRef<'a>
LL | |
LL | |
LL | | where
LL | | <Left as HasChildrenOf>::T: 'a,
LL | | <Right as HasChildrenOf>::T: 'a
| | - help: consider adding a where clause: `, <Left as HasChildrenOf>::T: 'a`
LL | | = Either<&'a Left::T, &'a Right::T>;
| |________________________________________^ ...so that the definition in impl matches the definition from the trait
| |________________________________________^ found

error[E0309]: the associated type `<Right as HasChildrenOf>::T` may not live long enough
error: `impl` associated type signature for `TRef` doesn't match `trait` associated type signature
--> $DIR/issue-86787.rs:23:5
|
LL | type TRef<'a>;
| -------------- expected
...
LL | / type TRef<'a>
LL | |
LL | |
LL | | where
LL | | <Left as HasChildrenOf>::T: 'a,
LL | | <Right as HasChildrenOf>::T: 'a
| | - help: consider adding a where clause: `, <Right as HasChildrenOf>::T: 'a`
LL | | = Either<&'a Left::T, &'a Right::T>;
| |________________________________________^ ...so that the definition in impl matches the definition from the trait
| |________________________________________^ found

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0309`.
39 changes: 39 additions & 0 deletions src/test/ui/generic-associated-types/issue-88287.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// check-pass
// edition:2018

#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]

use std::future::Future;

trait SearchableResource<Criteria> {
type SearchResult;
}

trait SearchableResourceExt<Criteria>: SearchableResource<Criteria> {
type Future<'f, A: 'f + ?Sized, B: 'f>: Future<Output = Result<Vec<A::SearchResult>, ()>> + 'f
where
A: SearchableResource<B>;

fn search<'c>(&'c self, client: &'c ()) -> Self::Future<'c, Self, Criteria>;
}

type SearchFutureTy<'f, A, B: 'f>
where
A: SearchableResource<B> + ?Sized + 'f,
= impl Future<Output = Result<Vec<A::SearchResult>, ()>> + 'f;
impl<T, Criteria> SearchableResourceExt<Criteria> for T
where
T: SearchableResource<Criteria>,
{
type Future<'f, A, B: 'f>
where
A: SearchableResource<B> + ?Sized + 'f,
= SearchFutureTy<'f, A, B>;

fn search<'c>(&'c self, _client: &'c ()) -> Self::Future<'c, Self, Criteria> {
async move { todo!() }
}
}

fn main() {}
16 changes: 16 additions & 0 deletions src/test/ui/generic-associated-types/issue-88405.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// check-pass

#![feature(generic_associated_types)]

trait SomeTrait {}
trait OtherTrait {
type Item;
}

trait ErrorSimpleExample {
type AssociatedType: SomeTrait;
type GatBounded<T: SomeTrait>;
type ErrorMinimal: OtherTrait<Item = Self::GatBounded<Self::AssociatedType>>;
}

fn main() {}