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 8 pull requests #104902

Merged
merged 18 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
433d471
rustc_codegen_ssa: write `.dwp` in a streaming fashion
weihanglo Nov 24, 2022
3dee3aa
Use infcx.partially_normalize_associated_types_in
spastorino Nov 24, 2022
2c5d370
Clarify `SyntaxExtensionKind::LegacyDerive`.
nnethercote Nov 23, 2022
99d080d
Fix typo in miri sysroot
jyn514 Nov 25, 2022
eac8921
jsondoclint: Recognise Typedef as valid kind for Type::ResolvedPath
aDotInTheVoid Nov 25, 2022
31431cc
move 2 candidates into builtin candidate
lcnr Nov 22, 2022
84e9790
add comment
lcnr Nov 23, 2022
37b0a10
rustbuild: Don't build doc::SharedAssets when building JSON docs.
aDotInTheVoid Nov 25, 2022
f8b2e13
rustdoc: remove `cursor: pointer` from unclickable tooltip
notriddle Nov 25, 2022
75e4de6
rustdoc: revert tooltip background color on light theme to readable
notriddle Nov 25, 2022
9c7dc3e
Rollup merge of #104716 - lcnr:selection-candidate, r=jackh726
matthiaskrgr Nov 25, 2022
8f3f498
Rollup merge of #104760 - nnethercote:rm-LegacyDerive, r=petrochenkov
matthiaskrgr Nov 25, 2022
aec60c6
Rollup merge of #104797 - weihanglo:stream-write-dwp, r=jackh726
matthiaskrgr Nov 25, 2022
7fac504
Rollup merge of #104835 - spastorino:use-partially_normalize_associat…
matthiaskrgr Nov 25, 2022
287bb6d
Rollup merge of #104853 - jyn514:sysroot-typo, r=RalfJung
matthiaskrgr Nov 25, 2022
996de3a
Rollup merge of #104879 - aDotInTheVoid:jsondoclint-typedef, r=Guilla…
matthiaskrgr Nov 25, 2022
c72db77
Rollup merge of #104887 - aDotInTheVoid:rustbuild-json-doc-shared-ass…
matthiaskrgr Nov 25, 2022
12e1b84
Rollup merge of #104896 - notriddle:notriddle/tooltip, r=GuillaumeGomez
matthiaskrgr Nov 25, 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
9 changes: 5 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,17 +676,18 @@ fn link_dwarf_object<'a>(
thorin::MissingReferencedObjectBehaviour::Skip,
)?;

let output = package.finish()?.write()?;
let mut output_stream = BufWriter::new(
let output_stream = BufWriter::new(
OpenOptions::new()
.read(true)
.write(true)
.create(true)
.truncate(true)
.open(dwp_out_filename)?,
);
output_stream.write_all(&output)?;
output_stream.flush()?;
let mut output_stream = object::write::StreamingBuffer::new(output_stream);
package.finish()?.emit(&mut output_stream)?;
output_stream.result()?;
output_stream.into_inner().flush()?;

Ok(())
}) {
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,13 @@ pub enum SyntaxExtensionKind {

/// A token-based derive macro.
Derive(
/// An expander with signature TokenStream -> TokenStream (not yet).
/// An expander with signature TokenStream -> TokenStream.
/// The produced TokenSteam is appended to the input TokenSteam.
///
/// FIXME: The text above describes how this should work. Currently it
/// is handled identically to `LegacyDerive`. It should be migrated to
/// a token-based representation like `Bang` and `Attr`, instead of
/// using `MultiItemModifier`.
Box<dyn MultiItemModifier + sync::Sync + sync::Send>,
),

Expand Down
26 changes: 18 additions & 8 deletions compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use rustc_span::lev_distance::{
use rustc_span::symbol::sym;
use rustc_span::{symbol::Ident, Span, Symbol, DUMMY_SP};
use rustc_trait_selection::autoderef::{self, Autoderef};
use rustc_trait_selection::infer::InferCtxtExt as _;
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
use rustc_trait_selection::traits::query::method_autoderef::MethodAutoderefBadTy;
use rustc_trait_selection::traits::query::method_autoderef::{
Expand Down Expand Up @@ -716,9 +717,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
// maybe shouldn't include `Param`s, but rather fresh variables or be canonicalized,
// see issue #89650
let cause = traits::ObligationCause::misc(self.span, self.body_id);
let selcx = &mut traits::SelectionContext::new(self.fcx);
let traits::Normalized { value: xform_self_ty, obligations } =
traits::normalize(selcx, self.param_env, cause, xform_self_ty);
let InferOk { value: xform_self_ty, obligations } = self
.fcx
.partially_normalize_associated_types_in(cause, self.param_env, xform_self_ty);

debug!(
"assemble_inherent_impl_probe after normalization: xform_self_ty = {:?}/{:?}",
xform_self_ty, xform_ret_ty
Expand Down Expand Up @@ -1490,7 +1492,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
let mut xform_ret_ty = probe.xform_ret_ty;
debug!(?xform_ret_ty);

let selcx = &mut traits::SelectionContext::new(self);
let cause = traits::ObligationCause::misc(self.span, self.body_id);

let mut parent_pred = None;
Expand All @@ -1504,19 +1505,28 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
// `xform_ret_ty` hasn't been normalized yet, only `xform_self_ty`,
// see the reasons mentioned in the comments in `assemble_inherent_impl_probe`
// for why this is necessary
let traits::Normalized {
let InferOk {
value: normalized_xform_ret_ty,
obligations: normalization_obligations,
} = traits::normalize(selcx, self.param_env, cause.clone(), probe.xform_ret_ty);
} = self.fcx.partially_normalize_associated_types_in(
cause.clone(),
self.param_env,
probe.xform_ret_ty,
);
xform_ret_ty = normalized_xform_ret_ty;
debug!("xform_ret_ty after normalization: {:?}", xform_ret_ty);

// Check whether the impl imposes obligations we have to worry about.
let impl_def_id = probe.item.container_id(self.tcx);
let impl_bounds = self.tcx.predicates_of(impl_def_id);
let impl_bounds = impl_bounds.instantiate(self.tcx, substs);
let traits::Normalized { value: impl_bounds, obligations: norm_obligations } =
traits::normalize(selcx, self.param_env, cause.clone(), impl_bounds);

let InferOk { value: impl_bounds, obligations: norm_obligations } =
self.fcx.partially_normalize_associated_types_in(
cause.clone(),
self.param_env,
impl_bounds,
);

// Convert the bounds into obligations.
let impl_obligations = traits::predicates_for_generics(
Expand Down
23 changes: 0 additions & 23 deletions compiler/rustc_middle/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,6 @@ pub enum ImplSource<'tcx, N> {
/// Same as above, but for a function pointer type with the given signature.
FnPointer(ImplSourceFnPointerData<'tcx, N>),

/// ImplSource for a builtin `DeterminantKind` trait implementation.
DiscriminantKind(ImplSourceDiscriminantKindData),

/// ImplSource for a builtin `Pointee` trait implementation.
Pointee(ImplSourcePointeeData),

/// ImplSource automatically generated for a generator.
Generator(ImplSourceGeneratorData<'tcx, N>),

Expand All @@ -682,8 +676,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
ImplSource::Future(c) => c.nested,
ImplSource::Object(d) => d.nested,
ImplSource::FnPointer(d) => d.nested,
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
| ImplSource::Pointee(ImplSourcePointeeData) => vec![],
ImplSource::TraitAlias(d) => d.nested,
ImplSource::TraitUpcasting(d) => d.nested,
ImplSource::ConstDestruct(i) => i.nested,
Expand All @@ -701,8 +693,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
ImplSource::Future(c) => &c.nested,
ImplSource::Object(d) => &d.nested,
ImplSource::FnPointer(d) => &d.nested,
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
| ImplSource::Pointee(ImplSourcePointeeData) => &[],
ImplSource::TraitAlias(d) => &d.nested,
ImplSource::TraitUpcasting(d) => &d.nested,
ImplSource::ConstDestruct(i) => &i.nested,
Expand Down Expand Up @@ -751,12 +741,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
fn_ty: p.fn_ty,
nested: p.nested.into_iter().map(f).collect(),
}),
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData) => {
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
}
ImplSource::Pointee(ImplSourcePointeeData) => {
ImplSource::Pointee(ImplSourcePointeeData)
}
ImplSource::TraitAlias(d) => ImplSource::TraitAlias(ImplSourceTraitAliasData {
alias_def_id: d.alias_def_id,
substs: d.substs,
Expand Down Expand Up @@ -876,13 +860,6 @@ pub struct ImplSourceFnPointerData<'tcx, N> {
pub nested: Vec<N>,
}

// FIXME(@lcnr): This should be refactored and merged with other builtin vtables.
#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
pub struct ImplSourceDiscriminantKindData;

#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
pub struct ImplSourcePointeeData;

#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct ImplSourceConstDestructData<N> {
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_middle/src/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ pub type EvaluationCache<'tcx> = Cache<
/// parameter environment.
#[derive(PartialEq, Eq, Debug, Clone, TypeFoldable, TypeVisitable)]
pub enum SelectionCandidate<'tcx> {
/// A builtin implementation for some specific traits, used in cases
/// where we cannot rely an ordinary library implementations.
///
/// The most notable examples are `sized`, `Copy` and `Clone`. This is also
/// used for the `DiscriminantKind` and `Pointee` trait, both of which have
/// an associated type.
BuiltinCandidate {
/// `false` if there are no *further* obligations.
has_nested: bool,
Expand Down Expand Up @@ -141,12 +147,6 @@ pub enum SelectionCandidate<'tcx> {
is_const: bool,
},

/// Builtin implementation of `DiscriminantKind`.
DiscriminantKindCandidate,

/// Builtin implementation of `Pointee`.
PointeeCandidate,

TraitAliasCandidate,

/// Matching `dyn Trait` with a supertrait of `Trait`. The index is the
Expand Down
12 changes: 0 additions & 12 deletions compiler/rustc_middle/src/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> {

super::ImplSource::FnPointer(ref d) => write!(f, "({:?})", d),

super::ImplSource::DiscriminantKind(ref d) => write!(f, "{:?}", d),

super::ImplSource::Pointee(ref d) => write!(f, "{:?}", d),

super::ImplSource::Object(ref d) => write!(f, "{:?}", d),

super::ImplSource::Param(ref n, ct) => {
Expand Down Expand Up @@ -137,11 +133,3 @@ impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceConstDestructData<N> {
write!(f, "ImplSourceConstDestructData(nested={:?})", self.nested)
}
}

///////////////////////////////////////////////////////////////////////////
// Lift implementations

TrivialTypeTraversalAndLiftImpls! {
super::ImplSourceDiscriminantKindData,
super::ImplSourcePointeeData,
}
18 changes: 8 additions & 10 deletions compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use super::{
};
use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::InferCtxtExt as _;
use crate::infer::{self, InferCtxt, TyCtxtInferExt};
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
use crate::traits::query::normalize::AtExt as _;
Expand All @@ -28,7 +29,7 @@ use rustc_hir::GenericParam;
use rustc_hir::Item;
use rustc_hir::Node;
use rustc_infer::infer::error_reporting::TypeErrCtxt;
use rustc_infer::infer::TypeTrace;
use rustc_infer::infer::{InferOk, TypeTrace};
use rustc_middle::traits::select::OverflowError;
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::error::ExpectedFound;
Expand Down Expand Up @@ -2525,18 +2526,15 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}

self.probe(|_| {
let mut selcx = SelectionContext::new(self);

let cleaned_pred =
pred.fold_with(&mut ParamToVarFolder { infcx: self, var_map: Default::default() });

let cleaned_pred = super::project::normalize(
&mut selcx,
param_env,
ObligationCause::dummy(),
cleaned_pred,
)
.value;
let InferOk { value: cleaned_pred, .. } =
self.infcx.partially_normalize_associated_types_in(
ObligationCause::dummy(),
param_env,
cleaned_pred,
);

let obligation =
Obligation::new(self.tcx, ObligationCause::dummy(), param_env, cleaned_pred);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use super::{
DefIdOrName, Obligation, ObligationCause, ObligationCauseCode, PredicateObligation,
SelectionContext,
};
use super::{DefIdOrName, Obligation, ObligationCause, ObligationCauseCode, PredicateObligation};

use crate::autoderef::Autoderef;
use crate::infer::InferCtxt;
use crate::traits::normalize_to;

use hir::def::CtorOf;
use hir::HirId;
Expand All @@ -23,7 +19,7 @@ use rustc_hir::lang_items::LangItem;
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Node};
use rustc_infer::infer::error_reporting::TypeErrCtxt;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::LateBoundRegionConversionTime;
use rustc_infer::infer::{InferOk, LateBoundRegionConversionTime};
use rustc_middle::hir::map;
use rustc_middle::ty::{
self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, DefIdTree,
Expand Down Expand Up @@ -2979,13 +2975,12 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
self.tcx.mk_substs_trait(trait_pred.self_ty(), []),
)
});
let projection_ty = normalize_to(
&mut SelectionContext::new(self),
obligation.param_env,
obligation.cause.clone(),
projection_ty,
&mut vec![],
);
let InferOk { value: projection_ty, .. } = self
.partially_normalize_associated_types_in(
obligation.cause.clone(),
obligation.param_env,
projection_ty,
);

debug!(
normalized_projection_type = ?self.resolve_vars_if_possible(projection_ty)
Expand Down
Loading