Auto merge of #130473 - matthiaskrgr:rollup-lf29374, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #128535 (Format `std::env::consts` docstrings with markdown backticks) - #128961 (Fix #128930: Print documentation of CLI options missing their arg) - #129988 (Use `Vec` in `rustc_interface::Config::locale_resources`) - #130201 (Encode `coroutine_by_move_body_def_id` in crate metadata) - #130275 (Don't call `extern_crate` when local crate name is the same as a dependency and we have a trait error) - #130314 (Use the same precedence for all macro-like exprs) - #130440 (Don't ICE in `opaque_hidden_inferred_bound` lint for RPITIT in trait with no default method body) - #130458 (`rustc_codegen_ssa` cleanups) - #130469 (Mark `where_clauses_object_safety` as removed) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
f609b7e058
58 changed files with 603 additions and 427 deletions
|
@ -1293,7 +1293,7 @@ impl Expr {
|
||||||
ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node),
|
ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node),
|
||||||
ExprKind::Unary(..) => ExprPrecedence::Unary,
|
ExprKind::Unary(..) => ExprPrecedence::Unary,
|
||||||
ExprKind::Lit(_) | ExprKind::IncludedBytes(..) => ExprPrecedence::Lit,
|
ExprKind::Lit(_) | ExprKind::IncludedBytes(..) => ExprPrecedence::Lit,
|
||||||
ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast,
|
ExprKind::Cast(..) => ExprPrecedence::Cast,
|
||||||
ExprKind::Let(..) => ExprPrecedence::Let,
|
ExprKind::Let(..) => ExprPrecedence::Let,
|
||||||
ExprKind::If(..) => ExprPrecedence::If,
|
ExprKind::If(..) => ExprPrecedence::If,
|
||||||
ExprKind::While(..) => ExprPrecedence::While,
|
ExprKind::While(..) => ExprPrecedence::While,
|
||||||
|
@ -1317,17 +1317,18 @@ impl Expr {
|
||||||
ExprKind::Break(..) => ExprPrecedence::Break,
|
ExprKind::Break(..) => ExprPrecedence::Break,
|
||||||
ExprKind::Continue(..) => ExprPrecedence::Continue,
|
ExprKind::Continue(..) => ExprPrecedence::Continue,
|
||||||
ExprKind::Ret(..) => ExprPrecedence::Ret,
|
ExprKind::Ret(..) => ExprPrecedence::Ret,
|
||||||
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
|
|
||||||
ExprKind::OffsetOf(..) => ExprPrecedence::OffsetOf,
|
|
||||||
ExprKind::MacCall(..) => ExprPrecedence::Mac,
|
|
||||||
ExprKind::Struct(..) => ExprPrecedence::Struct,
|
ExprKind::Struct(..) => ExprPrecedence::Struct,
|
||||||
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
|
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
|
||||||
ExprKind::Paren(..) => ExprPrecedence::Paren,
|
ExprKind::Paren(..) => ExprPrecedence::Paren,
|
||||||
ExprKind::Try(..) => ExprPrecedence::Try,
|
ExprKind::Try(..) => ExprPrecedence::Try,
|
||||||
ExprKind::Yield(..) => ExprPrecedence::Yield,
|
ExprKind::Yield(..) => ExprPrecedence::Yield,
|
||||||
ExprKind::Yeet(..) => ExprPrecedence::Yeet,
|
ExprKind::Yeet(..) => ExprPrecedence::Yeet,
|
||||||
ExprKind::FormatArgs(..) => ExprPrecedence::FormatArgs,
|
|
||||||
ExprKind::Become(..) => ExprPrecedence::Become,
|
ExprKind::Become(..) => ExprPrecedence::Become,
|
||||||
|
ExprKind::InlineAsm(..)
|
||||||
|
| ExprKind::Type(..)
|
||||||
|
| ExprKind::OffsetOf(..)
|
||||||
|
| ExprKind::FormatArgs(..)
|
||||||
|
| ExprKind::MacCall(..) => ExprPrecedence::Mac,
|
||||||
ExprKind::Err(_) | ExprKind::Dummy => ExprPrecedence::Err,
|
ExprKind::Err(_) | ExprKind::Dummy => ExprPrecedence::Err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,10 +265,7 @@ pub enum ExprPrecedence {
|
||||||
Field,
|
Field,
|
||||||
Index,
|
Index,
|
||||||
Try,
|
Try,
|
||||||
InlineAsm,
|
|
||||||
OffsetOf,
|
|
||||||
Mac,
|
Mac,
|
||||||
FormatArgs,
|
|
||||||
|
|
||||||
Array,
|
Array,
|
||||||
Repeat,
|
Repeat,
|
||||||
|
@ -333,17 +330,14 @@ impl ExprPrecedence {
|
||||||
| ExprPrecedence::ConstBlock
|
| ExprPrecedence::ConstBlock
|
||||||
| ExprPrecedence::Field
|
| ExprPrecedence::Field
|
||||||
| ExprPrecedence::ForLoop
|
| ExprPrecedence::ForLoop
|
||||||
| ExprPrecedence::FormatArgs
|
|
||||||
| ExprPrecedence::Gen
|
| ExprPrecedence::Gen
|
||||||
| ExprPrecedence::If
|
| ExprPrecedence::If
|
||||||
| ExprPrecedence::Index
|
| ExprPrecedence::Index
|
||||||
| ExprPrecedence::InlineAsm
|
|
||||||
| ExprPrecedence::Lit
|
| ExprPrecedence::Lit
|
||||||
| ExprPrecedence::Loop
|
| ExprPrecedence::Loop
|
||||||
| ExprPrecedence::Mac
|
| ExprPrecedence::Mac
|
||||||
| ExprPrecedence::Match
|
| ExprPrecedence::Match
|
||||||
| ExprPrecedence::MethodCall
|
| ExprPrecedence::MethodCall
|
||||||
| ExprPrecedence::OffsetOf
|
|
||||||
| ExprPrecedence::Paren
|
| ExprPrecedence::Paren
|
||||||
| ExprPrecedence::Path
|
| ExprPrecedence::Path
|
||||||
| ExprPrecedence::PostfixMatch
|
| ExprPrecedence::PostfixMatch
|
||||||
|
|
|
@ -157,7 +157,7 @@ pub trait ArchiveBuilderBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_mingw_dll_import_lib(
|
fn create_mingw_dll_import_lib(
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
lib_name: &str,
|
lib_name: &str,
|
||||||
import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,
|
import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::{fmt, io, mem};
|
||||||
use rustc_target::spec::LldFlavor;
|
use rustc_target::spec::LldFlavor;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Command {
|
pub(crate) struct Command {
|
||||||
program: Program,
|
program: Program,
|
||||||
args: Vec<OsString>,
|
args: Vec<OsString>,
|
||||||
env: Vec<(OsString, OsString)>,
|
env: Vec<(OsString, OsString)>,
|
||||||
|
@ -23,15 +23,15 @@ enum Program {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Command {
|
impl Command {
|
||||||
pub fn new<P: AsRef<OsStr>>(program: P) -> Command {
|
pub(crate) fn new<P: AsRef<OsStr>>(program: P) -> Command {
|
||||||
Command::_new(Program::Normal(program.as_ref().to_owned()))
|
Command::_new(Program::Normal(program.as_ref().to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
|
pub(crate) fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
|
||||||
Command::_new(Program::CmdBatScript(program.as_ref().to_owned()))
|
Command::_new(Program::CmdBatScript(program.as_ref().to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
|
pub(crate) fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
|
||||||
Command::_new(Program::Lld(program.as_ref().to_owned(), flavor))
|
Command::_new(Program::Lld(program.as_ref().to_owned(), flavor))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,12 +39,12 @@ impl Command {
|
||||||
Command { program, args: Vec::new(), env: Vec::new(), env_remove: Vec::new() }
|
Command { program, args: Vec::new(), env: Vec::new(), env_remove: Vec::new() }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
|
pub(crate) fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
|
||||||
self._arg(arg.as_ref());
|
self._arg(arg.as_ref());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn args<I>(&mut self, args: I) -> &mut Command
|
pub(crate) fn args<I>(&mut self, args: I) -> &mut Command
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item: AsRef<OsStr>>,
|
I: IntoIterator<Item: AsRef<OsStr>>,
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,7 @@ impl Command {
|
||||||
self.args.push(arg.to_owned());
|
self.args.push(arg.to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
|
pub(crate) fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
|
||||||
where
|
where
|
||||||
K: AsRef<OsStr>,
|
K: AsRef<OsStr>,
|
||||||
V: AsRef<OsStr>,
|
V: AsRef<OsStr>,
|
||||||
|
@ -71,7 +71,7 @@ impl Command {
|
||||||
self.env.push((key.to_owned(), value.to_owned()));
|
self.env.push((key.to_owned(), value.to_owned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn env_remove<K>(&mut self, key: K) -> &mut Command
|
pub(crate) fn env_remove<K>(&mut self, key: K) -> &mut Command
|
||||||
where
|
where
|
||||||
K: AsRef<OsStr>,
|
K: AsRef<OsStr>,
|
||||||
{
|
{
|
||||||
|
@ -83,11 +83,11 @@ impl Command {
|
||||||
self.env_remove.push(key.to_owned());
|
self.env_remove.push(key.to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn output(&mut self) -> io::Result<Output> {
|
pub(crate) fn output(&mut self) -> io::Result<Output> {
|
||||||
self.command().output()
|
self.command().output()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn command(&self) -> process::Command {
|
pub(crate) fn command(&self) -> process::Command {
|
||||||
let mut ret = match self.program {
|
let mut ret = match self.program {
|
||||||
Program::Normal(ref p) => process::Command::new(p),
|
Program::Normal(ref p) => process::Command::new(p),
|
||||||
Program::CmdBatScript(ref p) => {
|
Program::CmdBatScript(ref p) => {
|
||||||
|
@ -111,17 +111,17 @@ impl Command {
|
||||||
|
|
||||||
// extensions
|
// extensions
|
||||||
|
|
||||||
pub fn get_args(&self) -> &[OsString] {
|
pub(crate) fn get_args(&self) -> &[OsString] {
|
||||||
&self.args
|
&self.args
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_args(&mut self) -> Vec<OsString> {
|
pub(crate) fn take_args(&mut self) -> Vec<OsString> {
|
||||||
mem::take(&mut self.args)
|
mem::take(&mut self.args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a `true` if we're pretty sure that this'll blow OS spawn limits,
|
/// Returns a `true` if we're pretty sure that this'll blow OS spawn limits,
|
||||||
/// or `false` if we should attempt to spawn and see what the OS says.
|
/// or `false` if we should attempt to spawn and see what the OS says.
|
||||||
pub fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
|
pub(crate) fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
|
||||||
// We mostly only care about Windows in this method, on Unix the limits
|
// We mostly only care about Windows in this method, on Unix the limits
|
||||||
// can be gargantuan anyway so we're pretty unlikely to hit them
|
// can be gargantuan anyway so we're pretty unlikely to hit them
|
||||||
if cfg!(unix) {
|
if cfg!(unix) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ use crate::errors;
|
||||||
/// and prevent inspection of linker output in case of errors, which we occasionally do.
|
/// and prevent inspection of linker output in case of errors, which we occasionally do.
|
||||||
/// This should be acceptable because other messages from rustc are in English anyway,
|
/// This should be acceptable because other messages from rustc are in English anyway,
|
||||||
/// and may also be desirable to improve searchability of the linker diagnostics.
|
/// and may also be desirable to improve searchability of the linker diagnostics.
|
||||||
pub fn disable_localization(linker: &mut Command) {
|
pub(crate) fn disable_localization(linker: &mut Command) {
|
||||||
// No harm in setting both env vars simultaneously.
|
// No harm in setting both env vars simultaneously.
|
||||||
// Unix-style linkers.
|
// Unix-style linkers.
|
||||||
linker.env("LC_ALL", "C");
|
linker.env("LC_ALL", "C");
|
||||||
|
@ -41,7 +41,7 @@ pub fn disable_localization(linker: &mut Command) {
|
||||||
/// The third parameter is for env vars, used on windows to set up the
|
/// The third parameter is for env vars, used on windows to set up the
|
||||||
/// path for MSVC to find its DLLs, and gcc to find its bundled
|
/// path for MSVC to find its DLLs, and gcc to find its bundled
|
||||||
/// toolchain
|
/// toolchain
|
||||||
pub fn get_linker<'a>(
|
pub(crate) fn get_linker<'a>(
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
linker: &Path,
|
linker: &Path,
|
||||||
flavor: LinkerFlavor,
|
flavor: LinkerFlavor,
|
||||||
|
@ -215,28 +215,36 @@ fn link_or_cc_args<L: Linker + ?Sized>(
|
||||||
macro_rules! generate_arg_methods {
|
macro_rules! generate_arg_methods {
|
||||||
($($ty:ty)*) => { $(
|
($($ty:ty)*) => { $(
|
||||||
impl $ty {
|
impl $ty {
|
||||||
pub fn verbatim_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
#[allow(unused)]
|
||||||
|
pub(crate) fn verbatim_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
||||||
verbatim_args(self, args)
|
verbatim_args(self, args)
|
||||||
}
|
}
|
||||||
pub fn verbatim_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
#[allow(unused)]
|
||||||
|
pub(crate) fn verbatim_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||||
verbatim_args(self, iter::once(arg))
|
verbatim_args(self, iter::once(arg))
|
||||||
}
|
}
|
||||||
pub fn link_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>, IntoIter: ExactSizeIterator>) -> &mut Self {
|
#[allow(unused)]
|
||||||
|
pub(crate) fn link_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>, IntoIter: ExactSizeIterator>) -> &mut Self {
|
||||||
link_args(self, args)
|
link_args(self, args)
|
||||||
}
|
}
|
||||||
pub fn link_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
#[allow(unused)]
|
||||||
|
pub(crate) fn link_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||||
link_args(self, iter::once(arg))
|
link_args(self, iter::once(arg))
|
||||||
}
|
}
|
||||||
pub fn cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
#[allow(unused)]
|
||||||
|
pub(crate) fn cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
||||||
cc_args(self, args)
|
cc_args(self, args)
|
||||||
}
|
}
|
||||||
pub fn cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
#[allow(unused)]
|
||||||
|
pub(crate) fn cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||||
cc_args(self, iter::once(arg))
|
cc_args(self, iter::once(arg))
|
||||||
}
|
}
|
||||||
pub fn link_or_cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
#[allow(unused)]
|
||||||
|
pub(crate) fn link_or_cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
||||||
link_or_cc_args(self, args)
|
link_or_cc_args(self, args)
|
||||||
}
|
}
|
||||||
pub fn link_or_cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
#[allow(unused)]
|
||||||
|
pub(crate) fn link_or_cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||||
link_or_cc_args(self, iter::once(arg))
|
link_or_cc_args(self, iter::once(arg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +271,7 @@ generate_arg_methods! {
|
||||||
/// represents the meaning of each option being passed down. This trait is then
|
/// represents the meaning of each option being passed down. This trait is then
|
||||||
/// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
|
/// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
|
||||||
/// MSVC linker (e.g., `link.exe`) is being used.
|
/// MSVC linker (e.g., `link.exe`) is being used.
|
||||||
pub trait Linker {
|
pub(crate) trait Linker {
|
||||||
fn cmd(&mut self) -> &mut Command;
|
fn cmd(&mut self) -> &mut Command;
|
||||||
fn is_cc(&self) -> bool {
|
fn is_cc(&self) -> bool {
|
||||||
false
|
false
|
||||||
|
@ -314,12 +322,12 @@ pub trait Linker {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl dyn Linker + '_ {
|
impl dyn Linker + '_ {
|
||||||
pub fn take_cmd(&mut self) -> Command {
|
pub(crate) fn take_cmd(&mut self) -> Command {
|
||||||
mem::replace(self.cmd(), Command::new(""))
|
mem::replace(self.cmd(), Command::new(""))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GccLinker<'a> {
|
struct GccLinker<'a> {
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
target_cpu: &'a str,
|
target_cpu: &'a str,
|
||||||
|
@ -849,7 +857,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MsvcLinker<'a> {
|
struct MsvcLinker<'a> {
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
}
|
}
|
||||||
|
@ -1103,7 +1111,7 @@ impl<'a> Linker for MsvcLinker<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EmLinker<'a> {
|
struct EmLinker<'a> {
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
}
|
}
|
||||||
|
@ -1220,7 +1228,7 @@ impl<'a> Linker for EmLinker<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WasmLd<'a> {
|
struct WasmLd<'a> {
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
}
|
}
|
||||||
|
@ -1404,7 +1412,7 @@ impl<'a> WasmLd<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Linker shepherd script for L4Re (Fiasco)
|
/// Linker shepherd script for L4Re (Fiasco)
|
||||||
pub struct L4Bender<'a> {
|
struct L4Bender<'a> {
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
hinted_static: bool,
|
hinted_static: bool,
|
||||||
|
@ -1510,7 +1518,7 @@ impl<'a> Linker for L4Bender<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> L4Bender<'a> {
|
impl<'a> L4Bender<'a> {
|
||||||
pub fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
|
fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
|
||||||
L4Bender { cmd, sess, hinted_static: false }
|
L4Bender { cmd, sess, hinted_static: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1523,14 +1531,14 @@ impl<'a> L4Bender<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Linker for AIX.
|
/// Linker for AIX.
|
||||||
pub struct AixLinker<'a> {
|
struct AixLinker<'a> {
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
hinted_static: Option<bool>,
|
hinted_static: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AixLinker<'a> {
|
impl<'a> AixLinker<'a> {
|
||||||
pub fn new(cmd: Command, sess: &'a Session) -> AixLinker<'a> {
|
fn new(cmd: Command, sess: &'a Session) -> AixLinker<'a> {
|
||||||
AixLinker { cmd, sess, hinted_static: None }
|
AixLinker { cmd, sess, hinted_static: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1758,7 +1766,7 @@ pub(crate) fn linked_symbols(
|
||||||
|
|
||||||
/// Much simplified and explicit CLI for the NVPTX linker. The linker operates
|
/// Much simplified and explicit CLI for the NVPTX linker. The linker operates
|
||||||
/// with bitcode and uses LLVM backend to generate a PTX assembly.
|
/// with bitcode and uses LLVM backend to generate a PTX assembly.
|
||||||
pub struct PtxLinker<'a> {
|
struct PtxLinker<'a> {
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
}
|
}
|
||||||
|
@ -1824,7 +1832,7 @@ impl<'a> Linker for PtxLinker<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The `self-contained` LLVM bitcode linker
|
/// The `self-contained` LLVM bitcode linker
|
||||||
pub struct LlbcLinker<'a> {
|
struct LlbcLinker<'a> {
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
}
|
}
|
||||||
|
@ -1895,7 +1903,7 @@ impl<'a> Linker for LlbcLinker<'a> {
|
||||||
fn linker_plugin_lto(&mut self) {}
|
fn linker_plugin_lto(&mut self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BpfLinker<'a> {
|
struct BpfLinker<'a> {
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ use rustc_target::spec::{ef_avr_arch, RelocModel, Target};
|
||||||
/// <dd>The metadata can be found in the `.rustc` section of the shared library.</dd>
|
/// <dd>The metadata can be found in the `.rustc` section of the shared library.</dd>
|
||||||
/// </dl>
|
/// </dl>
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DefaultMetadataLoader;
|
pub(crate) struct DefaultMetadataLoader;
|
||||||
|
|
||||||
static AIX_METADATA_SYMBOL_NAME: &'static str = "__aix_rust_metadata";
|
static AIX_METADATA_SYMBOL_NAME: &'static str = "__aix_rust_metadata";
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ fn macho_is_arm64e(target: &Target) -> bool {
|
||||||
target.llvm_target.starts_with("arm64e")
|
target.llvm_target.starts_with("arm64e")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum MetadataPosition {
|
pub(crate) enum MetadataPosition {
|
||||||
First,
|
First,
|
||||||
Last,
|
Last,
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ pub enum MetadataPosition {
|
||||||
/// * ELF - All other targets are similar to Windows in that there's a
|
/// * ELF - All other targets are similar to Windows in that there's a
|
||||||
/// `SHF_EXCLUDE` flag we can set on sections in an object file to get
|
/// `SHF_EXCLUDE` flag we can set on sections in an object file to get
|
||||||
/// automatically removed from the final output.
|
/// automatically removed from the final output.
|
||||||
pub fn create_wrapper_file(
|
pub(crate) fn create_wrapper_file(
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
section_name: String,
|
section_name: String,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
pub mod archive;
|
pub mod archive;
|
||||||
pub mod command;
|
pub(crate) mod command;
|
||||||
pub mod link;
|
pub mod link;
|
||||||
pub mod linker;
|
pub(crate) mod linker;
|
||||||
pub mod lto;
|
pub mod lto;
|
||||||
pub mod metadata;
|
pub mod metadata;
|
||||||
pub mod rpath;
|
pub(crate) mod rpath;
|
||||||
pub mod symbol_export;
|
pub mod symbol_export;
|
||||||
pub mod write;
|
pub mod write;
|
||||||
|
|
|
@ -6,14 +6,14 @@ use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_fs_util::try_canonicalize;
|
use rustc_fs_util::try_canonicalize;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
pub struct RPathConfig<'a> {
|
pub(super) struct RPathConfig<'a> {
|
||||||
pub libs: &'a [&'a Path],
|
pub libs: &'a [&'a Path],
|
||||||
pub out_filename: PathBuf,
|
pub out_filename: PathBuf,
|
||||||
pub is_like_osx: bool,
|
pub is_like_osx: bool,
|
||||||
pub linker_is_gnu: bool,
|
pub linker_is_gnu: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec<OsString> {
|
pub(super) fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec<OsString> {
|
||||||
debug!("preparing the RPATH!");
|
debug!("preparing the RPATH!");
|
||||||
|
|
||||||
let rpaths = get_rpaths(config);
|
let rpaths = get_rpaths(config);
|
||||||
|
|
|
@ -18,7 +18,7 @@ use tracing::debug;
|
||||||
|
|
||||||
use crate::base::allocator_kind_for_codegen;
|
use crate::base::allocator_kind_for_codegen;
|
||||||
|
|
||||||
pub fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
|
fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
|
||||||
crates_export_threshold(tcx.crate_types())
|
crates_export_threshold(tcx.crate_types())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId)
|
||||||
!tcx.reachable_set(()).contains(&def_id)
|
!tcx.reachable_set(()).contains(&def_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
providers.reachable_non_generics = reachable_non_generics_provider;
|
providers.reachable_non_generics = reachable_non_generics_provider;
|
||||||
providers.is_reachable_non_generic = is_reachable_non_generic_provider_local;
|
providers.is_reachable_non_generic = is_reachable_non_generic_provider_local;
|
||||||
providers.exported_symbols = exported_symbols_provider_local;
|
providers.exported_symbols = exported_symbols_provider_local;
|
||||||
|
@ -525,7 +525,7 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is the symbol name of the given instance instantiated in a specific crate.
|
/// This is the symbol name of the given instance instantiated in a specific crate.
|
||||||
pub fn symbol_name_for_instance_in_crate<'tcx>(
|
pub(crate) fn symbol_name_for_instance_in_crate<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
symbol: ExportedSymbol<'tcx>,
|
symbol: ExportedSymbol<'tcx>,
|
||||||
instantiating_crate: CrateNum,
|
instantiating_crate: CrateNum,
|
||||||
|
@ -582,7 +582,7 @@ pub fn symbol_name_for_instance_in_crate<'tcx>(
|
||||||
/// This is the symbol name of the given instance as seen by the linker.
|
/// This is the symbol name of the given instance as seen by the linker.
|
||||||
///
|
///
|
||||||
/// On 32-bit Windows symbols are decorated according to their calling conventions.
|
/// On 32-bit Windows symbols are decorated according to their calling conventions.
|
||||||
pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
|
pub(crate) fn linking_symbol_name_for_instance_in_crate<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
symbol: ExportedSymbol<'tcx>,
|
symbol: ExportedSymbol<'tcx>,
|
||||||
instantiating_crate: CrateNum,
|
instantiating_crate: CrateNum,
|
||||||
|
@ -661,7 +661,7 @@ pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
|
||||||
format!("{prefix}{undecorated}{suffix}{args_in_bytes}")
|
format!("{prefix}{undecorated}{suffix}{args_in_bytes}")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exporting_symbol_name_for_instance_in_crate<'tcx>(
|
pub(crate) fn exporting_symbol_name_for_instance_in_crate<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
symbol: ExportedSymbol<'tcx>,
|
symbol: ExportedSymbol<'tcx>,
|
||||||
cnum: CrateNum,
|
cnum: CrateNum,
|
||||||
|
|
|
@ -335,7 +335,7 @@ pub type TargetMachineFactoryFn<B> = Arc<
|
||||||
+ Sync,
|
+ Sync,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
pub type ExportedSymbols = FxHashMap<CrateNum, Arc<Vec<(String, SymbolExportInfo)>>>;
|
type ExportedSymbols = FxHashMap<CrateNum, Arc<Vec<(String, SymbolExportInfo)>>>;
|
||||||
|
|
||||||
/// Additional resources used by optimize_and_codegen (not module specific)
|
/// Additional resources used by optimize_and_codegen (not module specific)
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -437,9 +437,9 @@ fn generate_lto_work<B: ExtraBackendMethods>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CompiledModules {
|
struct CompiledModules {
|
||||||
pub modules: Vec<CompiledModule>,
|
modules: Vec<CompiledModule>,
|
||||||
pub allocator_module: Option<CompiledModule>,
|
allocator_module: Option<CompiledModule>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn need_bitcode_in_object(tcx: TyCtxt<'_>) -> bool {
|
fn need_bitcode_in_object(tcx: TyCtxt<'_>) -> bool {
|
||||||
|
@ -462,7 +462,7 @@ fn need_pre_lto_bitcode_for_incr_comp(sess: &Session) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_async_codegen<B: ExtraBackendMethods>(
|
pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
|
||||||
backend: B,
|
backend: B,
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
target_cpu: String,
|
target_cpu: String,
|
||||||
|
@ -836,13 +836,13 @@ pub enum FatLtoInput<B: WriteBackendMethods> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Actual LTO type we end up choosing based on multiple factors.
|
/// Actual LTO type we end up choosing based on multiple factors.
|
||||||
pub enum ComputedLtoType {
|
pub(crate) enum ComputedLtoType {
|
||||||
No,
|
No,
|
||||||
Thin,
|
Thin,
|
||||||
Fat,
|
Fat,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compute_per_cgu_lto_type(
|
pub(crate) fn compute_per_cgu_lto_type(
|
||||||
sess_lto: &Lto,
|
sess_lto: &Lto,
|
||||||
opts: &config::Options,
|
opts: &config::Options,
|
||||||
sess_crate_types: &[CrateType],
|
sess_crate_types: &[CrateType],
|
||||||
|
@ -1087,7 +1087,7 @@ struct Diagnostic {
|
||||||
// A cut-down version of `rustc_errors::Subdiag` that impls `Send`. It's
|
// A cut-down version of `rustc_errors::Subdiag` that impls `Send`. It's
|
||||||
// missing the following fields from `rustc_errors::Subdiag`.
|
// missing the following fields from `rustc_errors::Subdiag`.
|
||||||
// - `span`: it doesn't impl `Send`.
|
// - `span`: it doesn't impl `Send`.
|
||||||
pub struct Subdiagnostic {
|
pub(crate) struct Subdiagnostic {
|
||||||
level: Level,
|
level: Level,
|
||||||
messages: Vec<(DiagMessage, Style)>,
|
messages: Vec<(DiagMessage, Style)>,
|
||||||
}
|
}
|
||||||
|
@ -1779,7 +1779,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||||
|
|
||||||
/// `FatalError` is explicitly not `Send`.
|
/// `FatalError` is explicitly not `Send`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct WorkerFatalError;
|
pub(crate) struct WorkerFatalError;
|
||||||
|
|
||||||
fn spawn_work<'a, B: ExtraBackendMethods>(
|
fn spawn_work<'a, B: ExtraBackendMethods>(
|
||||||
cgcx: &'a CodegenContext<B>,
|
cgcx: &'a CodegenContext<B>,
|
||||||
|
@ -1867,7 +1867,7 @@ pub struct SharedEmitterMain {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SharedEmitter {
|
impl SharedEmitter {
|
||||||
pub fn new() -> (SharedEmitter, SharedEmitterMain) {
|
fn new() -> (SharedEmitter, SharedEmitterMain) {
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
|
|
||||||
(SharedEmitter { sender }, SharedEmitterMain { receiver })
|
(SharedEmitter { sender }, SharedEmitterMain { receiver })
|
||||||
|
@ -1883,7 +1883,7 @@ impl SharedEmitter {
|
||||||
drop(self.sender.send(SharedEmitterMessage::InlineAsmError(cookie, msg, level, source)));
|
drop(self.sender.send(SharedEmitterMessage::InlineAsmError(cookie, msg, level, source)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fatal(&self, msg: &str) {
|
fn fatal(&self, msg: &str) {
|
||||||
drop(self.sender.send(SharedEmitterMessage::Fatal(msg.to_string())));
|
drop(self.sender.send(SharedEmitterMessage::Fatal(msg.to_string())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1930,7 +1930,7 @@ impl Emitter for SharedEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SharedEmitterMain {
|
impl SharedEmitterMain {
|
||||||
pub fn check(&self, sess: &Session, blocking: bool) {
|
fn check(&self, sess: &Session, blocking: bool) {
|
||||||
loop {
|
loop {
|
||||||
let message = if blocking {
|
let message = if blocking {
|
||||||
match self.receiver.recv() {
|
match self.receiver.recv() {
|
||||||
|
@ -2087,17 +2087,17 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn codegen_finished(&self, tcx: TyCtxt<'_>) {
|
pub(crate) fn codegen_finished(&self, tcx: TyCtxt<'_>) {
|
||||||
self.wait_for_signal_to_codegen_item();
|
self.wait_for_signal_to_codegen_item();
|
||||||
self.check_for_errors(tcx.sess);
|
self.check_for_errors(tcx.sess);
|
||||||
drop(self.coordinator.sender.send(Box::new(Message::CodegenComplete::<B>)));
|
drop(self.coordinator.sender.send(Box::new(Message::CodegenComplete::<B>)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_for_errors(&self, sess: &Session) {
|
pub(crate) fn check_for_errors(&self, sess: &Session) {
|
||||||
self.shared_emitter_main.check(sess, false);
|
self.shared_emitter_main.check(sess, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wait_for_signal_to_codegen_item(&self) {
|
pub(crate) fn wait_for_signal_to_codegen_item(&self) {
|
||||||
match self.codegen_worker_receive.recv() {
|
match self.codegen_worker_receive.recv() {
|
||||||
Ok(CguMessage) => {
|
Ok(CguMessage) => {
|
||||||
// Ok to proceed.
|
// Ok to proceed.
|
||||||
|
@ -2110,7 +2110,7 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
|
pub(crate) fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
|
||||||
_backend: &B,
|
_backend: &B,
|
||||||
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,
|
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,
|
||||||
module: ModuleCodegen<B::Module>,
|
module: ModuleCodegen<B::Module>,
|
||||||
|
@ -2120,7 +2120,7 @@ pub fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
|
||||||
drop(tx_to_llvm_workers.send(Box::new(Message::CodegenDone::<B> { llvm_work_item, cost })));
|
drop(tx_to_llvm_workers.send(Box::new(Message::CodegenDone::<B> { llvm_work_item, cost })));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
|
pub(crate) fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
|
||||||
_backend: &B,
|
_backend: &B,
|
||||||
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,
|
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,
|
||||||
module: CachedModuleCodegen,
|
module: CachedModuleCodegen,
|
||||||
|
@ -2129,7 +2129,7 @@ pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
|
||||||
drop(tx_to_llvm_workers.send(Box::new(Message::CodegenDone::<B> { llvm_work_item, cost: 0 })));
|
drop(tx_to_llvm_workers.send(Box::new(Message::CodegenDone::<B> { llvm_work_item, cost: 0 })));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
|
pub(crate) fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
|
||||||
_backend: &B,
|
_backend: &B,
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,
|
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,
|
||||||
|
|
|
@ -44,47 +44,23 @@ use crate::{
|
||||||
errors, meth, mir, CachedModuleCodegen, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind,
|
errors, meth, mir, CachedModuleCodegen, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate {
|
pub(crate) fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate {
|
||||||
match op {
|
match (op, signed) {
|
||||||
BinOp::Eq => IntPredicate::IntEQ,
|
(BinOp::Eq, _) => IntPredicate::IntEQ,
|
||||||
BinOp::Ne => IntPredicate::IntNE,
|
(BinOp::Ne, _) => IntPredicate::IntNE,
|
||||||
BinOp::Lt => {
|
(BinOp::Lt, true) => IntPredicate::IntSLT,
|
||||||
if signed {
|
(BinOp::Lt, false) => IntPredicate::IntULT,
|
||||||
IntPredicate::IntSLT
|
(BinOp::Le, true) => IntPredicate::IntSLE,
|
||||||
} else {
|
(BinOp::Le, false) => IntPredicate::IntULE,
|
||||||
IntPredicate::IntULT
|
(BinOp::Gt, true) => IntPredicate::IntSGT,
|
||||||
}
|
(BinOp::Gt, false) => IntPredicate::IntUGT,
|
||||||
}
|
(BinOp::Ge, true) => IntPredicate::IntSGE,
|
||||||
BinOp::Le => {
|
(BinOp::Ge, false) => IntPredicate::IntUGE,
|
||||||
if signed {
|
op => bug!("bin_op_to_icmp_predicate: expected comparison operator, found {:?}", op),
|
||||||
IntPredicate::IntSLE
|
|
||||||
} else {
|
|
||||||
IntPredicate::IntULE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BinOp::Gt => {
|
|
||||||
if signed {
|
|
||||||
IntPredicate::IntSGT
|
|
||||||
} else {
|
|
||||||
IntPredicate::IntUGT
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BinOp::Ge => {
|
|
||||||
if signed {
|
|
||||||
IntPredicate::IntSGE
|
|
||||||
} else {
|
|
||||||
IntPredicate::IntUGE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
op => bug!(
|
|
||||||
"comparison_op_to_icmp_predicate: expected comparison operator, \
|
|
||||||
found {:?}",
|
|
||||||
op
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bin_op_to_fcmp_predicate(op: BinOp) -> RealPredicate {
|
pub(crate) fn bin_op_to_fcmp_predicate(op: BinOp) -> RealPredicate {
|
||||||
match op {
|
match op {
|
||||||
BinOp::Eq => RealPredicate::RealOEQ,
|
BinOp::Eq => RealPredicate::RealOEQ,
|
||||||
BinOp::Ne => RealPredicate::RealUNE,
|
BinOp::Ne => RealPredicate::RealUNE,
|
||||||
|
@ -92,13 +68,7 @@ pub fn bin_op_to_fcmp_predicate(op: BinOp) -> RealPredicate {
|
||||||
BinOp::Le => RealPredicate::RealOLE,
|
BinOp::Le => RealPredicate::RealOLE,
|
||||||
BinOp::Gt => RealPredicate::RealOGT,
|
BinOp::Gt => RealPredicate::RealOGT,
|
||||||
BinOp::Ge => RealPredicate::RealOGE,
|
BinOp::Ge => RealPredicate::RealOGE,
|
||||||
op => {
|
op => bug!("bin_op_to_fcmp_predicate: expected comparison operator, found {:?}", op),
|
||||||
bug!(
|
|
||||||
"comparison_op_to_fcmp_predicate: expected comparison operator, \
|
|
||||||
found {:?}",
|
|
||||||
op
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +105,7 @@ pub fn compare_simd_types<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
///
|
///
|
||||||
/// The `old_info` argument is a bit odd. It is intended for use in an upcast,
|
/// The `old_info` argument is a bit odd. It is intended for use in an upcast,
|
||||||
/// where the new vtable for an object will be derived from the old one.
|
/// where the new vtable for an object will be derived from the old one.
|
||||||
pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
source: Ty<'tcx>,
|
source: Ty<'tcx>,
|
||||||
target: Ty<'tcx>,
|
target: Ty<'tcx>,
|
||||||
|
@ -154,7 +124,8 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
let old_info =
|
let old_info =
|
||||||
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
|
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
|
||||||
if data_a.principal_def_id() == data_b.principal_def_id() {
|
if data_a.principal_def_id() == data_b.principal_def_id() {
|
||||||
// A NOP cast that doesn't actually change anything, should be allowed even with invalid vtables.
|
// A NOP cast that doesn't actually change anything, should be allowed even with
|
||||||
|
// invalid vtables.
|
||||||
return old_info;
|
return old_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +153,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Coerces `src` to `dst_ty`. `src_ty` must be a pointer.
|
/// Coerces `src` to `dst_ty`. `src_ty` must be a pointer.
|
||||||
pub fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
pub(crate) fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
src: Bx::Value,
|
src: Bx::Value,
|
||||||
src_ty: Ty<'tcx>,
|
src_ty: Ty<'tcx>,
|
||||||
|
@ -227,7 +198,7 @@ pub fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Coerces `src` to `dst_ty` which is guaranteed to be a `dyn*` type.
|
/// Coerces `src` to `dst_ty` which is guaranteed to be a `dyn*` type.
|
||||||
pub fn cast_to_dyn_star<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
pub(crate) fn cast_to_dyn_star<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
src: Bx::Value,
|
src: Bx::Value,
|
||||||
src_ty_and_layout: TyAndLayout<'tcx>,
|
src_ty_and_layout: TyAndLayout<'tcx>,
|
||||||
|
@ -250,7 +221,7 @@ pub fn cast_to_dyn_star<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
|
|
||||||
/// Coerces `src`, which is a reference to a value of type `src_ty`,
|
/// Coerces `src`, which is a reference to a value of type `src_ty`,
|
||||||
/// to a value of type `dst_ty`, and stores the result in `dst`.
|
/// to a value of type `dst_ty`, and stores the result in `dst`.
|
||||||
pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
pub(crate) fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
src: PlaceRef<'tcx, Bx::Value>,
|
src: PlaceRef<'tcx, Bx::Value>,
|
||||||
dst: PlaceRef<'tcx, Bx::Value>,
|
dst: PlaceRef<'tcx, Bx::Value>,
|
||||||
|
@ -305,7 +276,7 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
///
|
///
|
||||||
/// If `is_unchecked` is true, this does no masking, and adds sufficient `assume`
|
/// If `is_unchecked` is true, this does no masking, and adds sufficient `assume`
|
||||||
/// calls or operation flags to preserve as much freedom to optimize as possible.
|
/// calls or operation flags to preserve as much freedom to optimize as possible.
|
||||||
pub fn build_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
pub(crate) fn build_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
lhs: Bx::Value,
|
lhs: Bx::Value,
|
||||||
mut rhs: Bx::Value,
|
mut rhs: Bx::Value,
|
||||||
|
@ -369,11 +340,11 @@ pub fn wants_msvc_seh(sess: &Session) -> bool {
|
||||||
/// Returns `true` if this session's target requires the new exception
|
/// Returns `true` if this session's target requires the new exception
|
||||||
/// handling LLVM IR instructions (catchpad / cleanuppad / ... instead
|
/// handling LLVM IR instructions (catchpad / cleanuppad / ... instead
|
||||||
/// of landingpad)
|
/// of landingpad)
|
||||||
pub fn wants_new_eh_instructions(sess: &Session) -> bool {
|
pub(crate) fn wants_new_eh_instructions(sess: &Session) -> bool {
|
||||||
wants_wasm_eh(sess) || wants_msvc_seh(sess)
|
wants_wasm_eh(sess) || wants_msvc_seh(sess)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
pub(crate) fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
cx: &'a Bx::CodegenCx,
|
cx: &'a Bx::CodegenCx,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
) {
|
) {
|
||||||
|
@ -454,7 +425,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
|
|
||||||
let isize_ty = cx.type_isize();
|
let isize_ty = cx.type_isize();
|
||||||
let ptr_ty = cx.type_ptr();
|
let ptr_ty = cx.type_ptr();
|
||||||
let (arg_argc, arg_argv) = get_argc_argv(cx, &mut bx);
|
let (arg_argc, arg_argv) = get_argc_argv(&mut bx);
|
||||||
|
|
||||||
let (start_fn, start_ty, args, instance) = if let EntryFnType::Main { sigpipe } = entry_type
|
let (start_fn, start_ty, args, instance) = if let EntryFnType::Main { sigpipe } = entry_type
|
||||||
{
|
{
|
||||||
|
@ -497,33 +468,30 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Obtain the `argc` and `argv` values to pass to the rust start function.
|
/// Obtain the `argc` and `argv` values to pass to the rust start function.
|
||||||
fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(bx: &mut Bx) -> (Bx::Value, Bx::Value) {
|
||||||
cx: &'a Bx::CodegenCx,
|
if bx.cx().sess().target.os.contains("uefi") {
|
||||||
bx: &mut Bx,
|
|
||||||
) -> (Bx::Value, Bx::Value) {
|
|
||||||
if cx.sess().target.os.contains("uefi") {
|
|
||||||
// Params for UEFI
|
// Params for UEFI
|
||||||
let param_handle = bx.get_param(0);
|
let param_handle = bx.get_param(0);
|
||||||
let param_system_table = bx.get_param(1);
|
let param_system_table = bx.get_param(1);
|
||||||
let ptr_size = bx.tcx().data_layout.pointer_size;
|
let ptr_size = bx.tcx().data_layout.pointer_size;
|
||||||
let ptr_align = bx.tcx().data_layout.pointer_align.abi;
|
let ptr_align = bx.tcx().data_layout.pointer_align.abi;
|
||||||
let arg_argc = bx.const_int(cx.type_isize(), 2);
|
let arg_argc = bx.const_int(bx.cx().type_isize(), 2);
|
||||||
let arg_argv = bx.alloca(2 * ptr_size, ptr_align);
|
let arg_argv = bx.alloca(2 * ptr_size, ptr_align);
|
||||||
bx.store(param_handle, arg_argv, ptr_align);
|
bx.store(param_handle, arg_argv, ptr_align);
|
||||||
let arg_argv_el1 = bx.inbounds_ptradd(arg_argv, bx.const_usize(ptr_size.bytes()));
|
let arg_argv_el1 = bx.inbounds_ptradd(arg_argv, bx.const_usize(ptr_size.bytes()));
|
||||||
bx.store(param_system_table, arg_argv_el1, ptr_align);
|
bx.store(param_system_table, arg_argv_el1, ptr_align);
|
||||||
(arg_argc, arg_argv)
|
(arg_argc, arg_argv)
|
||||||
} else if cx.sess().target.main_needs_argc_argv {
|
} else if bx.cx().sess().target.main_needs_argc_argv {
|
||||||
// Params from native `main()` used as args for rust start function
|
// Params from native `main()` used as args for rust start function
|
||||||
let param_argc = bx.get_param(0);
|
let param_argc = bx.get_param(0);
|
||||||
let param_argv = bx.get_param(1);
|
let param_argv = bx.get_param(1);
|
||||||
let arg_argc = bx.intcast(param_argc, cx.type_isize(), true);
|
let arg_argc = bx.intcast(param_argc, bx.cx().type_isize(), true);
|
||||||
let arg_argv = param_argv;
|
let arg_argv = param_argv;
|
||||||
(arg_argc, arg_argv)
|
(arg_argc, arg_argv)
|
||||||
} else {
|
} else {
|
||||||
// The Rust start function doesn't need `argc` and `argv`, so just pass zeros.
|
// The Rust start function doesn't need `argc` and `argv`, so just pass zeros.
|
||||||
let arg_argc = bx.const_int(cx.type_int(), 0);
|
let arg_argc = bx.const_int(bx.cx().type_int(), 0);
|
||||||
let arg_argv = bx.const_null(cx.type_ptr());
|
let arg_argv = bx.const_null(bx.cx().type_ptr());
|
||||||
(arg_argc, arg_argv)
|
(arg_argc, arg_argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -985,7 +953,8 @@ impl CrateInfo {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
CrateType::Staticlib | CrateType::Rlib => {
|
CrateType::Staticlib | CrateType::Rlib => {
|
||||||
// We don't invoke the linker for these, so we don't need to collect the NatVis for them.
|
// We don't invoke the linker for these, so we don't need to collect the NatVis for
|
||||||
|
// them.
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -999,7 +968,7 @@ impl CrateInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
providers.backend_optimization_level = |tcx, cratenum| {
|
providers.backend_optimization_level = |tcx, cratenum| {
|
||||||
let for_speed = match tcx.sess.opts.optimize {
|
let for_speed = match tcx.sess.opts.optimize {
|
||||||
// If globally no optimisation is done, #[optimize] has no effect.
|
// If globally no optimisation is done, #[optimize] has no effect.
|
||||||
|
|
|
@ -317,9 +317,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
"extern mutable statics are not allowed with `#[linkage]`",
|
"extern mutable statics are not allowed with `#[linkage]`",
|
||||||
);
|
);
|
||||||
diag.note(
|
diag.note(
|
||||||
"marking the extern static mutable would allow changing which symbol \
|
"marking the extern static mutable would allow changing which \
|
||||||
the static references rather than make the target of the symbol \
|
symbol the static references rather than make the target of the \
|
||||||
mutable",
|
symbol mutable",
|
||||||
);
|
);
|
||||||
diag.emit();
|
diag.emit();
|
||||||
}
|
}
|
||||||
|
@ -711,18 +711,19 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
|
||||||
if let Some(MetaItemLit { kind: LitKind::Int(ordinal, LitIntType::Unsuffixed), .. }) =
|
if let Some(MetaItemLit { kind: LitKind::Int(ordinal, LitIntType::Unsuffixed), .. }) =
|
||||||
sole_meta_list
|
sole_meta_list
|
||||||
{
|
{
|
||||||
// According to the table at https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-header,
|
// According to the table at
|
||||||
// the ordinal must fit into 16 bits. Similarly, the Ordinal field in COFFShortExport (defined
|
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-header, the
|
||||||
// in llvm/include/llvm/Object/COFFImportFile.h), which we use to communicate import information
|
// ordinal must fit into 16 bits. Similarly, the Ordinal field in COFFShortExport (defined
|
||||||
// to LLVM for `#[link(kind = "raw-dylib"_])`, is also defined to be uint16_t.
|
// in llvm/include/llvm/Object/COFFImportFile.h), which we use to communicate import
|
||||||
|
// information to LLVM for `#[link(kind = "raw-dylib"_])`, is also defined to be uint16_t.
|
||||||
//
|
//
|
||||||
// FIXME: should we allow an ordinal of 0? The MSVC toolchain has inconsistent support for this:
|
// FIXME: should we allow an ordinal of 0? The MSVC toolchain has inconsistent support for
|
||||||
// both LINK.EXE and LIB.EXE signal errors and abort when given a .DEF file that specifies
|
// this: both LINK.EXE and LIB.EXE signal errors and abort when given a .DEF file that
|
||||||
// a zero ordinal. However, llvm-dlltool is perfectly happy to generate an import library
|
// specifies a zero ordinal. However, llvm-dlltool is perfectly happy to generate an import
|
||||||
// for such a .DEF file, and MSVC's LINK.EXE is also perfectly happy to consume an import
|
// library for such a .DEF file, and MSVC's LINK.EXE is also perfectly happy to consume an
|
||||||
// library produced by LLVM with an ordinal of 0, and it generates an .EXE. (I don't know yet
|
// import library produced by LLVM with an ordinal of 0, and it generates an .EXE. (I
|
||||||
// if the resulting EXE runs, as I haven't yet built the necessary DLL -- see earlier comment
|
// don't know yet if the resulting EXE runs, as I haven't yet built the necessary DLL --
|
||||||
// about LINK.EXE failing.)
|
// see earlier comment about LINK.EXE failing.)
|
||||||
if *ordinal <= u16::MAX as u128 {
|
if *ordinal <= u16::MAX as u128 {
|
||||||
Some(ordinal.get() as u16)
|
Some(ordinal.get() as u16)
|
||||||
} else {
|
} else {
|
||||||
|
@ -755,6 +756,6 @@ fn check_link_name_xor_ordinal(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
*providers = Providers { codegen_fn_attrs, should_inherit_track_caller, ..*providers };
|
*providers = Providers { codegen_fn_attrs, should_inherit_track_caller, ..*providers };
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ mod temp_stable_hash_impls {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
pub(crate) fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
bx: &Bx,
|
bx: &Bx,
|
||||||
span: Option<Span>,
|
span: Option<Span>,
|
||||||
li: LangItem,
|
li: LangItem,
|
||||||
|
@ -129,7 +129,7 @@ pub fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
(bx.fn_abi_of_instance(instance, ty::List::empty()), bx.get_fn_addr(instance), instance)
|
(bx.fn_abi_of_instance(instance, ty::List::empty()), bx.get_fn_addr(instance), instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shift_mask_val<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
pub(crate) fn shift_mask_val<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
llty: Bx::Type,
|
llty: Bx::Type,
|
||||||
mask_llty: Bx::Type,
|
mask_llty: Bx::Type,
|
||||||
|
@ -200,7 +200,8 @@ pub fn i686_decorated_name(
|
||||||
let mut decorated_name = String::with_capacity(name.len() + 6);
|
let mut decorated_name = String::with_capacity(name.len() + 6);
|
||||||
|
|
||||||
if disable_name_mangling {
|
if disable_name_mangling {
|
||||||
// LLVM uses a binary 1 ('\x01') prefix to a name to indicate that mangling needs to be disabled.
|
// LLVM uses a binary 1 ('\x01') prefix to a name to indicate that mangling needs to be
|
||||||
|
// disabled.
|
||||||
decorated_name.push('\x01');
|
decorated_name.push('\x01');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ pub fn tag_base_type<'tcx>(tcx: TyCtxt<'tcx>, enum_type_and_layout: TyAndLayout<
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tag_base_type_opt<'tcx>(
|
fn tag_base_type_opt<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
enum_type_and_layout: TyAndLayout<'tcx>,
|
enum_type_and_layout: TyAndLayout<'tcx>,
|
||||||
) -> Option<Ty<'tcx>> {
|
) -> Option<Ty<'tcx>> {
|
||||||
|
@ -76,9 +76,9 @@ pub fn tag_base_type_opt<'tcx>(
|
||||||
Primitive::Float(f) => Integer::from_size(f.size()).unwrap(),
|
Primitive::Float(f) => Integer::from_size(f.size()).unwrap(),
|
||||||
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
|
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
|
||||||
Primitive::Pointer(_) => {
|
Primitive::Pointer(_) => {
|
||||||
// If the niche is the NULL value of a reference, then `discr_enum_ty` will be
|
// If the niche is the NULL value of a reference, then `discr_enum_ty` will
|
||||||
// a RawPtr. CodeView doesn't know what to do with enums whose base type is a
|
// be a RawPtr. CodeView doesn't know what to do with enums whose base type
|
||||||
// pointer so we fix this up to just be `usize`.
|
// is a pointer so we fix this up to just be `usize`.
|
||||||
// DWARF might be able to deal with this but with an integer type we are on
|
// DWARF might be able to deal with this but with an integer type we are on
|
||||||
// the safe side there too.
|
// the safe side there too.
|
||||||
tcx.data_layout.ptr_sized_integer()
|
tcx.data_layout.ptr_sized_integer()
|
||||||
|
|
|
@ -95,7 +95,8 @@ fn push_debuginfo_type_name<'tcx>(
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Computing the layout can still fail here, e.g. if the target architecture
|
// Computing the layout can still fail here, e.g. if the target architecture
|
||||||
// cannot represent the type. See https://github.com/rust-lang/rust/issues/94961.
|
// cannot represent the type. See
|
||||||
|
// https://github.com/rust-lang/rust/issues/94961.
|
||||||
tcx.dcx().emit_fatal(e.into_diagnostic());
|
tcx.dcx().emit_fatal(e.into_diagnostic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -575,33 +576,20 @@ pub fn push_item_name(tcx: TyCtxt<'_>, def_id: DefId, qualified: bool, output: &
|
||||||
}
|
}
|
||||||
|
|
||||||
fn coroutine_kind_label(coroutine_kind: Option<CoroutineKind>) -> &'static str {
|
fn coroutine_kind_label(coroutine_kind: Option<CoroutineKind>) -> &'static str {
|
||||||
|
use CoroutineDesugaring::*;
|
||||||
|
use CoroutineKind::*;
|
||||||
|
use CoroutineSource::*;
|
||||||
match coroutine_kind {
|
match coroutine_kind {
|
||||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Gen, CoroutineSource::Block)) => {
|
Some(Desugared(Gen, Block)) => "gen_block",
|
||||||
"gen_block"
|
Some(Desugared(Gen, Closure)) => "gen_closure",
|
||||||
}
|
Some(Desugared(Gen, Fn)) => "gen_fn",
|
||||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Gen, CoroutineSource::Closure)) => {
|
Some(Desugared(Async, Block)) => "async_block",
|
||||||
"gen_closure"
|
Some(Desugared(Async, Closure)) => "async_closure",
|
||||||
}
|
Some(Desugared(Async, Fn)) => "async_fn",
|
||||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Gen, CoroutineSource::Fn)) => "gen_fn",
|
Some(Desugared(AsyncGen, Block)) => "async_gen_block",
|
||||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Block)) => {
|
Some(Desugared(AsyncGen, Closure)) => "async_gen_closure",
|
||||||
"async_block"
|
Some(Desugared(AsyncGen, Fn)) => "async_gen_fn",
|
||||||
}
|
Some(Coroutine(_)) => "coroutine",
|
||||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Closure)) => {
|
|
||||||
"async_closure"
|
|
||||||
}
|
|
||||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Fn)) => {
|
|
||||||
"async_fn"
|
|
||||||
}
|
|
||||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, CoroutineSource::Block)) => {
|
|
||||||
"async_gen_block"
|
|
||||||
}
|
|
||||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, CoroutineSource::Closure)) => {
|
|
||||||
"async_gen_closure"
|
|
||||||
}
|
|
||||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, CoroutineSource::Fn)) => {
|
|
||||||
"async_gen_fn"
|
|
||||||
}
|
|
||||||
Some(CoroutineKind::Coroutine(_)) => "coroutine",
|
|
||||||
None => "closure",
|
None => "closure",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ use crate::fluent_generated as fluent;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_incorrect_cgu_reuse_type)]
|
#[diag(codegen_ssa_incorrect_cgu_reuse_type)]
|
||||||
pub struct IncorrectCguReuseType<'a> {
|
pub(crate) struct IncorrectCguReuseType<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub cgu_user_name: &'a str,
|
pub cgu_user_name: &'a str,
|
||||||
|
@ -32,14 +32,14 @@ pub struct IncorrectCguReuseType<'a> {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_cgu_not_recorded)]
|
#[diag(codegen_ssa_cgu_not_recorded)]
|
||||||
pub struct CguNotRecorded<'a> {
|
pub(crate) struct CguNotRecorded<'a> {
|
||||||
pub cgu_user_name: &'a str,
|
pub cgu_user_name: &'a str,
|
||||||
pub cgu_name: &'a str,
|
pub cgu_name: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_unknown_reuse_kind)]
|
#[diag(codegen_ssa_unknown_reuse_kind)]
|
||||||
pub struct UnknownReuseKind {
|
pub(crate) struct UnknownReuseKind {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub kind: Symbol,
|
pub kind: Symbol,
|
||||||
|
@ -47,14 +47,14 @@ pub struct UnknownReuseKind {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_missing_query_depgraph)]
|
#[diag(codegen_ssa_missing_query_depgraph)]
|
||||||
pub struct MissingQueryDepGraph {
|
pub(crate) struct MissingQueryDepGraph {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_malformed_cgu_name)]
|
#[diag(codegen_ssa_malformed_cgu_name)]
|
||||||
pub struct MalformedCguName {
|
pub(crate) struct MalformedCguName {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub user_path: String,
|
pub user_path: String,
|
||||||
|
@ -63,7 +63,7 @@ pub struct MalformedCguName {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_no_module_named)]
|
#[diag(codegen_ssa_no_module_named)]
|
||||||
pub struct NoModuleNamed<'a> {
|
pub(crate) struct NoModuleNamed<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub user_path: &'a str,
|
pub user_path: &'a str,
|
||||||
|
@ -73,7 +73,7 @@ pub struct NoModuleNamed<'a> {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_field_associated_value_expected)]
|
#[diag(codegen_ssa_field_associated_value_expected)]
|
||||||
pub struct FieldAssociatedValueExpected {
|
pub(crate) struct FieldAssociatedValueExpected {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
|
@ -81,7 +81,7 @@ pub struct FieldAssociatedValueExpected {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_no_field)]
|
#[diag(codegen_ssa_no_field)]
|
||||||
pub struct NoField {
|
pub(crate) struct NoField {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
|
@ -89,49 +89,49 @@ pub struct NoField {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_lib_def_write_failure)]
|
#[diag(codegen_ssa_lib_def_write_failure)]
|
||||||
pub struct LibDefWriteFailure {
|
pub(crate) struct LibDefWriteFailure {
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_version_script_write_failure)]
|
#[diag(codegen_ssa_version_script_write_failure)]
|
||||||
pub struct VersionScriptWriteFailure {
|
pub(crate) struct VersionScriptWriteFailure {
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_symbol_file_write_failure)]
|
#[diag(codegen_ssa_symbol_file_write_failure)]
|
||||||
pub struct SymbolFileWriteFailure {
|
pub(crate) struct SymbolFileWriteFailure {
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_ld64_unimplemented_modifier)]
|
#[diag(codegen_ssa_ld64_unimplemented_modifier)]
|
||||||
pub struct Ld64UnimplementedModifier;
|
pub(crate) struct Ld64UnimplementedModifier;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_linker_unsupported_modifier)]
|
#[diag(codegen_ssa_linker_unsupported_modifier)]
|
||||||
pub struct LinkerUnsupportedModifier;
|
pub(crate) struct LinkerUnsupportedModifier;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_L4Bender_exporting_symbols_unimplemented)]
|
#[diag(codegen_ssa_L4Bender_exporting_symbols_unimplemented)]
|
||||||
pub struct L4BenderExportingSymbolsUnimplemented;
|
pub(crate) struct L4BenderExportingSymbolsUnimplemented;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_no_natvis_directory)]
|
#[diag(codegen_ssa_no_natvis_directory)]
|
||||||
pub struct NoNatvisDirectory {
|
pub(crate) struct NoNatvisDirectory {
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_no_saved_object_file)]
|
#[diag(codegen_ssa_no_saved_object_file)]
|
||||||
pub struct NoSavedObjectFile<'a> {
|
pub(crate) struct NoSavedObjectFile<'a> {
|
||||||
pub cgu_name: &'a str,
|
pub cgu_name: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_copy_path_buf)]
|
#[diag(codegen_ssa_copy_path_buf)]
|
||||||
pub struct CopyPathBuf {
|
pub(crate) struct CopyPathBuf {
|
||||||
pub source_file: PathBuf,
|
pub source_file: PathBuf,
|
||||||
pub output_path: PathBuf,
|
pub output_path: PathBuf,
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
|
@ -180,20 +180,20 @@ pub struct IgnoringOutput {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_create_temp_dir)]
|
#[diag(codegen_ssa_create_temp_dir)]
|
||||||
pub struct CreateTempDir {
|
pub(crate) struct CreateTempDir {
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_add_native_library)]
|
#[diag(codegen_ssa_add_native_library)]
|
||||||
pub struct AddNativeLibrary {
|
pub(crate) struct AddNativeLibrary {
|
||||||
pub library_path: PathBuf,
|
pub library_path: PathBuf,
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_multiple_external_func_decl)]
|
#[diag(codegen_ssa_multiple_external_func_decl)]
|
||||||
pub struct MultipleExternalFuncDecl<'a> {
|
pub(crate) struct MultipleExternalFuncDecl<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub function: Symbol,
|
pub function: Symbol,
|
||||||
|
@ -215,7 +215,7 @@ pub enum LinkRlibError {
|
||||||
IncompatibleDependencyFormats { ty1: String, ty2: String, list1: String, list2: String },
|
IncompatibleDependencyFormats { ty1: String, ty2: String, list1: String, list2: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ThorinErrorWrapper(pub thorin::Error);
|
pub(crate) struct ThorinErrorWrapper(pub thorin::Error);
|
||||||
|
|
||||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for ThorinErrorWrapper {
|
impl<G: EmissionGuarantee> Diagnostic<'_, G> for ThorinErrorWrapper {
|
||||||
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
|
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
|
||||||
|
@ -343,7 +343,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for ThorinErrorWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LinkingFailed<'a> {
|
pub(crate) struct LinkingFailed<'a> {
|
||||||
pub linker_path: &'a PathBuf,
|
pub linker_path: &'a PathBuf,
|
||||||
pub exit_status: ExitStatus,
|
pub exit_status: ExitStatus,
|
||||||
pub command: &'a Command,
|
pub command: &'a Command,
|
||||||
|
@ -376,28 +376,28 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_link_exe_unexpected_error)]
|
#[diag(codegen_ssa_link_exe_unexpected_error)]
|
||||||
pub struct LinkExeUnexpectedError;
|
pub(crate) struct LinkExeUnexpectedError;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_repair_vs_build_tools)]
|
#[diag(codegen_ssa_repair_vs_build_tools)]
|
||||||
pub struct RepairVSBuildTools;
|
pub(crate) struct RepairVSBuildTools;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_missing_cpp_build_tool_component)]
|
#[diag(codegen_ssa_missing_cpp_build_tool_component)]
|
||||||
pub struct MissingCppBuildToolComponent;
|
pub(crate) struct MissingCppBuildToolComponent;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_select_cpp_build_tool_workload)]
|
#[diag(codegen_ssa_select_cpp_build_tool_workload)]
|
||||||
pub struct SelectCppBuildToolWorkload;
|
pub(crate) struct SelectCppBuildToolWorkload;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_visual_studio_not_installed)]
|
#[diag(codegen_ssa_visual_studio_not_installed)]
|
||||||
pub struct VisualStudioNotInstalled;
|
pub(crate) struct VisualStudioNotInstalled;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_linker_not_found)]
|
#[diag(codegen_ssa_linker_not_found)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct LinkerNotFound {
|
pub(crate) struct LinkerNotFound {
|
||||||
pub linker_path: PathBuf,
|
pub linker_path: PathBuf,
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
@ -406,7 +406,7 @@ pub struct LinkerNotFound {
|
||||||
#[diag(codegen_ssa_unable_to_exe_linker)]
|
#[diag(codegen_ssa_unable_to_exe_linker)]
|
||||||
#[note]
|
#[note]
|
||||||
#[note(codegen_ssa_command_note)]
|
#[note(codegen_ssa_command_note)]
|
||||||
pub struct UnableToExeLinker {
|
pub(crate) struct UnableToExeLinker {
|
||||||
pub linker_path: PathBuf,
|
pub linker_path: PathBuf,
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
pub command_formatted: String,
|
pub command_formatted: String,
|
||||||
|
@ -414,38 +414,38 @@ pub struct UnableToExeLinker {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_msvc_missing_linker)]
|
#[diag(codegen_ssa_msvc_missing_linker)]
|
||||||
pub struct MsvcMissingLinker;
|
pub(crate) struct MsvcMissingLinker;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_self_contained_linker_missing)]
|
#[diag(codegen_ssa_self_contained_linker_missing)]
|
||||||
pub struct SelfContainedLinkerMissing;
|
pub(crate) struct SelfContainedLinkerMissing;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_check_installed_visual_studio)]
|
#[diag(codegen_ssa_check_installed_visual_studio)]
|
||||||
pub struct CheckInstalledVisualStudio;
|
pub(crate) struct CheckInstalledVisualStudio;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_insufficient_vs_code_product)]
|
#[diag(codegen_ssa_insufficient_vs_code_product)]
|
||||||
pub struct InsufficientVSCodeProduct;
|
pub(crate) struct InsufficientVSCodeProduct;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_processing_dymutil_failed)]
|
#[diag(codegen_ssa_processing_dymutil_failed)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct ProcessingDymutilFailed {
|
pub(crate) struct ProcessingDymutilFailed {
|
||||||
pub status: ExitStatus,
|
pub status: ExitStatus,
|
||||||
pub output: String,
|
pub output: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_unable_to_run_dsymutil)]
|
#[diag(codegen_ssa_unable_to_run_dsymutil)]
|
||||||
pub struct UnableToRunDsymutil {
|
pub(crate) struct UnableToRunDsymutil {
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_stripping_debug_info_failed)]
|
#[diag(codegen_ssa_stripping_debug_info_failed)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct StrippingDebugInfoFailed<'a> {
|
pub(crate) struct StrippingDebugInfoFailed<'a> {
|
||||||
pub util: &'a str,
|
pub util: &'a str,
|
||||||
pub status: ExitStatus,
|
pub status: ExitStatus,
|
||||||
pub output: String,
|
pub output: String,
|
||||||
|
@ -453,58 +453,59 @@ pub struct StrippingDebugInfoFailed<'a> {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_unable_to_run)]
|
#[diag(codegen_ssa_unable_to_run)]
|
||||||
pub struct UnableToRun<'a> {
|
pub(crate) struct UnableToRun<'a> {
|
||||||
pub util: &'a str,
|
pub util: &'a str,
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_linker_file_stem)]
|
#[diag(codegen_ssa_linker_file_stem)]
|
||||||
pub struct LinkerFileStem;
|
pub(crate) struct LinkerFileStem;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_static_library_native_artifacts)]
|
#[diag(codegen_ssa_static_library_native_artifacts)]
|
||||||
pub struct StaticLibraryNativeArtifacts;
|
pub(crate) struct StaticLibraryNativeArtifacts;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_static_library_native_artifacts_to_file)]
|
#[diag(codegen_ssa_static_library_native_artifacts_to_file)]
|
||||||
pub struct StaticLibraryNativeArtifactsToFile<'a> {
|
pub(crate) struct StaticLibraryNativeArtifactsToFile<'a> {
|
||||||
pub path: &'a Path,
|
pub path: &'a Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_link_script_unavailable)]
|
#[diag(codegen_ssa_link_script_unavailable)]
|
||||||
pub struct LinkScriptUnavailable;
|
pub(crate) struct LinkScriptUnavailable;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_link_script_write_failure)]
|
#[diag(codegen_ssa_link_script_write_failure)]
|
||||||
pub struct LinkScriptWriteFailure {
|
pub(crate) struct LinkScriptWriteFailure {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_failed_to_write)]
|
#[diag(codegen_ssa_failed_to_write)]
|
||||||
pub struct FailedToWrite {
|
pub(crate) struct FailedToWrite {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_unable_to_write_debugger_visualizer)]
|
#[diag(codegen_ssa_unable_to_write_debugger_visualizer)]
|
||||||
pub struct UnableToWriteDebuggerVisualizer {
|
pub(crate) struct UnableToWriteDebuggerVisualizer {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_rlib_archive_build_failure)]
|
#[diag(codegen_ssa_rlib_archive_build_failure)]
|
||||||
pub struct RlibArchiveBuildFailure {
|
pub(crate) struct RlibArchiveBuildFailure {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
|
// Public for rustc_codegen_llvm::back::archive
|
||||||
pub enum ExtractBundledLibsError<'a> {
|
pub enum ExtractBundledLibsError<'a> {
|
||||||
#[diag(codegen_ssa_extract_bundled_libs_open_file)]
|
#[diag(codegen_ssa_extract_bundled_libs_open_file)]
|
||||||
OpenFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
|
OpenFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
|
||||||
|
@ -533,26 +534,26 @@ pub enum ExtractBundledLibsError<'a> {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_unsupported_arch)]
|
#[diag(codegen_ssa_unsupported_arch)]
|
||||||
pub struct UnsupportedArch<'a> {
|
pub(crate) struct UnsupportedArch<'a> {
|
||||||
pub arch: &'a str,
|
pub arch: &'a str,
|
||||||
pub os: &'a str,
|
pub os: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
pub enum AppleSdkRootError<'a> {
|
pub(crate) enum AppleSdkRootError<'a> {
|
||||||
#[diag(codegen_ssa_apple_sdk_error_sdk_path)]
|
#[diag(codegen_ssa_apple_sdk_error_sdk_path)]
|
||||||
SdkPath { sdk_name: &'a str, error: Error },
|
SdkPath { sdk_name: &'a str, error: Error },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_read_file)]
|
#[diag(codegen_ssa_read_file)]
|
||||||
pub struct ReadFileError {
|
pub(crate) struct ReadFileError {
|
||||||
pub message: std::io::Error,
|
pub message: std::io::Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_unsupported_link_self_contained)]
|
#[diag(codegen_ssa_unsupported_link_self_contained)]
|
||||||
pub struct UnsupportedLinkSelfContained;
|
pub(crate) struct UnsupportedLinkSelfContained;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_archive_build_failure)]
|
#[diag(codegen_ssa_archive_build_failure)]
|
||||||
|
@ -571,7 +572,7 @@ pub struct UnknownArchiveKind<'a> {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_expected_used_symbol)]
|
#[diag(codegen_ssa_expected_used_symbol)]
|
||||||
pub struct ExpectedUsedSymbol {
|
pub(crate) struct ExpectedUsedSymbol {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
@ -579,45 +580,45 @@ pub struct ExpectedUsedSymbol {
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_multiple_main_functions)]
|
#[diag(codegen_ssa_multiple_main_functions)]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct MultipleMainFunctions {
|
pub(crate) struct MultipleMainFunctions {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_metadata_object_file_write)]
|
#[diag(codegen_ssa_metadata_object_file_write)]
|
||||||
pub struct MetadataObjectFileWrite {
|
pub(crate) struct MetadataObjectFileWrite {
|
||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_invalid_windows_subsystem)]
|
#[diag(codegen_ssa_invalid_windows_subsystem)]
|
||||||
pub struct InvalidWindowsSubsystem {
|
pub(crate) struct InvalidWindowsSubsystem {
|
||||||
pub subsystem: Symbol,
|
pub subsystem: Symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_shuffle_indices_evaluation)]
|
#[diag(codegen_ssa_shuffle_indices_evaluation)]
|
||||||
pub struct ShuffleIndicesEvaluation {
|
pub(crate) struct ShuffleIndicesEvaluation {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_missing_memory_ordering)]
|
#[diag(codegen_ssa_missing_memory_ordering)]
|
||||||
pub struct MissingMemoryOrdering;
|
pub(crate) struct MissingMemoryOrdering;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_unknown_atomic_ordering)]
|
#[diag(codegen_ssa_unknown_atomic_ordering)]
|
||||||
pub struct UnknownAtomicOrdering;
|
pub(crate) struct UnknownAtomicOrdering;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_atomic_compare_exchange)]
|
#[diag(codegen_ssa_atomic_compare_exchange)]
|
||||||
pub struct AtomicCompareExchange;
|
pub(crate) struct AtomicCompareExchange;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_unknown_atomic_operation)]
|
#[diag(codegen_ssa_unknown_atomic_operation)]
|
||||||
pub struct UnknownAtomicOperation;
|
pub(crate) struct UnknownAtomicOperation;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
pub enum InvalidMonomorphization<'tcx> {
|
pub enum InvalidMonomorphization<'tcx> {
|
||||||
|
@ -986,7 +987,7 @@ impl IntoDiagArg for ExpectedPointerMutability {
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_invalid_no_sanitize)]
|
#[diag(codegen_ssa_invalid_no_sanitize)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct InvalidNoSanitize {
|
pub(crate) struct InvalidNoSanitize {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
@ -994,7 +995,7 @@ pub struct InvalidNoSanitize {
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_invalid_link_ordinal_nargs)]
|
#[diag(codegen_ssa_invalid_link_ordinal_nargs)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct InvalidLinkOrdinalNargs {
|
pub(crate) struct InvalidLinkOrdinalNargs {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
@ -1002,14 +1003,14 @@ pub struct InvalidLinkOrdinalNargs {
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_illegal_link_ordinal_format)]
|
#[diag(codegen_ssa_illegal_link_ordinal_format)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct InvalidLinkOrdinalFormat {
|
pub(crate) struct InvalidLinkOrdinalFormat {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_target_feature_safe_trait)]
|
#[diag(codegen_ssa_target_feature_safe_trait)]
|
||||||
pub struct TargetFeatureSafeTrait {
|
pub(crate) struct TargetFeatureSafeTrait {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
@ -1050,7 +1051,7 @@ pub(crate) struct ErrorCallingDllTool<'a> {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_ssa_error_creating_remark_dir)]
|
#[diag(codegen_ssa_error_creating_remark_dir)]
|
||||||
pub struct ErrorCreatingRemarkDir {
|
pub(crate) struct ErrorCreatingRemarkDir {
|
||||||
pub error: std::io::Error,
|
pub error: std::io::Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ impl CompiledModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CachedModuleCodegen {
|
pub(crate) struct CachedModuleCodegen {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub source: WorkProduct,
|
pub source: WorkProduct,
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ use tracing::{debug, instrument};
|
||||||
use crate::traits::*;
|
use crate::traits::*;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct VirtualIndex(u64);
|
pub(crate) struct VirtualIndex(u64);
|
||||||
|
|
||||||
impl<'a, 'tcx> VirtualIndex {
|
impl<'a, 'tcx> VirtualIndex {
|
||||||
pub fn from_index(index: usize) -> Self {
|
pub(crate) fn from_index(index: usize) -> Self {
|
||||||
VirtualIndex(index as u64)
|
VirtualIndex(index as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ impl<'a, 'tcx> VirtualIndex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_optional_fn<Bx: BuilderMethods<'a, 'tcx>>(
|
pub(crate) fn get_optional_fn<Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
self,
|
self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
llvtable: Bx::Value,
|
llvtable: Bx::Value,
|
||||||
|
@ -61,7 +61,7 @@ impl<'a, 'tcx> VirtualIndex {
|
||||||
self.get_fn_inner(bx, llvtable, ty, fn_abi, false)
|
self.get_fn_inner(bx, llvtable, ty, fn_abi, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_fn<Bx: BuilderMethods<'a, 'tcx>>(
|
pub(crate) fn get_fn<Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
self,
|
self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
llvtable: Bx::Value,
|
llvtable: Bx::Value,
|
||||||
|
@ -71,7 +71,7 @@ impl<'a, 'tcx> VirtualIndex {
|
||||||
self.get_fn_inner(bx, llvtable, ty, fn_abi, true)
|
self.get_fn_inner(bx, llvtable, ty, fn_abi, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_usize<Bx: BuilderMethods<'a, 'tcx>>(
|
pub(crate) fn get_usize<Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
self,
|
self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
llvtable: Bx::Value,
|
llvtable: Bx::Value,
|
||||||
|
@ -115,7 +115,7 @@ fn expect_dyn_trait_in_self(ty: Ty<'_>) -> ty::PolyExistentialTraitRef<'_> {
|
||||||
/// making an object `Foo<dyn Trait>` from a value of type `Foo<T>`, then
|
/// making an object `Foo<dyn Trait>` from a value of type `Foo<T>`, then
|
||||||
/// `trait_ref` would map `T: Trait`.
|
/// `trait_ref` would map `T: Trait`.
|
||||||
#[instrument(level = "debug", skip(cx))]
|
#[instrument(level = "debug", skip(cx))]
|
||||||
pub fn get_vtable<'tcx, Cx: CodegenMethods<'tcx>>(
|
pub(crate) fn get_vtable<'tcx, Cx: CodegenMethods<'tcx>>(
|
||||||
cx: &Cx,
|
cx: &Cx,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
||||||
|
|
|
@ -69,13 +69,13 @@ enum LocalKind {
|
||||||
SSA(DefLocation),
|
SSA(DefLocation),
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LocalAnalyzer<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
|
struct LocalAnalyzer<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> {
|
||||||
fx: &'mir FunctionCx<'a, 'tcx, Bx>,
|
fx: &'a FunctionCx<'b, 'tcx, Bx>,
|
||||||
dominators: &'mir Dominators<mir::BasicBlock>,
|
dominators: &'a Dominators<mir::BasicBlock>,
|
||||||
locals: IndexVec<mir::Local, LocalKind>,
|
locals: IndexVec<mir::Local, LocalKind>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
|
impl<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> LocalAnalyzer<'a, 'b, 'tcx, Bx> {
|
||||||
fn define(&mut self, local: mir::Local, location: DefLocation) {
|
fn define(&mut self, local: mir::Local, location: DefLocation) {
|
||||||
let kind = &mut self.locals[local];
|
let kind = &mut self.locals[local];
|
||||||
match *kind {
|
match *kind {
|
||||||
|
@ -152,9 +152,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
impl<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> Visitor<'tcx> for LocalAnalyzer<'a, 'b, 'tcx, Bx> {
|
||||||
for LocalAnalyzer<'mir, 'a, 'tcx, Bx>
|
|
||||||
{
|
|
||||||
fn visit_assign(
|
fn visit_assign(
|
||||||
&mut self,
|
&mut self,
|
||||||
place: &mir::Place<'tcx>,
|
place: &mir::Place<'tcx>,
|
||||||
|
|
|
@ -996,7 +996,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
// To get a `*mut RcBox<Self>`, we just keep unwrapping newtypes until
|
// To get a `*mut RcBox<Self>`, we just keep unwrapping newtypes until
|
||||||
// we get a value of a built-in pointer type.
|
// we get a value of a built-in pointer type.
|
||||||
//
|
//
|
||||||
// This is also relevant for `Pin<&mut Self>`, where we need to peel the `Pin`.
|
// This is also relevant for `Pin<&mut Self>`, where we need to peel the
|
||||||
|
// `Pin`.
|
||||||
while !op.layout.ty.is_unsafe_ptr() && !op.layout.ty.is_ref() {
|
while !op.layout.ty.is_unsafe_ptr() && !op.layout.ty.is_ref() {
|
||||||
let (idx, _) = op.layout.non_1zst_field(bx).expect(
|
let (idx, _) = op.layout.non_1zst_field(bx).expect(
|
||||||
"not exactly one non-1-ZST field in a `DispatchFromDyn` type",
|
"not exactly one non-1-ZST field in a `DispatchFromDyn` type",
|
||||||
|
@ -1004,9 +1005,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
op = op.extract_field(bx, idx);
|
op = op.extract_field(bx, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now that we have `*dyn Trait` or `&dyn Trait`, split it up into its
|
// Now that we have `*dyn Trait` or `&dyn Trait`, split it up into its
|
||||||
// data pointer and vtable. Look up the method in the vtable, and pass
|
// data pointer and vtable. Look up the method in the vtable, and pass
|
||||||
// the data pointer as the first argument
|
// the data pointer as the first argument.
|
||||||
llfn = Some(meth::VirtualIndex::from_index(idx).get_fn(
|
llfn = Some(meth::VirtualIndex::from_index(idx).get_fn(
|
||||||
bx,
|
bx,
|
||||||
meta,
|
meta,
|
||||||
|
@ -1212,10 +1213,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
mergeable_succ,
|
mergeable_succ,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
pub(crate) fn codegen_block(&mut self, mut bb: mir::BasicBlock) {
|
||||||
pub fn codegen_block(&mut self, mut bb: mir::BasicBlock) {
|
|
||||||
let llbb = match self.try_llbb(bb) {
|
let llbb = match self.try_llbb(bb) {
|
||||||
Some(llbb) => llbb,
|
Some(llbb) => llbb,
|
||||||
None => return,
|
None => return,
|
||||||
|
@ -1255,7 +1254,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn codegen_block_as_unreachable(&mut self, bb: mir::BasicBlock) {
|
pub(crate) fn codegen_block_as_unreachable(&mut self, bb: mir::BasicBlock) {
|
||||||
let llbb = match self.try_llbb(bb) {
|
let llbb = match self.try_llbb(bb) {
|
||||||
Some(llbb) => llbb,
|
Some(llbb) => llbb,
|
||||||
None => return,
|
None => return,
|
||||||
|
@ -1440,8 +1439,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
let (mut llval, align, by_ref) = match op.val {
|
let (mut llval, align, by_ref) = match op.val {
|
||||||
Immediate(_) | Pair(..) => match arg.mode {
|
Immediate(_) | Pair(..) => match arg.mode {
|
||||||
PassMode::Indirect { attrs, .. } => {
|
PassMode::Indirect { attrs, .. } => {
|
||||||
// Indirect argument may have higher alignment requirements than the type's alignment.
|
// Indirect argument may have higher alignment requirements than the type's
|
||||||
// This can happen, e.g. when passing types with <4 byte alignment on the stack on x86.
|
// alignment. This can happen, e.g. when passing types with <4 byte alignment
|
||||||
|
// on the stack on x86.
|
||||||
let required_align = match attrs.pointee_align {
|
let required_align = match attrs.pointee_align {
|
||||||
Some(pointee_align) => cmp::max(pointee_align, arg.layout.align.abi),
|
Some(pointee_align) => cmp::max(pointee_align, arg.layout.align.abi),
|
||||||
None => arg.layout.align.abi,
|
None => arg.layout.align.abi,
|
||||||
|
@ -1740,7 +1740,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like `llbb`, but may fail if the basic block should be skipped.
|
/// Like `llbb`, but may fail if the basic block should be skipped.
|
||||||
pub fn try_llbb(&mut self, bb: mir::BasicBlock) -> Option<Bx::BasicBlock> {
|
pub(crate) fn try_llbb(&mut self, bb: mir::BasicBlock) -> Option<Bx::BasicBlock> {
|
||||||
match self.cached_llbbs[bb] {
|
match self.cached_llbbs[bb] {
|
||||||
CachedLlbb::None => {
|
CachedLlbb::None => {
|
||||||
let llbb = Bx::append_block(self.cx, self.llfn, &format!("{bb:?}"));
|
let llbb = Bx::append_block(self.cx, self.llfn, &format!("{bb:?}"));
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::mir::operand::OperandRef;
|
||||||
use crate::traits::*;
|
use crate::traits::*;
|
||||||
|
|
||||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
pub fn eval_mir_constant_to_operand(
|
pub(crate) fn eval_mir_constant_to_operand(
|
||||||
&self,
|
&self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
constant: &mir::ConstOperand<'tcx>,
|
constant: &mir::ConstOperand<'tcx>,
|
||||||
|
@ -32,27 +32,28 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
/// that the given `constant` is an `Const::Unevaluated` and must be convertible to
|
/// that the given `constant` is an `Const::Unevaluated` and must be convertible to
|
||||||
/// a `ValTree`. If you want a more general version of this, talk to `wg-const-eval` on zulip.
|
/// a `ValTree`. If you want a more general version of this, talk to `wg-const-eval` on zulip.
|
||||||
///
|
///
|
||||||
/// Note that this function is cursed, since usually MIR consts should not be evaluated to valtrees!
|
/// Note that this function is cursed, since usually MIR consts should not be evaluated to
|
||||||
pub fn eval_unevaluated_mir_constant_to_valtree(
|
/// valtrees!
|
||||||
|
fn eval_unevaluated_mir_constant_to_valtree(
|
||||||
&self,
|
&self,
|
||||||
constant: &mir::ConstOperand<'tcx>,
|
constant: &mir::ConstOperand<'tcx>,
|
||||||
) -> Result<Result<ty::ValTree<'tcx>, Ty<'tcx>>, ErrorHandled> {
|
) -> Result<Result<ty::ValTree<'tcx>, Ty<'tcx>>, ErrorHandled> {
|
||||||
let uv = match self.monomorphize(constant.const_) {
|
let uv = match self.monomorphize(constant.const_) {
|
||||||
mir::Const::Unevaluated(uv, _) => uv.shrink(),
|
mir::Const::Unevaluated(uv, _) => uv.shrink(),
|
||||||
mir::Const::Ty(_, c) => match c.kind() {
|
mir::Const::Ty(_, c) => match c.kind() {
|
||||||
// A constant that came from a const generic but was then used as an argument to old-style
|
// A constant that came from a const generic but was then used as an argument to
|
||||||
// simd_shuffle (passing as argument instead of as a generic param).
|
// old-style simd_shuffle (passing as argument instead of as a generic param).
|
||||||
rustc_type_ir::ConstKind::Value(_, valtree) => return Ok(Ok(valtree)),
|
rustc_type_ir::ConstKind::Value(_, valtree) => return Ok(Ok(valtree)),
|
||||||
other => span_bug!(constant.span, "{other:#?}"),
|
other => span_bug!(constant.span, "{other:#?}"),
|
||||||
},
|
},
|
||||||
// We should never encounter `Const::Val` unless MIR opts (like const prop) evaluate
|
// We should never encounter `Const::Val` unless MIR opts (like const prop) evaluate
|
||||||
// a constant and write that value back into `Operand`s. This could happen, but is unlikely.
|
// a constant and write that value back into `Operand`s. This could happen, but is
|
||||||
// Also: all users of `simd_shuffle` are on unstable and already need to take a lot of care
|
// unlikely. Also: all users of `simd_shuffle` are on unstable and already need to take
|
||||||
// around intrinsics. For an issue to happen here, it would require a macro expanding to a
|
// a lot of care around intrinsics. For an issue to happen here, it would require a
|
||||||
// `simd_shuffle` call without wrapping the constant argument in a `const {}` block, but
|
// macro expanding to a `simd_shuffle` call without wrapping the constant argument in a
|
||||||
// the user pass through arbitrary expressions.
|
// `const {}` block, but the user pass through arbitrary expressions.
|
||||||
// FIXME(oli-obk): replace the magic const generic argument of `simd_shuffle` with a real
|
// FIXME(oli-obk): replace the magic const generic argument of `simd_shuffle` with a
|
||||||
// const generic, and get rid of this entire function.
|
// real const generic, and get rid of this entire function.
|
||||||
other => span_bug!(constant.span, "{other:#?}"),
|
other => span_bug!(constant.span, "{other:#?}"),
|
||||||
};
|
};
|
||||||
let uv = self.monomorphize(uv);
|
let uv = self.monomorphize(uv);
|
||||||
|
|
|
@ -5,7 +5,7 @@ use super::FunctionCx;
|
||||||
use crate::traits::*;
|
use crate::traits::*;
|
||||||
|
|
||||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
pub fn codegen_coverage(&self, bx: &mut Bx, kind: &CoverageKind, scope: SourceScope) {
|
pub(crate) fn codegen_coverage(&self, bx: &mut Bx, kind: &CoverageKind, scope: SourceScope) {
|
||||||
// Determine the instance that coverage data was originally generated for.
|
// Determine the instance that coverage data was originally generated for.
|
||||||
let instance = if let Some(inlined) = scope.inlined_instance(&self.mir.source_scopes) {
|
let instance = if let Some(inlined) = scope.inlined_instance(&self.mir.source_scopes) {
|
||||||
self.monomorphize(inlined)
|
self.monomorphize(inlined)
|
||||||
|
|
|
@ -24,6 +24,7 @@ pub struct FunctionDebugContext<'tcx, S, L> {
|
||||||
/// Maps from an inlined function to its debug info declaration.
|
/// Maps from an inlined function to its debug info declaration.
|
||||||
pub inlined_function_scopes: FxHashMap<Instance<'tcx>, S>,
|
pub inlined_function_scopes: FxHashMap<Instance<'tcx>, S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub enum VariableKind {
|
pub enum VariableKind {
|
||||||
ArgumentVariable(usize /*index*/),
|
ArgumentVariable(usize /*index*/),
|
||||||
|
@ -243,7 +244,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
|
|
||||||
/// Apply debuginfo and/or name, after creating the `alloca` for a local,
|
/// Apply debuginfo and/or name, after creating the `alloca` for a local,
|
||||||
/// or initializing the local with an operand (whichever applies).
|
/// or initializing the local with an operand (whichever applies).
|
||||||
pub fn debug_introduce_local(&self, bx: &mut Bx, local: mir::Local) {
|
pub(crate) fn debug_introduce_local(&self, bx: &mut Bx, local: mir::Local) {
|
||||||
let full_debug_info = bx.sess().opts.debuginfo == DebugInfo::Full;
|
let full_debug_info = bx.sess().opts.debuginfo == DebugInfo::Full;
|
||||||
|
|
||||||
let vars = match &self.per_local_var_debug_info {
|
let vars = match &self.per_local_var_debug_info {
|
||||||
|
@ -426,7 +427,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn debug_introduce_locals(&self, bx: &mut Bx) {
|
pub(crate) fn debug_introduce_locals(&self, bx: &mut Bx) {
|
||||||
if bx.sess().opts.debuginfo == DebugInfo::Full || !bx.sess().fewer_names() {
|
if bx.sess().opts.debuginfo == DebugInfo::Full || !bx.sess().fewer_names() {
|
||||||
for local in self.locals.indices() {
|
for local in self.locals.indices() {
|
||||||
self.debug_introduce_local(bx, local);
|
self.debug_introduce_local(bx, local);
|
||||||
|
@ -435,7 +436,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Partition all `VarDebugInfo` in `self.mir`, by their base `Local`.
|
/// Partition all `VarDebugInfo` in `self.mir`, by their base `Local`.
|
||||||
pub fn compute_per_local_var_debug_info(
|
pub(crate) fn compute_per_local_var_debug_info(
|
||||||
&self,
|
&self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
) -> Option<IndexVec<mir::Local, Vec<PerLocalVarDebugInfo<'tcx, Bx::DIVariable>>>> {
|
) -> Option<IndexVec<mir::Local, Vec<PerLocalVarDebugInfo<'tcx, Bx::DIVariable>>>> {
|
||||||
|
|
|
@ -15,8 +15,8 @@ use crate::traits::*;
|
||||||
|
|
||||||
mod analyze;
|
mod analyze;
|
||||||
mod block;
|
mod block;
|
||||||
pub mod constant;
|
mod constant;
|
||||||
pub mod coverageinfo;
|
mod coverageinfo;
|
||||||
pub mod debuginfo;
|
pub mod debuginfo;
|
||||||
mod intrinsic;
|
mod intrinsic;
|
||||||
mod locals;
|
mod locals;
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl<V: CodegenObject> OperandValue<V> {
|
||||||
/// If this is ZeroSized/Immediate/Pair, return an array of the 0/1/2 values.
|
/// If this is ZeroSized/Immediate/Pair, return an array of the 0/1/2 values.
|
||||||
/// If this is Ref, return the place.
|
/// If this is Ref, return the place.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn immediates_or_place(self) -> Either<ArrayVec<V, 2>, PlaceValue<V>> {
|
pub(crate) fn immediates_or_place(self) -> Either<ArrayVec<V, 2>, PlaceValue<V>> {
|
||||||
match self {
|
match self {
|
||||||
OperandValue::ZeroSized => Either::Left(ArrayVec::new()),
|
OperandValue::ZeroSized => Either::Left(ArrayVec::new()),
|
||||||
OperandValue::Immediate(a) => Either::Left(ArrayVec::from_iter([a])),
|
OperandValue::Immediate(a) => Either::Left(ArrayVec::from_iter([a])),
|
||||||
|
@ -75,7 +75,7 @@ impl<V: CodegenObject> OperandValue<V> {
|
||||||
|
|
||||||
/// Given an array of 0/1/2 immediate values, return ZeroSized/Immediate/Pair.
|
/// Given an array of 0/1/2 immediate values, return ZeroSized/Immediate/Pair.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_immediates(immediates: ArrayVec<V, 2>) -> Self {
|
pub(crate) fn from_immediates(immediates: ArrayVec<V, 2>) -> Self {
|
||||||
let mut it = immediates.into_iter();
|
let mut it = immediates.into_iter();
|
||||||
let Some(a) = it.next() else {
|
let Some(a) = it.next() else {
|
||||||
return OperandValue::ZeroSized;
|
return OperandValue::ZeroSized;
|
||||||
|
@ -90,7 +90,7 @@ impl<V: CodegenObject> OperandValue<V> {
|
||||||
/// optional metadata as backend values.
|
/// optional metadata as backend values.
|
||||||
///
|
///
|
||||||
/// If you're making a place, use [`Self::deref`] instead.
|
/// If you're making a place, use [`Self::deref`] instead.
|
||||||
pub fn pointer_parts(self) -> (V, Option<V>) {
|
pub(crate) fn pointer_parts(self) -> (V, Option<V>) {
|
||||||
match self {
|
match self {
|
||||||
OperandValue::Immediate(llptr) => (llptr, None),
|
OperandValue::Immediate(llptr) => (llptr, None),
|
||||||
OperandValue::Pair(llptr, llextra) => (llptr, Some(llextra)),
|
OperandValue::Pair(llptr, llextra) => (llptr, Some(llextra)),
|
||||||
|
@ -105,7 +105,7 @@ impl<V: CodegenObject> OperandValue<V> {
|
||||||
/// alignment, then maybe you want [`OperandRef::deref`] instead.
|
/// alignment, then maybe you want [`OperandRef::deref`] instead.
|
||||||
///
|
///
|
||||||
/// This is the inverse of [`PlaceValue::address`].
|
/// This is the inverse of [`PlaceValue::address`].
|
||||||
pub fn deref(self, align: Align) -> PlaceValue<V> {
|
pub(crate) fn deref(self, align: Align) -> PlaceValue<V> {
|
||||||
let (llval, llextra) = self.pointer_parts();
|
let (llval, llextra) = self.pointer_parts();
|
||||||
PlaceValue { llval, llextra, align }
|
PlaceValue { llval, llextra, align }
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
||||||
OperandRef { val: OperandValue::ZeroSized, layout }
|
OperandRef { val: OperandValue::ZeroSized, layout }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
pub(crate) fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
val: mir::ConstValue<'tcx>,
|
val: mir::ConstValue<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
|
@ -334,7 +334,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
||||||
OperandRef { val, layout }
|
OperandRef { val, layout }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extract_field<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
pub(crate) fn extract_field<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||||
&self,
|
&self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
i: usize,
|
i: usize,
|
||||||
|
@ -478,8 +478,8 @@ impl<'a, 'tcx, V: CodegenObject> OperandValue<V> {
|
||||||
debug!("OperandRef::store: operand={:?}, dest={:?}", self, dest);
|
debug!("OperandRef::store: operand={:?}, dest={:?}", self, dest);
|
||||||
match self {
|
match self {
|
||||||
OperandValue::ZeroSized => {
|
OperandValue::ZeroSized => {
|
||||||
// Avoid generating stores of zero-sized values, because the only way to have a zero-sized
|
// Avoid generating stores of zero-sized values, because the only way to have a
|
||||||
// value is through `undef`/`poison`, and the store itself is useless.
|
// zero-sized value is through `undef`/`poison`, and the store itself is useless.
|
||||||
}
|
}
|
||||||
OperandValue::Ref(val) => {
|
OperandValue::Ref(val) => {
|
||||||
assert!(dest.layout.is_sized(), "cannot directly store unsized values");
|
assert!(dest.layout.is_sized(), "cannot directly store unsized values");
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::{base, MemFlags};
|
||||||
|
|
||||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
#[instrument(level = "trace", skip(self, bx))]
|
#[instrument(level = "trace", skip(self, bx))]
|
||||||
pub fn codegen_rvalue(
|
pub(crate) fn codegen_rvalue(
|
||||||
&mut self,
|
&mut self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
dest: PlaceRef<'tcx, Bx::Value>,
|
dest: PlaceRef<'tcx, Bx::Value>,
|
||||||
|
@ -419,7 +419,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn codegen_rvalue_unsized(
|
pub(crate) fn codegen_rvalue_unsized(
|
||||||
&mut self,
|
&mut self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
indirect_dest: PlaceRef<'tcx, Bx::Value>,
|
indirect_dest: PlaceRef<'tcx, Bx::Value>,
|
||||||
|
@ -440,7 +440,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn codegen_rvalue_operand(
|
pub(crate) fn codegen_rvalue_operand(
|
||||||
&mut self,
|
&mut self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
rvalue: &mir::Rvalue<'tcx>,
|
rvalue: &mir::Rvalue<'tcx>,
|
||||||
|
@ -836,7 +836,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
OperandRef { val, layout: self.cx.layout_of(mk_ptr_ty(self.cx.tcx(), ty)) }
|
OperandRef { val, layout: self.cx.layout_of(mk_ptr_ty(self.cx.tcx(), ty)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn codegen_scalar_binop(
|
fn codegen_scalar_binop(
|
||||||
&mut self,
|
&mut self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
op: mir::BinOp,
|
op: mir::BinOp,
|
||||||
|
@ -981,7 +981,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn codegen_fat_ptr_binop(
|
fn codegen_fat_ptr_binop(
|
||||||
&mut self,
|
&mut self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
op: mir::BinOp,
|
op: mir::BinOp,
|
||||||
|
@ -1023,7 +1023,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn codegen_scalar_checked_binop(
|
fn codegen_scalar_checked_binop(
|
||||||
&mut self,
|
&mut self,
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
op: mir::BinOp,
|
op: mir::BinOp,
|
||||||
|
@ -1047,10 +1047,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
|
|
||||||
OperandValue::Pair(val, of)
|
OperandValue::Pair(val, of)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
pub(crate) fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Span) -> bool {
|
||||||
pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Span) -> bool {
|
|
||||||
match *rvalue {
|
match *rvalue {
|
||||||
mir::Rvalue::Cast(mir::CastKind::Transmute, ref operand, cast_ty) => {
|
mir::Rvalue::Cast(mir::CastKind::Transmute, ref operand, cast_ty) => {
|
||||||
let operand_ty = operand.ty(self.mir, self.cx.tcx());
|
let operand_ty = operand.ty(self.mir, self.cx.tcx());
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::traits::*;
|
||||||
|
|
||||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
#[instrument(level = "debug", skip(self, bx))]
|
#[instrument(level = "debug", skip(self, bx))]
|
||||||
pub fn codegen_statement(&mut self, bx: &mut Bx, statement: &mir::Statement<'tcx>) {
|
pub(crate) fn codegen_statement(&mut self, bx: &mut Bx, statement: &mir::Statement<'tcx>) {
|
||||||
self.set_debug_loc(bx, statement.source_info);
|
self.set_debug_loc(bx, statement.source_info);
|
||||||
match statement.kind {
|
match statement.kind {
|
||||||
mir::StatementKind::Assign(box (ref place, ref rvalue)) => {
|
mir::StatementKind::Assign(box (ref place, ref rvalue)) => {
|
||||||
|
|
|
@ -45,11 +45,13 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
// The info in this case is the length of the str, so the size is that
|
// The info in this case is the length of the str, so the size is that
|
||||||
// times the unit size.
|
// times the unit size.
|
||||||
(
|
(
|
||||||
// All slice sizes must fit into `isize`, so this multiplication cannot (signed) wrap.
|
// All slice sizes must fit into `isize`, so this multiplication cannot (signed)
|
||||||
|
// wrap.
|
||||||
// NOTE: ideally, we want the effects of both `unchecked_smul` and `unchecked_umul`
|
// NOTE: ideally, we want the effects of both `unchecked_smul` and `unchecked_umul`
|
||||||
// (resulting in `mul nsw nuw` in LLVM IR), since we know that the multiplication
|
// (resulting in `mul nsw nuw` in LLVM IR), since we know that the multiplication
|
||||||
// cannot signed wrap, and that both operands are non-negative. But at the time of writing,
|
// cannot signed wrap, and that both operands are non-negative. But at the time of
|
||||||
// the `LLVM-C` binding can't do this, and it doesn't seem to enable any further optimizations.
|
// writing, the `LLVM-C` binding can't do this, and it doesn't seem to enable any
|
||||||
|
// further optimizations.
|
||||||
bx.unchecked_smul(info.unwrap(), bx.const_usize(unit.size.bytes())),
|
bx.unchecked_smul(info.unwrap(), bx.const_usize(unit.size.bytes())),
|
||||||
bx.const_usize(unit.align.abi.bytes()),
|
bx.const_usize(unit.align.abi.bytes()),
|
||||||
)
|
)
|
||||||
|
@ -67,9 +69,9 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
let (fn_abi, llfn, _instance) =
|
let (fn_abi, llfn, _instance) =
|
||||||
common::build_langcall(bx, None, LangItem::PanicNounwind);
|
common::build_langcall(bx, None, LangItem::PanicNounwind);
|
||||||
|
|
||||||
// Generate the call.
|
// Generate the call. Cannot use `do_call` since we don't have a MIR terminator so we
|
||||||
// Cannot use `do_call` since we don't have a MIR terminator so we can't create a `TerminationCodegenHelper`.
|
// can't create a `TerminationCodegenHelper`. (But we are in good company, this code is
|
||||||
// (But we are in good company, this code is duplicated plenty of times.)
|
// duplicated plenty of times.)
|
||||||
let fn_ty = bx.fn_decl_backend_type(fn_abi);
|
let fn_ty = bx.fn_decl_backend_type(fn_abi);
|
||||||
|
|
||||||
bx.call(
|
bx.call(
|
||||||
|
@ -148,9 +150,14 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
// The full formula for the size would be:
|
// The full formula for the size would be:
|
||||||
// let unsized_offset_adjusted = unsized_offset_unadjusted.align_to(unsized_align);
|
// let unsized_offset_adjusted = unsized_offset_unadjusted.align_to(unsized_align);
|
||||||
// let full_size = (unsized_offset_adjusted + unsized_size).align_to(full_align);
|
// let full_size = (unsized_offset_adjusted + unsized_size).align_to(full_align);
|
||||||
// However, `unsized_size` is a multiple of `unsized_align`.
|
// However, `unsized_size` is a multiple of `unsized_align`. Therefore, we can
|
||||||
// Therefore, we can equivalently do the `align_to(unsized_align)` *after* adding `unsized_size`:
|
// equivalently do the `align_to(unsized_align)` *after* adding `unsized_size`:
|
||||||
// let full_size = (unsized_offset_unadjusted + unsized_size).align_to(unsized_align).align_to(full_align);
|
//
|
||||||
|
// let full_size =
|
||||||
|
// (unsized_offset_unadjusted + unsized_size)
|
||||||
|
// .align_to(unsized_align)
|
||||||
|
// .align_to(full_align);
|
||||||
|
//
|
||||||
// Furthermore, `align >= unsized_align`, and therefore we only need to do:
|
// Furthermore, `align >= unsized_align`, and therefore we only need to do:
|
||||||
// let full_size = (unsized_offset_unadjusted + unsized_size).align_to(full_align);
|
// let full_size = (unsized_offset_unadjusted + unsized_size).align_to(full_align);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ use rustc_span::Span;
|
||||||
|
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
|
|
||||||
pub fn from_target_feature(
|
pub(crate) fn from_target_feature(
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
attr: &ast::Attribute,
|
attr: &ast::Attribute,
|
||||||
supported_target_features: &UnordMap<String, Option<Symbol>>,
|
supported_target_features: &UnordMap<String, Option<Symbol>>,
|
||||||
|
@ -146,7 +146,7 @@ fn asm_target_features(tcx: TyCtxt<'_>, did: DefId) -> &FxIndexSet<Symbol> {
|
||||||
|
|
||||||
/// Checks the function annotated with `#[target_feature]` is not a safe
|
/// Checks the function annotated with `#[target_feature]` is not a safe
|
||||||
/// trait method implementation, reporting an error if it is.
|
/// trait method implementation, reporting an error if it is.
|
||||||
pub fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_span: Span) {
|
pub(crate) fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_span: Span) {
|
||||||
if let DefKind::AssocFn = tcx.def_kind(id) {
|
if let DefKind::AssocFn = tcx.def_kind(id) {
|
||||||
let parent_id = tcx.local_parent(id);
|
let parent_id = tcx.local_parent(id);
|
||||||
if let DefKind::Trait | DefKind::Impl { of_trait: true } = tcx.def_kind(parent_id) {
|
if let DefKind::Trait | DefKind::Impl { of_trait: true } = tcx.def_kind(parent_id) {
|
||||||
|
|
|
@ -59,11 +59,15 @@ pub trait CodegenBackend {
|
||||||
fn locale_resource(&self) -> &'static str;
|
fn locale_resource(&self) -> &'static str;
|
||||||
|
|
||||||
fn init(&self, _sess: &Session) {}
|
fn init(&self, _sess: &Session) {}
|
||||||
|
|
||||||
fn print(&self, _req: &PrintRequest, _out: &mut String, _sess: &Session) {}
|
fn print(&self, _req: &PrintRequest, _out: &mut String, _sess: &Session) {}
|
||||||
|
|
||||||
fn target_features(&self, _sess: &Session, _allow_unstable: bool) -> Vec<Symbol> {
|
fn target_features(&self, _sess: &Session, _allow_unstable: bool) -> Vec<Symbol> {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_passes(&self) {}
|
fn print_passes(&self) {}
|
||||||
|
|
||||||
fn print_version(&self) {}
|
fn print_version(&self) {}
|
||||||
|
|
||||||
/// The metadata loader used to load rlib and dylib metadata.
|
/// The metadata loader used to load rlib and dylib metadata.
|
||||||
|
@ -75,6 +79,7 @@ pub trait CodegenBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn provide(&self, _providers: &mut Providers) {}
|
fn provide(&self, _providers: &mut Providers) {}
|
||||||
|
|
||||||
fn codegen_crate<'tcx>(
|
fn codegen_crate<'tcx>(
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
@ -120,6 +125,7 @@ pub trait ExtraBackendMethods:
|
||||||
kind: AllocatorKind,
|
kind: AllocatorKind,
|
||||||
alloc_error_handler_kind: AllocatorKind,
|
alloc_error_handler_kind: AllocatorKind,
|
||||||
) -> Self::Module;
|
) -> Self::Module;
|
||||||
|
|
||||||
/// This generates the codegen unit and returns it along with
|
/// This generates the codegen unit and returns it along with
|
||||||
/// a `u64` giving an estimate of the unit's processing cost.
|
/// a `u64` giving an estimate of the unit's processing cost.
|
||||||
fn compile_codegen_unit(
|
fn compile_codegen_unit(
|
||||||
|
@ -127,6 +133,7 @@ pub trait ExtraBackendMethods:
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
cgu_name: Symbol,
|
cgu_name: Symbol,
|
||||||
) -> (ModuleCodegen<Self::Module>, u64);
|
) -> (ModuleCodegen<Self::Module>, u64);
|
||||||
|
|
||||||
fn target_machine_factory(
|
fn target_machine_factory(
|
||||||
&self,
|
&self,
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
|
|
|
@ -25,6 +25,7 @@ pub trait MiscMethods<'tcx>: BackendTypes {
|
||||||
fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx>;
|
fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx>;
|
||||||
fn set_frame_pointer_type(&self, llfn: Self::Function);
|
fn set_frame_pointer_type(&self, llfn: Self::Function);
|
||||||
fn apply_target_cpu_attr(&self, llfn: Self::Function);
|
fn apply_target_cpu_attr(&self, llfn: Self::Function);
|
||||||
/// Declares the extern "C" main function for the entry point. Returns None if the symbol already exists.
|
/// Declares the extern "C" main function for the entry point. Returns None if the symbol
|
||||||
|
/// already exists.
|
||||||
fn declare_c_main(&self, fn_type: Self::Type) -> Option<Self::Function>;
|
fn declare_c_main(&self, fn_type: Self::Type) -> Option<Self::Function>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,7 +320,7 @@ fn run_compiler(
|
||||||
output_dir: odir,
|
output_dir: odir,
|
||||||
ice_file,
|
ice_file,
|
||||||
file_loader,
|
file_loader,
|
||||||
locale_resources: DEFAULT_LOCALE_RESOURCES,
|
locale_resources: DEFAULT_LOCALE_RESOURCES.to_vec(),
|
||||||
lint_caps: Default::default(),
|
lint_caps: Default::default(),
|
||||||
psess_created: None,
|
psess_created: None,
|
||||||
hash_untracked_state: None,
|
hash_untracked_state: None,
|
||||||
|
@ -1218,17 +1218,30 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
|
||||||
// Parse with *all* options defined in the compiler, we don't worry about
|
// Parse with *all* options defined in the compiler, we don't worry about
|
||||||
// option stability here we just want to parse as much as possible.
|
// option stability here we just want to parse as much as possible.
|
||||||
let mut options = getopts::Options::new();
|
let mut options = getopts::Options::new();
|
||||||
for option in config::rustc_optgroups() {
|
let optgroups = config::rustc_optgroups();
|
||||||
|
for option in &optgroups {
|
||||||
(option.apply)(&mut options);
|
(option.apply)(&mut options);
|
||||||
}
|
}
|
||||||
let matches = options.parse(args).unwrap_or_else(|e| {
|
let matches = options.parse(args).unwrap_or_else(|e| {
|
||||||
let msg = match e {
|
let msg: Option<String> = match e {
|
||||||
getopts::Fail::UnrecognizedOption(ref opt) => CG_OPTIONS
|
getopts::Fail::UnrecognizedOption(ref opt) => CG_OPTIONS
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&(name, ..)| ('C', name))
|
.map(|&(name, ..)| ('C', name))
|
||||||
.chain(Z_OPTIONS.iter().map(|&(name, ..)| ('Z', name)))
|
.chain(Z_OPTIONS.iter().map(|&(name, ..)| ('Z', name)))
|
||||||
.find(|&(_, name)| *opt == name.replace('_', "-"))
|
.find(|&(_, name)| *opt == name.replace('_', "-"))
|
||||||
.map(|(flag, _)| format!("{e}. Did you mean `-{flag} {opt}`?")),
|
.map(|(flag, _)| format!("{e}. Did you mean `-{flag} {opt}`?")),
|
||||||
|
getopts::Fail::ArgumentMissing(ref opt) => {
|
||||||
|
optgroups.iter().find(|option| option.name == opt).map(|option| {
|
||||||
|
// Print the help just for the option in question.
|
||||||
|
let mut options = getopts::Options::new();
|
||||||
|
(option.apply)(&mut options);
|
||||||
|
// getopt requires us to pass a function for joining an iterator of
|
||||||
|
// strings, even though in this case we expect exactly one string.
|
||||||
|
options.usage_with_format(|it| {
|
||||||
|
it.fold(format!("{e}\nUsage:"), |a, b| a + "\n" + &b)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
early_dcx.early_fatal(msg.unwrap_or_else(|| e.to_string()));
|
early_dcx.early_fatal(msg.unwrap_or_else(|| e.to_string()));
|
||||||
|
|
|
@ -287,7 +287,10 @@ impl DefKind {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_fn_like(self) -> bool {
|
pub fn is_fn_like(self) -> bool {
|
||||||
matches!(self, DefKind::Fn | DefKind::AssocFn | DefKind::Closure)
|
matches!(
|
||||||
|
self,
|
||||||
|
DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::SyntheticCoroutineBody
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether `query get_codegen_attrs` should be used with this definition.
|
/// Whether `query get_codegen_attrs` should be used with this definition.
|
||||||
|
|
|
@ -1726,7 +1726,7 @@ impl Expr<'_> {
|
||||||
ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node),
|
ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node),
|
||||||
ExprKind::Unary(..) => ExprPrecedence::Unary,
|
ExprKind::Unary(..) => ExprPrecedence::Unary,
|
||||||
ExprKind::Lit(_) => ExprPrecedence::Lit,
|
ExprKind::Lit(_) => ExprPrecedence::Lit,
|
||||||
ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast,
|
ExprKind::Cast(..) => ExprPrecedence::Cast,
|
||||||
ExprKind::DropTemps(ref expr, ..) => expr.precedence(),
|
ExprKind::DropTemps(ref expr, ..) => expr.precedence(),
|
||||||
ExprKind::If(..) => ExprPrecedence::If,
|
ExprKind::If(..) => ExprPrecedence::If,
|
||||||
ExprKind::Let(..) => ExprPrecedence::Let,
|
ExprKind::Let(..) => ExprPrecedence::Let,
|
||||||
|
@ -1744,11 +1744,12 @@ impl Expr<'_> {
|
||||||
ExprKind::Continue(..) => ExprPrecedence::Continue,
|
ExprKind::Continue(..) => ExprPrecedence::Continue,
|
||||||
ExprKind::Ret(..) => ExprPrecedence::Ret,
|
ExprKind::Ret(..) => ExprPrecedence::Ret,
|
||||||
ExprKind::Become(..) => ExprPrecedence::Become,
|
ExprKind::Become(..) => ExprPrecedence::Become,
|
||||||
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
|
|
||||||
ExprKind::OffsetOf(..) => ExprPrecedence::OffsetOf,
|
|
||||||
ExprKind::Struct(..) => ExprPrecedence::Struct,
|
ExprKind::Struct(..) => ExprPrecedence::Struct,
|
||||||
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
|
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
|
||||||
ExprKind::Yield(..) => ExprPrecedence::Yield,
|
ExprKind::Yield(..) => ExprPrecedence::Yield,
|
||||||
|
ExprKind::Type(..) | ExprKind::InlineAsm(..) | ExprKind::OffsetOf(..) => {
|
||||||
|
ExprPrecedence::Mac
|
||||||
|
}
|
||||||
ExprKind::Err(_) => ExprPrecedence::Err,
|
ExprKind::Err(_) => ExprPrecedence::Err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,7 +311,9 @@ pub struct Config {
|
||||||
pub output_file: Option<OutFileName>,
|
pub output_file: Option<OutFileName>,
|
||||||
pub ice_file: Option<PathBuf>,
|
pub ice_file: Option<PathBuf>,
|
||||||
pub file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
|
pub file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
|
||||||
pub locale_resources: &'static [&'static str],
|
/// The list of fluent resources, used for lints declared with
|
||||||
|
/// [`Diagnostic`](rustc_errors::Diagnostic) and [`LintDiagnostic`](rustc_errors::LintDiagnostic).
|
||||||
|
pub locale_resources: Vec<&'static str>,
|
||||||
|
|
||||||
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,
|
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,
|
||||||
|
|
||||||
|
|
|
@ -583,6 +583,11 @@ fn register_builtins(store: &mut LintStore) {
|
||||||
"const_eval_mutable_ptr_in_final_value",
|
"const_eval_mutable_ptr_in_final_value",
|
||||||
"partially allowed now, otherwise turned into a hard error",
|
"partially allowed now, otherwise turned into a hard error",
|
||||||
);
|
);
|
||||||
|
store.register_removed(
|
||||||
|
"where_clauses_object_safety",
|
||||||
|
"converted into hard error, see PR #125380 \
|
||||||
|
<https://github.com/rust-lang/rust/pull/125380> for more information",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_internals(store: &mut LintStore) {
|
fn register_internals(store: &mut LintStore) {
|
||||||
|
|
|
@ -72,6 +72,18 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
|
||||||
let hir::ItemKind::OpaqueTy(opaque) = &item.kind else {
|
let hir::ItemKind::OpaqueTy(opaque) = &item.kind else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If this is an RPITIT from a trait method with no body, then skip.
|
||||||
|
// That's because although we may have an opaque type on the function,
|
||||||
|
// it won't have a hidden type, so proving predicates about it is
|
||||||
|
// not really meaningful.
|
||||||
|
if let hir::OpaqueTyOrigin::FnReturn(method_def_id) = opaque.origin
|
||||||
|
&& let hir::Node::TraitItem(trait_item) = cx.tcx.hir_node_by_def_id(method_def_id)
|
||||||
|
&& !trait_item.defaultness.has_value()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let def_id = item.owner_id.def_id.to_def_id();
|
let def_id = item.owner_id.def_id.to_def_id();
|
||||||
let infcx = &cx.tcx.infer_ctxt().build();
|
let infcx = &cx.tcx.infer_ctxt().build();
|
||||||
// For every projection predicate in the opaque type's explicit bounds,
|
// For every projection predicate in the opaque type's explicit bounds,
|
||||||
|
|
|
@ -290,6 +290,7 @@ provide! { tcx, def_id, other, cdata,
|
||||||
fn_arg_names => { table }
|
fn_arg_names => { table }
|
||||||
coroutine_kind => { table_direct }
|
coroutine_kind => { table_direct }
|
||||||
coroutine_for_closure => { table }
|
coroutine_for_closure => { table }
|
||||||
|
coroutine_by_move_body_def_id => { table }
|
||||||
eval_static_initializer => {
|
eval_static_initializer => {
|
||||||
Ok(cdata
|
Ok(cdata
|
||||||
.root
|
.root
|
||||||
|
|
|
@ -1488,9 +1488,18 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
if def_kind == DefKind::Closure
|
if def_kind == DefKind::Closure
|
||||||
&& tcx.type_of(def_id).skip_binder().is_coroutine_closure()
|
&& tcx.type_of(def_id).skip_binder().is_coroutine_closure()
|
||||||
{
|
{
|
||||||
|
let coroutine_for_closure = self.tcx.coroutine_for_closure(def_id);
|
||||||
self.tables
|
self.tables
|
||||||
.coroutine_for_closure
|
.coroutine_for_closure
|
||||||
.set_some(def_id.index, self.tcx.coroutine_for_closure(def_id).into());
|
.set_some(def_id.index, coroutine_for_closure.into());
|
||||||
|
|
||||||
|
// If this async closure has a by-move body, record it too.
|
||||||
|
if tcx.needs_coroutine_by_move_body_def_id(coroutine_for_closure) {
|
||||||
|
self.tables.coroutine_by_move_body_def_id.set_some(
|
||||||
|
coroutine_for_closure.index,
|
||||||
|
self.tcx.coroutine_by_move_body_def_id(coroutine_for_closure).into(),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let DefKind::Static { .. } = def_kind {
|
if let DefKind::Static { .. } = def_kind {
|
||||||
if !self.tcx.is_foreign_item(def_id) {
|
if !self.tcx.is_foreign_item(def_id) {
|
||||||
|
|
|
@ -446,6 +446,7 @@ define_tables! {
|
||||||
fn_arg_names: Table<DefIndex, LazyArray<Ident>>,
|
fn_arg_names: Table<DefIndex, LazyArray<Ident>>,
|
||||||
coroutine_kind: Table<DefIndex, hir::CoroutineKind>,
|
coroutine_kind: Table<DefIndex, hir::CoroutineKind>,
|
||||||
coroutine_for_closure: Table<DefIndex, RawDefId>,
|
coroutine_for_closure: Table<DefIndex, RawDefId>,
|
||||||
|
coroutine_by_move_body_def_id: Table<DefIndex, RawDefId>,
|
||||||
eval_static_initializer: Table<DefIndex, LazyValue<mir::interpret::ConstAllocation<'static>>>,
|
eval_static_initializer: Table<DefIndex, LazyValue<mir::interpret::ConstAllocation<'static>>>,
|
||||||
trait_def: Table<DefIndex, LazyValue<ty::TraitDef>>,
|
trait_def: Table<DefIndex, LazyValue<ty::TraitDef>>,
|
||||||
trait_item_def_id: Table<DefIndex, RawDefId>,
|
trait_item_def_id: Table<DefIndex, RawDefId>,
|
||||||
|
|
|
@ -24,7 +24,7 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||||
|
|
||||||
// This just reproduces the logic from Instance::requires_inline.
|
// This just reproduces the logic from Instance::requires_inline.
|
||||||
match tcx.def_kind(def_id) {
|
match tcx.def_kind(def_id) {
|
||||||
DefKind::Ctor(..) | DefKind::Closure => return true,
|
DefKind::Ctor(..) | DefKind::Closure | DefKind::SyntheticCoroutineBody => return true,
|
||||||
DefKind::Fn | DefKind::AssocFn => {}
|
DefKind::Fn | DefKind::AssocFn => {}
|
||||||
_ => return false,
|
_ => return false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,8 @@ use rustc_const_eval::util;
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_data_structures::steal::Steal;
|
use rustc_data_structures::steal::Steal;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::{CtorKind, DefKind};
|
||||||
use rustc_hir::def_id::LocalDefId;
|
use rustc_hir::def_id::LocalDefId;
|
||||||
use rustc_hir::intravisit::{self, Visitor};
|
|
||||||
use rustc_index::IndexVec;
|
use rustc_index::IndexVec;
|
||||||
use rustc_middle::mir::{
|
use rustc_middle::mir::{
|
||||||
AnalysisPhase, Body, CallSource, ClearCrossCrate, ConstOperand, ConstQualifs, LocalDecl,
|
AnalysisPhase, Body, CallSource, ClearCrossCrate, ConstOperand, ConstQualifs, LocalDecl,
|
||||||
|
@ -224,26 +223,31 @@ fn is_mir_available(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||||
/// MIR associated with them.
|
/// MIR associated with them.
|
||||||
fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
|
fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
|
||||||
// All body-owners have MIR associated with them.
|
// All body-owners have MIR associated with them.
|
||||||
let set: FxIndexSet<_> = tcx.hir().body_owners().collect();
|
let mut set: FxIndexSet<_> = tcx.hir().body_owners().collect();
|
||||||
|
|
||||||
// Additionally, tuple struct/variant constructors have MIR, but
|
// Coroutine-closures (e.g. async closures) have an additional by-move MIR
|
||||||
// they don't have a BodyId, so we need to build them separately.
|
// body that isn't in the HIR.
|
||||||
struct GatherCtors {
|
for body_owner in tcx.hir().body_owners() {
|
||||||
set: FxIndexSet<LocalDefId>,
|
if let DefKind::Closure = tcx.def_kind(body_owner)
|
||||||
}
|
&& tcx.needs_coroutine_by_move_body_def_id(body_owner.to_def_id())
|
||||||
impl<'tcx> Visitor<'tcx> for GatherCtors {
|
{
|
||||||
fn visit_variant_data(&mut self, v: &'tcx hir::VariantData<'tcx>) {
|
set.insert(tcx.coroutine_by_move_body_def_id(body_owner).expect_local());
|
||||||
if let hir::VariantData::Tuple(_, _, def_id) = *v {
|
|
||||||
self.set.insert(def_id);
|
|
||||||
}
|
|
||||||
intravisit::walk_struct_def(self, v)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut gather_ctors = GatherCtors { set };
|
// tuple struct/variant constructors have MIR, but they don't have a BodyId,
|
||||||
tcx.hir().visit_all_item_likes_in_crate(&mut gather_ctors);
|
// so we need to build them separately.
|
||||||
|
for item in tcx.hir_crate_items(()).free_items() {
|
||||||
|
if let DefKind::Struct | DefKind::Enum = tcx.def_kind(item.owner_id) {
|
||||||
|
for variant in tcx.adt_def(item.owner_id).variants() {
|
||||||
|
if let Some((CtorKind::Fn, ctor_def_id)) = variant.ctor {
|
||||||
|
set.insert(ctor_def_id.expect_local());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gather_ctors.set
|
set
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mir_const_qualif(tcx: TyCtxt<'_>, def: LocalDefId) -> ConstQualifs {
|
fn mir_const_qualif(tcx: TyCtxt<'_>, def: LocalDefId) -> ConstQualifs {
|
||||||
|
|
|
@ -1376,7 +1376,7 @@ enum OptionStability {
|
||||||
|
|
||||||
pub struct RustcOptGroup {
|
pub struct RustcOptGroup {
|
||||||
pub apply: Box<dyn Fn(&mut getopts::Options) -> &mut getopts::Options>,
|
pub apply: Box<dyn Fn(&mut getopts::Options) -> &mut getopts::Options>,
|
||||||
name: &'static str,
|
pub name: &'static str,
|
||||||
stability: OptionStability,
|
stability: OptionStability,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,11 @@ fn compute_symbol_name<'tcx>(
|
||||||
// and we want to be sure to avoid any symbol conflicts here.
|
// and we want to be sure to avoid any symbol conflicts here.
|
||||||
let is_globally_shared_function = matches!(
|
let is_globally_shared_function = matches!(
|
||||||
tcx.def_kind(instance.def_id()),
|
tcx.def_kind(instance.def_id()),
|
||||||
DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Ctor(..)
|
DefKind::Fn
|
||||||
|
| DefKind::AssocFn
|
||||||
|
| DefKind::Closure
|
||||||
|
| DefKind::SyntheticCoroutineBody
|
||||||
|
| DefKind::Ctor(..)
|
||||||
) && matches!(
|
) && matches!(
|
||||||
MonoItem::Fn(instance).instantiation_mode(tcx),
|
MonoItem::Fn(instance).instantiation_mode(tcx),
|
||||||
InstantiationMode::GloballyShared { may_conflict: true }
|
InstantiationMode::GloballyShared { may_conflict: true }
|
||||||
|
|
|
@ -1669,6 +1669,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||||
let name = self.tcx.crate_name(trait_def_id.krate);
|
let name = self.tcx.crate_name(trait_def_id.krate);
|
||||||
let spans: Vec<_> = [trait_def_id, found_type]
|
let spans: Vec<_> = [trait_def_id, found_type]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
.filter(|def_id| def_id.krate != LOCAL_CRATE)
|
||||||
.filter_map(|def_id| self.tcx.extern_crate(def_id.krate))
|
.filter_map(|def_id| self.tcx.extern_crate(def_id.krate))
|
||||||
.map(|data| {
|
.map(|data| {
|
||||||
let dependency = if data.dependency_of == LOCAL_CRATE {
|
let dependency = if data.dependency_of == LOCAL_CRATE {
|
||||||
|
|
|
@ -935,106 +935,147 @@ impl fmt::Debug for ArgsOs {
|
||||||
pub mod consts {
|
pub mod consts {
|
||||||
use crate::sys::env::os;
|
use crate::sys::env::os;
|
||||||
|
|
||||||
/// A string describing the architecture of the CPU that is currently
|
/// A string describing the architecture of the CPU that is currently in use.
|
||||||
/// in use.
|
/// An example value may be: `"x86"`, `"arm"` or `"riscv64"`.
|
||||||
///
|
///
|
||||||
/// Some possible values:
|
/// <details><summary>Full list of possible values</summary>
|
||||||
///
|
///
|
||||||
/// - x86
|
/// * `"x86"`
|
||||||
/// - x86_64
|
/// * `"x86_64"`
|
||||||
/// - arm
|
/// * `"arm"`
|
||||||
/// - aarch64
|
/// * `"aarch64"`
|
||||||
/// - loongarch64
|
/// * `"m68k"`
|
||||||
/// - m68k
|
/// * `"mips"`
|
||||||
/// - csky
|
/// * `"mips32r6"`
|
||||||
/// - mips
|
/// * `"mips64"`
|
||||||
/// - mips64
|
/// * `"mips64r6"`
|
||||||
/// - powerpc
|
/// * `"csky"`
|
||||||
/// - powerpc64
|
/// * `"powerpc"`
|
||||||
/// - riscv64
|
/// * `"powerpc64"`
|
||||||
/// - s390x
|
/// * `"riscv32"`
|
||||||
/// - sparc64
|
/// * `"riscv64"`
|
||||||
|
/// * `"s390x"`
|
||||||
|
/// * `"sparc"`
|
||||||
|
/// * `"sparc64"`
|
||||||
|
/// * `"hexagon"`
|
||||||
|
/// * `"loongarch64"`
|
||||||
|
///
|
||||||
|
/// </details>
|
||||||
#[stable(feature = "env", since = "1.0.0")]
|
#[stable(feature = "env", since = "1.0.0")]
|
||||||
pub const ARCH: &str = env!("STD_ENV_ARCH");
|
pub const ARCH: &str = env!("STD_ENV_ARCH");
|
||||||
|
|
||||||
/// The family of the operating system. Example value is `unix`.
|
/// A string describing the family of the operating system.
|
||||||
|
/// An example value may be: `"unix"`, or `"windows"`.
|
||||||
///
|
///
|
||||||
/// Some possible values:
|
/// This value may be an empty string if the family is unknown.
|
||||||
///
|
///
|
||||||
/// - unix
|
/// <details><summary>Full list of possible values</summary>
|
||||||
/// - windows
|
///
|
||||||
|
/// * `"unix"`
|
||||||
|
/// * `"windows"`
|
||||||
|
/// * `"itron"`
|
||||||
|
/// * `"wasm"`
|
||||||
|
/// * `""`
|
||||||
|
///
|
||||||
|
/// </details>
|
||||||
#[stable(feature = "env", since = "1.0.0")]
|
#[stable(feature = "env", since = "1.0.0")]
|
||||||
pub const FAMILY: &str = os::FAMILY;
|
pub const FAMILY: &str = os::FAMILY;
|
||||||
|
|
||||||
/// A string describing the specific operating system in use.
|
/// A string describing the specific operating system in use.
|
||||||
/// Example value is `linux`.
|
/// An example value may be: `"linux"`, or `"freebsd"`.
|
||||||
///
|
///
|
||||||
/// Some possible values:
|
/// <details><summary>Full list of possible values</summary>
|
||||||
///
|
///
|
||||||
/// - linux
|
/// * `"linux"`
|
||||||
/// - macos
|
/// * `"windows"`
|
||||||
/// - ios
|
/// * `"macos"`
|
||||||
/// - freebsd
|
/// * `"android"`
|
||||||
/// - dragonfly
|
/// * `"ios"`
|
||||||
/// - netbsd
|
/// * `"openbsd"`
|
||||||
/// - openbsd
|
/// * `"freebsd"`
|
||||||
/// - solaris
|
/// * `"netbsd"`
|
||||||
/// - android
|
/// * `"wasi"`
|
||||||
/// - windows
|
/// * `"hermit"`
|
||||||
|
/// * `"aix"`
|
||||||
|
/// * `"apple"`
|
||||||
|
/// * `"dragonfly"`
|
||||||
|
/// * `"emscripten"`
|
||||||
|
/// * `"espidf"`
|
||||||
|
/// * `"fortanix"`
|
||||||
|
/// * `"uefi"`
|
||||||
|
/// * `"fuchsia"`
|
||||||
|
/// * `"haiku"`
|
||||||
|
/// * `"hermit"`
|
||||||
|
/// * `"watchos"`
|
||||||
|
/// * `"visionos"`
|
||||||
|
/// * `"tvos"`
|
||||||
|
/// * `"horizon"`
|
||||||
|
/// * `"hurd"`
|
||||||
|
/// * `"illumos"`
|
||||||
|
/// * `"l4re"`
|
||||||
|
/// * `"nto"`
|
||||||
|
/// * `"redox"`
|
||||||
|
/// * `"solaris"`
|
||||||
|
/// * `"solid_asp3`
|
||||||
|
/// * `"vita"`
|
||||||
|
/// * `"vxworks"`
|
||||||
|
/// * `"xous"`
|
||||||
|
///
|
||||||
|
/// </details>
|
||||||
#[stable(feature = "env", since = "1.0.0")]
|
#[stable(feature = "env", since = "1.0.0")]
|
||||||
pub const OS: &str = os::OS;
|
pub const OS: &str = os::OS;
|
||||||
|
|
||||||
/// Specifies the filename prefix used for shared libraries on this
|
/// Specifies the filename prefix, if any, used for shared libraries on this platform.
|
||||||
/// platform. Example value is `lib`.
|
/// This is either `"lib"` or an empty string. (`""`).
|
||||||
///
|
|
||||||
/// Some possible values:
|
|
||||||
///
|
|
||||||
/// - lib
|
|
||||||
/// - `""` (an empty string)
|
|
||||||
#[stable(feature = "env", since = "1.0.0")]
|
#[stable(feature = "env", since = "1.0.0")]
|
||||||
pub const DLL_PREFIX: &str = os::DLL_PREFIX;
|
pub const DLL_PREFIX: &str = os::DLL_PREFIX;
|
||||||
|
|
||||||
/// Specifies the filename suffix used for shared libraries on this
|
/// Specifies the filename suffix, if any, used for shared libraries on this platform.
|
||||||
/// platform. Example value is `.so`.
|
/// An example value may be: `".so"`, `".elf"`, or `".dll"`.
|
||||||
///
|
///
|
||||||
/// Some possible values:
|
/// The possible values are identical to those of [`DLL_EXTENSION`], but with the leading period included.
|
||||||
///
|
|
||||||
/// - .so
|
|
||||||
/// - .dylib
|
|
||||||
/// - .dll
|
|
||||||
#[stable(feature = "env", since = "1.0.0")]
|
#[stable(feature = "env", since = "1.0.0")]
|
||||||
pub const DLL_SUFFIX: &str = os::DLL_SUFFIX;
|
pub const DLL_SUFFIX: &str = os::DLL_SUFFIX;
|
||||||
|
|
||||||
/// Specifies the file extension used for shared libraries on this
|
/// Specifies the file extension, if any, used for shared libraries on this platform that goes after the dot.
|
||||||
/// platform that goes after the dot. Example value is `so`.
|
/// An example value may be: `"so"`, `"elf"`, or `"dll"`.
|
||||||
///
|
///
|
||||||
/// Some possible values:
|
/// <details><summary>Full list of possible values</summary>
|
||||||
///
|
///
|
||||||
/// - so
|
/// * `"so"`
|
||||||
/// - dylib
|
/// * `"dylib"`
|
||||||
/// - dll
|
/// * `"dll"`
|
||||||
|
/// * `"sgxs"`
|
||||||
|
/// * `"a"`
|
||||||
|
/// * `"elf"`
|
||||||
|
/// * `"wasm"`
|
||||||
|
/// * `""` (an empty string)
|
||||||
|
///
|
||||||
|
/// </details>
|
||||||
#[stable(feature = "env", since = "1.0.0")]
|
#[stable(feature = "env", since = "1.0.0")]
|
||||||
pub const DLL_EXTENSION: &str = os::DLL_EXTENSION;
|
pub const DLL_EXTENSION: &str = os::DLL_EXTENSION;
|
||||||
|
|
||||||
/// Specifies the filename suffix used for executable binaries on this
|
/// Specifies the filename suffix, if any, used for executable binaries on this platform.
|
||||||
/// platform. Example value is `.exe`.
|
/// An example value may be: `".exe"`, or `".efi"`.
|
||||||
///
|
///
|
||||||
/// Some possible values:
|
/// The possible values are identical to those of [`EXE_EXTENSION`], but with the leading period included.
|
||||||
///
|
|
||||||
/// - .exe
|
|
||||||
/// - .nexe
|
|
||||||
/// - .pexe
|
|
||||||
/// - `""` (an empty string)
|
|
||||||
#[stable(feature = "env", since = "1.0.0")]
|
#[stable(feature = "env", since = "1.0.0")]
|
||||||
pub const EXE_SUFFIX: &str = os::EXE_SUFFIX;
|
pub const EXE_SUFFIX: &str = os::EXE_SUFFIX;
|
||||||
|
|
||||||
/// Specifies the file extension, if any, used for executable binaries
|
/// Specifies the file extension, if any, used for executable binaries on this platform.
|
||||||
/// on this platform. Example value is `exe`.
|
/// An example value may be: `"exe"`, or an empty string (`""`).
|
||||||
///
|
///
|
||||||
/// Some possible values:
|
/// <details><summary>Full list of possible values</summary>
|
||||||
///
|
///
|
||||||
/// - exe
|
/// * `"exe"`
|
||||||
/// - `""` (an empty string)
|
/// * `"efi"`
|
||||||
|
/// * `"js"`
|
||||||
|
/// * `"sgxs"`
|
||||||
|
/// * `"elf"`
|
||||||
|
/// * `"wasm"`
|
||||||
|
/// * `""` (an empty string)
|
||||||
|
///
|
||||||
|
/// </details>
|
||||||
#[stable(feature = "env", since = "1.0.0")]
|
#[stable(feature = "env", since = "1.0.0")]
|
||||||
pub const EXE_EXTENSION: &str = os::EXE_EXTENSION;
|
pub const EXE_EXTENSION: &str = os::EXE_EXTENSION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,7 +262,7 @@ pub(crate) fn create_config(
|
||||||
output_file: None,
|
output_file: None,
|
||||||
output_dir: None,
|
output_dir: None,
|
||||||
file_loader: None,
|
file_loader: None,
|
||||||
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES,
|
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
|
||||||
lint_caps,
|
lint_caps,
|
||||||
psess_created: None,
|
psess_created: None,
|
||||||
hash_untracked_state: None,
|
hash_untracked_state: None,
|
||||||
|
|
|
@ -143,7 +143,7 @@ pub(crate) fn run(
|
||||||
output_file: None,
|
output_file: None,
|
||||||
output_dir: None,
|
output_dir: None,
|
||||||
file_loader: None,
|
file_loader: None,
|
||||||
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES,
|
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
|
||||||
lint_caps,
|
lint_caps,
|
||||||
psess_created: None,
|
psess_created: None,
|
||||||
hash_untracked_state: None,
|
hash_untracked_state: None,
|
||||||
|
|
|
@ -65,7 +65,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf, linker: Option<&Path
|
||||||
output_dir: None,
|
output_dir: None,
|
||||||
ice_file: None,
|
ice_file: None,
|
||||||
file_loader: None,
|
file_loader: None,
|
||||||
locale_resources: &[],
|
locale_resources: Vec::new(),
|
||||||
lint_caps: Default::default(),
|
lint_caps: Default::default(),
|
||||||
psess_created: None,
|
psess_created: None,
|
||||||
hash_untracked_state: None,
|
hash_untracked_state: None,
|
||||||
|
|
|
@ -12,8 +12,13 @@ extern crate foreign;
|
||||||
|
|
||||||
struct NoCopy;
|
struct NoCopy;
|
||||||
|
|
||||||
|
async fn call_once(f: impl async FnOnce()) {
|
||||||
|
f().await;
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
block_on::block_on(async {
|
block_on::block_on(async {
|
||||||
foreign::closure()().await;
|
foreign::closure()().await;
|
||||||
|
call_once(foreign::closure()).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
34
tests/ui/async-await/async-closures/inline-body.rs
Normal file
34
tests/ui/async-await/async-closures/inline-body.rs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
//@ edition: 2021
|
||||||
|
//@ compile-flags: -Zinline-mir
|
||||||
|
//@ build-pass
|
||||||
|
|
||||||
|
// Ensure that we don't hit a Steal ICE because we forgot to ensure
|
||||||
|
// `mir_inliner_callees` for the synthetic by-move coroutine body since
|
||||||
|
// its def-id wasn't previously being considered.
|
||||||
|
|
||||||
|
#![feature(async_closure, noop_waker)]
|
||||||
|
|
||||||
|
use std::future::Future;
|
||||||
|
use std::pin::pin;
|
||||||
|
use std::task::*;
|
||||||
|
|
||||||
|
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
|
||||||
|
let mut fut = pin!(fut);
|
||||||
|
let ctx = &mut Context::from_waker(Waker::noop());
|
||||||
|
|
||||||
|
loop {
|
||||||
|
match fut.as_mut().poll(ctx) {
|
||||||
|
Poll::Pending => {}
|
||||||
|
Poll::Ready(t) => break t,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn call_once<T>(f: impl async FnOnce() -> T) -> T {
|
||||||
|
f().await
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let c = async || {};
|
||||||
|
block_on(call_once(c));
|
||||||
|
}
|
|
@ -1,2 +1,5 @@
|
||||||
error: Argument to option 'cap-lints' missing
|
error: Argument to option 'cap-lints' missing
|
||||||
|
Usage:
|
||||||
|
--cap-lints LEVEL Set the most restrictive lint level. More restrictive
|
||||||
|
lints are capped at this level
|
||||||
|
|
||||||
|
|
16
tests/ui/impl-trait/opaque-hidden-inferred-rpitit.rs
Normal file
16
tests/ui/impl-trait/opaque-hidden-inferred-rpitit.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
// Make sure that the `opaque_hidden_inferred_bound` lint doesn't fire on
|
||||||
|
// RPITITs with no hidden type.
|
||||||
|
|
||||||
|
trait T0 {}
|
||||||
|
|
||||||
|
trait T1 {
|
||||||
|
type A: Send;
|
||||||
|
}
|
||||||
|
|
||||||
|
trait T2 {
|
||||||
|
fn foo() -> impl T1<A = ((), impl T0)>;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
1
tests/ui/invalid-compile-flags/print-without-arg.rs
Normal file
1
tests/ui/invalid-compile-flags/print-without-arg.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
//@ compile-flags: --print
|
5
tests/ui/invalid-compile-flags/print-without-arg.stderr
Normal file
5
tests/ui/invalid-compile-flags/print-without-arg.stderr
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
error: Argument to option 'print' missing
|
||||||
|
Usage:
|
||||||
|
--print [crate-name|file-names|sysroot|target-libdir|cfg|check-cfg|calling-conventions|target-list|target-cpus|target-features|relocation-models|code-models|tls-models|target-spec-json|all-target-specs-json|native-static-libs|stack-protector-strategies|link-args|deployment-target]
|
||||||
|
Compiler information to print on stdout
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
pub struct B;
|
15
tests/ui/typeck/foreign_struct_trait_unimplemented.rs
Normal file
15
tests/ui/typeck/foreign_struct_trait_unimplemented.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
//@ aux-build:foreign_struct_trait_unimplemented.rs
|
||||||
|
|
||||||
|
extern crate foreign_struct_trait_unimplemented;
|
||||||
|
|
||||||
|
pub trait Test {}
|
||||||
|
|
||||||
|
struct A;
|
||||||
|
impl Test for A {}
|
||||||
|
|
||||||
|
fn needs_test(_: impl Test) {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
needs_test(foreign_struct_trait_unimplemented::B);
|
||||||
|
//~^ ERROR the trait bound `B: Test` is not satisfied
|
||||||
|
}
|
23
tests/ui/typeck/foreign_struct_trait_unimplemented.stderr
Normal file
23
tests/ui/typeck/foreign_struct_trait_unimplemented.stderr
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
error[E0277]: the trait bound `B: Test` is not satisfied
|
||||||
|
--> $DIR/foreign_struct_trait_unimplemented.rs:13:16
|
||||||
|
|
|
||||||
|
LL | needs_test(foreign_struct_trait_unimplemented::B);
|
||||||
|
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Test` is not implemented for `B`
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
help: there are multiple different versions of crate `foreign_struct_trait_unimplemented` in the dependency graph
|
||||||
|
--> $DIR/foreign_struct_trait_unimplemented.rs:3:1
|
||||||
|
|
|
||||||
|
LL | extern crate foreign_struct_trait_unimplemented;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one version of crate `foreign_struct_trait_unimplemented` is used here, as a direct dependency of the current crate
|
||||||
|
= help: you can use `cargo tree` to explore your dependency tree
|
||||||
|
note: required by a bound in `needs_test`
|
||||||
|
--> $DIR/foreign_struct_trait_unimplemented.rs:10:23
|
||||||
|
|
|
||||||
|
LL | fn needs_test(_: impl Test) {}
|
||||||
|
| ^^^^ required by this bound in `needs_test`
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0277`.
|
Loading…
Add table
Add a link
Reference in a new issue