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

'static bound not enforced in borrowed trait coercion #10751

Closed
mitsuhiko opened this issue Dec 1, 2013 · 3 comments
Closed

'static bound not enforced in borrowed trait coercion #10751

mitsuhiko opened this issue Dec 1, 2013 · 3 comments
Labels
A-trait-system Area: Trait system A-type-system Area: Type system

Comments

@mitsuhiko
Copy link
Contributor

Current bug report

I would not expect this program to compile:

trait A {}                 
impl<T: 'static> A for T {}

fn main() {                
    let a = 3;             
    let b = &a;            
    let c = &b as &A;      
}                          

Original Bug Report

fn main() {
    let x = 42;
    let ref_x = &x;

    let any_x : &Any = &ref_x as &Any;
    println!("{:?}", any_x);
}

Results in

error: internal compiler error: non-static region found when hashing a type
This message reflects a bug in the Rust compiler. 
We would appreciate a bug report: https://github.com/mozilla/rust/wiki/HOWTO-submit-a-Rust-bug-report
task 'rustc' failed at 'explicit failure', /Users/mitsuhiko/Development/rust/src/libsyntax/diagnostic.rs:102
task '<main>' failed at 'explicit failure', /Users/mitsuhiko/Development/rust/src/librustc/lib.rs:396
@alexcrichton
Copy link
Member

cc @nikomatsakis, this should have aborted much earlier in compilation. I've updated the title of the bug to be what the root cause is.

@dmski
Copy link
Contributor

dmski commented Mar 25, 2014

Not sure if related to this issue, but this also compiles (taken from irc):

trait U {}
trait T<X: U> {}
trait S<Y> { fn m(x: ~T<Y>) {} }

fn main() {}

dmski added a commit to dmski/rust that referenced this issue Apr 8, 2014
bors added a commit that referenced this issue Apr 18, 2014
There wasn't a check for builtin bounds when looking up vtables, only for trait bounds. This led to types sometimes implementing traits they shouldn't have been able to.

Closes #10751
dmski added a commit to dmski/rust that referenced this issue Apr 23, 2014
@alexcrichton
Copy link
Member

This issue has since been fixed, closing.

flip1995 pushed a commit to flip1995/rust that referenced this issue May 20, 2023
Add configuration options to `--explain`

This PR rearranges some modules, taking `metadata_collector` out of `internal_lints` and making public just the necessary functions for `explain()` to use.

The output looks something like this:
```sh
$ cargo run --bin cargo-clippy --manifest-path ../rust-clippy/Cargo.toml -- --explain cognitive_complexity
### What it does
Checks for methods with high cognitive complexity.

### Why is this bad?
Methods of high cognitive complexity tend to be hard to
both read and maintain. Also LLVM will tend to optimize small methods better.

### Known problems
Sometimes it's hard to find a way to reduce the
complexity.

### Example
You'll see it when you get the warning.

========================================
Configuration for clippy::cognitive_complexity:
- cognitive-complexity-threshold: The maximum cognitive complexity a function can have (default: 25)
```

Fixes rust-lang#9990
r? `@xFrednet`

---

changelog: Docs: `cargo clippy --explain LINT` now shows possible configuration options for the explained lint
[rust-lang#10751](rust-lang/rust-clippy#10751)
<!-- changelog_checked -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system A-type-system Area: Type system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants