Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4e05d79
Upgrade to nightly-2025-10-10
github-actions[bot] Oct 21, 2025
eb70a4a
Upgrade to nightly-2025-10-11
github-actions[bot] Oct 21, 2025
bb20515
Upgrade to nightly-2025-10-12
github-actions[bot] Oct 21, 2025
f60e2cd
Remove StatementKind::Deinit
nilehmann Oct 21, 2025
7144eb5
Upgrade to nightly-2025-10-13
github-actions[bot] Oct 21, 2025
ffb0e00
Upgrade to nightly-2025-10-14
github-actions[bot] Oct 21, 2025
43ed721
Upgrade to nightly-2025-10-15
github-actions[bot] Oct 21, 2025
b625cce
Upgrade to nightly-2025-10-16
github-actions[bot] Oct 21, 2025
0be3a96
Upgrade to nightly-2025-10-17
github-actions[bot] Oct 21, 2025
52a49eb
Upgrade to nightly-2025-10-18
github-actions[bot] Oct 21, 2025
b57f882
Upgrade to nightly-2025-10-19
github-actions[bot] Oct 21, 2025
7fd2163
impl_trait_ref
nilehmann Oct 21, 2025
e84af3d
Upgrade to nightly-2025-10-20
github-actions[bot] Oct 22, 2025
8a2ae63
Upgrade to nightly-2025-10-21
github-actions[bot] Oct 22, 2025
44de0ad
Upgrade to nightly-2025-10-22
github-actions[bot] Oct 30, 2025
5cb794d
Upgrade to nightly-2025-10-23
github-actions[bot] Oct 30, 2025
64f1ca5
Upgrade to nightly-2025-10-24
github-actions[bot] Oct 30, 2025
f428185
Remove NullOp
nilehmann Oct 30, 2025
ef4ce39
Upgrade to nightly-2025-10-25
github-actions[bot] Oct 30, 2025
c2bb314
Upgrade to nightly-2025-10-26
github-actions[bot] Oct 30, 2025
f754b5b
AnnotateSnippetEmitter
nilehmann Nov 4, 2025
755d9d9
Upgrade to nightly-2025-10-27
github-actions[bot] Nov 4, 2025
1812e3a
Upgrade to nightly-2025-10-28
github-actions[bot] Nov 4, 2025
0d38c95
Upgrade to nightly-2025-10-29
github-actions[bot] Nov 4, 2025
57b6ad8
Upgrade to nightly-2025-10-30
github-actions[bot] Nov 4, 2025
b49839e
Upgrade to nightly-2025-10-31
github-actions[bot] Nov 4, 2025
61629d1
Remove hir::QPath::LangItem
nilehmann Nov 6, 2025
b85c18d
Upgrade to nightly-2025-11-01
github-actions[bot] Nov 6, 2025
c4bdeeb
Mutability DataflowAnalysis
nilehmann Nov 6, 2025
0561a30
Upgrade to nightly-2025-11-02
github-actions[bot] Nov 6, 2025
3628ade
Upgrade to nightly-2025-11-03
github-actions[bot] Nov 6, 2025
0d2671a
Upgrade to nightly-2025-11-04
github-actions[bot] Nov 6, 2025
16bcb74
Upgrade to nightly-2025-11-05
github-actions[bot] Nov 6, 2025
3ef4c5f
Upgrade to nightly-2025-11-06
github-actions[bot] Nov 6, 2025
11af667
Upgrade to nightly-2025-11-07
github-actions[bot] Nov 7, 2025
6d32b4b
Fix emitter creation
nilehmann Nov 11, 2025
52bb304
Upgrade to nightly-2025-11-08
github-actions[bot] Nov 11, 2025
5a6d9bc
Upgrade to nightly-2025-11-09
github-actions[bot] Nov 11, 2025
a3eb125
Upgrade to nightly-2025-11-10
github-actions[bot] Nov 11, 2025
8101410
ConstItemRhs
nilehmann Nov 11, 2025
bcd4dd3
Upgrade to nightly-2025-11-11
github-actions[bot] Nov 11, 2025
9e3cbe0
Upgrade to nightly-2025-11-12
github-actions[bot] Nov 12, 2025
94e7670
Upgrade to nightly-2025-11-13
github-actions[bot] Nov 13, 2025
0d49383
Upgrade to nightly-2025-11-14
github-actions[bot] Nov 14, 2025
ab5ed9c
Upgrade to nightly-2025-11-15
github-actions[bot] Nov 16, 2025
0271079
Upgrade to nightly-2025-11-16
github-actions[bot] Nov 16, 2025
58b9ca5
Upgrade to nightly-2025-11-17
github-actions[bot] Nov 17, 2025
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
6 changes: 0 additions & 6 deletions crates/flux-desugar/src/desugar/lift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,6 @@ impl<'genv> RustItemCtxt<'_, 'genv, '_> {
let segment = self.lift_path_segment(segment)?;
Ok(fhir::QPath::TypeRelative(self.genv.alloc(qself), self.genv.alloc(segment)))
}
hir::QPath::LangItem(_, _) => {
Err(self.emit_unsupported(&format!(
"unsupported type: `{}`",
rustc_hir_pretty::qpath_to_string(&self.genv.tcx(), &qpath)
)))
}
}
}

Expand Down
11 changes: 5 additions & 6 deletions crates/flux-driver/src/collector/detached_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,11 @@ impl TraitImplResolver {
for (trait_id, impl_ids) in tcx.all_local_trait_impls(()) {
let trait_ = LookupRes::DefId(*trait_id);
for impl_id in impl_ids {
if let Some(poly_trait_ref) = tcx.impl_trait_ref(*impl_id) {
let self_ty = poly_trait_ref.instantiate_identity().self_ty();
let self_ty = LookupRes::new(&self_ty);
let key = TraitImplKey { trait_, self_ty };
items.insert(key, *impl_id);
}
let poly_trait_ref = tcx.impl_trait_ref(*impl_id);
let self_ty = poly_trait_ref.instantiate_identity().self_ty();
let self_ty = LookupRes::new(&self_ty);
let key = TraitImplKey { trait_, self_ty };
items.insert(key, *impl_id);
}
}
Self { items }
Expand Down
2 changes: 1 addition & 1 deletion crates/flux-driver/src/collector/extern_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<'a, 'sess, 'tcx> ExternSpecCollector<'a, 'sess, 'tcx> {
} else {
let opt_extern_impl_id = self.tcx().impl_of_assoc(callee_id);
if let Some(extern_impl_id) = opt_extern_impl_id {
debug_assert!(self.tcx().trait_id_of_impl(extern_impl_id).is_none());
debug_assert!(!self.tcx().impl_is_of_trait(extern_impl_id));
Ok(ExternImplItem { impl_id: extern_impl_id, item_id: callee_id })
} else {
Err(self.invalid_item_in_inherent_impl(item.owner_id, callee_id))
Expand Down
6 changes: 4 additions & 2 deletions crates/flux-driver/src/collector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl<'a, 'tcx> SpecCollector<'a, 'tcx> {
ItemKind::TyAlias(..) => self.collect_type_alias(owner_id, attrs)?,
ItemKind::Impl(..) => self.collect_impl(owner_id, attrs)?,
ItemKind::Trait(..) => self.collect_trait(owner_id, attrs)?,
ItemKind::Const(.., body_id) => {
ItemKind::Const(.., rhs) => {
// The flux-rs macro puts defs as an outer attribute on a `const _: () = { }`. We
// consider these defs to be defined in the parent of the const.
self.specs
Expand All @@ -148,7 +148,9 @@ impl<'a, 'tcx> SpecCollector<'a, 'tcx> {
.or_default()
.extend(attrs.items());

if attrs.extern_spec() {
if attrs.extern_spec()
&& let hir::ConstItemRhs::Body(body_id) = rhs
{
return ExternSpecCollector::collect(self, *body_id);
}

Expand Down
102 changes: 74 additions & 28 deletions crates/flux-errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ use flux_common::result::{ErrorCollector, ErrorEmitter};
use rustc_data_structures::sync;
pub use rustc_errors::ErrorGuaranteed;
use rustc_errors::{
Diagnostic, ErrCode, FatalAbort, FatalError, LazyFallbackBundle,
Diagnostic, ErrCode, FatalAbort, FatalError, LazyFallbackBundle, TerminalUrl,
annotate_snippet_emitter_writer::AnnotateSnippetEmitter,
emitter::{Emitter, HumanEmitter, HumanReadableErrorType, stderr_destination},
emitter::{Emitter, HumanEmitter, HumanReadableErrorType, OutputTheme, stderr_destination},
json::JsonEmitter,
translation::Translator,
};
use rustc_session::{
config::{self, ErrorOutputType},
parse::ParseSess,
};
use rustc_session::{config, parse::ParseSess};
use rustc_span::source_map::SourceMap;

pub struct FluxSession {
Expand Down Expand Up @@ -75,43 +72,92 @@ impl FluxSession {
}

fn emitter(
opts: &config::Options,
sopts: &config::Options,
source_map: Arc<SourceMap>,
fallback_fluent_bundle: LazyFallbackBundle,
) -> Box<dyn Emitter + sync::DynSend> {
let track_diagnostics = opts.unstable_opts.track_diagnostics;

let translator = Translator { fluent_bundle: None, fallback_fluent_bundle };
match opts.error_format {
ErrorOutputType::HumanReadable { kind, color_config } => {
if let HumanReadableErrorType::AnnotateSnippet = kind {
let emitter =
AnnotateSnippetEmitter::new(Some(source_map), translator, false, false);
Box::new(emitter)
} else {
let dst = stderr_destination(color_config);
let emitter = HumanEmitter::new(dst, translator)
.sm(Some(source_map))
.short_message(kind.short())
.diagnostic_width(opts.diagnostic_width)
.track_diagnostics(track_diagnostics)
.terminal_url(opts.unstable_opts.terminal_urls);
Box::new(emitter)

// All the code below is copied from rustc_session::session::default_emitter
let macro_backtrace = sopts.unstable_opts.macro_backtrace;
let track_diagnostics = sopts.unstable_opts.track_diagnostics;
let terminal_url = match sopts.unstable_opts.terminal_urls {
TerminalUrl::Auto => {
match (std::env::var("COLORTERM").as_deref(), std::env::var("TERM").as_deref()) {
(Ok("truecolor"), Ok("xterm-256color"))
if sopts.unstable_features.is_nightly_build() =>
{
TerminalUrl::Yes
}
_ => TerminalUrl::No,
}
}
ErrorOutputType::Json { pretty, json_rendered, color_config } => {
t => t,
};

let source_map = if sopts.unstable_opts.link_only { None } else { Some(source_map) };

match sopts.error_format {
config::ErrorOutputType::HumanReadable { kind, color_config } => {
match kind {
HumanReadableErrorType::AnnotateSnippet { short, unicode } => {
let emitter =
AnnotateSnippetEmitter::new(stderr_destination(color_config), translator)
.sm(source_map)
.short_message(short)
.diagnostic_width(sopts.diagnostic_width)
.macro_backtrace(macro_backtrace)
.track_diagnostics(track_diagnostics)
.terminal_url(terminal_url)
.theme(if unicode { OutputTheme::Unicode } else { OutputTheme::Ascii })
.ignored_directories_in_source_blocks(
sopts
.unstable_opts
.ignore_directory_in_diagnostics_source_blocks
.clone(),
);
Box::new(emitter.ui_testing(sopts.unstable_opts.ui_testing))
}
HumanReadableErrorType::Default { short } => {
let emitter = HumanEmitter::new(stderr_destination(color_config), translator)
.sm(source_map)
.short_message(short)
.diagnostic_width(sopts.diagnostic_width)
.macro_backtrace(macro_backtrace)
.track_diagnostics(track_diagnostics)
.terminal_url(terminal_url)
.theme(OutputTheme::Ascii)
.ignored_directories_in_source_blocks(
sopts
.unstable_opts
.ignore_directory_in_diagnostics_source_blocks
.clone(),
);
Box::new(emitter.ui_testing(sopts.unstable_opts.ui_testing))
}
}
}
config::ErrorOutputType::Json { pretty, json_rendered, color_config } => {
Box::new(
JsonEmitter::new(
Box::new(io::BufWriter::new(io::stderr())),
Some(source_map),
source_map,
translator,
pretty,
json_rendered,
color_config,
)
.ui_testing(sopts.unstable_opts.ui_testing)
.ignored_directories_in_source_blocks(
sopts
.unstable_opts
.ignore_directory_in_diagnostics_source_blocks
.clone(),
)
.diagnostic_width(sopts.diagnostic_width)
.macro_backtrace(macro_backtrace)
.track_diagnostics(track_diagnostics)
.diagnostic_width(opts.diagnostic_width)
.terminal_url(opts.unstable_opts.terminal_urls),
.terminal_url(terminal_url),
)
}
}
Expand Down
22 changes: 6 additions & 16 deletions crates/flux-fhir-analysis/src/conv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,7 @@ impl<'genv, 'tcx: 'genv, P: ConvPhase<'genv, 'tcx>> ConvCtxt<P> {
let assoc_segment =
fhir::PathSegment { args: &[], constraints: &[], ident, res: fhir::Res::Err };
let mut env = Env::empty();
let alias_ty =
self.conv_type_relative_type_path(&mut env, ident.span, res, &assoc_segment)?;
let alias_ty = self.conv_type_relative_type_path(&mut env, res, &assoc_segment)?;
return Ok(rty::Sort::Alias(rty::AliasKind::Projection, alias_ty));
}
fhir::SortRes::PrimSort(fhir::PrimSort::Set) => {
Expand Down Expand Up @@ -1444,7 +1443,7 @@ impl<'genv, 'tcx: 'genv, P: ConvPhase<'genv, 'tcx>> ConvCtxt<P> {
let qself_res =
if let Some(path) = qself.as_path() { path.res } else { fhir::Res::Err };
let alias_ty = self
.conv_type_relative_type_path(env, qself.span, qself_res, segment)?
.conv_type_relative_type_path(env, qself_res, segment)?
.shift_in_escaping(1);
let bty = rty::BaseTy::Alias(rty::AliasKind::Projection, alias_ty);
let sort = bty.sort();
Expand All @@ -1464,18 +1463,14 @@ impl<'genv, 'tcx: 'genv, P: ConvPhase<'genv, 'tcx>> ConvCtxt<P> {
fn conv_type_relative_path<Tag: AssocItemTag>(
&mut self,
tag: Tag,
qself_span: Span,
qself_res: fhir::Res,
assoc_ident: Ident,
) -> QueryResult<(Tag::AssocItem<'tcx>, rty::TraitRef)> {
let tcx = self.tcx();

let bound = match qself_res {
fhir::Res::SelfTyAlias { alias_to: impl_def_id, is_trait_impl: true } => {
let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else {
// A cycle error occurred most likely (comment copied from rustc)
span_bug!(qself_span, "expected cycle error");
};
let trait_ref = tcx.impl_trait_ref(impl_def_id);

self.probe_single_bound_for_assoc_item(
|| {
Expand Down Expand Up @@ -1535,16 +1530,11 @@ impl<'genv, 'tcx: 'genv, P: ConvPhase<'genv, 'tcx>> ConvCtxt<P> {
fn conv_type_relative_type_path(
&mut self,
env: &mut Env,
qself_span: Span,
qself_res: fhir::Res,
assoc_segment: &fhir::PathSegment,
) -> QueryResult<rty::AliasTy> {
let (assoc_item, trait_ref) = self.conv_type_relative_path(
AssocTag::Type,
qself_span,
qself_res,
assoc_segment.ident,
)?;
let (assoc_item, trait_ref) =
self.conv_type_relative_path(AssocTag::Type, qself_res, assoc_segment.ident)?;

let assoc_id = assoc_item.def_id;
let mut args = trait_ref.args.to_vec();
Expand Down Expand Up @@ -2487,7 +2477,7 @@ impl<'genv, 'tcx: 'genv, P: ConvPhase<'genv, 'tcx>> ConvCtxt<P> {
let qself_res =
if let Some(path) = qself.as_path() { path.res } else { fhir::Res::Err };
let (assoc_reft, trait_ref) =
self.conv_type_relative_path(AssocReftTag, qself.span, qself_res, *name)?;
self.conv_type_relative_path(AssocReftTag, qself_res, *name)?;
rty::AliasReft { assoc_id: assoc_reft.def_id, args: trait_ref.args }
}
};
Expand Down
6 changes: 1 addition & 5 deletions crates/flux-infer/src/projections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,7 @@ impl<'a, 'infcx, 'genv, 'tcx> Normalizer<'a, 'infcx, 'genv, 'tcx> {
// IntoIter<{v. i32[v] | v > 0}, Global> MATCH IntoIter<T, A>
// => {T -> {v. i32[v] | v > 0}, A -> Global}

let impl_trait_ref = self
.genv()
.impl_trait_ref(impl_def_id)?
.unwrap()
.skip_binder();
let impl_trait_ref = self.genv().impl_trait_ref(impl_def_id)?.skip_binder();

let generics = self.tcx().generics_of(impl_def_id);

Expand Down
14 changes: 4 additions & 10 deletions crates/flux-middle/src/global_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,14 @@ impl<'genv, 'tcx> GlobalEnv<'genv, 'tcx> {
self.inner.queries.check_wf(self, def_id)
}

pub fn impl_trait_ref(
self,
impl_id: DefId,
) -> QueryResult<Option<rty::EarlyBinder<rty::TraitRef>>> {
let Some(trait_ref) = self.tcx().impl_trait_ref(impl_id) else { return Ok(None) };
pub fn impl_trait_ref(self, impl_id: DefId) -> QueryResult<rty::EarlyBinder<rty::TraitRef>> {
let trait_ref = self.tcx().impl_trait_ref(impl_id);
let trait_ref = trait_ref.skip_binder();
let trait_ref = trait_ref
.lower(self.tcx())
.map_err(|err| QueryErr::unsupported(trait_ref.def_id, err.into_err()))?
.refine(&Refiner::default_for_item(self, impl_id)?)?;
Ok(Some(rty::EarlyBinder(trait_ref)))
Ok(rty::EarlyBinder(trait_ref))
}

pub fn generics_of(self, def_id: impl IntoQueryParam<DefId>) -> QueryResult<rty::Generics> {
Expand Down Expand Up @@ -323,10 +320,7 @@ impl<'genv, 'tcx> GlobalEnv<'genv, 'tcx> {

// Otherwise, check if the trait has a default body
if let Some(body) = self.default_assoc_refinement_body(trait_assoc_id)? {
let impl_trait_ref = self
.impl_trait_ref(impl_id)?
.unwrap()
.instantiate_identity();
let impl_trait_ref = self.impl_trait_ref(impl_id)?.instantiate_identity();
return Ok(rty::EarlyBinder(body.instantiate(self.tcx(), &impl_trait_ref.args, &[])));
}

Expand Down
18 changes: 3 additions & 15 deletions crates/flux-refineck/src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,8 @@ fn find_trait_item(
) -> QueryResult<Option<(rty::TraitRef, DefId)>> {
let tcx = genv.tcx();
let def_id = def_id.to_def_id();
if let Some(impl_id) = tcx.impl_of_assoc(def_id)
&& let Some(impl_trait_ref) = genv.impl_trait_ref(impl_id)?
{
let impl_trait_ref = impl_trait_ref.instantiate_identity();
if let Some(impl_id) = tcx.trait_impl_of_assoc(def_id) {
let impl_trait_ref = genv.impl_trait_ref(impl_id)?.instantiate_identity();
let trait_item_id = tcx.associated_item(def_id).trait_item_def_id().unwrap();
return Ok(Some((impl_trait_ref, trait_item_id)));
}
Expand Down Expand Up @@ -1390,7 +1388,7 @@ impl<'ck, 'genv, 'tcx, M: Mode> Checker<'ck, 'genv, 'tcx, M> {
self.check_binary_op(infcx, env, stmt_span, *bin_op, op1, op2)
.with_span(stmt_span)
}
Rvalue::NullaryOp(null_op, ty) => Ok(self.check_nullary_op(*null_op, ty)),

Rvalue::UnaryOp(UnOp::PtrMetadata, Operand::Copy(place))
| Rvalue::UnaryOp(UnOp::PtrMetadata, Operand::Move(place)) => {
self.check_raw_ptr_metadata(infcx, env, stmt_span, place)
Expand Down Expand Up @@ -1520,16 +1518,6 @@ impl<'ck, 'genv, 'tcx, M: Mode> Checker<'ck, 'genv, 'tcx, M> {
}
}

fn check_nullary_op(&self, null_op: mir::NullOp, _ty: &ty::Ty) -> Ty {
match null_op {
mir::NullOp::SizeOf | mir::NullOp::AlignOf => {
// We could try to get the layout of type to index this with the actual value, but
// this enough for now. Revisit if we ever need the precision.
Ty::uint(UintTy::Usize)
}
}
}

fn check_unary_op(
&mut self,
infcx: &mut InferCtxt<'_, 'genv, 'tcx>,
Expand Down
3 changes: 1 addition & 2 deletions crates/flux-refineck/src/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::ty::TypingMode;

pub fn check_impl_against_trait(genv: GlobalEnv, impl_id: MaybeExternId) -> QueryResult {
let trait_id = genv.tcx().trait_id_of_impl(impl_id.resolved_id()).unwrap();
let trait_id = genv.tcx().impl_trait_id(impl_id.resolved_id());

let impl_assoc_refts = genv.assoc_refinements_of(impl_id)?;
let trait_assoc_refts = genv.assoc_refinements_of(trait_id)?;
Expand All @@ -37,7 +37,6 @@ pub fn check_impl_against_trait(genv: GlobalEnv, impl_id: MaybeExternId) -> Quer

let impl_trait_ref = genv
.impl_trait_ref(impl_id.resolved_id())?
.unwrap()
.instantiate_identity();

let rustc_infcx = genv
Expand Down
1 change: 0 additions & 1 deletion crates/flux-refineck/src/ghost_statements/fold_unfold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ impl<M: Mode> FoldUnfoldAnalysis<'_, '_, '_, M> {
Rvalue::Repeat(op, _) => {
self.operand(op, env)?;
}
Rvalue::NullaryOp(_, _) => {}
}
M::projection(self, env, place)?;
}
Expand Down
Loading