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 7 pull requests #118019

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6649219
Remove asmjs from library
workingjubilee Oct 29, 2023
e9a009f
Remove asmjs from tests
workingjubilee Oct 29, 2023
c88fc2e
Remove asmjs from CI
workingjubilee Oct 29, 2023
e8a0274
Remove asmjs from miri
workingjubilee Oct 29, 2023
ca4d6d1
Remove asmjs from tools
workingjubilee Oct 29, 2023
0c1a452
Remove asmjs from bootstrap
workingjubilee Oct 29, 2023
208f378
Remove asmjs from compiler
workingjubilee Oct 29, 2023
dbb2500
Officially remove asmjs platform support
workingjubilee Oct 29, 2023
e6779d9
library: use `copied` instead of manual `map`
DaniPopes Nov 3, 2023
2736430
compiler: use `copied` instead of manual `map`
DaniPopes Nov 3, 2023
890ce26
When using existing fn as module, don't claim it doesn't exist
estebank Nov 16, 2023
ae62ebe
Don't require intercrate mode for negative coherence
compiler-errors Nov 16, 2023
d688b86
Ignore but do not assume region obligations from unifying headers in …
compiler-errors Nov 16, 2023
ae179a0
emit basic smir
ouz-a Nov 8, 2023
0f0e9ba
cover statements
ouz-a Nov 8, 2023
ebd9c14
better formatting for statements
ouz-a Nov 9, 2023
c821603
remove unwrap
ouz-a Nov 14, 2023
3883645
change smir to StableMir
ouz-a Nov 14, 2023
71c9904
move pretty into stable_mir
ouz-a Nov 15, 2023
3b0e1d2
only free lifetimes may get erased
lcnr Nov 17, 2023
92657f1
use new apis and add new function
ouz-a Nov 17, 2023
2e71bdd
Rollup merge of #117338 - workingjubilee:asmjs-meets-thanatos, r=b-naber
matthiaskrgr Nov 17, 2023
5ecf69c
Rollup merge of #117549 - DaniPopes:more-copied, r=b-naber
matthiaskrgr Nov 17, 2023
8bfefa1
Rollup merge of #117745 - ouz-a:emit_smir, r=celinval
matthiaskrgr Nov 17, 2023
95010db
Rollup merge of #117964 - estebank:issue-81232, r=petrochenkov
matthiaskrgr Nov 17, 2023
09b964a
Rollup merge of #117992 - compiler-errors:sound-but-not-complete, r=lcnr
matthiaskrgr Nov 17, 2023
7eb676f
Rollup merge of #117994 - compiler-errors:throw-away-regions-in-coher…
matthiaskrgr Nov 17, 2023
e3ec371
Rollup merge of #118006 - lcnr:discriminant-docs, r=compiler-errors
matthiaskrgr Nov 17, 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3815,6 +3815,7 @@ dependencies = [
"rustc_query_system",
"rustc_resolve",
"rustc_session",
"rustc_smir",
"rustc_span",
"rustc_symbol_mangling",
"rustc_target",
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
// Merge attributes into the inner expression.
if !e.attrs.is_empty() {
let old_attrs =
self.attrs.get(&ex.hir_id.local_id).map(|la| *la).unwrap_or(&[]);
let old_attrs = self.attrs.get(&ex.hir_id.local_id).copied().unwrap_or(&[]);
self.attrs.insert(
ex.hir_id.local_id,
&*self.arena.alloc_from_iter(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
/// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
/// resolver (if any).
fn orig_opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
self.resolver.node_id_to_def_id.get(&node).map(|local_def_id| *local_def_id)
self.resolver.node_id_to_def_id.get(&node).copied()
}

/// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
Expand Down Expand Up @@ -542,7 +542,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
self.generics_def_id_map
.iter()
.rev()
.find_map(|map| map.get(&local_def_id).map(|local_def_id| *local_def_id))
.find_map(|map| map.get(&local_def_id).copied())
.unwrap_or(local_def_id)
}

Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,11 +990,7 @@ unsafe fn embed_bitcode(
// reason (see issue #90326 for historical background).
let is_aix = target_is_aix(cgcx);
let is_apple = target_is_apple(cgcx);
if is_apple
|| is_aix
|| cgcx.opts.target_triple.triple().starts_with("wasm")
|| cgcx.opts.target_triple.triple().starts_with("asmjs")
{
if is_apple || is_aix || cgcx.opts.target_triple.triple().starts_with("wasm") {
// We don't need custom section flags, create LLVM globals.
let llconst = common::bytes_in_context(llcx, bitcode);
let llglobal = llvm::LLVMAddGlobal(
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2243,9 +2243,9 @@ fn linker_with_args<'a>(
// ------------ Late order-dependent options ------------

// Doesn't really make sense.
// FIXME: In practice built-in target specs use this for arbitrary order-independent options,
// introduce a target spec option for order-independent linker options, migrate built-in specs
// to it and remove the option.
// FIXME: In practice built-in target specs use this for arbitrary order-independent options.
// Introduce a target spec option for order-independent linker options, migrate built-in specs
// to it and remove the option. Currently the last holdout is wasm32-unknown-emscripten.
add_post_link_args(cmd, sess, flavor);

Ok(cmd.take_cmd())
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ rustc_privacy = { path = "../rustc_privacy" }
rustc_query_system = { path = "../rustc_query_system" }
rustc_resolve = { path = "../rustc_resolve" }
rustc_session = { path = "../rustc_session" }
rustc_smir ={ path = "../rustc_smir" }
rustc_span = { path = "../rustc_span" }
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }
rustc_target = { path = "../rustc_target" }
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_driver_impl/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use rustc_middle::mir::{write_mir_graphviz, write_mir_pretty};
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::config::{OutFileName, PpHirMode, PpMode, PpSourceMode};
use rustc_session::Session;
use rustc_smir::rustc_internal::pretty::write_smir_pretty;
use rustc_span::symbol::Ident;
use rustc_span::FileName;

Expand Down Expand Up @@ -325,6 +326,11 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
write_mir_graphviz(ex.tcx(), None, &mut out).unwrap();
String::from_utf8(out).unwrap()
}
StableMir => {
let mut out = Vec::new();
write_smir_pretty(ex.tcx(), &mut out).unwrap();
String::from_utf8(out).unwrap()
}
ThirTree => {
let tcx = ex.tcx();
let mut out = String::new();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
self.suggest_boxing_for_return_impl_trait(
err,
ret_sp,
prior_arms.iter().chain(std::iter::once(&arm_span)).map(|s| *s),
prior_arms.iter().chain(std::iter::once(&arm_span)).copied(),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ pub trait LintContext {
db.note("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information");
},
BuiltinLintDiagnostics::UnexpectedCfgName((name, name_span), value) => {
let possibilities: Vec<Symbol> = sess.parse_sess.check_config.expecteds.keys().map(|s| *s).collect();
let possibilities: Vec<Symbol> = sess.parse_sess.check_config.expecteds.keys().copied().collect();

// Suggest the most probable if we found one
if let Some(best_match) = find_best_match_for_name(&possibilities, name, None) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ pub fn write_allocations<'tcx>(
fn alloc_ids_from_alloc(
alloc: ConstAllocation<'_>,
) -> impl DoubleEndedIterator<Item = AllocId> + '_ {
alloc.inner().provenance().ptrs().values().map(|id| *id)
alloc.inner().provenance().ptrs().values().copied()
}

fn alloc_ids_from_const_val(val: ConstValue<'_>) -> impl Iterator<Item = AllocId> + '_ {
Expand Down
14 changes: 13 additions & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,19 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
},
)
});
(format!("use of undeclared crate or module `{ident}`"), suggestion)
if let Ok(binding) = self.early_resolve_ident_in_lexical_scope(
ident,
ScopeSet::All(ValueNS),
parent_scope,
None,
false,
ignore_binding,
) {
let descr = binding.res().descr();
(format!("{descr} `{ident}` is not a crate or module"), suggestion)
} else {
(format!("use of undeclared crate or module `{ident}`"), suggestion)
}
}
}

Expand Down
12 changes: 8 additions & 4 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2926,12 +2926,13 @@ fn parse_pretty(handler: &EarlyErrorHandler, unstable_opts: &UnstableOptions) ->
"thir-tree" => ThirTree,
"thir-flat" => ThirFlat,
"mir" => Mir,
"stable-mir" => StableMir,
"mir-cfg" => MirCFG,
name => handler.early_error(format!(
"argument to `unpretty` must be one of `normal`, `identified`, \
`expanded`, `expanded,identified`, `expanded,hygiene`, \
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
`hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir` or \
`hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir`, `stable-mir`, or \
`mir-cfg`; got {name}"
)),
};
Expand Down Expand Up @@ -3106,6 +3107,8 @@ pub enum PpMode {
Mir,
/// `-Zunpretty=mir-cfg`
MirCFG,
/// `-Zunpretty=stable-mir`
StableMir,
}

impl PpMode {
Expand All @@ -3122,21 +3125,22 @@ impl PpMode {
| ThirTree
| ThirFlat
| Mir
| MirCFG => true,
| MirCFG
| StableMir => true,
}
}
pub fn needs_hir(&self) -> bool {
use PpMode::*;
match *self {
Source(_) | AstTree | AstTreeExpanded => false,

Hir(_) | HirTree | ThirTree | ThirFlat | Mir | MirCFG => true,
Hir(_) | HirTree | ThirTree | ThirFlat | Mir | MirCFG | StableMir => true,
}
}

pub fn needs_analysis(&self) -> bool {
use PpMode::*;
matches!(*self, Hir(PpHirMode::Typed) | Mir | MirCFG | ThirTree | ThirFlat)
matches!(*self, Hir(PpHirMode::Typed) | Mir | StableMir | MirCFG | ThirTree | ThirFlat)
}
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_smir/src/rustc_internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::hash::Hash;
use std::ops::Index;

mod internal;
pub mod pretty;

pub fn stable<'tcx, S: Stable<'tcx>>(item: S) -> S::T {
with_tables(|tables| item.stable(tables))
Expand Down
20 changes: 20 additions & 0 deletions compiler/rustc_smir/src/rustc_internal/pretty.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::io;

use super::run;
use rustc_middle::ty::TyCtxt;

pub fn write_smir_pretty<'tcx, W: io::Write>(tcx: TyCtxt<'tcx>, w: &mut W) -> io::Result<()> {
writeln!(
w,
"// WARNING: This is highly experimental output it's intended for stable-mir developers only."
)?;
writeln!(
w,
"// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir."
)?;
let _ = run(tcx, || {
let items = stable_mir::all_local_items();
let _ = items.iter().map(|item| -> io::Result<()> { item.dump(w) }).collect::<Vec<_>>();
});
Ok(())
}
7 changes: 6 additions & 1 deletion compiler/rustc_smir/src/rustc_smir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//!
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.

use crate::rustc_internal::{IndexMap, RustcInternal};
use crate::rustc_internal::{internal, IndexMap, RustcInternal};
use crate::rustc_smir::stable_mir::ty::{BoundRegion, Region};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
Expand Down Expand Up @@ -105,6 +105,10 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
tables.tcx.type_of(item.internal(&mut *tables)).instantiate_identity().stable(&mut *tables)
}

fn const_literal(&self, cnst: &stable_mir::ty::Const) -> String {
internal(cnst).to_string()
}

fn span_of_an_item(&self, def_id: stable_mir::DefId) -> Span {
let mut tables = self.0.borrow_mut();
tables.tcx.def_span(tables[def_id]).stable(&mut *tables)
Expand Down Expand Up @@ -404,6 +408,7 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> {
.map(|decl| stable_mir::mir::LocalDecl {
ty: decl.ty.stable(tables),
span: decl.source_info.span.stable(tables),
mutability: decl.mutability.stable(tables),
})
.collect(),
self.arg_count,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/abi/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,6 @@ impl<'a, Ty> FnAbi<'a, Ty> {
wasm::compute_c_abi_info(cx, self)
}
}
"asmjs" => wasm::compute_c_abi_info(cx, self),
"bpf" => bpf::compute_abi_info(self),
arch => {
return Err(AdjustForForeignAbiError::Unsupported {
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,6 @@ supported_targets! {
("thumbv7a-pc-windows-msvc", thumbv7a_pc_windows_msvc),
("thumbv7a-uwp-windows-msvc", thumbv7a_uwp_windows_msvc),

("asmjs-unknown-emscripten", asmjs_unknown_emscripten),
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
("wasm32-unknown-unknown", wasm32_unknown_unknown),
("wasm32-wasi", wasm32_wasi),
Expand Down Expand Up @@ -2244,10 +2243,6 @@ impl TargetOptions {
add_link_args(&mut self.pre_link_args, flavor, args);
}

fn add_post_link_args(&mut self, flavor: LinkerFlavor, args: &[&'static str]) {
add_link_args(&mut self.post_link_args, flavor, args);
}

fn update_from_cli(&mut self) {
self.linker_flavor = LinkerFlavor::from_cli_json(
self.linker_flavor_json,
Expand Down
18 changes: 11 additions & 7 deletions compiler/rustc_trait_selection/src/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,11 @@ fn impl_intersection_has_negative_obligation(
) -> bool {
debug!("negative_impl(impl1_def_id={:?}, impl2_def_id={:?})", impl1_def_id, impl2_def_id);

let ref infcx = tcx.infer_ctxt().intercrate(true).with_next_trait_solver(true).build();
// N.B. We don't need to use intercrate mode here because we're trying to prove
// the *existence* of a negative goal, not the non-existence of a positive goal.
// Without this, we over-eagerly register coherence ambiguity candidates when
// impl candidates do exist.
let ref infcx = tcx.infer_ctxt().with_next_trait_solver(true).build();
let universe = infcx.universe();

let impl1_header = fresh_impl_header(infcx, impl1_def_id);
Expand Down Expand Up @@ -542,14 +546,14 @@ fn try_prove_negated_where_clause<'tcx>(
};

// FIXME(with_negative_coherence): the infcx has region contraints from equating
// the impl headers as requirements. Given that the only region constraints we
// get are involving inference regions in the root, it shouldn't matter, but
// still sus.
// the impl headers as requirements.
//
// We probably should just throw away the region obligations registered up until
// now, or ideally use them as assumptions when proving the region obligations
// that we get from proving the negative predicate below.
// We ideally should use these region constraints as assumptions when proving
// the region obligations that we get from proving the negative predicate below.
let ref infcx = root_infcx.fork();
let _ = infcx.take_registered_region_obligations();
let _ = infcx.take_and_reset_region_constraints();

let ocx = ObligationCtxt::new(infcx);

ocx.register_obligation(Obligation::new(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ty_utils/src/assoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &[DefId] {
trait_fn_def_id,
)
})
.map(|def_id| *def_id),
.copied(),
),
)
}
Expand All @@ -69,7 +69,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &[DefId] {
impl_fn_def_id,
)
})
.map(|def_id| *def_id)
.copied()
})),
)
}
Expand Down
14 changes: 12 additions & 2 deletions compiler/stable_mir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

use crate::mir::mono::InstanceDef;
use crate::mir::Body;
use std::cell::Cell;
use std::fmt;
use std::fmt::Debug;
use std::{cell::Cell, io};

use self::ty::{
GenericPredicates, Generics, ImplDef, ImplTrait, IndexedVal, LineInfo, Span, TraitDecl,
Expand All @@ -36,10 +36,12 @@ pub mod mir;
pub mod ty;
pub mod visitor;

use crate::mir::pretty::function_name;
use crate::mir::Mutability;
use crate::ty::{AdtDef, AdtKind, ClosureDef, ClosureKind};
pub use error::*;
use mir::mono::Instance;
use ty::{FnDef, GenericArgs};
use ty::{Const, FnDef, GenericArgs};

/// Use String for now but we should replace it.
pub type Symbol = String;
Expand Down Expand Up @@ -137,6 +139,11 @@ impl CrateItem {
pub fn ty(&self) -> Ty {
with(|cx| cx.def_ty(self.0))
}

pub fn dump<W: io::Write>(&self, w: &mut W) -> io::Result<()> {
writeln!(w, "{}", function_name(*self))?;
self.body().dump(w)
}
}

/// Return the function where execution starts if the current
Expand Down Expand Up @@ -223,6 +230,9 @@ pub trait Context {
/// Returns the type of given crate item.
fn def_ty(&self, item: DefId) -> Ty;

/// Returns literal value of a const as a string.
fn const_literal(&self, cnst: &Const) -> String;

/// `Span` of an item
fn span_of_an_item(&self, def_id: DefId) -> Span;

Expand Down
1 change: 1 addition & 0 deletions compiler/stable_mir/src/mir.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod body;
pub mod mono;
pub mod pretty;
pub mod visit;

pub use body::*;
Expand Down
Loading
Loading