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

Allow mutate expressions and statements #79

Open
gnieto opened this issue Apr 4, 2018 · 4 comments
Open

Allow mutate expressions and statements #79

gnieto opened this issue Apr 4, 2018 · 4 comments
Labels
enhancement New feature or request mutation Related to specific mutations

Comments

@gnieto
Copy link
Collaborator

gnieto commented Apr 4, 2018

Since rust-lang/rust#49124, expressions and statements can be mutated if the flag stmt_expr_attributes is used.

Currently, mutagen assumes that mutations happen only on func/methods contexts. For example, there are some mutations that depends on methods_info.

We are also assuming this for the coverage information. We are prepending the static var on the beginning of the scope of a method, but we will need to think about how we will report the coverage when we will mutate single expressions or statements.

Related: 15b2e37

@gnieto gnieto added enhancement New feature or request mutation Related to specific mutations labels Apr 4, 2018
@llogiq
Copy link
Owner

llogiq commented Apr 5, 2018

First, what code would we mutate here? The only things that may contain exprs outside of fns are consts, statics and [_, N] types, and the latter take only constexprs which we cannot mutate. Am I missing something?

Second, we could introduce a global method info for all extra-function mutations, if there were any. As for statements, we can add our own global static within fold_item, as it returns a SmallVector<P<Item>>.

@llogiq
Copy link
Owner

llogiq commented Apr 7, 2018

Ah, I've now revisited the change. It means we could encounter #[mutate] attributes on statements or expressions within methods (or, unfortunately, elsewhere). For now I don't see the need to allow this. First, we'd have to explain why static FOO: u32 = #[mutate] 42; will crash. And usually people will want to mutation test a complete method or function. It rarely makes sense to choose a smaller view, unless you want to limit mutations, but in that case, I'd rather have a #[nomutate] attribute.

@gnieto
Copy link
Collaborator Author

gnieto commented Apr 8, 2018

Sorry for not making this enough clear.

I'm ok with not allowing this, but maybe we should give some feedback to the user. As now Rust allows to annotate expressions and statements, maybe we should, somehow, raise a warning that the annotated expr/stmt won't be mutated.

What do you think?

@llogiq
Copy link
Owner

llogiq commented Apr 8, 2018

Good idea. Our self.cx has a span_warn function that should make this a breeze. Would make for a good first issue I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mutation Related to specific mutations
Projects
None yet
Development

No branches or pull requests

2 participants