Skip to content

Rollup of 8 pull requests #120087

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

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9018d2c
Detect `NulInCStr` error earlier.
nnethercote Dec 6, 2023
2683c2b
Remove unused features
clubby789 Jan 14, 2024
290651b
don't store const var origins for known vars
lcnr Jan 16, 2024
f91ccf9
Remove tcx from SMIR run macro and accept closures
celinval Jan 10, 2024
2564811
Remove tcx function and make `internal` fn safer
celinval Jan 16, 2024
b82d1d3
Inline `create_dump_file_with_basename`
Zalathar Jan 16, 2024
1ec567b
Inline `dump_file_basename` into `dump_path`
Zalathar Jan 16, 2024
f1ef930
Don't ICE when deducing future output if other errors already occurred
oli-obk Jan 17, 2024
eb8c1f8
Remove spastorino from users_on_vacation
spastorino Jan 17, 2024
dcc13b2
Modify GenericArg and Term structs to use strict provenance rules
kamalesh0406 Jan 14, 2024
6a573cb
Revert changes to internal method for now
celinval Jan 18, 2024
80160cd
Rollup merge of #119172 - nnethercote:earlier-NulInCStr, r=petrochenkov
matthiaskrgr Jan 18, 2024
5c52dcc
Rollup merge of #119833 - celinval:smir-accept-closures, r=oli-obk
matthiaskrgr Jan 18, 2024
fc926b6
Rollup merge of #119955 - kamalesh0406:master, r=WaffleLapkin
matthiaskrgr Jan 18, 2024
8b250d0
Rollup merge of #119968 - clubby789:unused-feature, r=compiler-errors
matthiaskrgr Jan 18, 2024
ddbeccb
Rollup merge of #120021 - lcnr:const-var-value, r=compiler-errors
matthiaskrgr Jan 18, 2024
940c643
Rollup merge of #120038 - Zalathar:dump-path, r=WaffleLapkin
matthiaskrgr Jan 18, 2024
5f850f5
Rollup merge of #120057 - oli-obk:not_sure_wtf_is_going_on, r=compile…
matthiaskrgr Jan 18, 2024
d536a67
Rollup merge of #120073 - spastorino:remove-spastorino-on-vacations, …
matthiaskrgr Jan 18, 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: 0 additions & 2 deletions compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
#![feature(rustdoc_internals)]
#![feature(associated_type_bounds)]
#![feature(box_patterns)]
#![feature(const_trait_impl)]
#![feature(if_let_guard)]
#![feature(let_chains)]
#![feature(min_specialization)]
#![feature(negative_impls)]
#![feature(stmt_expr_attributes)]
#![recursion_limit = "256"]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

Expand Down
12 changes: 2 additions & 10 deletions compiler/rustc_ast/src/util/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use rustc_lexer::unescape::{
};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span;
use std::ops::Range;
use std::{ascii, fmt, str};

// Escapes a string, represented as a symbol. Reuses the original symbol,
Expand Down Expand Up @@ -39,7 +38,6 @@ pub enum LitError {
InvalidFloatSuffix,
NonDecimalFloat(u32),
IntTooLarge(u32),
NulInCStr(Range<usize>),
}

impl LitKind {
Expand Down Expand Up @@ -156,10 +154,7 @@ impl LitKind {
let s = symbol.as_str();
let mut buf = Vec::with_capacity(s.len());
let mut error = Ok(());
unescape_c_string(s, Mode::CStr, &mut |span, c| match c {
Ok(CStrUnit::Byte(0) | CStrUnit::Char('\0')) => {
error = Err(LitError::NulInCStr(span));
}
unescape_c_string(s, Mode::CStr, &mut |_span, c| match c {
Ok(CStrUnit::Byte(b)) => buf.push(b),
Ok(CStrUnit::Char(c)) => {
buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes())
Expand All @@ -179,10 +174,7 @@ impl LitKind {
// can convert the symbol directly to a `Lrc<u8>` on success.
let s = symbol.as_str();
let mut error = Ok(());
unescape_c_string(s, Mode::RawCStr, &mut |span, c| match c {
Ok(CStrUnit::Byte(0) | CStrUnit::Char('\0')) => {
error = Err(LitError::NulInCStr(span));
}
unescape_c_string(s, Mode::RawCStr, &mut |_, c| match c {
Ok(_) => {}
Err(err) => {
if err.is_fatal() {
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
#![allow(internal_features)]
#![feature(rustdoc_internals)]
#![doc(rust_logo)]
#![feature(if_let_guard)]
#![feature(box_patterns)]
#![feature(let_chains)]
#![recursion_limit = "256"]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast_passes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#![feature(if_let_guard)]
#![feature(iter_is_partitioned)]
#![feature(let_chains)]
#![recursion_limit = "256"]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_ast_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#![feature(box_patterns)]
#![feature(let_chains)]
#![recursion_limit = "256"]

mod helpers;
pub mod pp;
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
#![feature(let_chains)]
#![feature(min_specialization)]
#![feature(never_type)]
#![feature(lazy_cell)]
#![feature(rustc_attrs)]
#![feature(stmt_expr_attributes)]
#![feature(trusted_step)]
#![feature(try_blocks)]
#![recursion_limit = "256"]

#[macro_use]
extern crate rustc_middle;
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
#![feature(rustdoc_internals)]
#![doc(rust_logo)]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(array_windows)]
#![feature(box_patterns)]
#![feature(decl_macro)]
#![feature(if_let_guard)]
#![feature(is_sorted)]
#![feature(let_chains)]
#![feature(lint_reasons)]
#![feature(proc_macro_internals)]
#![feature(proc_macro_quote)]
#![recursion_limit = "256"]

extern crate proc_macro;

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
#![feature(iter_intersperse)]
#![feature(let_chains)]
#![feature(min_specialization)]
#![feature(never_type)]
#![feature(impl_trait_in_assoc_type)]
#![recursion_limit = "256"]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
#![feature(if_let_guard)]
#![feature(let_chains)]
#![feature(negative_impls)]
#![feature(never_type)]
#![feature(strict_provenance)]
#![feature(try_blocks)]
#![recursion_limit = "256"]

//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
//! The backend-agnostic functions of this crate use functions defined in various traits that
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_const_eval/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@ Rust MIR: a lowered representation of Rust.
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(decl_macro)]
#![feature(exact_size_is_empty)]
#![feature(let_chains)]
#![feature(map_try_insert)]
#![feature(min_specialization)]
#![feature(slice_ptr_get)]
#![feature(option_get_or_insert_default)]
#![feature(never_type)]
#![feature(trait_alias)]
#![feature(trusted_len)]
#![feature(trusted_step)]
#![feature(try_blocks)]
#![feature(yeet_expr)]
#![feature(if_let_guard)]
#![recursion_limit = "256"]

#[macro_use]
extern crate tracing;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#![allow(internal_features)]
#![allow(rustc::default_hash_types)]
#![allow(rustc::potential_query_instability)]
#![cfg_attr(not(parallel_compiler), feature(cell_leak))]
#![deny(rustc::diagnostic_outside_of_impl)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(unsafe_op_in_unsafe_fn)]
Expand All @@ -18,7 +19,6 @@
#![feature(allocator_api)]
#![feature(array_windows)]
#![feature(auto_traits)]
#![feature(cell_leak)]
#![feature(cfg_match)]
#![feature(core_intrinsics)]
#![feature(extend_one)]
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
#![feature(rustdoc_internals)]
#![allow(internal_features)]
#![feature(decl_macro)]
#![feature(lazy_cell)]
#![feature(let_chains)]
#![feature(panic_update_hook)]
#![feature(result_flattening)]
#![recursion_limit = "256"]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![feature(let_chains)]
#![feature(lazy_cell)]
#![feature(rustc_attrs)]
#![feature(type_alias_impl_trait)]
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
#![feature(array_windows)]
#![feature(associated_type_defaults)]
#![feature(box_into_inner)]
#![feature(box_patterns)]
#![feature(extract_if)]
#![feature(if_let_guard)]
#![feature(let_chains)]
#![feature(negative_impls)]
#![feature(never_type)]
#![feature(rustc_attrs)]
#![feature(yeet_expr)]
#![feature(try_blocks)]
#![feature(box_patterns)]
#![feature(error_reporter)]
#![allow(incomplete_features)]
#![allow(internal_features)]
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#![feature(proc_macro_diagnostic)]
#![feature(proc_macro_internals)]
#![feature(proc_macro_span)]
#![feature(rustc_attrs)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
#![deny(rustc::untranslatable_diagnostic)]
#![allow(internal_features)]

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#![feature(never_type)]
#![feature(rustc_attrs)]
#![feature(variant_count)]
#![recursion_limit = "256"]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#![allow(internal_features)]
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ This API is completely unstable and subject to change.
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![allow(internal_features)]
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(if_let_guard)]
#![feature(is_sorted)]
Expand All @@ -71,8 +70,6 @@ This API is completely unstable and subject to change.
#![feature(lazy_cell)]
#![feature(slice_partition_dedup)]
#![feature(try_blocks)]
#![feature(type_alias_impl_trait)]
#![recursion_limit = "256"]

#[macro_use]
extern crate tracing;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub(super) fn check_fn<'a, 'tcx>(
let inputs_fn = fn_sig.inputs().iter().copied();
for (idx, (param_ty, param)) in inputs_fn.chain(maybe_va_list).zip(body.params).enumerate() {
// Check the pattern.
let ty: Option<&hir::Ty<'_>> = try { inputs_hir?.get(idx)? };
let ty: Option<&hir::Ty<'_>> = inputs_hir.and_then(|h| h.get(idx));
let ty_span = ty.map(|ty| ty.span);
fcx.check_pat_top(param.pat, param_ty, ty_span, None, None);

Expand Down
14 changes: 10 additions & 4 deletions compiler/rustc_hir_typeck/src/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,16 +754,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
get_future_output(obligation.predicate, obligation.cause.span)
})?
}
ty::Alias(ty::Projection, _) => {
return Some(Ty::new_error_with_message(
self.tcx,
closure_span,
"this projection should have been projected to an opaque type",
));
}
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => self
.tcx
.explicit_item_bounds(def_id)
.iter_instantiated_copied(self.tcx, args)
.find_map(|(p, s)| get_future_output(p.as_predicate(), s))?,
ty::Error(_) => return Some(ret_ty),
_ => span_bug!(
closure_span,
"async fn coroutine return type not an inference variable: {ret_ty}"
),
_ => {
span_bug!(closure_span, "invalid async fn coroutine return type: {ret_ty:?}")
}
};

let output_ty = self.normalize(closure_span, output_ty);
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#![feature(box_patterns)]
#![feature(min_specialization)]
#![feature(control_flow_enum)]
#![recursion_limit = "256"]

#[macro_use]
extern crate tracing;
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_incremental/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![allow(internal_features)]
#![recursion_limit = "256"]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

Expand Down
11 changes: 2 additions & 9 deletions compiler/rustc_index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@
#![deny(rustc::diagnostic_outside_of_impl)]
#![cfg_attr(
feature = "nightly",
feature(
allow_internal_unstable,
extend_one,
min_specialization,
new_uninit,
step_trait,
stmt_expr_attributes,
test
)
feature(extend_one, min_specialization, new_uninit, step_trait, test)
)]
#![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))]
#![cfg_attr(feature = "nightly", allow(internal_features))]

pub mod bit_set;
Expand Down
33 changes: 23 additions & 10 deletions compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{Body, Closure, Expr, ExprKind, FnRetTy, HirId, Local, LocalSource};
use rustc_middle::hir::nested_filter;
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
use rustc_middle::infer::unify_key::{
ConstVariableOrigin, ConstVariableOriginKind, ConstVariableValue,
};
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter, Print, Printer};
use rustc_middle::ty::{self, InferConst};
Expand Down Expand Up @@ -178,17 +180,23 @@ fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'tcx>, ns: Namespace) -> FmtPrinte
}
};
printer.ty_infer_name_resolver = Some(Box::new(ty_getter));
let const_getter = move |ct_vid| {
if infcx.probe_const_var(ct_vid).is_ok() {
let const_getter = move |ct_vid| match infcx
.inner
.borrow_mut()
.const_unification_table()
.probe_value(ct_vid)
{
ConstVariableValue::Known { value: _ } => {
warn!("resolved const var in error message");
}
if let ConstVariableOriginKind::ConstParameterDefinition(name, _) =
infcx.inner.borrow_mut().const_unification_table().probe_value(ct_vid).origin.kind
{
return Some(name);
} else {
None
}
ConstVariableValue::Unknown { origin, universe: _ } => {
if let ConstVariableOriginKind::ConstParameterDefinition(name, _) = origin.kind {
return Some(name);
} else {
None
}
}
};
printer.const_infer_name_resolver = Some(Box::new(const_getter));
printer
Expand Down Expand Up @@ -303,7 +311,12 @@ impl<'tcx> InferCtxt<'tcx> {
GenericArgKind::Const(ct) => {
if let ty::ConstKind::Infer(InferConst::Var(vid)) = ct.kind() {
let origin =
self.inner.borrow_mut().const_unification_table().probe_value(vid).origin;
match self.inner.borrow_mut().const_unification_table().probe_value(vid) {
ConstVariableValue::Known { value } => {
bug!("resolved infer var: {vid:?} {value}")
}
ConstVariableValue::Unknown { origin, universe: _ } => origin,
};
if let ConstVariableOriginKind::ConstParameterDefinition(name, def_id) =
origin.kind
{
Expand Down
10 changes: 2 additions & 8 deletions compiler/rustc_infer/src/infer/freshen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,8 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
match ct.kind() {
ty::ConstKind::Infer(ty::InferConst::Var(v)) => {
let opt_ct = self
.infcx
.inner
.borrow_mut()
.const_unification_table()
.probe_value(v)
.val
.known();
let opt_ct =
self.infcx.inner.borrow_mut().const_unification_table().probe_value(v).known();
self.freshen_const(opt_ct, ty::InferConst::Var(v), ty::InferConst::Fresh, ct.ty())
}
ty::ConstKind::Infer(ty::InferConst::EffectVar(v)) => {
Expand Down
Loading