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 13 pull requests #123109

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
17ba73c
Document `adt_const_params` feature in Unstable Book
Shadlock0133 Mar 2, 2023
2624e91
Soft-destabilize `RustcEncodable`/`RustcDecodable`
jhpratt Sep 21, 2023
fbf21c5
Remove RustcEncodable/Decodable from 2024 prelude
jhpratt Sep 21, 2023
9154757
Implement `-L builtin:$path`
Veykril Feb 29, 2024
9ae4e3e
Make use of sysroot in librustdoc/config.rs for builtin:$path
Veykril Mar 4, 2024
2fae4ee
Make sysroot mandatory for rustdoc
Veykril Mar 6, 2024
3d65c92
Replace implementation with @RUSTC_BUILTIN prefix substitution var
Veykril Mar 6, 2024
69af113
enable cargo miri test doctests
onur-ozkan Mar 25, 2024
1ad3954
std library unix/thread.rs: fix NetBSD code for ILP32 CPUs.
he32 Mar 25, 2024
bff13e9
`UnixStream`: override `read_buf`
a1phyr Mar 26, 2024
ff6d9f7
Unix: Support more platforms with `preadv` and `pwritev`
a1phyr Mar 22, 2024
7b4e507
unix fs: Make hurd and horizon using explicit new rather than From
sthibaul Mar 25, 2024
22bc5c5
In ConstructCoroutineInClosureShim, pass receiver by ref, not pointer
compiler-errors Mar 25, 2024
2cfd532
Change `f16` and `f128` clippy stubs to be nonpanicking
tgross35 Mar 26, 2024
3878b37
Rename
Nadrieril Mar 2, 2024
14f186c
Store `Place` instead of `PlaceBuilder` in `MatchPair`
Nadrieril Mar 2, 2024
7764e8a
Port backtrace dylib-dep test to a ui test
jieyouxu Mar 23, 2024
bf7a745
Inherited -> TypeckRootCtxt
compiler-errors Mar 26, 2024
d7df149
Rollup merge of #108675 - Shadlock0133:adt_const_params, r=compiler-e…
workingjubilee Mar 26, 2024
775923f
Rollup merge of #116016 - jhpratt:kill-rustc-serialize, r=ehuss
workingjubilee Mar 26, 2024
2e9c73b
Rollup merge of #121843 - ferrocene:builtin-path, r=petrochenkov
workingjubilee Mar 26, 2024
4bc6445
Rollup merge of #122439 - Nadrieril:store-built-place, r=compiler-errors
workingjubilee Mar 26, 2024
1104d3b
Rollup merge of #122880 - a1phyr:preadv_more_platform, r=workingjubilee
workingjubilee Mar 26, 2024
4cd34b1
Rollup merge of #122958 - jieyouxu:port-backtrace-dylib-dep, r=workin…
workingjubilee Mar 26, 2024
c361983
Rollup merge of #123038 - he32:netbsd-ilp32-fix, r=workingjubilee
workingjubilee Mar 26, 2024
086ec4f
Rollup merge of #123049 - compiler-errors:coroutine-closure-rcvr, r=o…
workingjubilee Mar 26, 2024
e9ea30f
Rollup merge of #123055 - onur-ozkan:miri-rustdoc, r=RalfJung
workingjubilee Mar 26, 2024
c9393df
Rollup merge of #123057 - sthibaul:systemtime, r=jhpratt
workingjubilee Mar 26, 2024
9bebf31
Rollup merge of #123084 - a1phyr:unixstream_read_buf, r=workingjubilee
workingjubilee Mar 26, 2024
2e010f6
Rollup merge of #123087 - tgross35:clippy-f16-f128-check-stubs, r=bly…
workingjubilee Mar 26, 2024
b24c54e
Rollup merge of #123103 - compiler-errors:inherited-is-a-weird-name, …
workingjubilee Mar 26, 2024
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
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let can_coerce_to_return_ty = match self.ret_coercion.as_ref() {
Some(ret_coercion) => {
let ret_ty = ret_coercion.borrow().expected_ty();
let ret_ty = self.inh.infcx.shallow_resolve(ret_ty);
let ret_ty = self.infcx.shallow_resolve(ret_ty);
self.can_coerce(arm_ty, ret_ty)
&& prior_arm.map_or(true, |(_, ty, _)| self.can_coerce(ty, ret_ty))
// The match arms need to unify for the case of `impl Trait`.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
bound_vars,
);

let c_result = self.inh.infcx.canonicalize_response(result);
let c_result = self.infcx.canonicalize_response(result);
self.typeck_results.borrow_mut().user_provided_sigs.insert(expr_def_id, c_result);

// Normalize only after registering in `user_provided_sigs`.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir_typeck/src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
.any(|n| roots_reachable_from_non_diverging.visited(n));

let infer_var_infos: UnordBag<_> = self
.inh
.infer_var_info
.borrow()
.items()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub(in super::super) fn resolve_rvalue_scopes(&self, def_id: DefId) {
let scope_tree = self.tcx.region_scope_tree(def_id);
let rvalue_scopes = { rvalue_scopes::resolve_rvalue_scopes(self, scope_tree, def_id) };
let mut typeck_results = self.inh.typeck_results.borrow_mut();
let mut typeck_results = self.typeck_results.borrow_mut();
typeck_results.rvalue_scopes = rvalue_scopes;
}

Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod suggestions;
use crate::coercion::DynamicCoerceMany;
use crate::fallback::DivergingFallbackBehavior;
use crate::fn_ctxt::checks::DivergingBlockBehavior;
use crate::{CoroutineTypes, Diverges, EnclosingBreakables, Inherited};
use crate::{CoroutineTypes, Diverges, EnclosingBreakables, TypeckRootCtxt};
use hir::def_id::CRATE_DEF_ID;
use rustc_errors::{DiagCtxt, ErrorGuaranteed};
use rustc_hir as hir;
Expand Down Expand Up @@ -108,7 +108,7 @@ pub struct FnCtxt<'a, 'tcx> {

pub(super) enclosing_breakables: RefCell<EnclosingBreakables<'tcx>>,

pub(super) inh: &'a Inherited<'tcx>,
pub(super) root_ctxt: &'a TypeckRootCtxt<'tcx>,

pub(super) fallback_has_occurred: Cell<bool>,

Expand All @@ -118,12 +118,12 @@ pub struct FnCtxt<'a, 'tcx> {

impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn new(
inh: &'a Inherited<'tcx>,
root_ctxt: &'a TypeckRootCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
body_id: LocalDefId,
) -> FnCtxt<'a, 'tcx> {
let (diverging_fallback_behavior, diverging_block_behavior) =
parse_never_type_options_attr(inh.tcx);
parse_never_type_options_attr(root_ctxt.tcx);
FnCtxt {
body_id,
param_env,
Expand All @@ -137,7 +137,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
stack: Vec::new(),
by_id: Default::default(),
}),
inh,
root_ctxt,
fallback_has_occurred: Cell::new(false),
diverging_fallback_behavior,
diverging_block_behavior,
Expand Down Expand Up @@ -206,9 +206,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

impl<'a, 'tcx> Deref for FnCtxt<'a, 'tcx> {
type Target = Inherited<'tcx>;
type Target = TypeckRootCtxt<'tcx>;
fn deref(&self) -> &Self::Target {
self.inh
self.root_ctxt
}
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_hir_typeck/src/gather_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
Some(ref ty) => {
let o_ty = self.fcx.lower_ty(ty);

let c_ty =
self.fcx.inh.infcx.canonicalize_user_type_annotation(UserType::Ty(o_ty.raw));
let c_ty = self.fcx.infcx.canonicalize_user_type_annotation(UserType::Ty(o_ty.raw));
debug!("visit_local: ty.hir_id={:?} o_ty={:?} c_ty={:?}", ty.hir_id, o_ty, c_ty);
self.fcx
.typeck_results
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_hir_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ pub mod expr_use_visitor;
mod fallback;
mod fn_ctxt;
mod gather_locals;
mod inherited;
mod intrinsicck;
mod mem_categorization;
mod method;
mod op;
mod pat;
mod place_op;
mod rvalue_scopes;
mod typeck_root_ctxt;
mod upvar;
mod writeback;

pub use fn_ctxt::FnCtxt;
pub use inherited::Inherited;
pub use typeck_root_ctxt::TypeckRootCtxt;

use crate::check::check_fn;
use crate::coercion::DynamicCoerceMany;
Expand Down Expand Up @@ -170,11 +170,11 @@ fn typeck_with_fallback<'tcx>(

let param_env = tcx.param_env(def_id);

let inh = Inherited::new(tcx, def_id);
let root_ctxt = TypeckRootCtxt::new(tcx, def_id);
if let Some(inspector) = inspector {
inh.infcx.attach_obligation_inspector(inspector);
root_ctxt.infcx.attach_obligation_inspector(inspector);
}
let mut fcx = FnCtxt::new(&inh, param_env, def_id);
let mut fcx = FnCtxt::new(&root_ctxt, param_env, def_id);

if let Some(hir::FnSig { header, decl, .. }) = fn_sig {
let fn_sig = if decl.output.get_infer_ret_ty().is_some() {
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_hir_typeck/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

if !pat_adjustments.is_empty() {
debug!("default binding mode is now {:?}", def_bm);
self.inh
.typeck_results
self.typeck_results
.borrow_mut()
.pat_adjustments_mut()
.insert(pat.hir_id, pat_adjustments);
Expand Down Expand Up @@ -614,7 +613,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => BindingMode::convert(ba),
};
// ...and store it in a side table:
self.inh.typeck_results.borrow_mut().pat_binding_modes_mut().insert(pat.hir_id, bm);
self.typeck_results.borrow_mut().pat_binding_modes_mut().insert(pat.hir_id, bm);

debug!("check_pat_ident: pat.hir_id={:?} bm={:?}", pat.hir_id, bm);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ use rustc_trait_selection::traits::{self, PredicateObligation, TraitEngine, Trai
use std::cell::RefCell;
use std::ops::Deref;

/// Closures defined within the function. For example:
// Data shared between a "typeck root" and its nested bodies,
/// e.g. closures defined within the function. For example:
/// ```ignore (illustrative)
/// fn foo() {
/// bar(move|| { ... })
/// }
/// ```
/// Here, the function `foo()` and the closure passed to
/// `bar()` will each have their own `FnCtxt`, but they will
/// share the inherited fields.
pub struct Inherited<'tcx> {
/// share the inference context, will process obligations together,
/// can access each other's local types (scoping permitted), etc.
pub struct TypeckRootCtxt<'tcx> {
pub(super) infcx: InferCtxt<'tcx>,

pub(super) typeck_results: RefCell<ty::TypeckResults<'tcx>>,
Expand Down Expand Up @@ -65,14 +67,14 @@ pub struct Inherited<'tcx> {
pub(super) infer_var_info: RefCell<UnordMap<ty::TyVid, ty::InferVarInfo>>,
}

impl<'tcx> Deref for Inherited<'tcx> {
impl<'tcx> Deref for TypeckRootCtxt<'tcx> {
type Target = InferCtxt<'tcx>;
fn deref(&self) -> &Self::Target {
&self.infcx
}
}

impl<'tcx> Inherited<'tcx> {
impl<'tcx> TypeckRootCtxt<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self {
let hir_owner = tcx.local_def_id_to_hir_id(def_id).owner;

Expand All @@ -83,7 +85,7 @@ impl<'tcx> Inherited<'tcx> {
.build();
let typeck_results = RefCell::new(ty::TypeckResults::new(hir_owner));

Inherited {
TypeckRootCtxt {
typeck_results,
fulfillment_cx: RefCell::new(<dyn TraitEngine<'_>>::new(&infcx)),
infcx,
Expand Down
55 changes: 32 additions & 23 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,30 +315,39 @@ fn test_search_paths_tracking_hash_different_order() {
json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
};

let push = |opts: &mut Options, search_path| {
opts.search_paths.push(SearchPath::from_cli_opt(
"not-a-sysroot".as_ref(),
&opts.target_triple,
&early_dcx,
search_path,
));
};

// Reference
v1.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "native=abc"));
v1.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "crate=def"));
v1.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "dependency=ghi"));
v1.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "framework=jkl"));
v1.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "all=mno"));

v2.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "native=abc"));
v2.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "dependency=ghi"));
v2.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "crate=def"));
v2.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "framework=jkl"));
v2.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "all=mno"));

v3.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "crate=def"));
v3.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "framework=jkl"));
v3.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "native=abc"));
v3.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "dependency=ghi"));
v3.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "all=mno"));

v4.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "all=mno"));
v4.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "native=abc"));
v4.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "crate=def"));
v4.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "dependency=ghi"));
v4.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "framework=jkl"));
push(&mut v1, "native=abc");
push(&mut v1, "crate=def");
push(&mut v1, "dependency=ghi");
push(&mut v1, "framework=jkl");
push(&mut v1, "all=mno");

push(&mut v2, "native=abc");
push(&mut v2, "dependency=ghi");
push(&mut v2, "crate=def");
push(&mut v2, "framework=jkl");
push(&mut v2, "all=mno");

push(&mut v3, "crate=def");
push(&mut v3, "framework=jkl");
push(&mut v3, "native=abc");
push(&mut v3, "dependency=ghi");
push(&mut v3, "all=mno");

push(&mut v4, "all=mno");
push(&mut v4, "native=abc");
push(&mut v4, "crate=def");
push(&mut v4, "dependency=ghi");
push(&mut v4, "framework=jkl");

assert_same_hash(&v1, &v2);
assert_same_hash(&v1, &v3);
Expand Down
18 changes: 11 additions & 7 deletions compiler/rustc_mir_build/src/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,10 @@ impl<'pat, 'tcx> TestCase<'pat, 'tcx> {
#[derive(Debug, Clone)]
pub(crate) struct MatchPair<'pat, 'tcx> {
/// This place...
place: PlaceBuilder<'tcx>,
// This can be `None` if it referred to a non-captured place in a closure.
// Invariant: place.is_none() => test_case is Irrefutable
// In other words this must be `Some(_)` after simplification.
place: Option<Place<'tcx>>,

/// ... must pass this test...
// Invariant: after creation and simplification in `Candidate::new()`, this must not be
Expand Down Expand Up @@ -1595,11 +1598,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fn pick_test(
&mut self,
candidates: &mut [&mut Candidate<'_, 'tcx>],
) -> (PlaceBuilder<'tcx>, Test<'tcx>) {
) -> (Place<'tcx>, Test<'tcx>) {
// Extract the match-pair from the highest priority candidate
let match_pair = &candidates.first().unwrap().match_pairs[0];
let test = self.test(match_pair);
let match_place = match_pair.place.clone();
// Unwrap is ok after simplification.
let match_place = match_pair.place.unwrap();
debug!(?test, ?match_pair);

(match_place, test)
Expand Down Expand Up @@ -1640,7 +1644,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// - candidate 1 becomes `[y @ false]` since we know that `x` was `false`.
fn sort_candidates<'b, 'c, 'pat>(
&mut self,
match_place: &PlaceBuilder<'tcx>,
match_place: Place<'tcx>,
test: &Test<'tcx>,
mut candidates: &'b mut [&'c mut Candidate<'pat, 'tcx>],
) -> (
Expand All @@ -1658,7 +1662,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// sorting.
while let Some(candidate) = candidates.first_mut() {
let Some(branch) =
self.sort_candidate(&match_place, test, candidate, &target_candidates)
self.sort_candidate(match_place, test, candidate, &target_candidates)
else {
break;
};
Expand Down Expand Up @@ -1786,7 +1790,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// For each of the N possible test outcomes, build the vector of candidates that applies if
// the test has that particular outcome.
let (remaining_candidates, target_candidates) =
self.sort_candidates(&match_place, &test, candidates);
self.sort_candidates(match_place, &test, candidates);

// The block that we should branch to if none of the
// `target_candidates` match.
Expand Down Expand Up @@ -1826,7 +1830,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
scrutinee_span,
start_block,
remainder_start,
&match_place,
match_place,
&test,
target_blocks,
);
Expand Down
17 changes: 9 additions & 8 deletions compiler/rustc_mir_build/src/build/matches/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// identify what tests are needed, perform the tests, and then filter
// the candidates based on the result.

use crate::build::expr::as_place::PlaceBuilder;
use crate::build::matches::{Candidate, MatchPair, Test, TestBranch, TestCase, TestKind};
use crate::build::Builder;
use rustc_data_structures::fx::FxIndexMap;
Expand Down Expand Up @@ -55,18 +54,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Test { span: match_pair.pattern.span, kind }
}

#[instrument(skip(self, target_blocks, place_builder), level = "debug")]
#[instrument(skip(self, target_blocks, place), level = "debug")]
pub(super) fn perform_test(
&mut self,
match_start_span: Span,
scrutinee_span: Span,
block: BasicBlock,
otherwise_block: BasicBlock,
place_builder: &PlaceBuilder<'tcx>,
place: Place<'tcx>,
test: &Test<'tcx>,
target_blocks: FxIndexMap<TestBranch<'tcx>, BasicBlock>,
) {
let place = place_builder.to_place(self);
let place_ty = place.ty(&self.local_decls, self.tcx);
debug!(?place, ?place_ty);
let target_block = |branch| target_blocks.get(&branch).copied().unwrap_or(otherwise_block);
Expand Down Expand Up @@ -475,7 +473,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// tighter match code if we do something a bit different.
pub(super) fn sort_candidate(
&mut self,
test_place: &PlaceBuilder<'tcx>,
test_place: Place<'tcx>,
test: &Test<'tcx>,
candidate: &mut Candidate<'_, 'tcx>,
sorted_candidates: &FxIndexMap<TestBranch<'tcx>, Vec<&mut Candidate<'_, 'tcx>>>,
Expand All @@ -486,8 +484,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// than one, but it'd be very unusual to have two sides that
// both require tests; you'd expect one side to be simplified
// away.)
let (match_pair_index, match_pair) =
candidate.match_pairs.iter().enumerate().find(|&(_, mp)| mp.place == *test_place)?;
let (match_pair_index, match_pair) = candidate
.match_pairs
.iter()
.enumerate()
.find(|&(_, mp)| mp.place == Some(test_place))?;

let fully_matched;
let ret = match (&test.kind, &match_pair.test_case) {
Expand Down Expand Up @@ -521,7 +522,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
candidate
.match_pairs
.iter()
.any(|mp| mp.place == *test_place && is_covering_range(&mp.test_case))
.any(|mp| mp.place == Some(test_place) && is_covering_range(&mp.test_case))
};
if sorted_candidates
.get(&TestBranch::Failure)
Expand Down
Loading
Loading