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 #89939

Merged
merged 22 commits into from
Oct 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
11140ff
Stabilize `unreachable_unchecked` as `const fn`
jhpratt Oct 4, 2021
8007dfa
Remove alloc::prelude
Amanieu Oct 14, 2021
2a1fbb8
test fix: aarch64 atomics are only outlined on Linux.
hkratz Oct 15, 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
024baa9
[fuchsia] Update process info struct
joshuaseaton Oct 15, 2021
d3bddf3
updating docs to reflect current situation
gilescope Oct 15, 2021
9ae0804
Rollup merge of #89509 - jhpratt:stabilize-const_unreachable_unchecke…
matthiaskrgr Oct 16, 2021
dfed1a6
Rollup merge of #89898 - Amanieu:remove_alloc_prelude, r=joshtriplett
matthiaskrgr Oct 16, 2021
e56b5ee
Rollup merge of #89902 - rusticstuff:outline-atomics-linux-only, r=wo…
matthiaskrgr Oct 16, 2021
e98669a
Rollup merge of #89906 - yuvaldolev:move-format-version-to-rustdoc-js…
matthiaskrgr Oct 16, 2021
27a7ced
Rollup merge of #89912 - davidtwco:issue-89280-split-lines-multiple-l…
matthiaskrgr Oct 16, 2021
e8efe09
Rollup merge of #89914 - jackh726:gat_genericboundfailure, r=estebank
matthiaskrgr Oct 16, 2021
502d57b
Rollup merge of #89915 - jackh726:outlives_cleanup, r=nikomatsakis
matthiaskrgr Oct 16, 2021
4fa5d6e
Rollup merge of #89918 - JohnTitor:gats-tests, r=jackh726
matthiaskrgr Oct 16, 2021
29f05c6
Rollup merge of #89921 - joshuaseaton:zircon-process, r=tmandry
matthiaskrgr Oct 16, 2021
8e20470
Rollup merge of #89925 - gilescope:update-docs-atomic-usage, r=m-ou-se
matthiaskrgr Oct 16, 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;

Expand Down
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;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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(
Expand Down
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;
Expand Down
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.
//!
Expand Down Expand Up @@ -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};

Expand Down Expand Up @@ -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);
}

Expand Down
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;

Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
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};
Expand Down Expand Up @@ -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
Expand Up @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_traits/src/implied_outlives_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
},
Expand Down
51 changes: 48 additions & 3 deletions compiler/rustc_typeck/src/check/regionck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Loading