Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump rust-toolchain to nightly-2021-04-25 #605

Merged
merged 6 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions crates/rustc_codegen_spirv/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,8 @@ impl CheckSpirvAttrVisitor<'_> {
},

SpirvAttribute::Entry(_) => match target {
Target::Fn
| Target::Method(MethodKind::Trait { body: true })
| Target::Method(MethodKind::Inherent) => {
Target::Fn |
Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be indented? Maybe Rustfmt isn't updated to handle or patterns.

Suggested change
Target::Fn |
Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => {
Target::Fn |
Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => {

// FIXME(eddyb) further check entry-point attribute validity,
// e.g. signature, shouldn't have `#[inline]` or generics, etc.
Ok(())
Expand Down Expand Up @@ -337,10 +336,8 @@ impl CheckSpirvAttrVisitor<'_> {
},

SpirvAttribute::UnrollLoops => match target {
Target::Fn
| Target::Closure
| Target::Method(MethodKind::Trait { body: true })
| Target::Method(MethodKind::Inherent) => Ok(()),
Target::Fn | Target::Closure |
Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => Ok(()),

_ => Err(Expected("function or closure")),
},
Expand Down
6 changes: 2 additions & 4 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,8 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
}
}

// silly clippy, we can't rename this!
#[allow(clippy::wrong_self_convention)]
fn to_immediate_scalar(&mut self, val: Self::Value, scalar: &Scalar) -> Self::Value {
if scalar.is_bool() {
let bool = SpirvType::Bool.def(self.span(), self);
Expand Down Expand Up @@ -1142,10 +1144,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
None
}

fn fptosui_may_trap(&self, _val: Self::Value, _dest_ty: Self::Type) -> bool {
false
}

fn fptoui(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value {
if val.ty == dest_ty {
val
Expand Down
4 changes: 0 additions & 4 deletions crates/rustc_codegen_spirv/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ impl<'a, 'tcx> Deref for Builder<'a, 'tcx> {
}

impl<'a, 'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'tcx> {
fn create_pgo_func_name_var(&self, _instance: Instance<'tcx>) -> Self::Value {
todo!()
}

fn set_function_source_hash(&mut self, _: rustc_middle::ty::Instance<'tcx>, _: u64) -> bool {
todo!()
}
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/src/builder/spirv_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
match_ty_pat(cx, a, ty).or_else(|Unapplicable| match_ty_pat(cx, b, ty))
}
_ => match (pat, cx.lookup_type(ty)) {
(TyPat::Any, _) | (&TyPat::T, _) | (TyPat::Either(..), _) => unreachable!(),
(TyPat::Any | &TyPat::T | TyPat::Either(..), _) => unreachable!(),

(TyPat::Void, SpirvType::Void) => Ok([None]),
(TyPat::Pointer(_, pat), SpirvType::Pointer { pointee: ty, .. })
Expand Down Expand Up @@ -978,7 +978,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
Token::String(_) | Token::Placeholder(_, _) | Token::Typeof(_, _, _) => None,
};
match (kind, word) {
(OperandKind::IdResultType, _) | (OperandKind::IdResult, _) => {
(OperandKind::IdResultType | OperandKind::IdResult, _) => {
bug!("should be handled by parse_operands")
}
(OperandKind::IdMemorySemantics, _) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/builder_spirv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ impl BuilderSpirv {
Ok(()) => Ok(()),

// `Shallow` becomes `Indirect` when placed behind a pointer.
Err(IllegalConst::Shallow(cause)) | Err(IllegalConst::Indirect(cause)) => {
Err(IllegalConst::Shallow(cause) | IllegalConst::Indirect(cause)) => {
Err(IllegalConst::Indirect(cause))
}
},
Expand Down
10 changes: 8 additions & 2 deletions crates/rustc_codegen_spirv/src/codegen_cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use rustc_middle::mir::Body;
use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt};
use rustc_middle::ty::{Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt, TyS};
use rustc_session::Session;
use rustc_span::def_id::LOCAL_CRATE;
use rustc_span::def_id::{DefId, LOCAL_CRATE};
use rustc_span::symbol::{sym, Symbol};
use rustc_span::{SourceFile, Span, DUMMY_SP};
use rustc_target::abi::call::FnAbi;
Expand Down Expand Up @@ -425,10 +425,16 @@ impl<'tcx> DebugInfoMethods<'tcx> for CodegenCx<'tcx> {
}
}

impl<'tcx> CoverageInfoMethods for CodegenCx<'tcx> {
impl<'tcx> CoverageInfoMethods<'tcx> for CodegenCx<'tcx> {
fn coverageinfo_finalize(&self) {
todo!()
}
fn get_pgo_func_name_var(&self, _: Instance<'tcx>) -> SpirvValue {
todo!()
}
fn define_unused_fn(&self, _: DefId) {
todo!()
}
}

impl<'tcx> AsmMethods for CodegenCx<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/decorations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl SerializedSpan {

// Sanity check - assuming `SerializedSpan` isn't corrupted, this assert
// could only ever fail because of a hash collision.
assert!(self.lo <= self.hi && self.hi <= file.byte_length());
assert!(self.lo <= self.hi && self.hi <= (file.end_pos.0 - file.start_pos.0));

Some(Span::with_root_ctxt(
file.start_pos + Pos::from_u32(self.lo),
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/src/linker/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::simple_passes::outgoing_edges;
use rspirv::dr::{Block, Function, Instruction, Module, ModuleHeader, Operand};
use rspirv::spirv::{FunctionControl, Op, StorageClass, Word};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use std::mem::replace;
use std::mem::take;

type FunctionMap = FxHashMap<Word, Function>;

Expand Down Expand Up @@ -416,7 +416,7 @@ fn fuse_trivial_branches(function: &mut Function) {
};
let pred_insts = &function.blocks[pred].instructions;
if pred_insts.last().unwrap().class.opcode == Op::Branch {
let mut dest_insts = replace(&mut function.blocks[dest_block].instructions, Vec::new());
let mut dest_insts = take(&mut function.blocks[dest_block].instructions);
let pred_insts = &mut function.blocks[pred].instructions;
pred_insts.pop(); // pop the branch
pred_insts.append(&mut dest_insts);
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/linker/new_structurizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ impl Structurizer<'_> {
// Also update the existing merge if it happens to be the `block`
// we just moved (this should only be relevant to infinite loops).
self.func.blocks_mut()[while_body_block].instructions =
mem::replace(&mut self.func.blocks_mut()[block].instructions, vec![]);
mem::take(&mut self.func.blocks_mut()[block].instructions);
if region.merge == block {
region.merge = while_body_block;
region.merge_id = while_body_block_id;
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/src/linker/simple_passes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rspirv::dr::{Block, Function, Module};
use rspirv::spirv::{Op, Word};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use std::mem::replace;
use std::mem::take;

pub fn shift_ids(module: &mut Module, add: u32) {
module.all_inst_iter_mut().for_each(|inst| {
Expand Down Expand Up @@ -66,7 +66,7 @@ pub fn block_ordering_pass(func: &mut Function) {
let entry_label = func.blocks[0].label_id().unwrap();
visit_postorder(func, &mut visited, &mut postorder, entry_label);

let mut old_blocks = replace(&mut func.blocks, Vec::new());
let mut old_blocks = take(&mut func.blocks);
// Order blocks according to reverse postorder
for &block in postorder.iter().rev() {
let index = old_blocks
Expand Down
14 changes: 7 additions & 7 deletions crates/rustc_codegen_spirv/src/linker/specializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@ impl<'a, S: Specialization> InferCx<'a, S> {
/// are handled (using `generic_params` and `S::concrete_fallback()`).
fn into_replacements(mut self, generic_params: RangeTo<Param>) -> Replacements {
let mut with_instance: IndexMap<_, Vec<_>> = IndexMap::new();
for (loc, instance) in mem::replace(&mut self.instantiated_operands, vec![]) {
for (loc, instance) in mem::take(&mut self.instantiated_operands) {
with_instance
.entry(Instance {
generic_id: instance.generic_id,
Expand All @@ -2233,7 +2233,7 @@ impl<'a, S: Specialization> InferCx<'a, S> {
.push(loc);
}

let with_concrete_or_param = mem::replace(&mut self.inferred_operands, vec![])
let with_concrete_or_param = mem::take(&mut self.inferred_operands)
.into_iter()
.map(|(loc, v)| {
(
Expand Down Expand Up @@ -2345,11 +2345,11 @@ impl<'a, S: Specialization> Expander<'a, S> {

// HACK(eddyb) steal `Vec`s so that we can still call methods on `self` below.
let module = self.builder.module_mut();
let mut entry_points = mem::replace(&mut module.entry_points, vec![]);
let debugs = mem::replace(&mut module.debugs, vec![]);
let annotations = mem::replace(&mut module.annotations, vec![]);
let types_global_values = mem::replace(&mut module.types_global_values, vec![]);
let functions = mem::replace(&mut module.functions, vec![]);
let mut entry_points = mem::take(&mut module.entry_points);
let debugs = mem::take(&mut module.debugs);
let annotations = mem::take(&mut module.annotations);
let types_global_values = mem::take(&mut module.types_global_values);
let functions = mem::take(&mut module.functions);

// Adjust `OpEntryPoint ...` in-place to use the new IDs for *Interface*
// module-scoped `OpVariable`s (which should each have one instance).
Expand Down
18 changes: 10 additions & 8 deletions crates/rustc_codegen_spirv/src/spirv_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ impl SpirvType {
}
8 | 16 | 32 | 64 => (),
128 => cx.zombie_with_span(result, def_span, "u128"),
other => cx
.tcx
.sess
.fatal(&format!("Integer width {} invalid for spir-v", other)),
other => cx.zombie_with_span(
result,
def_span,
&format!("Integer width {} invalid for spir-v", other),
),
};
result
}
Expand All @@ -130,10 +131,11 @@ impl SpirvType {
cx.zombie_with_span(result, def_span, "f64 without OpCapability Float64")
}
32 | 64 => (),
other => cx
.tcx
.sess
.fatal(&format!("Float width {} invalid for spir-v", other)),
other => cx.zombie_with_span(
result,
def_span,
&format!("Float width {} invalid for spir-v", other),
),
};
result
}
Expand Down
4 changes: 2 additions & 2 deletions crates/spirv-builder/src/depfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use raw_string::{RawStr, RawString};
use std::fs::File;
use std::io::{BufRead, BufReader, Error, ErrorKind, Read};
use std::mem::replace;
use std::mem::{replace, take};
use std::path::Path;

/// Read a Makfile-style dependency file.
Expand Down Expand Up @@ -136,7 +136,7 @@ impl State {
) -> Result<(), Error> {
self.finish_path()?;
if let Some(target) = self.target.take() {
f(target, replace(&mut self.deps, Vec::new()))?;
f(target, take(&mut self.deps))?;
}
Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions crates/spirv-std/macros/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ impl Parse for ImageType {
let int = input.parse::<syn::LitInt>().unwrap();
set_unique!(
dimensionality = match (int.base10_digits(), int.suffix()) {
("1", "D") | ("1", "d") => Dimensionality::OneD,
("2", "D") | ("2", "d") => Dimensionality::TwoD,
("3", "D") | ("3", "d") => Dimensionality::ThreeD,
("1", "D" | "d") => Dimensionality::OneD,
("2", "D" | "d") => Dimensionality::TwoD,
("3", "D" | "d") => Dimensionality::ThreeD,
_ => return Err(syn::Error::new(int.span(), "Unexpected integer")),
}
);
Expand Down
2 changes: 1 addition & 1 deletion crates/spirv-std/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fn create_vectored_fn(
syn::Pat::Ident(pat) if pat.ident == COMPONENT_ARG_NAME => Some(&mut ty.ty),
_ => None,
},
_ => None,
syn::FnArg::Receiver(_) => None,
});

if component_type.is_none() {
Expand Down
Loading