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

Merged
merged 33 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
cfb7841
implement checks for tail calls
WaffleLapkin May 11, 2023
3208b86
use `expect(incomplete_feature)` instead of `allow` in tail call tests
WaffleLapkin Nov 29, 2024
d93ea6b
simplify things by using `tcx.fn_trait_kind_from_def_id`
WaffleLapkin Nov 29, 2024
ef5808a
add a fixme for tailcalls with opaque types
WaffleLapkin Nov 29, 2024
c6454dd
don't polymorphize without a reason to
WaffleLapkin Nov 29, 2024
144d6cc
simplify things using `tcx.as_lang_item`
WaffleLapkin Nov 29, 2024
b81391e
CI: use free runners for i686-gnu jobs
marcoieni Dec 3, 2024
7338710
Fix typo
Kobzol Dec 3, 2024
f676ed2
Fix copy-pasted tool name
Kobzol Dec 3, 2024
b24d608
Replace `black` with `ruff` for formatting Python code
Kobzol Dec 3, 2024
d5eb93b
Remove dependency on `black`
Kobzol Dec 3, 2024
7cc6f4d
CI: rfl: move job forward to Linux v6.13-rc1
ojeda Dec 3, 2024
0b737a1
Exclude additional subtrees in `ruff` config
Kobzol Dec 4, 2024
536516f
Reformat Python code with `ruff`
Kobzol Dec 4, 2024
62c7ce4
Avoid fetching the anon const hir node that is already available
oli-obk Dec 5, 2024
9aa4be0
Normalize target-cpus.rs stdout test for LLVM changes
TimNN Dec 5, 2024
8f0ea9a
Adapt codegen tests for NUW inference
TimNN Dec 5, 2024
fad5f51
Always display first line of impl blocks even when collapsed
GuillaumeGomez Oct 25, 2024
32e6826
Update browser-ui-test version to 0.18.2
GuillaumeGomez Oct 25, 2024
5d26acc
Add GUI test for impl block doc display
GuillaumeGomez Oct 25, 2024
abcd094
Update GUI tests
GuillaumeGomez Oct 25, 2024
6e0dabd
Turn `markdown_split_summary_and_content` into a method of `Markdown`
GuillaumeGomez Oct 28, 2024
448d9ad
Use text ellipsis instead of bottom blurring
GuillaumeGomez Oct 29, 2024
90feb9a
Improve positioning of "..." in collapsed impl block
GuillaumeGomez Nov 19, 2024
854ebe7
Update GUI test after rebase
GuillaumeGomez Dec 2, 2024
a424813
Rollup merge of #132155 - GuillaumeGomez:impl-block-doc, r=rustdoc
GuillaumeGomez Dec 5, 2024
7416c33
Rollup merge of #133256 - MarcoIeni:use-linux-free-runners, r=Kobzol
GuillaumeGomez Dec 5, 2024
e941e73
Rollup merge of #133607 - WaffleLapkin:tail-call-checks, r=compiler-e…
GuillaumeGomez Dec 5, 2024
5a9c9ef
Rollup merge of #133821 - Kobzol:replace-black-with-ruff, r=onur-ozkan
GuillaumeGomez Dec 5, 2024
9765a4e
Rollup merge of #133827 - ojeda:ci-rfl, r=lqd
GuillaumeGomez Dec 5, 2024
e82ee96
Rollup merge of #133910 - TimNN:llvm-target-cpus, r=jieyouxu
GuillaumeGomez Dec 5, 2024
beb9b24
Rollup merge of #133921 - TimNN:nuw-infer, r=nikic
GuillaumeGomez Dec 5, 2024
5dc05a8
Rollup merge of #133936 - oli-obk:push-qmvqsmwqrtqr, r=lqd
GuillaumeGomez Dec 5, 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
26 changes: 10 additions & 16 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ use rustc_errors::codes::*;
use rustc_errors::{
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, struct_span_code_err,
};
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Namespace, Res};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{GenericArg, GenericArgs, HirId};
use rustc_hir::{self as hir, AnonConst, GenericArg, GenericArgs, HirId};
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::ObligationCause;
use rustc_middle::middle::stability::AllowUnstable;
Expand Down Expand Up @@ -2089,7 +2088,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
qpath.span(),
format!("Const::lower_const_arg: invalid qpath {qpath:?}"),
),
hir::ConstArgKind::Anon(anon) => self.lower_anon_const(anon.def_id),
hir::ConstArgKind::Anon(anon) => self.lower_anon_const(anon),
hir::ConstArgKind::Infer(span) => self.ct_infer(None, span),
}
}
Expand Down Expand Up @@ -2180,27 +2179,22 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
/// Literals and const generic parameters are eagerly converted to a constant, everything else
/// becomes `Unevaluated`.
#[instrument(skip(self), level = "debug")]
fn lower_anon_const(&self, def: LocalDefId) -> Const<'tcx> {
fn lower_anon_const(&self, anon: &AnonConst) -> Const<'tcx> {
let tcx = self.tcx();

let body_id = match tcx.hir_node_by_def_id(def) {
hir::Node::AnonConst(ac) => ac.body,
node => span_bug!(
tcx.def_span(def.to_def_id()),
"from_anon_const can only process anonymous constants, not {node:?}"
),
};

let expr = &tcx.hir().body(body_id).value;
let expr = &tcx.hir().body(anon.body).value;
debug!(?expr);

let ty = tcx.type_of(def).no_bound_vars().expect("const parameter types cannot be generic");
let ty = tcx
.type_of(anon.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic");

match self.try_lower_anon_const_lit(ty, expr) {
Some(v) => v,
None => ty::Const::new_unevaluated(tcx, ty::UnevaluatedConst {
def: def.to_def_id(),
args: ty::GenericArgs::identity_for_item(tcx, def.to_def_id()),
def: anon.def_id.to_def_id(),
args: ty::GenericArgs::identity_for_item(tcx, anon.def_id.to_def_id()),
}),
}
}
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,12 @@ rustc_queries! {
cache_on_disk_if { true }
}

/// Checks well-formedness of tail calls (`become f()`).
query check_tail_calls(key: LocalDefId) -> Result<(), rustc_errors::ErrorGuaranteed> {
desc { |tcx| "tail-call-checking `{}`", tcx.def_path_str(key) }
cache_on_disk_if { true }
}

/// Returns the types assumed to be well formed while "inside" of the given item.
///
/// Note that we've liberated the late bound regions of function signatures, so
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_mir_build/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ pub(crate) fn mir_build<'tcx>(tcx: TyCtxtAt<'tcx>, def: LocalDefId) -> Body<'tcx
return construct_error(tcx, def, e);
}

if let Err(err) = tcx.check_tail_calls(def) {
return construct_error(tcx, def, err);
}

let body = match tcx.thir_body(def) {
Err(error_reported) => construct_error(tcx, def, error_reported),
Ok((thir, expr)) => {
Expand Down
Loading
Loading