Skip to content

ICE in cargo doc with optin_builtin_traits #55321

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

Closed
carado opened this issue Oct 24, 2018 · 3 comments
Closed

ICE in cargo doc with optin_builtin_traits #55321

carado opened this issue Oct 24, 2018 · 3 comments
Labels
A-synthetic-impls Area: Synthetic impls, used by rustdoc to document auto traits and traits with blanket impls I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@carado
Copy link

carado commented Oct 24, 2018

Hi, I noticed a weird internal error using cargo doc. The smallest example I could make to reproduce the bug is an basic library project (cargo init --lib) whose lib.rs contains:

#![feature(optin_builtin_traits)]

// the bug doesn't occur if the declaration of B is moved here

pub struct A();

// the bug still happens if the declaration of B is moved here

impl !Send for A {}
impl !Sync for A {}

pub struct B<T: ?Sized>(A, Box<T>);

cargo build, cargo build --release, and cargo check all work fine; and as mentioned in the code, the place where B is declared seems to matter.

Here is the output and trace of cargo doc --verbose: [log was from an out of date nightly rust, see my comment below for the log for the latest nightly as of this edit]

Have a nice day.

@carado
Copy link
Author

carado commented Oct 25, 2018

My bad, I appear to have accidentally used a version of rust that wasn't up to date.
The bug still occurs in the latest nightly, here's the backtrace:

RUST_BACKTRACE=1 cargo doc --verbose
 Documenting rust-test-2 v0.1.0 (/home/carado/tmp/rust-test-2)                  
     Running `rustdoc --edition=2018 --crate-name rust_test_2 src/lib.rs --color always -o /home/carado/tmp/rust-test-2/target/doc -L dependency=/home/carado/tmp/rust-test-2/target/debug/deps`
thread '<unnamed>' panicked at 'Failed to fully process: B<T> DefId(2/0:825 ~ core[f7f8]::marker[0]::Send[0]) ParamEnv { caller_bounds: [], reveal: UserFacing }', librustc/traits/auto_trait.rs:193:17
stack backtrace:                                                                
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace                 
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49                   
   1: std::sys_common::backtrace::print                                         
             at libstd/sys_common/backtrace.rs:71                               
             at libstd/sys_common/backtrace.rs:59                               
   2: std::panicking::default_hook::{{closure}}                                 
             at libstd/panicking.rs:211                                         
   3: std::panicking::default_hook                                              
             at libstd/panicking.rs:227                                         
   4: std::panicking::rust_panic_with_hook                                      
             at libstd/panicking.rs:476                                         
   5: std::panicking::continue_panic_fmt                                        
             at libstd/panicking.rs:390                                         
   6: std::panicking::begin_panic_fmt                                           
             at libstd/panicking.rs:345                                         
   7: rustc::traits::auto_trait::AutoTraitFinder::find_auto_trait_generics::{{closure}}::{{closure}}
             at /rustc/f99911a4a0bead7dd1f9ef2f90442844434cc391/src/<::std::macros::panic macros>:8
   8: rustc::ty::context::tls::with_context::{{closure}}                        
             at libcore/option.rs:396                                           
             at librustc/traits/auto_trait.rs:183                               
             at librustc/infer/mod.rs:526                                       
             at librustc/ty/context.rs:1670                                     
             at librustc/ty/context.rs:2016                                     
             at librustc/ty/context.rs:1955                                     
             at librustc/ty/context.rs:2015                                     
             at librustc/ty/context.rs:1669                                     
             at librustc/ty/context.rs:2116                                     
             at librustc/ty/context.rs:2100                                     
   9: rustc::ty::context::GlobalCtxt::enter_local                               
             at librustc/ty/context.rs:2091                                     
             at librustc/ty/context.rs:2100                                     
             at librustc/ty/context.rs:2111                                     
             at librustc/ty/context.rs:1662                                     
  10: rustc::traits::auto_trait::AutoTraitFinder::find_auto_trait_generics      
             at librustc/infer/mod.rs:525                                       
             at librustc/traits/auto_trait.rs:133                               
  11: rustdoc::clean::auto_trait::AutoTraitFinder::get_auto_trait_impl_for      
             at librustdoc/clean/auto_trait.rs:200                              
             at librustdoc/clean/auto_trait.rs:123                              
  12: rustdoc::clean::auto_trait::AutoTraitFinder::get_auto_trait_impls         
             at librustdoc/clean/auto_trait.rs:76                               
             at libcore/option.rs:632                                           
             at librustdoc/clean/auto_trait.rs:73                               
  13: rustdoc::clean::def_ctor::get_def_from_node_id                            
             at librustdoc/clean/auto_trait.rs:41                               
             at librustdoc/clean/def_ctor.rs:59                                 
  14: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector<'a, 'tcx, 'rcx, 'cstore> as rustdoc::fold::DocFolder>::fold_item
             at librustdoc/clean/auto_trait.rs:39                               
             at librustdoc/clean/mod.rs:3353                                    
             at librustdoc/passes/collect_trait_impls.rs:170                    
  15: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter           
             at librustdoc/fold.rs:61                                           
             at libcore/iter/mod.rs:1640                                        
             at liballoc/vec.rs:1908                                            
             at liballoc/vec.rs:1805                                            
             at liballoc/vec.rs:1800                                            
  16: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter           
  17: rustdoc::fold::DocFolder::fold_inner_recur                                
             at liballoc/vec.rs:1700                                            
             at libcore/iter/iterator.rs:1476                                   
             at librustdoc/fold.rs:110                                          
             at librustdoc/fold.rs:37                                           
  18: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector<'a, 'tcx, 'rcx, 'cstore> as rustdoc::fold::DocFolder>::fold_item
             at librustdoc/fold.rs:100                                          
             at librustdoc/passes/collect_trait_impls.rs:178                    
  19: rustdoc::passes::collect_trait_impls::collect_trait_impls                 
             at librustdoc/fold.rs:115                                          
             at libcore/option.rs:632                                           
             at librustdoc/fold.rs:115                                          
             at librustdoc/passes/collect_trait_impls.rs:26                     
  20: rustdoc::core::run_core::{{closure}}::{{closure}}                         
             at librustdoc/core.rs:614                                          
  21: rustc::ty::context::tls::enter_context                                    
             at librustc_driver/driver.rs:1353                                  
             at librustc/ty/context.rs:2048                                     
             at librustc/ty/context.rs:2016                                     
             at librustc/ty/context.rs:1955                                     
             at librustc/ty/context.rs:2015                                     
  22: <std::thread::local::LocalKey<T>>::with                                   
             at librustc/ty/context.rs:2047                                     
             at librustc/ty/context.rs:2005                                     
             at libstd/thread/local.rs:300                                      
             at libstd/thread/local.rs:254                                      
             at librustc/ty/context.rs:1997                                     
             at libstd/thread/local.rs:300                                      
             at libstd/thread/local.rs:254                                      
  23: rustc::ty::context::TyCtxt::create_and_enter                              
             at librustc/ty/context.rs:1989                                     
             at librustc/ty/context.rs:2027                                     
             at librustc/ty/context.rs:1243                                     
  24: rustc_driver::driver::phase_3_run_analysis_passes                         
             at librustc_driver/driver.rs:1261                                  
  25: <scoped_tls::ScopedKey<T>>::set                                           
             at librustdoc/core.rs:496                                          
             at librustc_driver/driver.rs:76                                    
             at /cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  26: rustdoc::core::run_core                                                   
             at librustc_driver/driver.rs:75                                    
             at librustdoc/core.rs:405                                          
  27: <scoped_tls::ScopedKey<T>>::set                                           
             at librustdoc/lib.rs:720                                           
             at /cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
             at libsyntax/lib.rs:106                                            
             at /cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  28: syntax::with_globals                                                      
             at libsyntax/lib.rs:105                                            
  29: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at librustdoc/lib.rs:716                                           
             at librustc_driver/lib.rs:1632                                     
             at libstd/panic.rs:313                                             
  30: std::panicking::try::do_call                                              
             at libstd/panicking.rs:310                                         
  31: __rust_maybe_catch_panic                                                  
             at libpanic_unwind/lib.rs:102                                      
  32: rustc_driver::monitor                                                     
             at libstd/panicking.rs:289                                         
             at libstd/panic.rs:392                                             
             at librustc_driver/lib.rs:1546                                     
             at librustc_driver/lib.rs:1557                                     
             at librustc_driver/lib.rs:1631                                     
  33: rustdoc::rust_input                                                       
             at librustdoc/lib.rs:716                                           
  34: rustdoc::main_args                                                        
             at librustdoc/lib.rs:613                                           
             at librustdoc/lib.rs:568                                           
  35: <scoped_tls::ScopedKey<T>>::set                                           
             at librustdoc/lib.rs:115                                           
             at libcore/option.rs:424                                           
             at librustdoc/lib.rs:115                                           
             at /cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
             at libsyntax/lib.rs:106                                            
             at /cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  36: syntax::with_globals                                                      
             at libsyntax/lib.rs:105                                            
  37: std::panicking::try::do_call                                              
             at libstd/thread/mod.rs:409                                        
             at libstd/panic.rs:313                                             
             at libstd/panicking.rs:310                                         
  38: __rust_maybe_catch_panic                                                  
             at libpanic_unwind/lib.rs:102                                      
  39: <F as alloc::boxed::FnBox<A>>::call_box                                   
             at libstd/panicking.rs:289                                         
             at libstd/panic.rs:392                                             
             at libstd/thread/mod.rs:408                                        
             at liballoc/boxed.rs:672                                           
  40: std::sys_common::thread::start_thread                                     
             at liballoc/boxed.rs:682                                           
             at libstd/sys_common/thread.rs:24                                  
  41: std::sys::unix::thread::Thread::new::thread_start                         
             at libstd/sys/unix/thread.rs:90                                    
  42: start_thread                                                              
             at /builddir/glibc-2.28/nptl/pthread_create.c:486                  
  43: __clone                                                                   
             at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95                    
                                                                                
error: internal compiler error: unexpected panic                                
                                                                                
note: the compiler unexpectedly panicked. this is a bug.                        
                                                                                
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
                                                                                
note: rustc 1.31.0-nightly (f99911a4a 2018-10-23) running on x86_64-unknown-linux-gnu
                                                                                
error: Could not document `rust-test-2`.                                        

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-name rust_test_2 src/lib.rs --color always -o /home/carado/tmp/rust-test-2/target/doc -L dependency=/home/carado/tmp/rust-test-2/target/debug/deps` (exit code: 1)

Sorry again about that.

@Centril Centril added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Oct 25, 2018
@Aaron1011
Copy link
Member

It looks like AutoTraitFinder is only checking for explicit negative impls at the very beginning, and not throughout the process. I should have a fix for this later today.

@Aaron1011 Aaron1011 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Oct 25, 2018
Aaron1011 added a commit to Aaron1011/rust that referenced this issue Oct 25, 2018
Fixes rust-lang#55321

When AutoTraitFinder begins examining a type, it checks for an explicit
negative impl. However, it wasn't checking for negative impls found when
calling 'select' on predicates found from nested obligations.

This commit makes AutoTraitFinder check for negative impls whenever it
makes a call to 'select'. If a negative impl is found, it immediately
bails out.

Normal users of SelectioContext don't need to worry about this, since
they stop as soon as an Unimplemented error is encountered. However, we
add predicates to our ParamEnv when we encounter this error, so we need
to handle negative impls specially (so that we don't try adding them to
our ParamEnv).
@QuietMisdreavus QuietMisdreavus added A-synthetic-impls Area: Synthetic impls, used by rustdoc to document auto traits and traits with blanket impls regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Nov 7, 2018
@QuietMisdreavus
Copy link
Member

Looks like this error has been there the whole time that synthetic impls have been there - that sample fails all the way back to 1.26.0.

@pnkfelix pnkfelix added the P-high High priority label Nov 8, 2018
bors added a commit that referenced this issue Nov 13, 2018
…sakis

Check for negative impls when finding auto traits

Fixes #55321

When AutoTraitFinder begins examining a type, it checks for an explicit
negative impl. However, it wasn't checking for negative impls found when
calling 'select' on predicates found from nested obligations.

This commit makes AutoTraitFinder check for negative impls whenever it
makes a call to 'select'. If a negative impl is found, it immediately
bails out.

Normal users of SelectioContext don't need to worry about this, since
they stop as soon as an Unimplemented error is encountered. However, we
add predicates to our ParamEnv when we encounter this error, so we need
to handle negative impls specially (so that we don't try adding them to
our ParamEnv).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-synthetic-impls Area: Synthetic impls, used by rustdoc to document auto traits and traits with blanket impls I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants