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

BUG: compiler doesn't detect method-chain lifetime breach? #12568

Closed
phildawes opened this issue Feb 26, 2014 · 3 comments
Closed

BUG: compiler doesn't detect method-chain lifetime breach? #12568

phildawes opened this issue Feb 26, 2014 · 3 comments

Comments

@phildawes
Copy link
Contributor

The following code results in corrupt output: (Ubuntu 12.04 LTS, rust master pulled 25th Feb)

let arr : ~[&str] = std::os::args()[1].split_str("::").collect();
std::io::println("first " + arr[0]);
std::io::println("first again " + arr[0]);

$ rustc isolate_issue.rs
$ ./isolate_issue "foo::bar"
first fir
first again

Ashish Myles noted that an earlier version of rust failed to compile this code, giving an error about the reference to the return value of std::os::args() not being valid for the duration of its use.

https://mail.mozilla.org/pipermail/rust-dev/2014-February/008796.html

Pulling 'args' into a separate local variable works:

let args = std::os::args();
let arr : ~[&str] = args[1].split_str("::").collect();
std::io::println("first " + arr[0]);
std::io::println("first again " + arr[0]);

$ ./isolate_issue "foo::bar"
first foo
first again foo

@lilyball
Copy link
Contributor

As @flaper87 pointed out, this may be related to #12223.

@alexcrichton
Copy link
Member

I think @kballard is right, closing as a dupe of #12223

@flaper87
Copy link
Contributor

I do think it is a duplicate so, I'll close this bug as a duplicate of #12223

bors added a commit to rust-lang-ci/rust that referenced this issue Aug 21, 2023
Suggest type completions for type arguments and constant completions for constant arguments

When determining completions for generic arguments, suggest only types or only constants if the corresponding generic parameter is a type parameter or constant parameter.

Closes rust-lang#12568
flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 4, 2024
allow [`manual_unwrap_or_default`] in const function

closes: rust-lang#12568

---

changelog: allow [`manual_unwrap_or_default`] in const function

This is a small fix, I was originally decided to fix it along with `rust-lang#12568` but there are some problems needs to be addressed (which is why my branch is called `issue12569` 😆 ), so I decide to open a separated PR to fix them one at a time.
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

4 participants