diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-01-07 11:57:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-07 11:57:24 +0000 |
commit | 230b55bb532338fec1a9217f9ff8808cc0043772 (patch) | |
tree | e8bf9fee6760bc117b69603a59f6a3bb2c1949ab /gcc/rust/backend/rust-compile-fnparam.h | |
parent | bc27d113167ec6c6cc96b01c8559fc9b9219417c (diff) | |
parent | 34710b497e44d96b661ee89d50776313ef91b6b2 (diff) | |
download | gcc-230b55bb532338fec1a9217f9ff8808cc0043772.zip gcc-230b55bb532338fec1a9217f9ff8808cc0043772.tar.gz gcc-230b55bb532338fec1a9217f9ff8808cc0043772.tar.bz2 |
Merge #868
868: Add support for Wildcard pattern binding r=philberty a=philberty
Wildcard bindings allow us to bind expression to be unused such as:
let _ = 123;
They are more commonly used in destructuring of tuples such as:
let my_tuple = (1,2);
let (a,_) = my_tuple;
This is the initial basic support for the basic form of let _ = ...; and
it also allows us to ignore parameters within functions as well.
Fixes #557
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-fnparam.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-fnparam.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-fnparam.h b/gcc/rust/backend/rust-compile-fnparam.h index 92a7357..a7bf52a 100644 --- a/gcc/rust/backend/rust-compile-fnparam.h +++ b/gcc/rust/backend/rust-compile-fnparam.h @@ -52,6 +52,16 @@ public: fndecl, pattern.get_identifier (), decl_type, address_taken, locus); } + void visit (HIR::WildcardPattern &pattern) override + { + decl_type = ctx->get_backend ()->immutable_type (decl_type); + + bool address_taken = false; + compiled_param + = ctx->get_backend ()->parameter_variable (fndecl, "_", decl_type, + address_taken, locus); + } + private: CompileFnParam (Context *ctx, tree fndecl, tree decl_type, Location locus, const HIR::FunctionParam ¶m) |