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

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dbc0ed2
Unify stable and unstable sort implementations in same core module
Voultapher Nov 20, 2022
1ec59cd
Remove debug unused
Voultapher Nov 21, 2022
4b5844f
Document all unsafe blocks
Voultapher Nov 21, 2022
0368adb
Fix #107090, fix missing arguments for fluent
chenyukang Jan 18, 2023
81efdab
add tests for 107090
chenyukang Jan 18, 2023
280f69d
Fix IndexVec::drain_enumerated
compiler-errors Jan 19, 2023
c9c8e29
HACK: self ty ambiguity hack
compiler-errors Jan 19, 2023
ac4956b
Support `.comment` section like GCC/Clang (`!llvm.ident`)
ojeda May 28, 2022
aee75f2
Assert goal is fully normalized during assemble
compiler-errors Jan 19, 2023
f53f5b4
swap Ambiguity and Unimplemented in new trait engine
compiler-errors Jan 19, 2023
69890b2
trait solver: PointerSized
compiler-errors Jan 18, 2023
ed6aebb
trait solver: Implement Fn traits and tuple trait
compiler-errors Jan 19, 2023
d3cfe97
Custom MIR: Support binary and unary operations
tmiasko Jan 19, 2023
05889fc
rustdoc: remove redundant CSS selector `.sidebar .current`
notriddle Jan 19, 2023
1adb4d6
Fix typo in opaque_types.rs
eltociear Jan 20, 2023
ec3da87
Add note about absolute paths to Path::join
Erk- Jan 20, 2023
d8f8adf
add example of joining with a absolute path
Erk- Jan 20, 2023
a641b92
remove leading comma when there are no args in check macro expansion
DebugSteven Jan 19, 2023
112d85c
rustdoc: use CSS inline layout for radio line instead of flexbox
notriddle Jan 20, 2023
ea8a33b
Rollup merge of #97550 - ojeda:comment-section, r=bjorn3
matthiaskrgr Jan 20, 2023
8eb9542
Rollup merge of #104672 - Voultapher:unify-sort-modules, r=thomcc
matthiaskrgr Jan 20, 2023
9e8edd7
Rollup merge of #107061 - compiler-errors:new-solver-new-candidates-3…
matthiaskrgr Jan 20, 2023
2ce10bf
Rollup merge of #107085 - tmiasko:custom-mir-operators, r=oli-obk
matthiaskrgr Jan 20, 2023
0e24b97
Rollup merge of #107095 - notriddle:notriddle/sidebar-current, r=Guil…
matthiaskrgr Jan 20, 2023
0275e77
Rollup merge of #107111 - chenyukang:yukang/fix-107090-fluent-paramet…
matthiaskrgr Jan 20, 2023
76339c9
Rollup merge of #107112 - eltociear:patch-19, r=albertlarsan68
matthiaskrgr Jan 20, 2023
52b2ea6
Rollup merge of #107114 - Erk-:add-absolute-note-to-path-join, r=m-ou-se
matthiaskrgr Jan 20, 2023
2d2e629
Rollup merge of #107124 - DebugSteven:check-macro-expansion, r=albert…
matthiaskrgr Jan 20, 2023
4a914c6
Rollup merge of #107131 - notriddle:notriddle/rustdoc-radio-display-i…
matthiaskrgr Jan 20, 2023
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
18 changes: 18 additions & 0 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use rustc_target::abi::{
use rustc_target::spec::{HasTargetSpec, RelocModel, Target, TlsModel};
use smallvec::SmallVec;

use libc::c_uint;
use std::cell::{Cell, RefCell};
use std::ffi::CStr;
use std::str;
Expand Down Expand Up @@ -347,6 +348,23 @@ pub unsafe fn create_module<'ll>(
);
}

// Insert `llvm.ident` metadata.
//
// On the wasm targets it will get hooked up to the "producer" sections
// `processed-by` information.
let rustc_producer =
format!("rustc version {}", option_env!("CFG_VERSION").expect("CFG_VERSION"));
let name_metadata = llvm::LLVMMDStringInContext(
llcx,
rustc_producer.as_ptr().cast(),
rustc_producer.as_bytes().len() as c_uint,
);
llvm::LLVMAddNamedMetadataOperand(
llmod,
cstr!("llvm.ident").as_ptr(),
llvm::LLVMMDNodeInContext(llcx, &name_metadata, 1),
);

llmod
}

Expand Down
15 changes: 0 additions & 15 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,21 +907,6 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
);
}

// Insert `llvm.ident` metadata on the wasm targets since that will
// get hooked up to the "producer" sections `processed-by` information.
if tcx.sess.target.is_like_wasm {
let name_metadata = llvm::LLVMMDStringInContext(
debug_context.llcontext,
rustc_producer.as_ptr().cast(),
rustc_producer.as_bytes().len() as c_uint,
);
llvm::LLVMAddNamedMetadataOperand(
debug_context.llmod,
cstr!("llvm.ident").as_ptr(),
llvm::LLVMMDNodeInContext(debug_context.llcontext, &name_metadata, 1),
);
}

return unit_metadata;
};

Expand Down
26 changes: 13 additions & 13 deletions compiler/rustc_error_messages/locales/en-US/infer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -268,28 +268,28 @@ infer_but_calling_introduces = {$has_param_name ->
[true] `{$param_name}`
*[false] `fn` parameter
} has {$lifetime_kind ->
[named] lifetime `{$lifetime}`
*[anon] an anonymous lifetime `'_`
} but calling `{assoc_item}` introduces an implicit `'static` lifetime requirement
[true] lifetime `{$lifetime}`
*[false] an anonymous lifetime `'_`
} but calling `{$assoc_item}` introduces an implicit `'static` lifetime requirement
.label1 = {$has_lifetime ->
[named] lifetime `{$lifetime}`
*[anon] an anonymous lifetime `'_`
[true] lifetime `{$lifetime}`
*[false] an anonymous lifetime `'_`
}
.label2 = ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the {$has_impl_path ->
[named] `impl` of `{$impl_path}`
*[anon] inherent `impl`
[true] `impl` of `{$impl_path}`
*[false] inherent `impl`
}

infer_but_needs_to_satisfy = {$has_param_name ->
[true] `{$param_name}`
*[false] `fn` parameter
} has {$has_lifetime ->
[named] lifetime `{$lifetime}`
*[anon] an anonymous lifetime `'_`
[true] lifetime `{$lifetime}`
*[false] an anonymous lifetime `'_`
} but it needs to satisfy a `'static` lifetime requirement
.influencer = this data with {$has_lifetime ->
[named] lifetime `{$lifetime}`
*[anon] an anonymous lifetime `'_`
[true] lifetime `{$lifetime}`
*[false] an anonymous lifetime `'_`
}...
.require = {$spans_empty ->
*[true] ...is used and required to live as long as `'static` here
Expand All @@ -302,8 +302,8 @@ infer_more_targeted = {$has_param_name ->
[true] `{$param_name}`
*[false] `fn` parameter
} has {$has_lifetime ->
[named] lifetime `{$lifetime}`
*[anon] an anonymous lifetime `'_`
[true] lifetime `{$lifetime}`
*[false] an anonymous lifetime `'_`
} but calling `{$ident}` introduces an implicit `'static` lifetime requirement

infer_ril_introduced_here = `'static` requirement introduced here
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_index/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ impl<I: Idx, T> IndexVec<I, T> {
&'a mut self,
range: R,
) -> impl Iterator<Item = (I, T)> + 'a {
self.raw.drain(range).enumerate().map(|(n, t)| (I::new(n), t))
let begin = match range.start_bound() {
std::ops::Bound::Included(i) => *i,
std::ops::Bound::Excluded(i) => i.checked_add(1).unwrap(),
std::ops::Bound::Unbounded => 0,
};
self.raw.drain(range).enumerate().map(move |(n, t)| (I::new(begin + n), t))
}

#[inline]
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_infer/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,8 @@ pub struct ButNeedsToSatisfy {
#[subdiagnostic]
pub req_introduces_loc: Option<ReqIntroducedLocations>,

pub has_param_name: bool,
pub param_name: String,
pub spans_empty: bool,
pub has_lifetime: bool,
pub lifetime: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
let sp = var_origin.span();
let return_sp = sub_origin.span();
let param = self.find_param_with_region(*sup_r, *sub_r)?;
let simple_ident = param.param.pat.simple_ident();
let lifetime_name = if sup_r.has_name() { sup_r.to_string() } else { "'_".to_owned() };

let (mention_influencer, influencer_point) =
Expand Down Expand Up @@ -187,7 +188,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
req_introduces_loc: subdiag,

has_lifetime: sup_r.has_name(),
lifetime: sup_r.to_string(),
lifetime: lifetime_name.clone(),
has_param_name: simple_ident.is_some(),
param_name: simple_ident.map(|x| x.to_string()).unwrap_or_default(),
spans_empty,
bound,
};
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ where
}

ty::Alias(ty::Opaque, ty::AliasTy { def_id, ref substs, .. }) => {
// Skip lifetime paramters that are not captures.
// Skip lifetime parameters that are not captures.
let variances = self.tcx.variances_of(*def_id);

for (v, s) in std::iter::zip(variances, substs.iter()) {
Expand All @@ -492,7 +492,7 @@ where
ty::Alias(ty::Projection, proj)
if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder =>
{
// Skip lifetime paramters that are not captures.
// Skip lifetime parameters that are not captures.
let variances = self.tcx.variances_of(proj.def_id);

for (v, s) in std::iter::zip(variances, proj.substs.iter()) {
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,11 @@ LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M,
if (WasmCustomSections)
WasmCustomSections->eraseFromParent();

// `llvm.ident` named metadata also gets duplicated.
auto *llvmIdent = (*MOrErr)->getNamedMetadata("llvm.ident");
if (llvmIdent)
llvmIdent->eraseFromParent();

return MOrErr;
};
bool ClearDSOLocal = clearDSOLocalOnDeclarations(Mod, Target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
ExprKind::AddressOf { mutability, arg } => Ok(
Rvalue::AddressOf(*mutability, self.parse_place(*arg)?)
),
ExprKind::Binary { op, lhs, rhs } => Ok(
Rvalue::BinaryOp(*op, Box::new((self.parse_operand(*lhs)?, self.parse_operand(*rhs)?)))
),
ExprKind::Unary { op, arg } => Ok(
Rvalue::UnaryOp(*op, self.parse_operand(*arg)?)
),
_ => self.parse_operand(expr_id).map(Rvalue::Use),
)
}
Expand Down
41 changes: 39 additions & 2 deletions compiler/rustc_trait_selection/src/solve/assembly.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Code shared by trait and projection goals for candidate assembly.

use super::infcx_ext::InferCtxtExt;
use super::{CanonicalResponse, EvalCtxt, Goal, QueryResult};
use super::{CanonicalResponse, Certainty, EvalCtxt, Goal, MaybeCause, QueryResult};
use rustc_hir::def_id::DefId;
use rustc_infer::traits::query::NoSolution;
use rustc_infer::traits::util::elaborate_predicates;
Expand Down Expand Up @@ -79,7 +79,7 @@ pub(super) enum CandidateSource {
AliasBound(usize),
}

pub(super) trait GoalKind<'tcx>: TypeFoldable<'tcx> + Copy {
pub(super) trait GoalKind<'tcx>: TypeFoldable<'tcx> + Copy + Eq {
fn self_ty(self) -> Ty<'tcx>;

fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self;
Expand Down Expand Up @@ -117,13 +117,43 @@ pub(super) trait GoalKind<'tcx>: TypeFoldable<'tcx> + Copy {
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
) -> QueryResult<'tcx>;

fn consider_builtin_pointer_sized_candidate(
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
) -> QueryResult<'tcx>;

fn consider_builtin_fn_trait_candidates(
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
kind: ty::ClosureKind,
) -> QueryResult<'tcx>;

fn consider_builtin_tuple_candidate(
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
) -> QueryResult<'tcx>;
}

impl<'tcx> EvalCtxt<'_, 'tcx> {
pub(super) fn assemble_and_evaluate_candidates<G: GoalKind<'tcx>>(
&mut self,
goal: Goal<'tcx, G>,
) -> Vec<Candidate<'tcx>> {
debug_assert_eq!(goal, self.infcx.resolve_vars_if_possible(goal));

// HACK: `_: Trait` is ambiguous, because it may be satisfied via a builtin rule,
// object bound, alias bound, etc. We are unable to determine this until we can at
// least structually resolve the type one layer.
if goal.predicate.self_ty().is_ty_var() {
return vec![Candidate {
source: CandidateSource::BuiltinImpl,
result: self
.make_canonical_response(Certainty::Maybe(MaybeCause::Ambiguity))
.unwrap(),
}];
}

let mut candidates = Vec::new();

self.assemble_candidates_after_normalizing_self_ty(goal, &mut candidates);
Expand Down Expand Up @@ -169,6 +199,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
Ok((_, certainty)) => certainty,
Err(NoSolution) => return,
};
let normalized_ty = self.infcx.resolve_vars_if_possible(normalized_ty);

// NOTE: Alternatively we could call `evaluate_goal` here and only have a `Normalized` candidate.
// This doesn't work as long as we use `CandidateSource` in winnowing.
Expand Down Expand Up @@ -224,6 +255,12 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|| lang_items.clone_trait() == Some(trait_def_id)
{
G::consider_builtin_copy_clone_candidate(self, goal)
} else if lang_items.pointer_sized() == Some(trait_def_id) {
G::consider_builtin_pointer_sized_candidate(self, goal)
} else if let Some(kind) = self.tcx().fn_trait_kind_from_def_id(trait_def_id) {
G::consider_builtin_fn_trait_candidates(self, goal, kind)
} else if lang_items.tuple_trait() == Some(trait_def_id) {
G::consider_builtin_tuple_candidate(self, goal)
} else {
Err(NoSolution)
};
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_trait_selection/src/solve/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
.drain(..)
.map(|obligation| FulfillmentError {
obligation: obligation.clone(),
code: FulfillmentErrorCode::CodeSelectionError(SelectionError::Unimplemented),
code: FulfillmentErrorCode::CodeAmbiguity,
root_obligation: obligation,
})
.collect()
Expand All @@ -75,7 +75,9 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
Err(NoSolution) => {
errors.push(FulfillmentError {
obligation: obligation.clone(),
code: FulfillmentErrorCode::CodeAmbiguity,
code: FulfillmentErrorCode::CodeSelectionError(
SelectionError::Unimplemented,
),
root_obligation: obligation,
});
continue;
Expand Down
43 changes: 42 additions & 1 deletion compiler/rustc_trait_selection/src/solve/project_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::traits::{specialization_graph, translate_substs};

use super::assembly::{self, Candidate, CandidateSource};
use super::infcx_ext::InferCtxtExt;
use super::trait_goals::structural_traits;
use super::{Certainty, EvalCtxt, Goal, MaybeCause, QueryResult};
use rustc_errors::ErrorGuaranteed;
use rustc_hir::def::DefKind;
Expand All @@ -11,9 +12,9 @@ use rustc_infer::traits::query::NoSolution;
use rustc_infer::traits::specialization_graph::LeafDef;
use rustc_infer::traits::Reveal;
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams};
use rustc_middle::ty::TypeVisitable;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{ProjectionPredicate, TypeSuperVisitable, TypeVisitor};
use rustc_middle::ty::{ToPredicate, TypeVisitable};
use rustc_span::DUMMY_SP;
use std::iter;
use std::ops::ControlFlow;
Expand Down Expand Up @@ -351,6 +352,46 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
) -> QueryResult<'tcx> {
bug!("`Copy`/`Clone` does not have an associated type: {:?}", goal);
}

fn consider_builtin_pointer_sized_candidate(
_ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
) -> QueryResult<'tcx> {
bug!("`PointerSized` does not have an associated type: {:?}", goal);
}

fn consider_builtin_fn_trait_candidates(
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
goal_kind: ty::ClosureKind,
) -> QueryResult<'tcx> {
if let Some(tupled_inputs_and_output) =
structural_traits::extract_tupled_inputs_and_output_from_callable(
ecx.tcx(),
goal.predicate.self_ty(),
goal_kind,
)?
{
let pred = tupled_inputs_and_output
.map_bound(|(inputs, output)| ty::ProjectionPredicate {
projection_ty: ecx
.tcx()
.mk_alias_ty(goal.predicate.def_id(), [goal.predicate.self_ty(), inputs]),
term: output.into(),
})
.to_predicate(ecx.tcx());
Self::consider_assumption(ecx, goal, pred)
} else {
ecx.make_canonical_response(Certainty::Maybe(MaybeCause::Ambiguity))
}
}

fn consider_builtin_tuple_candidate(
_ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
) -> QueryResult<'tcx> {
bug!("`Tuple` does not have an associated type: {:?}", goal);
}
}

/// This behavior is also implemented in `rustc_ty_utils` and in the old `project` code.
Expand Down
Loading