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

Add macro for concatenating matrices #1080

Closed
wants to merge 13 commits into from
Prev Previous commit
Next Next commit
Add simple quote_spanned for cat macro
  • Loading branch information
birktj committed Feb 2, 2023
commit ad87d002c00090297c2cfe41afa28952d47d9662
5 changes: 3 additions & 2 deletions nalgebra-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -17,10 +17,11 @@
)]

use proc_macro::TokenStream;
use quote::{format_ident, quote, ToTokens, TokenStreamExt};
use quote::{format_ident, quote, quote_spanned, ToTokens, TokenStreamExt};
use syn::parse::{Error, Parse, ParseStream, Result};
use syn::punctuated::Punctuated;
use syn::{parse_macro_input, Token};
use syn::spanned::Spanned;
use syn::{Expr, Lit};

use proc_macro2::{Delimiter, Spacing, TokenStream as TokenStream2, TokenTree};
@@ -480,7 +481,7 @@ fn cat_impl(prefix: &str, matrix: Matrix) -> TokenStream2 {
if let ConcatElem::Expr(expr) = cell {
let ident = format_ident!("{}_cat_{}_{}", prefix, i, j);
let ident_shape = format_ident!("{}_cat_{}_{}_shape", prefix, i, j);
output.extend(std::iter::once(quote! {
output.extend(std::iter::once(quote_spanned! {expr.span()=>
let #ident = #expr;
let #ident_shape = #ident.shape_generic();
}));