Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
91eabf5
Add a sane error for rust-call functions not taking tuples during typ…
CraftSpider Nov 11, 2020
bf04b04
Missing feature-gate-abi file
CraftSpider Nov 11, 2020
1e9d5c7
Minor stylistic / review changes
CraftSpider Nov 12, 2020
2b7ffec
Don't special case constant operands when lowering intrinsics
tmiasko Nov 16, 2020
207de01
libary: Forward compiler-builtins "asm" and "mangled-names" feature
stlankes Nov 16, 2020
c03790f
Add //ignore-macos to pretty-std-collections.rs
est31 Nov 16, 2020
ed26f6e
compiletest: Fix a warning in debuginfo tests on windows-gnu
petrochenkov Nov 16, 2020
78a37f8
add optimization fuel checks to some mir passes
cjkenn Nov 16, 2020
2a5a379
Add two regression tests
Alexendoo Nov 16, 2020
b4c9424
update ui test for increased fuel usage
cjkenn Nov 17, 2020
92aa0e6
Use `span_suggestion_verbose` instead of `span_suggestion` for `fn` w…
ThePuzzlemaker Nov 15, 2020
b8ed466
Fix ui tests for `fn`s with qualifiers in `extern` blocks
ThePuzzlemaker Nov 15, 2020
c825c74
Move change to check_fn, fix up overloaded-calls-nontuple
CraftSpider Nov 17, 2020
e8426a6
Remove unnecessary abi import
CraftSpider Nov 17, 2020
614a748
Highlight MIR as Rust on GitHub
camelid Nov 17, 2020
7faebe5
Move capture lowering from THIR to MIR
arora-aman Nov 17, 2020
9f70e78
Remove THIR::ExprKind::SelfRef
arora-aman Nov 17, 2020
36972b0
fix handling the default config for profiler and sanitizers
12101111 Nov 18, 2020
5163912
Allow using `download-ci-llvm` from directories other than the root
jyn514 Nov 18, 2020
efcbf1b
Permit standalone generic parameters as const generic arguments in ma…
varkor Nov 18, 2020
85bc953
Add tests for multi-segment paths in const generic arguments
varkor Nov 18, 2020
51c2218
move fuel checks to later points in instcombine and const_prop, add o…
cjkenn Nov 18, 2020
1e524fb
change print-fuel ui test to check-pass
cjkenn Nov 18, 2020
2098ade
Remove redundant notes in E0275
estebank Nov 16, 2020
3527964
Account for indirect cyclic requirements
estebank Nov 18, 2020
c12e77b
review comment
estebank Nov 18, 2020
b556690
move checks later into optimization passes
cjkenn Nov 19, 2020
1d3305a
remove check from const promotion
cjkenn Nov 19, 2020
07de702
update print fuel test output again...
cjkenn Nov 19, 2020
5a58b50
Rollup merge of #78961 - CraftSpider:22565, r=oli-obk
Dylan-DPC Nov 19, 2020
3f0f224
Rollup merge of #79082 - ThePuzzlemaker:issue-78941-fix, r=estebank
Dylan-DPC Nov 19, 2020
29c8e50
Rollup merge of #79090 - hermitcore:builtins, r=Mark-Simulacrum
Dylan-DPC Nov 19, 2020
552d8c5
Rollup merge of #79094 - est31:ignore_macos, r=pietroalbini
Dylan-DPC Nov 19, 2020
05ff58e
Rollup merge of #79101 - tmiasko:lower-func-type, r=jonas-schievink
Dylan-DPC Nov 19, 2020
6010f7b
Rollup merge of #79102 - Alexendoo:ice-regression-tests, r=Mark-Simul…
Dylan-DPC Nov 19, 2020
470f768
Rollup merge of #79110 - estebank:issue-58964, r=oli-obk
Dylan-DPC Nov 19, 2020
04a4404
Rollup merge of #79116 - petrochenkov:gdbwarn, r=Mark-Simulacrum
Dylan-DPC Nov 19, 2020
2fdcd24
Rollup merge of #79117 - cjkenn:mir-fuel, r=oli-obk
Dylan-DPC Nov 19, 2020
62838c6
Rollup merge of #79147 - camelid:mir-gitattributes, r=oli-obk
Dylan-DPC Nov 19, 2020
5c7d530
Rollup merge of #79149 - sexxi-goose:upvar_ref, r=nikomatsakis
Dylan-DPC Nov 19, 2020
3b857a5
Rollup merge of #79155 - 12101111:fix-profiler-config, r=Mark-Simulacrum
Dylan-DPC Nov 19, 2020
de62272
Rollup merge of #79156 - jyn514:relative-llvm, r=Mark-Simulacrum
Dylan-DPC Nov 19, 2020
b5fffdc
Rollup merge of #79164 - varkor:unbraced-single-segment-const-argumen…
Dylan-DPC Nov 19, 2020
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
31 changes: 31 additions & 0 deletions compiler/rustc_typeck/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,37 @@ pub(super) fn check_fn<'a, 'tcx>(

fn_maybe_err(tcx, span, fn_sig.abi);

if fn_sig.abi == Abi::RustCall {
let expected_args = if let ImplicitSelfKind::None = decl.implicit_self { 1 } else { 2 };

let err = || {
let item = match tcx.hir().get(fn_id) {
Node::Item(hir::Item { kind: ItemKind::Fn(header, ..), .. }) => Some(header),
Node::ImplItem(hir::ImplItem {
kind: hir::ImplItemKind::Fn(header, ..), ..
}) => Some(header),
// Closures are RustCall, but they tuple their arguments, so shouldn't be checked
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => None,
node => bug!("Item being checked wasn't a function/closure: {:?}", node),
};

if let Some(header) = item {
tcx.sess.span_err(header.span, "A function with the \"rust-call\" ABI must take a single non-self argument that is a tuple")
}
};

if fn_sig.inputs().len() != expected_args {
err()
} else {
// FIXME(CraftSpider) Add a check on parameter expansion, so we don't just make the ICE happen later on
// This will probably require wide-scale changes to support a TupleKind obligation
// We can't resolve this without knowing the type of the param
if !matches!(fn_sig.inputs()[expected_args - 1].kind(), ty::Tuple(_) | ty::Param(_)) {
err()
}
}
}

if body.generator_kind.is_some() && can_be_generator.is_some() {
let yield_ty = fcx
.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span });
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ use rustc_hir::def::Res;
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
use rustc_hir::intravisit::Visitor;
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_hir::{HirIdMap, Node};
use rustc_hir::{HirIdMap, ImplicitSelfKind, Node};
use rustc_index::bit_set::BitSet;
use rustc_index::vec::Idx;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/abi/issues/issue-22565-rust-call.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![feature(unboxed_closures)]

extern "rust-call" fn b(_i: i32) {}
//~^ ERROR A function with the "rust-call" ABI must take a single non-self argument that is a tuple

fn main () {
b(10);
}
8 changes: 8 additions & 0 deletions src/test/ui/abi/issues/issue-22565-rust-call.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple
--> $DIR/issue-22565-rust-call.rs:3:1
|
LL | extern "rust-call" fn b(_i: i32) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

9 changes: 9 additions & 0 deletions src/test/ui/abi/rustcall-generic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// check-pass
#![feature(unboxed_closures)]

extern "rust-call" fn foo<T>(_: T) {}

fn main() {
foo(());
foo((1, 2));
}
12 changes: 6 additions & 6 deletions src/test/ui/feature-gates/feature-gate-abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change
extern "platform-intrinsic" fn f2() {} //~ ERROR platform intrinsics are experimental
//~^ ERROR intrinsic must be in
extern "vectorcall" fn f3() {} //~ ERROR vectorcall is experimental and subject to change
extern "rust-call" fn f4() {} //~ ERROR rust-call ABI is subject to change
extern "rust-call" fn f4(_: ()) {} //~ ERROR rust-call ABI is subject to change
extern "msp430-interrupt" fn f5() {} //~ ERROR msp430-interrupt ABI is experimental
extern "ptx-kernel" fn f6() {} //~ ERROR PTX ABIs are experimental and subject to change
extern "x86-interrupt" fn f7() {} //~ ERROR x86-interrupt ABI is experimental
Expand All @@ -30,7 +30,7 @@ trait Tr {
extern "platform-intrinsic" fn m2(); //~ ERROR platform intrinsics are experimental
//~^ ERROR intrinsic must be in
extern "vectorcall" fn m3(); //~ ERROR vectorcall is experimental and subject to change
extern "rust-call" fn m4(); //~ ERROR rust-call ABI is subject to change
extern "rust-call" fn m4(_: ()); //~ ERROR rust-call ABI is subject to change
extern "msp430-interrupt" fn m5(); //~ ERROR msp430-interrupt ABI is experimental
extern "ptx-kernel" fn m6(); //~ ERROR PTX ABIs are experimental and subject to change
extern "x86-interrupt" fn m7(); //~ ERROR x86-interrupt ABI is experimental
Expand All @@ -39,7 +39,7 @@ trait Tr {
extern "efiapi" fn m10(); //~ ERROR efiapi ABI is experimental and subject to change

extern "vectorcall" fn dm3() {} //~ ERROR vectorcall is experimental and subject to change
extern "rust-call" fn dm4() {} //~ ERROR rust-call ABI is subject to change
extern "rust-call" fn dm4(_: ()) {} //~ ERROR rust-call ABI is subject to change
extern "msp430-interrupt" fn dm5() {} //~ ERROR msp430-interrupt ABI is experimental
extern "ptx-kernel" fn dm6() {} //~ ERROR PTX ABIs are experimental and subject to change
extern "x86-interrupt" fn dm7() {} //~ ERROR x86-interrupt ABI is experimental
Expand All @@ -57,7 +57,7 @@ impl Tr for S {
extern "platform-intrinsic" fn m2() {} //~ ERROR platform intrinsics are experimental
//~^ ERROR intrinsic must be in
extern "vectorcall" fn m3() {} //~ ERROR vectorcall is experimental and subject to change
extern "rust-call" fn m4() {} //~ ERROR rust-call ABI is subject to change
extern "rust-call" fn m4(_: ()) {} //~ ERROR rust-call ABI is subject to change
extern "msp430-interrupt" fn m5() {} //~ ERROR msp430-interrupt ABI is experimental
extern "ptx-kernel" fn m6() {} //~ ERROR PTX ABIs are experimental and subject to change
extern "x86-interrupt" fn m7() {} //~ ERROR x86-interrupt ABI is experimental
Expand All @@ -73,7 +73,7 @@ impl S {
extern "platform-intrinsic" fn im2() {} //~ ERROR platform intrinsics are experimental
//~^ ERROR intrinsic must be in
extern "vectorcall" fn im3() {} //~ ERROR vectorcall is experimental and subject to change
extern "rust-call" fn im4() {} //~ ERROR rust-call ABI is subject to change
extern "rust-call" fn im4(_: ()) {} //~ ERROR rust-call ABI is subject to change
extern "msp430-interrupt" fn im5() {} //~ ERROR msp430-interrupt ABI is experimental
extern "ptx-kernel" fn im6() {} //~ ERROR PTX ABIs are experimental and subject to change
extern "x86-interrupt" fn im7() {} //~ ERROR x86-interrupt ABI is experimental
Expand All @@ -86,7 +86,7 @@ impl S {
type A1 = extern "rust-intrinsic" fn(); //~ ERROR intrinsics are subject to change
type A2 = extern "platform-intrinsic" fn(); //~ ERROR platform intrinsics are experimental
type A3 = extern "vectorcall" fn(); //~ ERROR vectorcall is experimental and subject to change
type A4 = extern "rust-call" fn(); //~ ERROR rust-call ABI is subject to change
type A4 = extern "rust-call" fn(_: ()); //~ ERROR rust-call ABI is subject to change
type A5 = extern "msp430-interrupt" fn(); //~ ERROR msp430-interrupt ABI is experimental
type A6 = extern "ptx-kernel" fn (); //~ ERROR PTX ABIs are experimental and subject to change
type A7 = extern "x86-interrupt" fn(); //~ ERROR x86-interrupt ABI is experimental
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/feature-gates/feature-gate-abi.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ LL | extern "vectorcall" fn f3() {}
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:18:8
|
LL | extern "rust-call" fn f4() {}
LL | extern "rust-call" fn f4(_: ()) {}
| ^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
Expand Down Expand Up @@ -113,7 +113,7 @@ LL | extern "vectorcall" fn m3();
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:33:12
|
LL | extern "rust-call" fn m4();
LL | extern "rust-call" fn m4(_: ());
| ^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
Expand Down Expand Up @@ -183,7 +183,7 @@ LL | extern "vectorcall" fn dm3() {}
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:42:12
|
LL | extern "rust-call" fn dm4() {}
LL | extern "rust-call" fn dm4(_: ()) {}
| ^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
Expand Down Expand Up @@ -270,7 +270,7 @@ LL | extern "vectorcall" fn m3() {}
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:60:12
|
LL | extern "rust-call" fn m4() {}
LL | extern "rust-call" fn m4(_: ()) {}
| ^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
Expand Down Expand Up @@ -357,7 +357,7 @@ LL | extern "vectorcall" fn im3() {}
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:76:12
|
LL | extern "rust-call" fn im4() {}
LL | extern "rust-call" fn im4(_: ()) {}
| ^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
Expand Down Expand Up @@ -444,7 +444,7 @@ LL | type A3 = extern "vectorcall" fn();
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:89:18
|
LL | type A4 = extern "rust-call" fn();
LL | type A4 = extern "rust-call" fn(_: ());
| ^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/overloaded-calls-nontuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ impl FnMut<isize> for S {
extern "rust-call" fn call_mut(&mut self, z: isize) -> isize {
self.x + self.y + z
}
//~^^^ ERROR A function with the "rust-call" ABI must take a single non-self argument
}

impl FnOnce<isize> for S {
type Output = isize;
extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) }
//~^ ERROR A function with the "rust-call" ABI must take a single non-self argument
}

fn main() {
Expand Down
16 changes: 14 additions & 2 deletions src/test/ui/overloaded-calls-nontuple.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple
--> $DIR/overloaded-calls-nontuple.rs:11:5
|
LL | extern "rust-call" fn call_mut(&mut self, z: isize) -> isize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple
--> $DIR/overloaded-calls-nontuple.rs:19:5
|
LL | extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit
--> $DIR/overloaded-calls-nontuple.rs:26:10
--> $DIR/overloaded-calls-nontuple.rs:28:10
|
LL | drop(s(3))
| ^^^^

error: aborting due to previous error
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0059`.