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

bytes!(..).to_owned() does not work in statement position #8770

Closed
lilyball opened this issue Aug 26, 2013 · 3 comments
Closed

bytes!(..).to_owned() does not work in statement position #8770

lilyball opened this issue Aug 26, 2013 · 3 comments

Comments

@lilyball
Copy link
Contributor

The expression bytes!("foo").to_owned() works when placed in an expression position, as in let x = bytes!("foo").to_owned(). However, it does not work in a statement position, as in just bytes!("foo").to_owned() by itself:

error: unexpected token: `.`
 bytes!("/bar").to_owned()
               ^
@lilyball
Copy link
Contributor Author

Looks like env!() has the same problem. I'm guessing this is common to all normal syntax extensions.

@lilyball
Copy link
Contributor Author

This affects macros as well

macro_rules! foo(() => ([3]))
foo().to_owned()

Untitled.rs:3:10: 3:11 error: unexpected token: `.`
Untitled.rs:3     foo!().to_owned()
                        ^

@huonw
Copy link
Member

huonw commented Aug 26, 2013

Looks like a dup of #5941. (foo!()).to_owned() should work.

@huonw huonw closed this as completed Aug 26, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 18, 2022
…petition, r=Manishearth

Maybe trait bound on type repetition

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: fix maybe trait on [`type_repetition_in_bounds`] lint

I simplified the two for loops, which did exactly the same. Only downside is, that I need a `copied`, but that's to convert from `&&` to `&`, to that should be a noop?

One more thing: I only handle [`TraitBoundModifier::Maybe`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.TraitBoundModifier.html#variant.Maybe). Can anyone give me an example (and testcase) for [`TraitBoundModifier::MaybeConst`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.TraitBoundModifier.html#variant.MaybeConst)?

closes rust-lang#8770
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants