On Thu, Oct 3, 2013 at 2:29 PM, Alex Crichton <notifications@github.com>wrote:

> In src/libsyntax/ext/source_util.rs:
>
> > @@ -60,6 +60,67 @@ pub fn expand_file(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
> >      base::MRExpr(cx.expr_str(topmost.call_site, filename))
> >  }
> >
> > +/** funcpathfile!(): expands to the current fully-qualified-function name
> > +    plus file path:line:col for lambda disambiguation
> > +    See also funcpath!() and func!().
> > +*/
> > +pub fn expand_funcpathfile(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
>
> macro_rules! funcpathfile( () => (format!("{}:{}|{}::{}", file!(), line!(), mod_path!(), func!())) )
>
>
I tried putting function_path! as a macro_rules! macro in
expand.rsalongside fail!, but there's a major problem: then the
strings are heap
allocated instead of static, which means their typical usage won't type
check in most places.

    // function_path! expands to the current fully-qualified-function
name.

    // See also function_prefix!, funcpathfile! and function!.
    macro_rules!
function_path(

        () =>
(

            format!(\"{}::{}\", function_prefix!(),
function!())


)

    )

rustc reports:

syntax-extension-funcpath.rs:117:33: 117:51 error: mismatched types:
expected `&str` but found `~str` (str storage differs: expected & but found
~)
syntax-extension-funcpath.rs:117             pub fn c() -> &str {
function_path!() }

^~~~~~~~~~~~~~~~~~
syntax-extension-funcpath.rs:120:33: 120:51 error: mismatched types:
expected `&str` but found `~str` (str storage differs: expected & but found
~)
syntax-extension-funcpath.rs:120             pub fn c() -> &str {
function_path!() }

^~~~~~~~~~~~~~~~~~
syntax-extension-funcpath.rs:138:37: 138:55 error: mismatched types:
expected `&str` but found `~str` (str storage differs: expected & but found
~)
syntax-extension-funcpath.rs:138                 pub fn c() -> &str {
function_path!() }

^~~~~~~~~~~~~~~~~~
syntax-extension-funcpath.rs:144:37: 144:55 error: mismatched types:
expected `&str` but found `~str` (str storage differs: expected & but found
~)
syntax-extension-funcpath.rs:144                 pub fn c() -> &str {
function_path!() }

^~~~~~~~~~~~~~~~~~
error: aborting due to 4 previous errors
task '<unnamed>' failed at 'explicit failure',
/usr/cn/rust/debug-build/rust/src/libsyntax/diagnostic.rs:98
task '<unnamed>' failed at 'explicit failure',
/usr/cn/rust/debug-build/rust/src/librustc/rustc.rs:391
make: *** [all] Error 101

I can't think of a solution to this offhand. Let me know if you have one.
Otherwise I'll revert to the way that works.